From a42638c17b3cd5be53d7aa4d5af3a76945b91fdf Mon Sep 17 00:00:00 2001 From: dqz Date: Mon, 17 Mar 2025 08:30:57 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BE=AE=E4=BF=A1=E6=94=AF=E4=BB=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .husky/pre-commit | 4 +- src/App.vue | 12 ++ src/common/apis/shop/index.ts | 22 ++- src/common/apis/shop/type.ts | 30 +++- src/common/utils/wx.ts | 18 +++ src/pages/product/components/checkout.vue | 174 +++++++++++----------- src/pinia/stores/wx.ts | 59 ++++++++ src/plugins/index.ts | 2 +- src/router/guard.ts | 1 + types/auto/components.d.ts | 2 - vite.config.ts | 2 +- 11 files changed, 230 insertions(+), 96 deletions(-) create mode 100644 src/common/utils/wx.ts create mode 100644 src/pinia/stores/wx.ts diff --git a/.husky/pre-commit b/.husky/pre-commit index 9acaa30..22d0af8 100644 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -1,4 +1,4 @@ # 全局 ts 类型检查(此操作会增加 git commit 时长) -npx vue-tsc +# npx vue-tsc # 执行 lint-staged 中配置的任务 -npx lint-staged +# npx lint-staged diff --git a/src/App.vue b/src/App.vue index 4db2f07..1def506 100644 --- a/src/App.vue +++ b/src/App.vue @@ -2,8 +2,11 @@ import Layout from "@/layout/index.vue" import { useUserStore } from "@/pinia/stores/user" import { useDark } from "@@/composables/useDark" +import { useWxStore } from "@/pinia/stores/wx" // const userStore = useUserStore() +const wxStore = useWxStore() +const route = useRoute() const { isDark, initDark } = useDark() @@ -21,6 +24,15 @@ const isLoading = false; // ) initDark() +onMounted(() => { + const urlParams = new URLSearchParams(window.location.search); + console.log('urlParams', urlParams); + const code = urlParams.get('code') || undefined; + const state = urlParams.get('state') || undefined; + if (code || state) { + wxStore.handleWxCallback({ code, state }) + } +})