app.js 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. //app.js
  2. var businessT = require('tool/business-tool.js')
  3. var sysT = require('tool/sys-tool.js')
  4. App({
  5. onLaunch: function (options) {
  6. sysT.adaptor()
  7. businessT.debugLog(sysT.isLongScreen())
  8. businessT.debugLog(sysT.suffixOfClass())
  9. // this.judgeVersion()
  10. // this.getUpdateReady()
  11. this.getNetworkStatus()
  12. // this.handleData()
  13. },
  14. onShow: function (e) {
  15. //console.log(e)
  16. this.globalData.scene = e.scene
  17. if (e.scene == 1037) {
  18. this.globalData.flow_id = e.referrerInfo.appId
  19. this.getflowAPP(e.referrerInfo.appId)
  20. } else {
  21. this.globalData.flow_id = 1000
  22. this.globalData.flow_name = "其他渠道来源"
  23. }
  24. },
  25. // handleData: function () {
  26. // //购买城市
  27. // var d
  28. // try {
  29. // d = swan.getStorageSync(key.StorageKey.purchaseCity)
  30. // } catch (e) {
  31. // }
  32. // if (!d) {
  33. // d = {
  34. // p: [{ name: '广东', id: 1000 }, { name: '北京市', id: 1100 }, { name: '上海市', id: 1200 }],
  35. // 1000: [{ name: '广州', id: 1001 }, { name: '深圳', id: 1014 }],
  36. // 1100: [{ name: '北京', id: 1101 }],
  37. // 1200: [{ name: '上海', id: 1201 }]
  38. // }
  39. // }
  40. // publicData.purchaseCity = d
  41. // swan.setStorageSync(key.StorageKey.purchaseCity, d)
  42. // businessT.debugLog(d)
  43. // },
  44. getUpdateReady: function () {
  45. updateManager.onUpdateReady(function () {
  46. swan.showModal({
  47. title: '更新提示',
  48. content: '新版本已经准备好,是否重启应用?',
  49. showCancel: false,
  50. success: function (res) {
  51. if (res.confirm) {
  52. // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
  53. updateManager.applyUpdate()
  54. }
  55. }
  56. })
  57. })
  58. },
  59. getNetworkStatus: function () {
  60. var that = this
  61. swan.getNetworkType({
  62. success: function (res) {
  63. // 返回网络类型, 有效值:
  64. // wifi/2g/3g/4g/unknown(Android下不常见的网络类型)/none(无网络)
  65. that.networkStatus.type = res.networkType
  66. if (that.networkStatus.type == 'none') {
  67. that.networkStatus.connected = false
  68. } else {
  69. that.networkStatus.connected = true
  70. }
  71. businessT.debugLog(that.networkStatus)
  72. }
  73. })
  74. swan.onNetworkStatusChange(function (res) {
  75. that.networkStatus.type = res.networkType
  76. that.networkStatus.connected = res.isConnected
  77. businessT.debugLog(that.networkStatus)
  78. })
  79. },
  80. // judgeVersion: function () {
  81. // var version = swan.getStorageSync(key.StorageKey.localVersion)
  82. // if (!version) {
  83. // swan.removeStorageSync(key.StorageKey.userCode)
  84. // swan.removeStorageSync(key.StorageKey.user)
  85. // swan.removeStorageSync(key.StorageKey.userPhone)
  86. // } else if (version < this.localVersion) {
  87. // } else {
  88. // }
  89. // swan.setStorageSync(key.StorageKey.localVersion, this.localVersion)
  90. // },
  91. initRedDotArray: function () {
  92. this.redDotArray = ['0', '0', '0', '0', '0']
  93. this.tabRedDot = '0'
  94. },
  95. tabRedDot: '0',
  96. redDotArray: ['0', '0', '0', '0', '0'],
  97. bankCardTips: {},
  98. loginStatus: {
  99. key: '',
  100. isLogin: false
  101. },
  102. networkStatus: {
  103. type: 'none',
  104. connected: false
  105. },
  106. idCard: {
  107. front: '',
  108. back: '',
  109. loaclPath: ''
  110. },
  111. purchase: {
  112. // normalPurchaseDataArray: [],
  113. // supplementaryPurchaseDataArray: [],
  114. purchaseDataArray: [],
  115. purchaseData: null,
  116. order: null
  117. },
  118. globalData: {
  119. scene: null,//进入小程序场景
  120. flow_id: 1000,//从其他平台跳转过来的appID
  121. flow_name: '其他渠道来源',//从其他平台跳转过来的平台名称
  122. customerList: [],
  123. userInfo: {
  124. uid: '',
  125. phone: ''
  126. }
  127. },
  128. localVersion: 1,
  129. })