main.js 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. import Vue from 'vue'
  2. import App from './App'
  3. import store from './store' // store
  4. import plugins from './plugins' // plugins
  5. import './permission' // permission
  6. import {refreshToken} from "@/api/login";
  7. // import uView from 'uview-ui'
  8. import uView from '@/uni_modules/uview-ui'
  9. import $ from '@/pages/common/fun.js'
  10. import {
  11. getRefreshToken,
  12. getExpiresTime,
  13. setToken
  14. } from '@/utils/auth'
  15. // 在main.js中注册全局组件
  16. import isLodingModel from './components/loading/loading.vue'
  17. Vue.component('isLodingModel', isLodingModel)
  18. // import navInfo from "@/pagesA/components/my-nav/nav.vue"
  19. // Vue.component('navInfo', navInfo)
  20. Vue.use(uView)
  21. Vue.use(plugins)
  22. Vue.config.productionTip = false
  23. Vue.prototype.$store = store
  24. Vue.prototype.$ = $
  25. Vue.prototype.$screenHeight = uni.getSystemInfoSync().windowHeight
  26. App.mpType = 'app'
  27. const app = new Vue({
  28. ...App
  29. })
  30. app.$mount()
  31. console.log(getExpiresTime(),'getExpiresTime()');
  32. // var rsing=0
  33. // rs()
  34. // let isrefresh=false
  35. // function rs(){
  36. // const nowTime = new Date().getTime()
  37. // if (rsing==0 && nowTime > (getExpiresTime()-10*1000)&& !isrefresh) {
  38. // console.log("===rs call",)
  39. // refreshToken({
  40. // refreshToken: getRefreshToken()
  41. // }).then((res) => {
  42. // console.log(res.data, 'ressss')
  43. // setToken(res.data)
  44. // isrefresh = true; // 设置标志变量为 true
  45. // rsing=0
  46. // setTimeout(function() {
  47. // isrefresh = false;
  48. // }, 11 * 1000)
  49. // }).catch(() => {
  50. // /*
  51. // showConfirm('登录状态已过期,您可以继续留在该页面,或者重新登录?').then(res => {
  52. // if (res.confirm) {
  53. // uni.navigateTo({
  54. // url: '/pages/login'
  55. // })
  56. // }
  57. // })*/
  58. // })
  59. // }
  60. // setTimeout(function(){
  61. // rs()
  62. // },1*1000)
  63. // }
  64. // #ifdef H5
  65. Vue.mixin({
  66. mounted() {
  67. if (this.isWeiXinBrowser() && !this.isCustomNav()) {
  68. this.navTitle()
  69. }
  70. },
  71. methods: {
  72. isWeiXinBrowser() {
  73. let ua = navigator.userAgent.toLowerCase()
  74. return ua.indexOf('micromessenger') != -1
  75. },
  76. isCustomNav() {
  77. return this.$mp && this.$mp.appOptions && this.$mp.appOptions.window && this.$mp.appOptions.window.navigationStyle === 'custom';
  78. },
  79. navTitle() {
  80. this.$nextTick(() => {
  81. let navTitleDom = document.getElementsByTagName('uni-page-head')
  82. if (navTitleDom.length) {
  83. navTitleDom[0].style.display = 'none'
  84. if (typeof wx !== 'undefined' && wx.hideNavigationBarLoading) {
  85. wx.hideNavigationBarLoading()
  86. }
  87. }
  88. })
  89. }
  90. }
  91. })
  92. // #endif