From 244408c5232ba7fe5e155babc250ad163ba4b006 Mon Sep 17 00:00:00 2001 From: dzq Date: Mon, 30 Jun 2025 15:39:46 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E5=BE=AE=E4=BF=A1=E7=99=BB=E5=BD=95):=20?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=BC=81=E4=B8=9A=E5=BE=AE=E4=BF=A1=E6=A8=A1?= =?UTF-8?q?=E6=8B=9F=E7=99=BB=E5=BD=95=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在checkout页面增加对企业微信模拟登录状态的判断 - 添加fakeQyLoginApi接口用于模拟企业微信登录 - 在wx store中新增isFakeQyLogin状态和fakeQyLogin方法 - 实现模拟登录逻辑,设置相关用户信息 --- src/common/apis/shop/index.ts | 7 ++++++ src/pages/product/ProductList.vue | 1 + src/pages/product/components/checkout.vue | 2 +- src/pinia/stores/wx.ts | 26 ++++++++++++++++++++--- 4 files changed, 32 insertions(+), 4 deletions(-) diff --git a/src/common/apis/shop/index.ts b/src/common/apis/shop/index.ts index 72ec1a6..2adc436 100644 --- a/src/common/apis/shop/index.ts +++ b/src/common/apis/shop/index.ts @@ -48,6 +48,13 @@ export function qyLogin(params: QyLoginRequestParams) { params }) } +export function fakeQyLoginApi(params: {corpid: string, userid: string}) { + return request>({ + url: "payment/login/qy/fake", + method: "get", + params + }) +} /** 根据openid获取用户订单信息 */ export function getOrdersByOpenIdApi(corpid: string, openid: string) { diff --git a/src/pages/product/ProductList.vue b/src/pages/product/ProductList.vue index b8c6f82..31c5534 100644 --- a/src/pages/product/ProductList.vue +++ b/src/pages/product/ProductList.vue @@ -79,6 +79,7 @@ onMounted(() => { } // scrollListener.push(scrollContainer.value?.addEventListener("scroll", throttledScroll)) // scrollListener.push(scrollContainer.value?.addEventListener("scroll", throttledUpdate)) + // wxStore.fakeQyLogin(); }) // 组件卸载前清理事件监听 diff --git a/src/pages/product/components/checkout.vue b/src/pages/product/components/checkout.vue index e622412..14df125 100644 --- a/src/pages/product/components/checkout.vue +++ b/src/pages/product/components/checkout.vue @@ -121,7 +121,7 @@ async function handleSubmit() { } } - if (!openid.value) { + if (!openid.value && !wxStore.isFakeQyLogin) { return showConfirmDialog({ title: "登录提示", message: "请从微信中打开" diff --git a/src/pinia/stores/wx.ts b/src/pinia/stores/wx.ts index e8ebe1f..1f7211e 100644 --- a/src/pinia/stores/wx.ts +++ b/src/pinia/stores/wx.ts @@ -1,5 +1,5 @@ import { pinia } from "@/pinia" -import { getOpenIdApi, getBalanceApi, qyLogin, getBalanceByQyUserid } from "@/common/apis/shop" +import { getOpenIdApi, getBalanceApi, qyLogin, getBalanceByQyUserid, fakeQyLoginApi } from "@/common/apis/shop" import { ab98UserDTO, GetBalanceResponse } from "@/common/apis/shop/type" import { useAb98UserStore } from "./ab98-user" @@ -32,6 +32,8 @@ export const useWxStore = defineStore("wx", () => { // 汇邦云用户信息 const ab98User = ref(null); + const isFakeQyLogin = ref(false); + // 设置 openid const setOpenid = (id: string) => { openid.value = id @@ -130,9 +132,27 @@ export const useWxStore = defineStore("wx", () => { } } + const fakeQyLogin = async () => { + isFakeQyLogin.value = true; + corpid.value = "wpZ1ZrEgAA2QTxIRcB4cMtY7hQbTcPAw"; + corpidLogin.value = true; + userid.value = "woZ1ZrEgAAV9AEdRt1MGQxSg-KDJrDlA"; + const res = await fakeQyLoginApi({ corpid: corpid.value, userid: userid.value}) + if (res && res.code == 0) { + userid.value = res.data.userid; + openid.value = "oMRxw6Eum0DB1IjI_pEX_yrawBHw"; + isCabinetAdmin.value = res.data.isCabinetAdmin === 1; + name.value = res.data.name; + qyUserId.value = res.data.qyUserId; + setAb98User(res.data.ab98User); + } + } + + return { code, state, openid, corpid, userid, balance, useBalance, - balanceLimit, isCabinetAdmin, corpidLogin, name, ab98User, qyUserId, - setOpenid, setBalance, handleWxCallback, setIsCabinetAdmin, refreshBalance, setAb98User } + balanceLimit, isCabinetAdmin, corpidLogin, name, ab98User, qyUserId, isFakeQyLogin, + setOpenid, setBalance, handleWxCallback, setIsCabinetAdmin, refreshBalance, setAb98User, + fakeQyLogin } }) /**