// app.js const request = require('./utils/request.js') const { host } = require('./utils/env') const API = require('./utils/api.js') const util = require('./utils/util'); App({ request: request, //请求封装 app.request.GET({}) util: util, //公共JS app.util.方法名() host:host, API: API.api, //接口地址 使用:app.API.offeringInfoList onLaunch() { //检测小程序版本更新 this.upDataApp(); //获取手机系统数据 this.getNavigationInfo() //获取字典数据 this.getTree() }, getTree:function(){ if(wx.getStorageSync('loginStatus')){ //获取字典数据 this.request.GET({ url:this.API.getTree, page:this, successFun:true }).then(res=>{ this.globalData.treeArr = res.data.data }) // wx.request({ // url: host.BASE_URL + API.api.getTree, // method: 'GET', // data: {}, // header: { // 'content-type': 'application/json', // 'Token': wx.getStorageSync('Authorization') ? wx.getStorageSync('Authorization') : '' //'Bearer ' + // }, // success: function (res) { // that.globalData.treeArr = res.data.data // }, // fail: function (error) { // console.log('字典:', error) // } // }) } }, //版本更新 upDataApp: function () { if (wx.canIUse('getUpdateManager')) { //判断当前微信版本是否支持版本更新 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: '新版本已经上线啦~,请您删除当前小程序,重新搜索打开哟~', }) }) } }) } else { wx.showModal({ // 如果希望用户在最新版本的客户端上体验您的小程序,可以这样子提示 title: '提示', content: '当前微信版本过低,无法使用该功能,请升级到最新微信版本后重试。' }) } }, //获取系统需要的高度,标题栏、状态栏等高度 getNavigationInfo:function(){ // 获取系统信息 const windowInfo = wx.getWindowInfo();//获取窗口信息 //获取胶囊数据 const menuButtonRes = wx.getMenuButtonBoundingClientRect() let statusBarHeight = windowInfo.statusBarHeight//状态栏的高度,单位px let navTop = menuButtonRes.top //胶囊距离顶部距离 let navObjWid = windowInfo.windowWidth - menuButtonRes.right + menuButtonRes.width // 胶囊按钮的宽度+胶囊右侧的距离 = windowWidth - right+胶囊宽度 let systemNum = { safeArea:windowInfo.safeArea, statusBarHeight:statusBarHeight,//状态栏的高度,单位px navHeight:statusBarHeight + menuButtonRes.height + (menuButtonRes.top - statusBarHeight) * 2, //导航栏总体高度=状态栏+标题栏 navTop:navTop, navObj: menuButtonRes.height, //胶囊高度 navObjWid:navObjWid //胶囊宽度(包括右边距离) } this.globalData.windowInfo = windowInfo this.globalData.menuButtonRes = menuButtonRes this.globalData.systemInfo = systemNum }, globalData: { windowInfo:{}, menuButtonRes:{}, systemInfo:{},//页面距离 allList: [{ list1: [{ "pagePath": "/pages/index/index", "iconPath": "gonghuiyuyue-wodeyuyuelan", "selectedIconPath": "yuyue1", "text": "扫码预约" },{ "pagePath": "/pages/weighingRecord/index", "iconPath": "jiluliebiao", "selectedIconPath": "jilu1", "text": "过磅记录" },{ "pagePath": "/pages/mine/index", "iconPath": "wode2", "selectedIconPath": "wode-active", "text": "我的" }], list2: [{ "pagePath": "/pages/queueCar/index", "iconPath": "paiduiguanli", "selectedIconPath": "paiduiquhao", "text": "排队车辆" },{ "pagePath": "/pages/salesOrderMan/index", "iconPath": "yundans", "selectedIconPath": "yundans-fill", "text": "物流订单" },{ "pagePath": "/pages/reservationMan/index", "iconPath": "gonghuiyuyue-wodeyuyuelan", "selectedIconPath": "yuyue1", "text": "预约管理" },{ "pagePath": "/pages/weighingRecord/index", "iconPath": "jiluliebiao", "selectedIconPath": "jilu1", "text": "过磅记录" },{ "pagePath": "/pages/mine/index", "iconPath": "wode2", "selectedIconPath": "wode-active", "text": "我的" }], list3: [{ "pagePath": "/pages/deliveryConfirm/index", "iconPath": "truck_line", "selectedIconPath": "truck_fill", "text": "发货确认" },{ "pagePath": "/pages/mine/index", "iconPath": "wode2", "selectedIconPath": "wode-active", "text": "我的" }], list4: [{ "pagePath": "/pages/salesOrderMan/index", "iconPath": "yundans", "selectedIconPath": "yundans-fill", "text": "物流订单" },{ "pagePath": "/pages/signReview/index", "iconPath": "qianshoushenpitongguo-xianxing", "selectedIconPath": "qianshoushenpitongguo", "text": "签收审核" },{ "pagePath": "/pages/mine/index", "iconPath": "wode2", "selectedIconPath": "wode-active", "text": "我的" }], list5: [{ "pagePath": "/pages/index/index", "iconPath": "gonghuiyuyue-wodeyuyuelan", "selectedIconPath": "yuyue1", "text": "扫码预约" },{ "pagePath": "/pages/salesOrderMan/index", "iconPath": "yundans", "selectedIconPath": "yundans-fill", "text": "物流订单" },{ "pagePath": "/pages/mine/index", "iconPath": "wode2", "selectedIconPath": "wode-active", "text": "我的" }], }], } })