1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- const { getUserInfo } = require('./api/common')
- const { isMobile } = require('./utils/validate')
- const { checkUpdateVersion } = require('./utils/util')
- App({
- onLaunch () {
- const that = this
-
- const systemInfo = wx.getSystemInfoSync()
-
- const menuButtonInfo = wx.getMenuButtonBoundingClientRect()
-
- that.globalData.navBarHeight = (menuButtonInfo.top - systemInfo.statusBarHeight) * 2 +
- menuButtonInfo.height + systemInfo.statusBarHeight
- that.globalData.menuRight = systemInfo.screenWidth - menuButtonInfo.right
- that.globalData.menuBottom = menuButtonInfo.top - systemInfo.statusBarHeight
- that.globalData.menuHeight = menuButtonInfo.height
- that.fetchUserData()
- checkUpdateVersion()
- },
- globalData: {
- wxMiniversion: 'v0.0.0',
- userInfo: {},
- navBarHeight: 0,
- menuRight: 0,
- menuBottom: 0,
- menuHeight: 0
- },
- async fetchUserData () {
- try {
- const { status, data } = await getUserInfo()
- if (status && Object.prototype.toString.call(data) === '[object Object]' && isMobile(data.user_phone)) {
- const temp = {
- ...data
- }
-
- if (!temp.user_nickname) {
- temp.user_nickname = 'bbs' + temp.user_phone.replace(/(\d{7})(.*)/, '$2')
- }
- if (temp.user_address && temp.user_address.indexOf('/') > -1) {
- temp.user_address = temp.user_address.split('/')
- }
- this.globalData.userInfo = temp
- }
- } catch (e) {}
- }
- })
|