App.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. <script>
  2. import store from '@/store'
  3. import StoreModel from '@/common/model/Store'
  4. import {
  5. getSceneData
  6. } from './core/app'
  7. import {
  8. isObject
  9. } from './utils/util'
  10. import storage from '@/utils/storage'
  11. export default {
  12. /**
  13. * 全局变量
  14. */
  15. globalData: {},
  16. onShow(path) {
  17. // console.log('app - onShow', path)
  18. // this.onStartupQuery(path)
  19. },
  20. /**
  21. * 初始化完成时触发
  22. */
  23. onLaunch(path) {
  24. // #ifdef MP
  25. // console.log('app - onLaunch', path)
  26. // #endif
  27. this.onStartupQuery(path)
  28. // #ifdef APP-PLUS
  29. this.$navTo('pages/txmLogin/index')
  30. // #endif
  31. // // app启动参数
  32. // this.onStartupQuery(isObject(query) ? query : {})
  33. },
  34. methods: {
  35. // app启动参数
  36. onStartupQuery(path) {
  37. const query = path.query
  38. // 微信鉴权
  39. StoreModel.getApiData(query).then((res) => {
  40. let param = query?.param ? query?.param.split(',') : ['', '']
  41. if (res.resCode) {
  42. if (param[1] === 'enterprise') {
  43. console.log('******************企业注册页面******************')
  44. } else if (param[1] === 'shopping') {
  45. if (!storage.get('wx_qym')) {
  46. this.$navTo('pages/authentication/index')
  47. return
  48. }
  49. console.log('******************商场选购页面******************')
  50. } else if (param[1] === 'activation') {
  51. console.log('******************用户激活页面******************')
  52. } else if (param[1] === 'tiaoxingma') {
  53. console.log('******************条形码******************')
  54. }
  55. if (param[0]) {
  56. console.log(param[0], 'padding')
  57. this.$navTo(param[0])
  58. } else {
  59. console.log('没有指定路由,跳转默认路由', storage.get('wx_v'))
  60. switch (storage.get('wx_v')) {
  61. case 'enterprise':
  62. if (storage.get('wx_userinfo').customertype == '代理商') {
  63. this.$navTo('pages/firm/home/index')
  64. } else {
  65. // 如果已经是代理商则直接登录
  66. this.$navTo('pages/firm/index')
  67. }
  68. break
  69. case 'shopping':
  70. if (!storage.get('wx_qym')) {
  71. this.$navTo('pages/authentication/index')
  72. } else {
  73. this.$navTo('pages/index/index')
  74. }
  75. break
  76. case 'activation':
  77. this.$navTo('pages/activationcode/index')
  78. break
  79. case 'tiaoxingma':
  80. this.$navTo('pages/tiaoxingma/index')
  81. break
  82. default:
  83. console.log('没有模式路由')
  84. this.$navTo('pages/empty')
  85. break
  86. }
  87. }
  88. } else {
  89. this.$navTo('pages/empty')
  90. let errMes = res.err || '错误!请退出重新打开'
  91. uni.showModal({
  92. title: '提示',
  93. content: errMes,
  94. showCancel: false
  95. })
  96. }
  97. // 激活路由器
  98. // this.$navTo('pages/activationcode/index')
  99. // 填写二维码
  100. // this.$navTo('pages/authentication/index')
  101. //
  102. // this.$navTo('pages/txmLogin/index')
  103. // this.$navTo('pages/tiaoxingma/index')
  104. // this.$navTo('pages/firm/authentication/index')
  105. // this.$navTo('pages/user/activatorder/index')
  106. })
  107. },
  108. // 小程序主动更新
  109. updateManager() {
  110. const updateManager = uni.getUpdateManager()
  111. updateManager.onCheckForUpdate((res) => {
  112. // 请求完新版本信息的回调
  113. // console.log(res.hasUpdate)
  114. })
  115. updateManager.onUpdateReady(() => {
  116. uni.showModal({
  117. title: '更新提示',
  118. content: '新版本已经准备好,即将重启应用',
  119. showCancel: false,
  120. success(res) {
  121. if (res.confirm) {
  122. // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
  123. updateManager.applyUpdate()
  124. }
  125. }
  126. })
  127. })
  128. updateManager.onUpdateFailed(() => {
  129. // 新的版本下载失败
  130. uni.showModal({
  131. title: '更新提示',
  132. content: '新版本下载失败',
  133. showCancel: false
  134. })
  135. })
  136. }
  137. }
  138. }
  139. </script>
  140. <style lang="scss">
  141. /* uView库样式 */
  142. @import './uni_modules/vk-uview-ui/index.scss';
  143. /* 项目基础样式 */
  144. @import './app.scss';
  145. /* iconfont图标库 */
  146. @import './utils/iconfont.scss';
  147. // 基础央视表
  148. @import './colorui/main.css';
  149. @import './colorui/icon.css';
  150. @import './colorui/animation.css';
  151. @import './colorui/reset.css';
  152. // gs-logo样式
  153. .gs-logo-box {
  154. width: 70rpx;
  155. height: 70rpx;
  156. border: 6rpx solid #fff;
  157. background: #fff;
  158. border-radius: 100%;
  159. overflow: hidden;
  160. }
  161. </style>