接龙登录校验

This commit is contained in:
ywyonui 2025-08-04 16:31:25 +08:00
parent e9225cf0ff
commit 373f64bedc
2 changed files with 38 additions and 2 deletions

View File

@ -165,7 +165,7 @@ async function submitRelay() {
}
showLoading('提交中...');
try {
const res = await relayFinishApi(params);
const res:any = await relayFinishApi(params);
hideLoading();
if (res && res.resultCode === 1 ) {
uni.showToast({title: '接龙成功', icon: 'success'});
@ -193,6 +193,14 @@ onLoad(async (options) => {
if (options && options.id) {
noticeId.value = options.id;
isLoading.value = true;
if (options.openId) {
//
const isLoggedIn = await userStore.loginByOpenId(options.openId);
if (!isLoggedIn) {
console.log("用户未登录,跳过处理");
return;
}
}
// 1.
try {
const detailRes = await getByJlIdApi({ jlId: noticeId.value });

View File

@ -1,5 +1,5 @@
import { defineStore } from "pinia";
import { authenticationApi, loginCode, loginPass, weChatLogin } from "@/api/system/login";
import { authenticationApi, loginCode, loginPass, weChatLogin, checkOpenId } from "@/api/system/login";
import { AUTH_KEY } from "@/config";
import { imagUrl } from "@/utils";
import { useWebSocket } from '@/utils/webSocket/webSocket'
@ -135,6 +135,34 @@ export const useUserStore = defineStore({
console.log(e)
}
},
async loginByOpenId(openId: string) {
try {
// 先校验当前登录的用户的openid如果和传入的openid匹配直接返回true
if (this.userdata && this.userdata.openId && openId && this.userdata.openId === openId) {
return true;
}
// 如果当前登录的用户的openid和传入的openid不匹配则调用checkOpenId接口进行校验
const res = await checkOpenId({
openId,
appCode: "JS",
});
if (res.resultCode == 1 && res.result) {
this.afterLoginAction(res.result);
return true;
} else {
uni.reLaunch({
url: "/pages/system/login/login",
});
return false;
}
} catch (e) {
console.log(e);
uni.reLaunch({
url: "/pages/system/login/login",
});
return false;
}
},
/**
* @description:
*/