103 lines
2.5 KiB
Vue
103 lines
2.5 KiB
Vue
<script>
|
|
export default {
|
|
data() {
|
|
return {}
|
|
},
|
|
onLaunch: function() {
|
|
let that = this
|
|
// 返回的是apk包信息
|
|
// #ifdef APP-PLUS
|
|
if (uni.getSystemInfoSync().platform === 'ios') { // ios首次安装没有网络
|
|
uni.onNetworkStatusChange(function(res) {
|
|
if (res.isConnected == true) {
|
|
uni.reLaunch({
|
|
url: '/pageTwo/login/login'
|
|
})
|
|
}
|
|
});
|
|
}
|
|
// #endif
|
|
// #ifdef MP-WEIXIN
|
|
// 版本更新
|
|
that.updataWeiXin()
|
|
// #endif
|
|
// that.handleConfigInfo()
|
|
console.log('App Launch')
|
|
},
|
|
onShow: function() {
|
|
console.log('App Show')
|
|
},
|
|
onHide: function() {
|
|
console.log('App Hide')
|
|
// #ifdef APP-PLUS
|
|
uni.offNetworkStatusChange(function(res) {
|
|
console.log("取消网络监听")
|
|
})
|
|
// #endif
|
|
},
|
|
methods: {
|
|
// 公共信息
|
|
handleConfigInfo() {
|
|
let that = this
|
|
// 线上版本及登录状态
|
|
that.$model.getHomeConfig({}).then(res => {
|
|
that.$store.commit('changeConfigInfo', res.data)
|
|
that.$tools.handleCancelUpdate(res.data.login_status.code)
|
|
// #ifdef APP-PLUS
|
|
plus.runtime.getProperty(plus.runtime.appid, function(info) {
|
|
that.$tools.handleoginversion(info.version, res.data.version_msg.version) //版本信息
|
|
})
|
|
// #endif
|
|
|
|
})
|
|
},
|
|
// 微信小程序更新
|
|
updataWeiXin() {
|
|
let that = this
|
|
const updateManager = uni.getUpdateManager()
|
|
// 请求完新版本信息的回调
|
|
updateManager.onCheckForUpdate(function(res) {
|
|
// console.log("是否有新版本", res.hasUpdate)
|
|
})
|
|
updateManager.onUpdateReady(function() {
|
|
uni.showModal({
|
|
title: '更新提示',
|
|
content: '新版本已经准备好,是否重启应用?',
|
|
success: function(res) {
|
|
if (res.confirm) {
|
|
// 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
|
|
updateManager.applyUpdate()
|
|
}
|
|
}
|
|
})
|
|
})
|
|
updateManager.onUpdateFailed(function() {
|
|
uni.showModal({
|
|
title: '新版本更新失败',
|
|
content: '请退出并移除小程序,重新打开...',
|
|
})
|
|
})
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style lang="scss">
|
|
/*每个页面公共css */
|
|
/* #ifndef APP-NVUE */
|
|
@import "/uni.scss";
|
|
@import "/scss/food.scss";
|
|
@import "/scss/common.scss";
|
|
@import "/scss/iconfont.css";
|
|
@import "/scss/iconfont-weapp-icon.css";
|
|
|
|
/* #endif*/
|
|
|
|
.content {
|
|
display: flex;
|
|
flex-direction: column;
|
|
align-items: center;
|
|
background-color: #f7f7f7;
|
|
min-height: 100vh;
|
|
}
|
|
</style> |