71 lines
1.7 KiB
JavaScript
71 lines
1.7 KiB
JavaScript
/*
|
|
* 手太欠
|
|
* 愿这世界都如故事里一样 美好而动人~
|
|
*/
|
|
|
|
import api from "api/index"
|
|
App({
|
|
onLaunch(options) {
|
|
// 检查用户登录状态
|
|
const token = wx.getStorageSync("token")
|
|
if(token){
|
|
this.globalData.isUser = true
|
|
}
|
|
|
|
// 检查系统更新
|
|
const updateManager = wx.getUpdateManager()
|
|
updateManager.onUpdateReady(function () {
|
|
wx.showModal({
|
|
title : '更新提示',
|
|
content : '新版本已经准备好,是否重启应用?',
|
|
cancelColor: '#666',
|
|
confirmColor: '#e50d01',
|
|
success : res=> {
|
|
if (res.confirm) {
|
|
updateManager.applyUpdate()
|
|
}
|
|
}
|
|
})
|
|
})
|
|
updateManager.onUpdateFailed(function(){
|
|
wx.showModal({
|
|
title : '更新提示',
|
|
content : '版本更新下载失败,请检查您的网络稍后重试',
|
|
showCancel: false,
|
|
confirmColor: '#e50d01'
|
|
})
|
|
})
|
|
|
|
// 获取系统信息
|
|
wx.getSystemInfo({
|
|
success: res=>{
|
|
this.globalData = {
|
|
barHeight: res.statusBarHeight
|
|
}
|
|
}
|
|
})
|
|
|
|
if(wx.getStorageSync("openid") == '') {
|
|
// 获取code
|
|
wx.login({
|
|
success: res => {
|
|
// 存储openid
|
|
api.auth.codeOpenid({code: res.code}).then(openidRes => {
|
|
wx.setStorageSync('openid', openidRes.data)
|
|
}).catch(err => {})
|
|
}
|
|
})
|
|
}
|
|
|
|
// 挂载api
|
|
wx.$api = api
|
|
},
|
|
globalData: {
|
|
isUser : false,
|
|
userInfo : null,
|
|
barHeight : '',
|
|
inviteText : '', // 邀请好友临时存储
|
|
isExperience: '', // 体验官身份
|
|
experienceAreaId: '' // 体验官区域
|
|
}
|
|
}) |