| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400 |
- import { createWebHashHistory, RouteRecordRaw } from 'vue-router'
- import { useLoginStore } from '@/stores'
- import service from '@/services'
- import Page from '@mobile/components/layouts/page/index.vue'
- import animateRouter from './animateRouter'
- const { getToken } = useLoginStore()
- const routes: Array<RouteRecordRaw> = [
- {
- path: '/:pathMatch(.*)*',
- name: 'error',
- component: () => import('../views/error/404.vue'),
- meta: {
- ignoreAuth: true,
- },
- },
- {
- path: '/boot',
- name: 'boot',
- component: () => import('../views/boot/index.vue'),
- meta: {
- ignoreAuth: true,
- },
- },
- {
- path: '/',
- component: Page,
- children: [
- {
- path: '',
- name: 'home',
- component: () => import('../views/home/index.vue'),
- }
- ]
- },
- {
- path: '/login',
- component: Page,
- children: [
- {
- path: '',
- name: 'login',
- component: () => import('../views/user/login/index.vue'),
- meta: {
- ignoreAuth: true,
- },
- }
- ]
- },
- {
- path: '/logoff',
- component: Page,
- children: [
- {
- path: '',
- name: 'logoff',
- component: () => import('../views/user/logoff/index.vue'),
- }
- ]
- },
- {
- path: '/register',
- component: Page,
- children: [
- {
- path: '',
- name: 'register',
- component: () => import('../views/user/register/index.vue'),
- meta: {
- ignoreAuth: true,
- },
- }
- ]
- },
- {
- path: '/forget',
- component: Page,
- children: [
- {
- path: '',
- name: 'forget',
- component: () => import('../views/user/forget/index.vue'),
- meta: {
- ignoreAuth: true,
- },
- },
- ]
- },
- {
- path: '/account',
- component: Page,
- children: [
- {
- path: 'certification',
- name: 'account-certification',
- component: () => import('../views/account/certification/index.vue'),
- meta: {
- ignoreAuth: true,
- },
- }
- ]
- },
- {
- path: '/news',
- component: Page,
- children: [
- {
- path: 'details',
- name: 'news-details',
- component: () => import('../views/news/details/index.vue'),
- meta: {
- ignoreAuth: true,
- },
- },
- {
- path: 'list',
- name: 'news-list',
- component: () => import('../views/news/list/index.vue'),
- meta: {
- ignoreAuth: true,
- },
- }
- ]
- },
- {
- path: '/product',
- component: Page,
- children: [
- {
- path: '',
- name: 'product',
- component: () => import('../views/product/list/index.vue'),
- meta: {
- ignoreAuth: true,
- },
- },
- {
- path: 'detail',
- name: 'product-detail',
- component: () => import('../views/product/detail/index.vue'),
- meta: {
- ignoreAuth: true,
- },
- }
- ]
- },
- {
- path: '/goods',
- component: Page,
- children: [
- {
- path: 'details',
- name: 'goods-details',
- component: () => import('../views/goods/details/index.vue'),
- meta: {
- ignoreAuth: true,
- },
- }
- ]
- },
- {
- path: '/market',
- component: Page,
- children: [
- {
- path: '',
- name: 'market',
- component: () => import('../views/market/main/index.vue'),
- },
- {
- path: 'detail',
- name: 'market-detail',
- component: () => import('../views/market/details/index.vue'),
- }
- ]
- },
- {
- path: '/bank',
- component: Page,
- children: [
- {
- path: 'bank',
- name: 'bank-wallet',
- component: () => import('../views/bank/wallet/index.vue'),
- },
- {
- path: 'sign',
- name: 'bank-sign',
- component: () => import('../views/bank/sign/index.vue'),
- },
- {
- path: 'edit',
- name: 'add-banksign',
- component: () => import('../views/bank/sign/components/edit/index.vue'),
- },
- {
- path: 'statement',
- name: 'bank-statement',
- component: () => import('../views/bank/statement/index.vue'),
- },
- {
- path: 'hisstatement',
- name: 'bank-hisstatement',
- component: () => import('../views/bank/hisstatement/index.vue'),
- },
- ]
- },
- {
- path: '/order',
- component: Page,
- children: [
- {
- path: '',
- name: 'my-order',
- component: () => import('../views/mine/order/list/index.vue'),
- },
- {
- path: 'purchasetradedetail',
- name: 'purchase-trade-detail',
- component: () => import('../views/mine/order/detail/purchasetrade/index.vue'),
- },
- {
- path: 'wrtradedetail',
- name: 'wrtrade-detail',
- component: () => import('../views/mine/order/detail/wrtrade/index.vue'),
- },
- {
- path: 'wrorderdetail',
- name: 'wrorder-detail',
- component: () => import('../views/mine/order/detail/wrorder/index.vue'),
- }
- ]
- },
- {
- path: '/wareorder',
- component: Page,
- children: [
- {
- path: '',
- name: 'my-wareorder',
- component: () => import('../views/mine/wareorder/list/index.vue'),
- },
- {
- path: 'wroutinapplydetail',
- name: 'wroutinapply-detail',
- component: () => import('../views/mine/wareorder/wroutinapplydetail/index.vue'),
- }
- ]
- },
- {
- path: '/rules',
- component: Page,
- children: [
- {
- path: 'ptgz',
- name: 'rules-ptgz',
- component: () => import('../views/rules/ptgz/index.vue'),
- },
- {
- path: 'myrz',
- name: 'rules-myrz',
- component: () => import('../views/rules/myrz/index.vue'),
- },
- {
- path: 'ccwl',
- name: 'rules-ccwl',
- component: () => import('../views/rules/ccwl/index.vue'),
- },
- {
- path: 'zcxy',
- name: 'rules-zcxy',
- component: () => import('../views/rules/zcxy/index.vue'),
- meta: {
- ignoreAuth: true,
- },
- },
- {
- path: 'yhkhfxgzs',
- name: 'rules-yhkhfxgzs',
- component: () => import('../views/rules/fxgzs/index.vue'),
- meta: {
- ignoreAuth: true,
- },
- },
- {
- path: 'yszc',
- name: 'rules-yszc',
- component: () => import('../views/rules/yszc/index.vue'),
- meta: {
- ignoreAuth: true,
- },
- },
- {
- path: 'gywm',
- name: 'rules-gywm',
- component: () => import('../views/rules/gywm/index.vue'),
- },
- {
- path: 'fpsm',
- name: 'rules-fpsm',
- component: () => import('../views/rules/fpsm/index.vue'),
- },
- {
- path: 'fwrx',
- name: 'rules-fwrx',
- component: () => import('../views/rules/fwrx/index.vue'),
- },
- ]
- },
- {
- path: '/credit',
- component: Page,
- children: [
- {
- path: 'signin',
- name: 'credit-signin',
- component: () => import('../views/credit/signin/index.vue'),
- },
- {
- path: 'statement',
- name: 'credit-statement',
- component: () => import('../views/credit/statement/index.vue'),
- },
- {
- path: 'lottery',
- name: 'credit-lottery',
- component: () => import('../views/credit/lottery/index.vue'),
- },
- ]
- },
- {
- path: '/mine',
- component: Page,
- children: [
- {
- path: 'generalize',
- name: 'mine-generalize',
- component: () => import('../views/mine/generalize/index.vue'),
- },
- {
- path: 'service',
- name: 'mine-service',
- component: () => import('../views/mine/service/index.vue'),
- },
- {
- path: 'address',
- name: 'mine-address',
- component: () => import('../views/mine/address/index.vue'),
- },
- ]
- },
- {
- path: '/setting',
- component: Page,
- children: [
- {
- path: '',
- name: 'setting',
- component: () => import('../views/setting/main/index.vue'),
- },
- {
- path: 'password',
- name: 'setting-password',
- component: () => import('../views/setting/password/index.vue'),
- },
- ]
- }
- ]
- const router = animateRouter.create({
- history: createWebHashHistory(),
- routes,
- })
- // 路由跳转拦截
- router.beforeEach((to, from, next) => {
- // 判断服务是否加载完成
- if (service.isReady) {
- if (to.meta.ignoreAuth || getToken()) {
- next();
- } else {
- next({
- name: 'login',
- query: { redirect: to.fullPath },
- });
- }
- } else {
- if (to.name === 'boot' || to.name === 'login') {
- next();
- } else {
- next({
- name: 'boot',
- query: { redirect: to.fullPath },
- });
- }
- }
- })
- export default router
|