App.vue 4.6 KB

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