123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198 |
- import Vue from 'vue'
- import VueRouter from 'vue-router'
- import { getUser } from '@/utils/auth'
- const Index = () => import('@/pages/index');
- const Login = () => import('@/pages/login');
- // 首页
- const Home = () => import('@/pages/subPages/home');
- const order = () => import('@/pages/subPages/order');
- const balance = () => import('@/pages/subPages/balance');
- const Message = () => import('@/pages/subPages/message');
- const View = () => import('@/pages/subPages/view');
- // 油卡充值
- const OilCard = () => import('@/pages/subPages/oilCard');
- // 手机卡充值
- const MobileCard = () => import('@/pages/subPages/mobileCard');
- // 接口文档
- const InterfaceDoc = () => import('@/pages/subPages/interfaceDoc')
- // 对账管理
- const Reconciliation = () =>import('@/pages/subPages/reconciliation');
- // 手机
- const phoneIndex = () => import('@/pages/phoneIndex');
- // 首页
- const phoneHome = () => import('@/pages/phoneSubPages/phoneHome');
- const phoneBalance = () => import('@/pages/phoneSubPages/phoneBalance');
- const phoneOrder = () => import('@/pages/phoneSubPages/phoneOrder');
- const phoneMessage = () => import('@/pages/phoneSubPages/phoneMessage');
- const phoneOilCard = () => import('@/pages/phoneSubPages/phoneOilCard');
- const phoneMobileCard = () => import('@/pages/phoneSubPages/phoneMobileCard');
- const phoneReconciliation = () => import('@/pages/phoneSubPages/phoneReconciliation');
- const phoneView = () => import('@/pages/phoneSubPages/phoneView');
- const phoneDoc = () => import('@/pages/phoneSubPages/phoneDoc');
- Vue.use(VueRouter)
- const routes = [
- {
- path: '/',
- name: 'Index',
- component: Index,
- // redirect:'/login',
- // redirect:'/order',
- children:[
- // 主页
- {
- path: '',
- name: 'home',
- component: Home
- },
- // 订单统计
- {
- path:'/order',
- name:'order',
- component:order
- },
- // 余额充值
- {
- path:'/balance',
- name:'balance',
- component:balance
- },
- // 实时动账
- {
- path:'/message',
- name:'message',
- component:Message
- },
- // 开发者设置
- {
- path:'/view',
- name:'view',
- component:View
- },
- // 油卡充值
- {
- path:'/oilCard',
- name:'oilCard',
- component:OilCard
- },
- // 话费充值
- {
- path:'/mobileCard',
- name:'mobileCard',
- component:MobileCard
- },
- // 接口文档
- {
- path:'/interfaceDoc',
- name:'interfaceDoc',
- component:InterfaceDoc
- },
- // 对账管理
- {
- path:'/reconciliation',
- name:'reconciliation',
- component:Reconciliation
- }
- ]
- },
- {
- path: '/login',
- name: 'Login',
- component: Login
- },
- {
- path: '/phoneIndex',
- name: 'phoneIndex',
- component: phoneIndex,
- redirect:'/phoneHome',
- children: [
- // 主页
- {
- path: '/phoneHome',
- name: 'phoneHome',
- component: phoneHome
- },
- // 余额充值
- {
- path:'/phoneBalance',
- name:'phoneBalance',
- component:phoneBalance
- },
- // 订单管理
- {
- path:'/phoneOrder',
- name:'phoneOrder',
- component:phoneOrder
- },
- // 账户日志 phoneMessage
- {
- path:'/phoneMessage',
- name:'phoneMessage',
- component:phoneMessage
- },
- // 油卡充值
- {
- path:'/phoneOilCard',
- name:'phoneOilCard',
- component: phoneOilCard
- },
- // 手机卡充值 phoneMobileCard
- {
- path:'/phoneMobileCard',
- name:'phoneMobileCard',
- component: phoneMobileCard
- },
- // 对账管理 phoneReconciliation
- {
- path:'/phoneReconciliation',
- name:'phoneReconciliation',
- component: phoneReconciliation
- },
- // 设置 phoneView
- {
- path:'/phoneView',
- name:'phoneView',
- component: phoneView
- },
- // 接口文档 phoneDoc
- {
- path:'/phoneDoc',
- name:'phoneDoc',
- component: phoneDoc
- }
- ]
- }
- ]
- const router = new VueRouter({
- routes,
- mode: 'hash',
- base: '/mchsrv'
- })
- /* 判断PC或移动端 */
- function IsPC() {
- var userAgentInfo = navigator.userAgent;
- var Agents = ["Android", "iPhone", "SymbianOS", "Windows Phone", "iPad", "iPod"];
- var flag = true;
- for (var v = 0; v < Agents.length; v++) {
- if (userAgentInfo.indexOf(Agents[v]) > 0) {
- flag = false;
- break;
- }
- }
- return flag;
- }
- router.beforeEach((to,from,next)=>{
- if (to.path !== '/login' && !getUser('name')) {
- next('/login')
- }
- if (IsPC() && to.path.indexOf('phone')>0) {
- next('/login')
- }
- next();
- });
- export default router
|