app.js 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. // app.js
  2. const request = require('./utils/request.js')
  3. const { host } = require('./utils/env')
  4. const API = require('./utils/api.js')
  5. const util = require('./utils/util');
  6. App({
  7. request: request, //请求封装 app.request.GET({})
  8. util: util, //公共JS app.util.方法名()
  9. host:host,
  10. API: API.api, //接口地址 使用:app.API.offeringInfoList
  11. onLaunch() {
  12. //检测小程序版本更新
  13. this.upDataApp();
  14. //获取手机系统数据
  15. this.getNavigationInfo()
  16. //获取字典数据
  17. this.getTree()
  18. },
  19. getTree:function(){
  20. if(wx.getStorageSync('loginStatus')){
  21. //获取字典数据
  22. this.request.GET({
  23. url:this.API.getTree,
  24. page:this,
  25. successFun:true
  26. }).then(res=>{
  27. this.globalData.treeArr = res.data.data
  28. })
  29. // wx.request({
  30. // url: host.BASE_URL + API.api.getTree,
  31. // method: 'GET',
  32. // data: {},
  33. // header: {
  34. // 'content-type': 'application/json',
  35. // 'Token': wx.getStorageSync('Authorization') ? wx.getStorageSync('Authorization') : '' //'Bearer ' +
  36. // },
  37. // success: function (res) {
  38. // that.globalData.treeArr = res.data.data
  39. // },
  40. // fail: function (error) {
  41. // console.log('字典:', error)
  42. // }
  43. // })
  44. }
  45. },
  46. //版本更新
  47. upDataApp: function () {
  48. if (wx.canIUse('getUpdateManager')) { //判断当前微信版本是否支持版本更新
  49. const updateManager = wx.getUpdateManager();
  50. updateManager.onCheckForUpdate(function (res) {
  51. if (res.hasUpdate) { // 请求完新版本信息的回调
  52. updateManager.onUpdateReady(function () {
  53. wx.showModal({
  54. title: '更新提示',
  55. content: '新版本已经准备好,是否重启应用?',
  56. success: function (res) {
  57. if (res.confirm) { // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
  58. updateManager.applyUpdate()
  59. }
  60. }
  61. })
  62. });
  63. updateManager.onUpdateFailed(function () {
  64. wx.showModal({ // 新的版本下载失败
  65. title: '已经有新版本了哟~',
  66. content: '新版本已经上线啦~,请您删除当前小程序,重新搜索打开哟~',
  67. })
  68. })
  69. }
  70. })
  71. } else {
  72. wx.showModal({ // 如果希望用户在最新版本的客户端上体验您的小程序,可以这样子提示
  73. title: '提示',
  74. content: '当前微信版本过低,无法使用该功能,请升级到最新微信版本后重试。'
  75. })
  76. }
  77. },
  78. //获取系统需要的高度,标题栏、状态栏等高度
  79. getNavigationInfo:function(){
  80. // 获取系统信息
  81. const windowInfo = wx.getWindowInfo();//获取窗口信息
  82. //获取胶囊数据
  83. const menuButtonRes = wx.getMenuButtonBoundingClientRect()
  84. let statusBarHeight = windowInfo.statusBarHeight//状态栏的高度,单位px
  85. let navTop = menuButtonRes.top //胶囊距离顶部距离
  86. let navObjWid = windowInfo.windowWidth - menuButtonRes.right + menuButtonRes.width // 胶囊按钮的宽度+胶囊右侧的距离 = windowWidth - right+胶囊宽度
  87. let systemNum = {
  88. safeArea:windowInfo.safeArea,
  89. statusBarHeight:statusBarHeight,//状态栏的高度,单位px
  90. navHeight:statusBarHeight + menuButtonRes.height + (menuButtonRes.top - statusBarHeight) * 2, //导航栏总体高度=状态栏+标题栏
  91. navTop:navTop,
  92. navObj: menuButtonRes.height, //胶囊高度
  93. navObjWid:navObjWid //胶囊宽度(包括右边距离)
  94. }
  95. this.globalData.windowInfo = windowInfo
  96. this.globalData.menuButtonRes = menuButtonRes
  97. this.globalData.systemInfo = systemNum
  98. },
  99. globalData: {
  100. windowInfo:{},
  101. menuButtonRes:{},
  102. systemInfo:{},//页面距离
  103. allList: [{
  104. list1: [{
  105. "pagePath": "/pages/index/index",
  106. "iconPath": "gonghuiyuyue-wodeyuyuelan",
  107. "selectedIconPath": "yuyue1",
  108. "text": "扫码预约"
  109. },{
  110. "pagePath": "/pages/weighingRecord/index",
  111. "iconPath": "jiluliebiao",
  112. "selectedIconPath": "jilu1",
  113. "text": "过磅记录"
  114. },{
  115. "pagePath": "/pages/mine/index",
  116. "iconPath": "wode2",
  117. "selectedIconPath": "wode-active",
  118. "text": "我的"
  119. }],
  120. list2: [{
  121. "pagePath": "/pages/queueCar/index",
  122. "iconPath": "paiduiguanli",
  123. "selectedIconPath": "paiduiquhao",
  124. "text": "排队车辆"
  125. },{
  126. "pagePath": "/pages/salesOrderMan/index",
  127. "iconPath": "yundans",
  128. "selectedIconPath": "yundans-fill",
  129. "text": "物流订单"
  130. },{
  131. "pagePath": "/pages/reservationMan/index",
  132. "iconPath": "gonghuiyuyue-wodeyuyuelan",
  133. "selectedIconPath": "yuyue1",
  134. "text": "预约管理"
  135. },{
  136. "pagePath": "/pages/weighingRecord/index",
  137. "iconPath": "jiluliebiao",
  138. "selectedIconPath": "jilu1",
  139. "text": "过磅记录"
  140. },{
  141. "pagePath": "/pages/mine/index",
  142. "iconPath": "wode2",
  143. "selectedIconPath": "wode-active",
  144. "text": "我的"
  145. }],
  146. list3: [{
  147. "pagePath": "/pages/deliveryConfirm/index",
  148. "iconPath": "truck_line",
  149. "selectedIconPath": "truck_fill",
  150. "text": "发货确认"
  151. },{
  152. "pagePath": "/pages/mine/index",
  153. "iconPath": "wode2",
  154. "selectedIconPath": "wode-active",
  155. "text": "我的"
  156. }],
  157. list4: [{
  158. "pagePath": "/pages/salesOrderMan/index",
  159. "iconPath": "yundans",
  160. "selectedIconPath": "yundans-fill",
  161. "text": "物流订单"
  162. },{
  163. "pagePath": "/pages/signReview/index",
  164. "iconPath": "qianshoushenpitongguo-xianxing",
  165. "selectedIconPath": "qianshoushenpitongguo",
  166. "text": "签收审核"
  167. },{
  168. "pagePath": "/pages/mine/index",
  169. "iconPath": "wode2",
  170. "selectedIconPath": "wode-active",
  171. "text": "我的"
  172. }],
  173. list5: [{
  174. "pagePath": "/pages/index/index",
  175. "iconPath": "gonghuiyuyue-wodeyuyuelan",
  176. "selectedIconPath": "yuyue1",
  177. "text": "扫码预约"
  178. },{
  179. "pagePath": "/pages/salesOrderMan/index",
  180. "iconPath": "yundans",
  181. "selectedIconPath": "yundans-fill",
  182. "text": "物流订单"
  183. },{
  184. "pagePath": "/pages/mine/index",
  185. "iconPath": "wode2",
  186. "selectedIconPath": "wode-active",
  187. "text": "我的"
  188. }],
  189. list6: [{ //ship
  190. "pagePath": "/pages/index/index",
  191. "iconPath": "gonghuiyuyue-wodeyuyuelan",
  192. "selectedIconPath": "yuyue1",
  193. "text": "扫码预约"
  194. },{
  195. "pagePath": "/otherPages/loadArrive/index",
  196. "iconPath": "loadArrive",
  197. "selectedIconPath": "yundans-fill",
  198. "text": "报港预约"
  199. },{
  200. "pagePath": "/pages/mine/index",
  201. "iconPath": "wode2",
  202. "selectedIconPath": "wode-active",
  203. "text": "我的"
  204. }],
  205. }],
  206. }
  207. })