app.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. //app.js
  2. import {
  3. guid
  4. } from '/utils/util.js'
  5. App({
  6. onLaunch: function() {
  7. /** 检查版本更新 */
  8. const updateManager = wx.getUpdateManager();
  9. updateManager.onCheckForUpdate(function (res) {
  10. if (res.hasUpdate)
  11. wx.clearStorageSync();
  12. })
  13. updateManager.onUpdateReady(function () {
  14. wx.showModal({
  15. title: '更新提示',
  16. content: '新版本已经准备好,是否重启应用?',
  17. success: function (res) {
  18. if (res.confirm) {
  19. // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
  20. updateManager.applyUpdate()
  21. }
  22. }
  23. })
  24. })
  25. //加载本地存储数据
  26. this.globalData.authorInfo = wx.getStorageSync('authorInfo')
  27. this.globalData.sellerUser = wx.getStorageSync('sellerUser')
  28. this.globalData.sellerShop = wx.getStorageSync('sellerShop')
  29. // 检查uuid参数,生成一个并写入本地存储
  30. var uuid = wx.getStorageSync('uuid')
  31. if (!uuid) {
  32. uuid = guid()
  33. this.globalData.uuid = uuid
  34. wx.setStorageSync('uuid', uuid)
  35. }
  36. else{
  37. this.globalData.uuid=uuid
  38. }
  39. },
  40. onShow(){
  41. //加载本地存储数据
  42. this.globalData.authorInfo = wx.getStorageSync('authorInfo')
  43. this.globalData.sellerUser = wx.getStorageSync('sellerUser')
  44. this.globalData.sellerShop = wx.getStorageSync('sellerShop')
  45. // 检查uuid参数,生成一个并写入本地存储
  46. var uuid = wx.getStorageSync('uuid')
  47. if (!uuid) {
  48. uuid = guid()
  49. this.globalData.uuid = uuid
  50. wx.setStorageSync('uuid', uuid)
  51. }
  52. else{
  53. this.globalData.uuid=uuid
  54. }
  55. },
  56. globalData: {
  57. /** 小程序类型 */
  58. miniProgramType:'miniprogramo2oseller',
  59. /** 用户uuid */
  60. uuid: null,
  61. /** 登录授权信息 */
  62. authorInfo:null,
  63. /** 卖家用户 */
  64. sellerUser: null,
  65. /** 卖家店铺 */
  66. sellerShop: null,
  67. /** 待处理订单角标 */
  68. orderNum:0,
  69. /** 今日订单数 */
  70. todayOrderNum:0,
  71. /** 今日订单金额 */
  72. todayOrderTotal:0,
  73. /** 待处理售后订单 */
  74. saleOrderTotal: 0,
  75. /** api 模式 */
  76. api_mode: 'prod',
  77. /** api域名 */
  78. // api_domain:{
  79. // api_base: 'http://192.168.1.199:7000/',//''https://dev.base.wdklian.com/',//,
  80. // api_buyer: 'http://192.168.1.199:7002/',//'https://api.buyer.wdklian.com/',//
  81. // api_seller: 'http://192.168.1.199:7003/',//'https://api.seller.wdklian.com/',//
  82. // api_admin: 'http://192.168.1.199:7004/',//'https://api.admin.wdklian.com/', //
  83. // }
  84. api_domain:{
  85. api_base: 'https://api.base.wdklian.com/',//,'https://api.base.wdklian.com/',//''https://dev.base.wdklian.com/',//,
  86. api_buyer: 'https://api.buyer.wdklian.com/',//'http://192.168.1.199:7002/',//'https://api.buyer.wdklian.com/',///'https://api.buyer.wdklian.com/',//
  87. api_seller: 'https://api.seller.wdklian.com/',//'http://192.168.1.199:7003/',//'https://api.seller.wdklian.com/',//
  88. api_admin: 'https://api.admin.wdklian.com/', //'http://192.168.1.199:7004/',//'https://api.admin.wdklian.com/', //
  89. }
  90. }
  91. })