diff --git a/.env.development b/.env.development index bbb054f..0920976 100644 --- a/.env.development +++ b/.env.development @@ -2,7 +2,7 @@ VITE_PORT = 9100 # 网站根目录 -VITE_PUBLIC_PATH = / +VITE_PUBLIC_PATH = /h5 # 是否删除console VITE_DROP_CONSOLE = true diff --git a/components.d.ts b/components.d.ts index 351b008..117afe9 100644 --- a/components.d.ts +++ b/components.d.ts @@ -7,10 +7,14 @@ export {} declare module '@vue/runtime-core' { export interface GlobalComponents { - SvgIcon: typeof import('./src/components/SvgIcon.vue')['default'] + Loading: typeof import('./src/components/Loading/Loading.vue')['default'] + SvgIcon: typeof import('./src/components/SvgIcon/SvgIcon.vue')['default'] VanButton: typeof import('vant/es')['Button'] VanConfigProvider: typeof import('vant/es')['ConfigProvider'] + VanIcon: typeof import('vant/es')['Icon'] + VanLoading: typeof import('vant/es')['Loading'] VanNavBar: typeof import('vant/es')['NavBar'] + VanOverlay: typeof import('vant/es')['Overlay'] VanTabbar: typeof import('vant/es')['Tabbar'] VanTabbarItem: typeof import('vant/es')['TabbarItem'] } diff --git a/src/components/Loading/Loading.vue b/src/components/Loading/Loading.vue new file mode 100644 index 0000000..a5e7a95 --- /dev/null +++ b/src/components/Loading/Loading.vue @@ -0,0 +1,38 @@ + + {{ text }} + + + + + diff --git a/src/components/SvgIcon.vue b/src/components/SvgIcon/SvgIcon.vue similarity index 100% rename from src/components/SvgIcon.vue rename to src/components/SvgIcon/SvgIcon.vue diff --git a/src/layout/index.vue b/src/layout/index.vue index 0350236..7a0e490 100644 --- a/src/layout/index.vue +++ b/src/layout/index.vue @@ -42,7 +42,7 @@ const currentRoute = useRoute() const getTitle = computed(() => currentRoute.meta.title as string) - + console.log(getTitle) // 菜单 const getMenus = computed(() => routeStore.menus.filter((item) => { @@ -50,7 +50,7 @@ }), ) - const getShowHeader = computed(() => currentRoute.meta.showHeader) + const getShowHeader = computed(() => currentRoute.meta.showHeader) || true // const getShowTabbar = computed(() => !currentRoute.meta.hiddenTabbar) // TODO 默认不显示tabbar const getShowTabbar = ref(false) diff --git a/src/router/business.ts b/src/router/business.ts index 94f1581..ec42786 100644 --- a/src/router/business.ts +++ b/src/router/business.ts @@ -20,5 +20,21 @@ export const BusinessRoute: RouteRecordRaw = { hiddenTabbar: true, }, }, + { + path: '/result/success', + name: 'PaySuccessResult', + component: () => import('@/views/result/PaySuccessResult.vue'), + meta: { + title: '支付成功', + }, + }, + { + path: '/result/error', + name: 'PayErrorResult', + component: () => import('@/views/result/PayErrorResult.vue'), + meta: { + title: '支付失败', + }, + }, ], } diff --git a/src/router/demo.ts b/src/router/demo.ts index 2b39363..3e693db 100644 --- a/src/router/demo.ts +++ b/src/router/demo.ts @@ -11,35 +11,19 @@ export const DemoRoute: RouteRecordRaw = { component: Layout, children: [ { - path: '/cashier/alipay', - name: 'AlipayCashier', - component: () => import('@/views/demo/cashier/AlipayCashier.vue'), + path: '/aggregate/alipay', + name: 'AliPayAggregate', + component: () => import('@/views/demo/aggregate/AliPayAggregate.vue'), meta: { - title: '支付宝收银台', + title: '支付宝聚合支付', }, }, { - path: '/cashier/wxJsapiPay', - name: 'WechatJsapiPay', - component: () => import('@/views/demo/cashier/WechatJsapiPay.vue'), + path: '/aggregate/wechatPay', + name: 'WechatPayAggregate', + component: () => import('@/views/demo/aggregate/WechatPayAggregate.vue'), meta: { - title: '支付宝收银台', - }, - }, - { - path: '/exception/timeout', - name: 'TimeoutPay', - component: () => import('@/views/demo/exception/TimeoutPay.vue'), - meta: { - title: '支付超时', - }, - }, - { - path: '/exception/errorPay', - name: 'TimeoutPay', - component: () => import('@/views/demo/exception/ErrorPay.vue'), - meta: { - title: '支付超时', + title: '微信聚合支付', }, }, ], diff --git a/src/router/index.ts b/src/router/index.ts index 973168f..726741a 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -7,6 +7,7 @@ import { useRouteStoreWidthOut } from '@/store/modules/route' import routeModuleList from './modules' import { BusinessRoute } from '@/router/business' import { DemoRoute } from '@/router/demo' +import { createRouterGuards } from "@/router/router-guards"; // 普通路由 export const constantRouter: RouteRecordRaw[] = [ @@ -30,8 +31,7 @@ const router = createRouter({ export function setupRouter(app: App) { app.use(router) - // TODO 不使用路由守卫 - // createRouterGuards(router) + createRouterGuards(router) } export default router diff --git a/src/router/router-guards.ts b/src/router/router-guards.ts index c731b95..b66f5f1 100644 --- a/src/router/router-guards.ts +++ b/src/router/router-guards.ts @@ -1,6 +1,5 @@ import { isNavigationFailure, Router } from 'vue-router' import { useRouteStoreWidthOut } from '@/store/modules/route' -import { useUserStoreWidthOut } from '@/store/modules/user' import { ACCESS_TOKEN } from '@/store/mutation-types' import { storage } from '@/utils/Storage' import { PageEnum } from '@/enums/pageEnum' @@ -11,10 +10,12 @@ const whitePathList = [LOGIN_PATH] // no redirect whitelist export function createRouterGuards(router: Router) { router.beforeEach(async (to, from, next) => { + // 所有的的页面都可以访问 + next() + return + // to: 即将要进入的目标 // from: 当前导航正要离开的路由 - const userStore = useUserStoreWidthOut() - if (from.path === LOGIN_PATH && to.name === PageEnum.ERROR_PAGE_NAME) { next(PageEnum.BASE_HOME) return diff --git a/src/styles/vant.less b/src/styles/vant.less index bdc8e22..5e8fd15 100644 --- a/src/styles/vant.less +++ b/src/styles/vant.less @@ -9,3 +9,11 @@ body { .van-action-sheet__cancel { color: var(--van-primary-color) !important; } + +// loading 遮罩全屏铺盖 +.loading-overlay { + display: flex; + align-items: center; + justify-content: center; + height: 100%; +} diff --git a/src/views/dashboard/index.vue b/src/views/dashboard/index.vue index 6fbe87e..d91f370 100644 --- a/src/views/dashboard/index.vue +++ b/src/views/dashboard/index.vue @@ -24,7 +24,7 @@ + + diff --git a/src/views/demo/aggregate/WechatPayAggregate.vue b/src/views/demo/aggregate/WechatPayAggregate.vue new file mode 100644 index 0000000..e2b7bf4 --- /dev/null +++ b/src/views/demo/aggregate/WechatPayAggregate.vue @@ -0,0 +1,112 @@ + + + + + + + 金额: {{ info.amount / 100.0 }} 元 + 标题: {{ info.title }} + 业务号: {{ info.businessNo }} + + + 去支付 + + + + + + diff --git a/src/views/demo/cashier/WechatJsapiPay.vue b/src/views/demo/cashier/AliPayH5Cashier.vue similarity index 94% rename from src/views/demo/cashier/WechatJsapiPay.vue rename to src/views/demo/cashier/AliPayH5Cashier.vue index b1df8de..0a8d203 100644 --- a/src/views/demo/cashier/WechatJsapiPay.vue +++ b/src/views/demo/cashier/AliPayH5Cashier.vue @@ -1,11 +1,11 @@ - - 123 - - + + + + diff --git a/src/views/demo/cashier/AlipayCashier.vue b/src/views/demo/cashier/WechatPayH5Cashier.vue similarity index 79% rename from src/views/demo/cashier/AlipayCashier.vue rename to src/views/demo/cashier/WechatPayH5Cashier.vue index f97969f..0a8d203 100644 --- a/src/views/demo/cashier/AlipayCashier.vue +++ b/src/views/demo/cashier/WechatPayH5Cashier.vue @@ -1,12 +1,11 @@ - - - 345 - - + + + + diff --git a/src/views/demo/exception/ErrorPay.vue b/src/views/demo/exception/ErrorPay.vue index 95606d2..6cebb2a 100644 --- a/src/views/demo/exception/ErrorPay.vue +++ b/src/views/demo/exception/ErrorPay.vue @@ -1,11 +1,43 @@ - - -支付错误 + + + + + + {{ msg }} + + - diff --git a/src/views/exception/403.vue b/src/views/exception/403.vue index 871289e..9ac6de3 100644 --- a/src/views/exception/403.vue +++ b/src/views/exception/403.vue @@ -5,7 +5,7 @@ 抱歉,你无权访问该页面 - 回到首页 + 回到首页 diff --git a/src/views/exception/500.vue b/src/views/exception/500.vue index 6744314..3ae7e88 100644 --- a/src/views/exception/500.vue +++ b/src/views/exception/500.vue @@ -5,7 +5,7 @@ 抱歉,服务器出错了 - 回到首页 + 回到首页 diff --git a/src/views/result/PayErrorResult.vue b/src/views/result/PayErrorResult.vue new file mode 100644 index 0000000..e4b61be --- /dev/null +++ b/src/views/result/PayErrorResult.vue @@ -0,0 +1,43 @@ + + + + + + + {{ msg }} + + + + + + + diff --git a/src/views/result/PaySuccessResult.vue b/src/views/result/PaySuccessResult.vue new file mode 100644 index 0000000..2519577 --- /dev/null +++ b/src/views/result/PaySuccessResult.vue @@ -0,0 +1,36 @@ + + + + + {{ msg }} + + + + + + +