Create your Gitee Account
Explore and code with more than 12 million developers,Free private repositories !:)
Sign up
文件
Clone or Download
app.js 1.97 KB
Copy Edit Raw Blame History
javazj authored 2019-04-13 10:11 . version 0.0.1
const WXAPI = require('wxapi/main')
App({
navigateToLogin: false,
onLaunch: function() {
const that = this;
// 检测新版本
const updateManager = wx.getUpdateManager()
updateManager.onUpdateReady(function () {
wx.showToast({
title: '新版本升级中',
icon: 'loading'
})
updateManager.applyUpdate()
})
/**
* 初次加载判断网络情况
* 无网络状态下根据实际情况进行调整
*/
wx.getNetworkType({
success(res) {
const networkType = res.networkType
if (networkType === 'none') {
that.globalData.isConnected = false
wx.showToast({
title: '当前无网络',
icon: 'loading',
duration: 2000
})
}
}
});
/**
* 监听网络状态变化
* 可根据业务需求进行调整
*/
wx.onNetworkStatusChange(function(res) {
if (!res.isConnected) {
that.globalData.isConnected = false
wx.showToast({
title: '网络已断开',
icon: 'loading',
duration: 2000
})
} else {
that.globalData.isConnected = true
wx.hideToast()
}
})
// 获取系统参数设置
WXAPI.queryConfigBatch('mallName').then(function(res) {
if (res.code === 0) {
res.data.forEach(ele => {
wx.setStorageSync(ele.key, ele.value);
})
}
})
},
goLoginPageTimeOut: function() {
if (this.navigateToLogin){
return
}
wx.removeStorageSync('token')
this.navigateToLogin = true
setTimeout(function() {
wx.navigateTo({
url: "/pages/authorize/index"
})
}, 1000)
},
onShow (e) {
this.globalData.launchOption = e
// 保存邀请人
if (e && e.query && e.query.inviter_id) {
wx.setStorageSync('referrer', e.query.inviter_id)
}
},
globalData: {
isConnected: true,
launchOption: undefined
}
})
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化