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 { showConfirm, } from '@/utils/common' 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() var rsing = 0 // rs() // let isrefresh=false // function rs(){ // const nowTime = new Date().getTime() // if (rsing==0 && nowTime > (getExpiresTime()-10*1000)&& !isrefresh) { // refreshToken({ // refreshToken: getRefreshToken() // }).then((res) => { // 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() { const currentPath = this.$route.path; this.$nextTick(() => { let navTitleDom = document.getElementsByClassName('uni-page-head__title'); // let navTitleDoms = navTitleDom.getElementsByTagName(''); if (navTitleDom.length) { if(currentPath == '/'||currentPath == '/pages/index' ||currentPath == '/pages/work/index'||currentPath == '/pages/mine/index'){ navTitleDom[0].style.display = 'none'; }else{ navTitleDom[0].innerText = '返回'; } if (typeof wx !== 'undefined' && wx.hideNavigationBarLoading) { wx.hideNavigationBarLoading() } } }) } } }) // #endif