// The Vue build version to load with the `import` command // (runtime-only or standalone) has been set in webpack.base.conf with an alias. import Vue from 'vue' import { VueJsonp } from 'vue-jsonp' Vue.use(VueJsonp) import App from './App' import router from './router' import store from './store/store' // 引入store import resource from 'vue-resource' // 引入vue-resource import tabbar from './components/tabbar.vue' import banner from './components/banner.vue' import back from './components/back.vue' import backIndex from './components/backindex.vue' import Vant from 'vant' import clipboard from 'clipboard' import 'vant/lib/index.css' import wx from 'weixin-js-sdk' import VConsole from 'vconsole'; const vconsole = new VConsole() import request from "@/utils/request" Vue.prototype.$axios = request Vue.prototype.$wx = wx Vue.component('tabbar', tabbar) Vue.component('banner', banner) Vue.component('back', back) Vue.component('backindex', backIndex) Vue.config.productionTip = false Vue.use(Vant) Vue.use(resource) import common from './script/common.js' Vue.use(common) Vue.prototype.clipboard = clipboard // 时间戳过滤器 Vue.filter('dateFormat', (dataStr) => { var time = new Date(dataStr) function timeAdd0(str) { if (str < 10) { str = '0' + str } return str } var y = time.getFullYear() var m = time.getMonth() + 1 var d = time.getDate() var h = time.getHours() var mm = time.getMinutes() var s = time.getSeconds() return y + '-' + timeAdd0(m) + '-' + timeAdd0(d) + ' ' + timeAdd0(h) + ':' + timeAdd0(mm) + ':' + timeAdd0(s) }) // import { getWxOpenId } from './script/wxGetOpenId.js' export { getWxOpenId } from './script/wxGetOpenId.js' const whiteList = ['/Login'] router.beforeEach((to, from, next) => { // if (to.matched.some(record => record.meta.needLogin)) { // 判断该路由是否需要登录权限 if (!whiteList.includes(to.path)) { console.log('有登录权限') if (!localStorage.getItem('userId')) { // 判断当前用户的登录信息userId是否存在 console.log('无userId') next('/Login') } else if (!localStorage.getItem('openid')) { console.log('无openId') // overallExample.getOpenid() getWxOpenId() console.log('overallExample.getOpenid()走完了') } else { console.log('什么都有') next() } } else { console.log('无登录权限') next(); } }) new Vue({ el: '#app', router, store: store, components: { App }, template: '', })