index.js 4.99 KB
Newer Older
xd's avatar
xd committed
1 2 3 4 5
import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/home.vue'

import { getXToken, configWx } from '@/utils/aCommon'
xulili's avatar
xulili committed
6
import mineRoute from  './mine'
xd's avatar
xd committed
7 8 9 10 11
Vue.use(VueRouter)

const routes = [
  {
    path: '/',
xd's avatar
xd committed
12 13
    name: 'Me',
    component: () => import('@/views/mainSale/me/main/index')
xd's avatar
xd committed
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
  },
  {
    path: '/turntableDetail',
    name: 'turntableDetail',
    component: () => import('../views/active/turntableDetail.vue')
  },
  {
    path: '/couponDetail',
    name: 'couponDetail',
    component: () => import('../views/active/couponDetail.vue')
  },
  {
    path: '/createActive',
    name: 'createActive',
    component: () => import('../views/active/createActive.vue')
  },
  {
    path: '/activeList',
    name: 'activeList',
    component: () => import('../views/active/activeList.vue')
  },
  {
    path: '/createBigWheelActive',
    name: 'createBigWheelActive',
    component: () => import('../views/active/createBigWheelActive.vue')
  },
40 41 42 43 44 45 46 47 48 49
  {
    path: '/createSuccess',
    name: 'createSuccess',
    component: () => import('@/views/active/createSuccess')
  },
  {
    path: '/activeDetail',
    name: 'activeDetail',
    component: () => import('@/views/active/activeDetail')
  },
xd's avatar
xd committed
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
  {
    path: '/mainSale',
    name: 'MainSale',
    component: () => import('@/views/mainSale/active/main/index')
  },
  {
    path: '/changeCounter',
    name: 'changeCounter',
    component: () => import('@/views/counter/changeCounter')
  },
  {
    path: '/counterInfo',
    name: 'counterInfo',
    component: () => import('@/views/counter/counterInfo')
  },
  {
    path: '/counterMaintain',
    name: 'counterMaintain',
    component: () => import('@/views/counter/counterMaintain')
  },
xd's avatar
xd committed
70 71 72 73 74
  {
    path: '/counterHome',
    name: 'counterHome',
    component: () => import('@/views/counter/counterHomePage')
  },
xd's avatar
xd committed
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
  {
    path: '/counterEdit',
    name: 'counterEdit',
    component: () => import('@/views/counter/counterEdit')
  },
  {
    path: '/chargeCode',
    name: 'chargeCode',
    component: () => import('@/views/counter/chargeCode')
  },
  {
    path: '/pushStoreInfo',
    name: 'pushStoreInfo',
    component: () => import('@/views/counter/pushStoreInfo')
  },
xd's avatar
xd committed
90 91 92
  {
    path: '/goodManage',
    name: 'goodManage',
qkx's avatar
qkx committed
93 94 95 96 97
    component: () => import('@/views/goods/manage')
  },
  {
    path: '/goodManage1',
    name: 'goodManage1',
xd's avatar
xd committed
98 99 100
    component: () => import('@/views/goods/goodManage')
  },
  {
qkx's avatar
qkx committed
101
    path: '/goodGrounding1',
xd's avatar
xd committed
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139
    name: 'goodGrounding',
    component: () => import('@/views/goods/goodGrounding')
  },
  {
    path: '/profitList',
    name: 'profitList',
    component: () => import('@/views/profit/index')
  },
  {
    path: '/actTemplate',
    name: 'ActTemplate',
    component: () => import('@/views/mainSale/active/template/index')
  },
  {
    path: '/me',
    name: 'Me',
    component: () => import('@/views/mainSale/me/main/index')
  },
  {
    path: '/task',
    name: 'Task',
    component: () => import('@/views/mainSale/me/task/index')
  },
  {
    path: '/taskList',
    name: 'taskList',
    component: () => import('@/views/task/taskList')
  },
  {
    path: '/newMemberTask',
    name: 'newMemberTask',
    component: () => import('@/views/task/newMemberTask')
  },
  {
    path: '/case',
    name: 'case',
    component: () => import('@/views/case/index')
  },
140 141 142 143 144
  {
    path: '/caseEdit',
    name: 'caseEdit',
    component: () => import('@/views/case/caseEdit')
  },
xd's avatar
xd committed
145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163
  {
    path: '/caseDetail',
    name: 'caseDetail',
    component: () => import('@/views/case/caseDetail')
  },
  {
    path: '/newInfo',
    name: 'newInfo',
    component: () => import('@/views/message/newInfo')
  },
  {
    path: '/voucherInfo',
    name: 'VoucherInfo',
    component: () => import('@/views/voucherInfo/index')
  },
  {
    path: '/qrCode',
    name: 'qrCode',
    component: () => import('@/views/qrCode/index')
xulili's avatar
xulili committed
164
  },
xd's avatar
xd committed
165
   ...mineRoute
xd's avatar
xd committed
166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217
  // {
  //   path: '/about',
  //   name: 'about',
  //   // route level code-splitting
  //   // this generates a separate chunk (about.[hash].js) for this route
  //   // which is lazy-loaded when the route is visited.
  //   component: () => import(/* webpackChunkName: "about" */ '../views/About.vue')
  // }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

const whiteList = ['/discount', 'discount']

router.beforeEach((to, from ,next) => {
  // alert(`--->route: beforeEach: to =${JSON.stringify(to)}. from =${from}. next =${JSON.stringify(next)}`)
  if(whiteList.indexOf(to.path) != -1) {
    // alert(`--->route: beforeEach: If: UnIn whiteList.`)
    if(sessionStorage.getItem('zConfigWx') === 'Pass'){
      next()
    } else {
      configWx(to)
    }

  } else {
    // alert(`--->route: beforeEach: If: In whiteList.`)

    next()
  }

  // if (whiteList.indexOf(to.path) !== -1) {
  //   next()
  // } else {
  //   if(sessionStorage.getItem('unionid')) {
  //     next()
  //   } else {
  //     getUnionId(to)
  //     // next()
  //   }
  // }
})

// async function getUnionId (to) {
//   await getXToken()
//   configWx(to)
// }

export default router