Files
sykl-mall/app.js
2023-07-22 19:01:37 +08:00

96 lines
2.5 KiB
JavaScript

/*
* 手太欠
* 愿这世界都如故事里一样 美好而动人~
*/
import api from "api/index"
App({
onLaunch(e) {
let { scene } = e
// 检查入口场景值
if(scene === 1011 || scene === 1047 || scene === 1124 || scene === 1089 || scene === 1038){
this.globalData.isOfficial = true
}
// 检查用户登录状态
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.systInfo = {
statusBarHeight: res.statusBarHeight,
safeArea : res.safeArea
}
}
})
// 挂载api
wx.$api = api
// 获取微信步数-云开发
// wx.cloud.init({
// traceUser: true,
// })
},
// 统一分享
// overShare () {
// let newInvite = wx.getStorageSync("inviteData")
// wx.onAppRoute(() =>{
// let pages = getCurrentPages(),
// view = pages[pages.length - 1]
// if (view) {
// wx.showShareMenu({
// withShareTicket: true,
// menus: ['shareAppMessage', 'shareTimeline'],
// })
// view.onShareAppMessage = function () {
// return {
// title: '分享标题',
// imageUrl: "http://cdn.siyuankunlun.com/materials/2022/09/14/code.jpg",
// path: '/pages/index/index?invite=' + newInvite
// };
// }
// }
// })
// },
globalData: {
systInfo : '',
isUser : false,
token : "",
isOfficial : false,
invite : "",
safeArea : '',
statusBarHeight: wx.getSystemInfoSync().statusBarHeight,
jiaonangheight: wx.getMenuButtonBoundingClientRect().height
}
})