App.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. <script>
  2. export default {
  3. globalData: {
  4. tabbarIndex: 0,
  5. authorization: '',
  6. storeId: '',
  7. userId: '',
  8. roleId:''
  9. },
  10. onLaunch: function() {
  11. console.log('App Launch');
  12. uni.getStorage({
  13. key: 'loginInfo',
  14. success: (res) => {
  15. console.log('登录')
  16. this.globalData.authorization = res.data.Authorization;
  17. this.globalData.userId = res.data.userId;
  18. // uni.showLoading({
  19. // title:'加载中……',
  20. // mask:true
  21. // })
  22. // uni.switchTab({
  23. // url:'pages/book/index/index'
  24. // })
  25. // uni.switchTab({
  26. // url:'pages/center/index/index',
  27. // })
  28. // uni.switchTab({
  29. // url:'pages/settlement/index/index'
  30. // })
  31. uni.switchTab({
  32. url: 'pages/book/index/index'
  33. })
  34. uni.setStorage({
  35. key: 'tabbarIndex',
  36. data: 1,
  37. success: (res) => {
  38. this.globalData.tabbarIndex = 1;
  39. }
  40. })
  41. },
  42. fail: () => {
  43. }
  44. })
  45. },
  46. onShow: function() {
  47. console.log('App Show ')
  48. uni.hideTabBar();
  49. // const KJJPush = uni.requireNativePlugin('KJ-JPush');
  50. // KJJPush.setAlias(this.globalData.userId,1,result => {
  51. // console.log("setAlias:"+JSON.stringify(result));
  52. // });
  53. // KJJPush.getAlias_seq(1,result => {
  54. // console.log("getAlias_seq:"+JSON.stringify(result));
  55. // });
  56. // #ifdef APP-PLUS
  57. setTimeout(()=>{
  58. this.versionVerification();
  59. },500)
  60. // #endif
  61. },
  62. mounted() {
  63. this.getDic();
  64. },
  65. onLoad: function() {
  66. },
  67. onHide: function() {
  68. console.log('App Hide')
  69. },
  70. watch: {
  71. '$store.state.dicChange'(newval, oldval) {
  72. if (newval) {
  73. console.log('')
  74. this.getDic();
  75. }
  76. }
  77. },
  78. methods: {
  79. versionVerification() {
  80. var productId = uni.getSystemInfoSync().platform == 'ios' ? 2 : 1;
  81. var versionNo = plus.runtime.version;
  82. console.log('当前版本号',productId,versionNo)
  83. this.$axios.post('system/sysVersion/', {
  84. "productId": productId,
  85. "versionNo": versionNo
  86. }).then(res => {
  87. console.log('查询到的版本',res)
  88. var url = res.data?res.data.productUrl:'';
  89. var status= res.data?res.data.status:1;
  90. if(status==0){
  91. if (url){
  92. uni.showModal({
  93. title: '提示',
  94. content: '版本过旧请升级',
  95. cancelText: '取消退出',
  96. confirmText: '前往升级',
  97. success: function(res) {
  98. if (res.confirm) {
  99. plus.runtime.openURL(url, function(res) {
  100. console.log(res);
  101. });
  102. } else if (res.cancel) {
  103. plus.runtime.quit();
  104. }
  105. }
  106. });
  107. }else{
  108. uni.showModal({
  109. title: '提示',
  110. content: '当前版本已经停用,请前往官网下载最新版本',
  111. showCancel:false,
  112. confirmText: '知道了',
  113. success: function(res) {
  114. if (res.confirm) {
  115. }
  116. }
  117. });
  118. }
  119. }
  120. }).catch(err => {
  121. console.log('错误',err.msg)
  122. })
  123. },
  124. getDic() {
  125. uni.getStorage({
  126. key: 'dic',
  127. fail: (err) => {
  128. this.$axios.post('app/dic/findAllDic', {}).then(res => {
  129. console.log(res.data)
  130. uni.setStorage({
  131. key: 'dic',
  132. data: res.data
  133. })
  134. this.$store.state.dicChange = false;
  135. }).catch(err => {
  136. console.log(err.msg)
  137. })
  138. }
  139. })
  140. },
  141. }
  142. }
  143. </script>
  144. <style>
  145. /* @import '@/common/css/common.scss';
  146. @import '@/common/css/iconfont.css'; */
  147. </style>
  148. <style lang="scss">
  149. /* 注意要写在第一行,同时给style标签加入lang="scss"属性 */
  150. @import "@/uni_modules/uview-ui/index.scss";
  151. </style>