12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- // app.js
- const api = require('./api/index')
- App({
- onLaunch() {
- wx.setStorageSync('showDialog', true)
- // 展示本地存储能力
- const logs = wx.getStorageSync('logs') || []
- logs.unshift(Date.now())
- wx.setStorageSync('logs', logs)
- //获取顶部navBar的信息
- const that = this;
- // 获取系统信息
- const systemInfo = wx.getSystemInfoSync();
- // 胶囊按钮位置信息
- const menuButtonInfo = wx.getMenuButtonBoundingClientRect();
- that.globalData.windowWidth = systemInfo.windowWidth
- that.globalData.windowHeight = systemInfo.windowHeight
- // 导航栏高度 = 状态栏高度 + 44
- that.globalData.navBarHeight = systemInfo.statusBarHeight + 44;
- that.globalData.menuRight = systemInfo.screenWidth - menuButtonInfo.right;
- that.globalData.menuTop = menuButtonInfo.top;
- that.globalData.menuHeight = menuButtonInfo.height;
- that.globalData.menuWidth = menuButtonInfo.width;
- wx.setStorageSync('height', that.globalData.navBarHeight)
- this.getPersonRights()
- this.checkVersion()
- //静态图片地址
- var Path = {
- develop: {
- localImagePath:'',
- imghttp:'https://www.xsip.cn/fileManager/downloadFile?fileId='
- }, // 开发环境地址
- trial: {
- localImagePath:'.',
- imghttp:'https://www.xsip.cn/fileManager/downloadFile?fileId='
- }, // 测试环境地址
- release:{
- localImagePath:'.',
- imghttp:'https://www.xsip.cn/fileManager/downloadFile?fileId='
- }, // 生产环境地址
- }
- const accountInfo = wx.getAccountInfoSync();
- const envVersion = accountInfo.miniProgram.envVersion;
- that.globalData.localImagePath = Path[envVersion].localImagePath;
- that.globalData.imghttp = Path[envVersion].imghttp;
- },
- globalData: {
- userInfo: null,
- navBarHeight: 0, // 导航栏高度
- menuRight: 0, // 胶囊距右方间距(方保持左、右间距一致)
- menuTop: 0, // 胶囊距顶部间距
- menuHeight: 0, // 胶囊高度(自定义内容可与胶囊高度保证一致)
- menuWidth:0,
- windowHeight:0,
- windowWidth:0,
- phone:'0755-82839168',
- localImagePath:'',//发布是'.',本地开发是''
- imghttp:'https://www.xsip.cn/fileManager/downloadFile?fileId='
- },
- getPersonRights(){
- api.getPersonRights({},false).then(res=>{
- if(res.code == 200){
- var data = JSON.stringify(res.data.data)
- wx.setStorageSync('vip', data)
- }
- })
- },
- checkVersion(){
- const updateManager = wx.getUpdateManager()
- updateManager.onCheckForUpdate(function (res) {
- // 请求完新版本信息的回调
- if (res.hasUpdate) {
- // 有新版本
- updateManager.onUpdateReady(function () {
- wx.showModal({
- title: '更新提示',
- content: '新版本已经准备好,是否立即重启应用?',
- success: function (res) {
- if (res.confirm) {
- // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
- updateManager.applyUpdate()
- }
- }
- })
- })
-
- updateManager.onUpdateFailed(function () {
- // 新版本下载失败
- wx.showModal({
- title: '更新提示',
- content: '新版本下载失败,请您删除当前小程序,到微信 “发现-小程序” 页,重新搜索打开呦~',
- })
- })
- }
- })
- }
- })
|