import Vue from 'vue' import App from './App' import store from './store' // store import plugins from './plugins' // plugins import './permission' // permission import {refreshToken} from "@/api/login"; // import uView from 'uview-ui' import uView from '@/uni_modules/uview-ui' import $ from '@/pages/common/fun.js' import { getRefreshToken, getExpiresTime, setToken } from '@/utils/auth' // 在main.js中注册全局组件 import isLodingModel from './components/loading/loading.vue' Vue.component('isLodingModel', isLodingModel) // import navInfo from "@/pagesA/components/my-nav/nav.vue" // Vue.component('navInfo', navInfo) Vue.use(uView) Vue.use(plugins) Vue.config.productionTip = false Vue.prototype.$store = store Vue.prototype.$ = $ Vue.prototype.$screenHeight = uni.getSystemInfoSync().windowHeight App.mpType = 'app' const app = new Vue({ ...App }) app.$mount() console.log(getExpiresTime(),'getExpiresTime()'); var rsing=0 rs() let isrefresh=false function rs(){ // const nowTime = new Date().getTime() // if (rsing==0 && nowTime > (getExpiresTime()-10*1000)&& !isrefresh) { // console.log("===rs call",) // refreshToken({ // refreshToken: getRefreshToken() // }).then((res) => { // console.log(res.data, 'ressss') // setToken(res.data) // isrefresh = true; // 设置标志变量为 true // rsing=0 // setTimeout(function() { // isrefresh = false; // }, 11 * 1000) // }).catch(() => { // showConfirm('登录状态已过期,您可以继续留在该页面,或者重新登录?').then(res => { // if (res.confirm) { // uni.navigateTo({ // url: '/pages/login' // }) // } // }) // }) // } // setTimeout(function(){ // rs() // },1*1000) } // 判断是否断网的函数 function isOffline() { return !navigator.onLine; } // 监听断网事件 window.addEventListener('offline', function() { if (isOffline()) { showConfirm('登录状态已过期,您可以继续留在该页面,或者重新登录?').then((res) => { if (res.confirm) { uni.navigateTo({ url: '/pages/login', }); } }); } }); // #ifdef H5 Vue.mixin({ mounted() { if (this.isWeiXinBrowser() && !this.isCustomNav()) { this.navTitle() } }, methods: { isWeiXinBrowser() { let ua = navigator.userAgent.toLowerCase() return ua.indexOf('micromessenger') != -1 }, isCustomNav() { return this.$mp && this.$mp.appOptions && this.$mp.appOptions.window && this.$mp.appOptions.window.navigationStyle === 'custom'; }, navTitle() { this.$nextTick(() => { let navTitleDom = document.getElementsByTagName('uni-page-head') if (navTitleDom.length) { navTitleDom[0].style.display = 'none' if (typeof wx !== 'undefined' && wx.hideNavigationBarLoading) { wx.hideNavigationBarLoading() } } }) } } }) // #endif