//app.js const http = require('utils/http.js'); const util = require('utils/util.js'); import touch from './utils/touch.js'; App({ onLaunch: function () { wx.getSystemInfo({ success: (res) => { this.scale = res.windowWidth / 750; } }) }, token: wx.getStorageSync('token') || '', scale: 1, globalData: { userInfo: {} }, isLogin: false, getUserInfo: function (token) { wx.setStorageSync('token', token) this.token = token || wx.getStorageSync('token') || ''; util.selfUserInfo(this.globalData).then((data) => { if (data) { this.userInfo = data; } }) }, showLoading() { wx.showLoading({ title: '加载中', mask: true }) }, hideLoading() { wx.hideLoading() }, $touch: new touch(), // 数据请求 $http: http, // 封装的方法 $util: util, })