12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- // 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'
- 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)
- })
- // Vue.prototype.common=common
- // Vue.http.options.emulateJSON = true;
- // Vue.http.options.headers = {'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8'};
- // Vue.http.interceptors.push((request, next) => {
- // next((response) => {}
- // })
- /* eslint-disable no-new */
- router.beforeEach((to, from, next) => {
- if (to.matched.some(record => record.meta.needLogin)) { // 判断该路由是否需要登录权限
- // 登录判断
- if (localStorage.getItem('userId')) { // 判断当前用户的登录信息loginInfo是否存在
- next()
- } else {
- next({
- path: '/Login'
- })
- }
- } else {
- next()
- }
- })
- new Vue({
- el: '#app',
- router,
- store: store,
- components: { App },
- template: '<App/>'
- })
|