App.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. <script>
  2. import { VerifyAppid } from 'API/cloud'
  3. import { appVersion } from 'config.js'
  4. import { mapActions, mapMutations } from 'vuex'
  5. // import UpdateApp from './utils/updateApp.js'
  6. export default {
  7. globalData: {
  8. // 图片缓存
  9. imgDict: {},
  10. // 选项默认选中值桥
  11. // guid 选项的唯一标识符
  12. // defaultVal 默认选中的值数组
  13. // maxlength 最多能选择多少项
  14. // list 自定义列表数据数组
  15. // title 标题名
  16. // config 其他配置信息
  17. // config.labelField 选项中展示的字段
  18. // config.valueField 选项值字段
  19. // config.checkFn 点击确定时的校验方法,必须返回一个Boolean值(暂时在user类型上实现)
  20. // params 请求附加参数 *list有值时该项不生效
  21. // request 自定义列表请求 *list有值时该项不生效
  22. selectedValBridge: {},
  23. auditInfo: {}, // 审批信息
  24. // 自定义表单
  25. // default 表单字段设置默认表单值
  26. // key-value (eg: { id: [{id: 15, name: '张三' }] } )
  27. // assignForm 保存表单时默认追加的 key-value (eg: { id: 15 })
  28. // fields 字段库
  29. formBridge: {},
  30. // 自定义筛选项中转
  31. // choose 已经选择的筛选字段
  32. // other 未选择的筛选字段
  33. filterBridge: {},
  34. // 临时数据缓存,用完即删
  35. cacheDataBridge: null
  36. },
  37. data() {
  38. return {
  39. loading: false,
  40. // isLaunchOk: false
  41. }
  42. },
  43. onLaunch: function() {
  44. // this.isLaunchOk = true
  45. // #ifdef APP-PLUS
  46. // const instance = new UpdateApp()
  47. // instance.check().then(resData => {
  48. // if (resData.downloadUrl) {
  49. // uni.showModal({
  50. // title: '更新提示',
  51. // content: resData.remark || '新版本已经准备好,是否更新?',
  52. // success(res) {
  53. // if (res.confirm) {
  54. // // 点击确定,更新
  55. // console.log('点击确定更新--')
  56. // instance.install(resData)
  57. // } else if (res.cancel && resData.force) {
  58. // // 点击取消
  59. // plus.runtime.quit()
  60. // }
  61. // },
  62. // fail(e) {
  63. // if (resData.force) {
  64. // plus.runtime.quit()
  65. // }
  66. // }
  67. // })
  68. // }
  69. // })
  70. // #endif
  71. this.initApp()
  72. },
  73. onShow: function() {
  74. console.log('App Show')
  75. // this.initApp()
  76. },
  77. onHide: function() {
  78. console.log('App Hide')
  79. },
  80. methods: {
  81. ...mapActions({
  82. setUserData: 'user/setUserData'
  83. }),
  84. ...mapMutations({
  85. SET_TOKEN: 'user/SET_TOKEN'
  86. }),
  87. async initApp() {
  88. if (this.loading) return
  89. this.loading = true
  90. const token = uni.getStorageSync('token') || null
  91. const version = uni.getStorageSync('version') || null
  92. const appid = uni.getStorageSync('appid') || ''
  93. // #ifdef MP-WEIXIN
  94. if (version !== appVersion) {
  95. // 升级后清空微信缓存,重新登录
  96. this.$clearStorage()
  97. this.$Router.reLaunch('/pages/login/index')
  98. this.loading = false
  99. return
  100. }
  101. // #endif
  102. this.SET_TOKEN(token)
  103. if (!token) {
  104. this.$clearStorage()
  105. this.$Router.reLaunch('/pages/login/index')
  106. this.loading = false
  107. return
  108. }
  109. await this.setUserData()
  110. this.loading = false
  111. },
  112. verifyApp(params) {
  113. }
  114. }
  115. }
  116. </script>
  117. <style lang="scss">
  118. @import './static/iconfont/iconfont.css';
  119. @import './static/iconfont-flutter/iconfont.css';
  120. /* 每个页面公共css */
  121. @import './style/reset.scss';
  122. @import './style/theme.scss';
  123. @import './style/uni.theme.scss';
  124. </style>