feat(微信登录): 添加企业微信模拟登录功能
- 在checkout页面增加对企业微信模拟登录状态的判断 - 添加fakeQyLoginApi接口用于模拟企业微信登录 - 在wx store中新增isFakeQyLogin状态和fakeQyLogin方法 - 实现模拟登录逻辑,设置相关用户信息
This commit is contained in:
parent
4599e5c6ad
commit
244408c523
|
@ -48,6 +48,13 @@ export function qyLogin(params: QyLoginRequestParams) {
|
|||
params
|
||||
})
|
||||
}
|
||||
export function fakeQyLoginApi(params: {corpid: string, userid: string}) {
|
||||
return request<ApiResponseData<QyLoginDTO>>({
|
||||
url: "payment/login/qy/fake",
|
||||
method: "get",
|
||||
params
|
||||
})
|
||||
}
|
||||
|
||||
/** 根据openid获取用户订单信息 */
|
||||
export function getOrdersByOpenIdApi(corpid: string, openid: string) {
|
||||
|
|
|
@ -79,6 +79,7 @@ onMounted(() => {
|
|||
}
|
||||
// scrollListener.push(scrollContainer.value?.addEventListener("scroll", throttledScroll))
|
||||
// scrollListener.push(scrollContainer.value?.addEventListener("scroll", throttledUpdate))
|
||||
// wxStore.fakeQyLogin();
|
||||
})
|
||||
|
||||
// 组件卸载前清理事件监听
|
||||
|
|
|
@ -121,7 +121,7 @@ async function handleSubmit() {
|
|||
}
|
||||
}
|
||||
|
||||
if (!openid.value) {
|
||||
if (!openid.value && !wxStore.isFakeQyLogin) {
|
||||
return showConfirmDialog({
|
||||
title: "登录提示",
|
||||
message: "请从微信中打开"
|
||||
|
|
|
@ -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<ab98UserDTO | null>(null);
|
||||
|
||||
const isFakeQyLogin = ref<boolean>(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 }
|
||||
})
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue