app.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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. /** api 模式 */
  74. api_mode: 'prod',
  75. /** api域名 */
  76. // api_domain:{
  77. // api_base: 'https://api.base.wdklian.com/',//''https://dev.base.wdklian.com/',//,
  78. // api_buyer: 'https://api.buyer.wdklian.com/',//'http://127.0.0.1:7002/',//
  79. // api_seller: 'https://api.seller.wdklian.com/',//'http://127.0.0.1:7003/',//
  80. // api_admin: 'https://api.admin.wdklian.com/', //'http://127.0.0.1:7004/',//
  81. // }
  82. api_domain:{
  83. api_base: 'https://api.base.wdklian.com/',//''https://dev.base.wdklian.com/',//,
  84. api_buyer: 'https://api.buyer.wdklian.com/',//'http://127.0.0.1:7002/',//
  85. api_seller: 'https://api.seller.wdklian.com/',//'http://127.0.0.1:7003/',//
  86. api_admin: 'https://api.admin.wdklian.com/', //'http://127.0.0.1:7004/',//
  87. }
  88. }
  89. })