| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451 |
- import { createWebHashHistory, RouteRecordRaw } from 'vue-router'
- import { useLoginStore } from '@/stores'
- import { clearPending } from '@/services/http/pending'
- import { homeRoutes, pageRoutes } from '@mobile/router/section'
- import service from '@/services'
- import Page from '@mobile/components/layouts/page/index.vue'
- import animateRouter from '@mobile/router/animateRouter'
- const loginStore = useLoginStore()
- const routes: Array<RouteRecordRaw> = [
- {
- path: '/:pathMatch(.*)*',
- name: 'error',
- component: () => import('@mobile/views/error/404.vue'),
- meta: {
- ignoreAuth: true,
- },
- },
- {
- path: '/boot',
- name: 'boot',
- component: () => import('../views/boot/index.vue'),
- meta: {
- ignoreAuth: true,
- },
- },
- {
- path: '/register',
- component: Page,
- children: [
- {
- path: '',
- name: 'register',
- component: () => import('@mobile/views/user/register/home.vue'),
- meta: {
- ignoreAuth: true,
- },
- props: {
- showYhkhfxgzs: false,
- insetStyle: false
- }
- }
- ]
- },
- {
- path: '/',
- component: Page,
- children: [
- {
- path: '',
- name: 'home',
- component: () => import('../views/home/index.vue'),
- children: [
- {
- path: '',
- name: 'home-index',
- component: () => import('../views/home/main/index.vue'),
- meta: {
- ignoreAuth: true,
- },
- },
- {
- path: 'spot',
- name: 'home-spot',
- component: () => import('../views/spot/goods/list/index.vue'),
- },
- {
- path: 'contract',
- name: 'home-contract',
- component: () => import('../views/contract/goods/list/index.vue'),
- },
- {
- path: 'wallet',
- name: 'home-wallet',
- component: () => import('../views/wallet/index.vue'),
- },
- ]
- }
- ],
- },
- {
- path: '/spot',
- component: Page,
- children: [
- {
- path: 'detail',
- name: 'spot-detail',
- component: () => import('../views/spot/detail/index.vue'),
- },
- {
- path: 'goods/detail',
- name: 'spot-goods-detail',
- component: () => import('../views/spot/goods/detail/index.vue'),
- },
- {
- path: 'goods/chart',
- name: 'spot-goods-chart',
- component: () => import('../views/spot/goods/chart/index.vue'),
- },
- ]
- },
- {
- path: '/contract',
- component: Page,
- children: [
- {
- path: 'detail',
- name: 'contract-detail',
- component: () => import('../views/contract/detail/index.vue'),
- },
- {
- path: 'goods/detail',
- name: 'contract-goods-detail',
- component: () => import('../views/contract/goods/detail/index.vue'),
- },
- {
- path: 'goods/chart',
- name: 'contract-goods-chart',
- component: () => import('../views/contract/goods/chart/index.vue'),
- },
- ]
- },
- {
- path: '/wallet',
- component: Page,
- children: [
- {
- path: 'transfer',
- name: 'wallet-transfer',
- component: () => import('../views/wallet/transfer/index.vue'),
- },
- {
- path: 'deposit',
- name: 'wallet-deposit',
- component: () => import('../views/wallet/deposit/index.vue'),
- },
- {
- path: 'deposit',
- name: 'wallet-withdraw',
- component: () => import('../views/wallet/withdraw/index.vue'),
- },
- ]
- },
- {
- path: '/setting',
- component: Page,
- children: [
- {
- path: '',
- name: 'setting',
- component: () => import('../views/setting/index.vue'),
- }
- ]
- },
- {
- path: '/user',
- component: Page,
- children: [
- {
- path: 'login',
- name: 'user-login',
- component: () => import('../views/user/login/index.vue'),
- meta: {
- ignoreAuth: true,
- },
- },
- {
- path: 'register',
- name: 'user-register',
- component: () => import('@mobile/views/user/register/Index.vue'),
- meta: {
- ignoreAuth: true,
- },
- props: {
- showYhkhfxgzs: false,
- insetStyle: false
- }
- },
- {
- path: 'forget',
- name: 'user-forget',
- component: () => import('@mobile/views/user/forget/Index.vue'),
- meta: {
- ignoreAuth: true,
- },
- props: {
- insetStyle: false
- }
- },
- {
- path: 'cancel',
- name: 'user-cancel',
- component: () => import('@mobile/views/user/cancel/Index.vue'),
- },
- {
- path: 'password',
- name: 'user-password',
- component: () => import('@mobile/views/user/password/Index.vue'),
- },
- {
- path: 'avatar',
- name: 'user-avatar',
- component: () => import('@mobile/views/user/avatar/Index.vue'),
- },
- ],
- },
- {
- path: '/report',
- component: Page,
- children: [
- {
- path: '',
- name: 'report',
- component: () => import('@mobile/views/report/index.vue'),
- }
- ]
- },
- {
- path: '/account',
- component: Page,
- children: [
- {
- path: 'certification',
- name: 'account-certification',
- component: () => import('@mobile/views/account/certification/Index.vue'),
- },
- {
- path: 'authresult',
- name: 'account-authresult',
- component: () => import('@mobile/views/account/authresult/Index.vue'),
- },
- {
- path: 'protocol',
- name: 'account-protocol',
- component: () => import('../../sbyj/views/account/protocol/Index.vue'),
- }
- ],
- },
- {
- path: '/news',
- component: Page,
- children: [
- {
- path: '',
- name: 'news-list',
- component: () => import('@mobile/views/news/list/Index.vue'),
- meta: {
- ignoreAuth: true,
- },
- },
- {
- path: 'detail',
- name: 'news-detail',
- component: () => import('@mobile/views/news/detail/Index.vue'),
- meta: {
- ignoreAuth: true,
- },
- },
- ],
- },
- {
- path: '/bank',
- component: Page,
- children: [
- {
- path: 'wallet',
- name: 'bank-wallet',
- component: () => import('@mobile/views/bank/wallet/Index.vue'),
- },
- {
- path: 'sign',
- name: 'bank-sign',
- component: () => import('@mobile/views/bank/sign/Index.vue'),
- },
- {
- path: 'capital',
- name: 'bank-capital',
- component: () => import('@mobile/views/bank/capital/index.vue'),
- }
- ],
- },
- {
- path: '/order',
- component: Page,
- children: [
- {
- path: 'list',
- name: 'order-list',
- component: () => import('../views/order/list/index.vue'),
- },
- {
- path: 'position',
- name: 'order-position',
- component: () => import('../views/order/position/index.vue'),
- props: {
- showBackButton: true
- }
- },
- {
- path: 'delivery',
- name: 'order-delivery',
- component: () => import('../views/order/delivery/index.vue'),
- }
- ]
- },
- {
- path: '/points',
- component: Page,
- children: [
- {
- path: 'account',
- name: 'points-account',
- component: () => import('@mobile/views/points/Index.vue'),
- }
- ]
- },
- {
- path: '/mine',
- component: Page,
- children: [
- {
- path: 'address',
- name: 'mine-address',
- component: () => import('@mobile/views/mine/address/Index.vue'),
- },
- {
- path: 'invoice',
- name: 'mine-invoice',
- component: () => import('@mobile/views/mine/invoice/Index.vue'),
- },
- {
- path: 'profile',
- name: 'mine-profile',
- component: () => import('@mobile/views/mine/profile/Index.vue'),
- },
- {
- path: 'setting',
- name: 'mine-setting',
- component: () => import('@mobile/views/mine/setting/Index.vue'),
- },
- {
- path: 'wechat',
- name: 'mine-wechat',
- component: () => import('@mobile/views/mine/wechat/Index.vue'),
- },
- {
- path: 'email',
- name: 'mine-email',
- component: () => import('@mobile/views/mine/email/Index.vue'),
- }
- ],
- },
- {
- path: '/notice',
- component: Page,
- children: [
- {
- path: '',
- name: 'notice-list',
- component: () => import('@mobile/views/notice/list/index.vue'),
- },
- ],
- },
- {
- path: '/rules',
- component: Page,
- children: [
- {
- path: "zcxy",
- name: "rules-zcxy",
- component: () => import("@mobile/views/rules/zcxy/Index.vue"),
- meta: {
- ignoreAuth: true,
- },
- },
- {
- path: "yhkhfxgzs",
- name: "rules-yhkhfxgzs",
- component: () => import("@mobile/views/rules/fxgzs/Index.vue"),
- meta: {
- ignoreAuth: true,
- },
- },
- {
- path: "yszc",
- name: "rules-yszc",
- component: () => import("@mobile/views/rules/yszc/Index.vue"),
- meta: {
- ignoreAuth: true,
- },
- },
- {
- path: "gywm",
- name: "rules-gywm",
- component: () => import("@mobile/views/rules/gywm/Index.vue"),
- meta: {
- ignoreAuth: true,
- },
- },
- {
- path: "fwrx",
- name: "rules-fwrx",
- component: () => import("@mobile/views/rules/fwrx/Index.vue"),
- meta: {
- ignoreAuth: true,
- },
- },
- ]
- },
- ]
- const router = animateRouter.create({
- history: createWebHashHistory(),
- routes,
- })
- // 路由跳转拦截
- router.beforeEach((to, from, next) => {
- clearPending()
- // 判断服务是否加载完成
- if (service.isReady) {
- if (to.meta.ignoreAuth || loginStore.token) {
- next()
- } else {
- if (to.matched.some((e) => e.name === 'home')) {
- // 如果是主页导航页面,强制跳转到首页
- next({
- name: 'home-index',
- replace: true,
- })
- } else {
- next({
- name: 'user-login',
- query: { redirect: to.fullPath },
- })
- }
- }
- } else {
- if (to.name === 'boot') {
- next()
- } else {
- next({
- name: 'boot',
- query: { redirect: to.fullPath },
- })
- }
- }
- })
- export default router
|