接龙登录校验
This commit is contained in:
parent
e9225cf0ff
commit
373f64bedc
@ -165,7 +165,7 @@ async function submitRelay() {
|
|||||||
}
|
}
|
||||||
showLoading('提交中...');
|
showLoading('提交中...');
|
||||||
try {
|
try {
|
||||||
const res = await relayFinishApi(params);
|
const res:any = await relayFinishApi(params);
|
||||||
hideLoading();
|
hideLoading();
|
||||||
if (res && res.resultCode === 1 ) {
|
if (res && res.resultCode === 1 ) {
|
||||||
uni.showToast({title: '接龙成功', icon: 'success'});
|
uni.showToast({title: '接龙成功', icon: 'success'});
|
||||||
@ -193,6 +193,14 @@ onLoad(async (options) => {
|
|||||||
if (options && options.id) {
|
if (options && options.id) {
|
||||||
noticeId.value = options.id;
|
noticeId.value = options.id;
|
||||||
isLoading.value = true;
|
isLoading.value = true;
|
||||||
|
if (options.openId) {
|
||||||
|
// 检查登录状态
|
||||||
|
const isLoggedIn = await userStore.loginByOpenId(options.openId);
|
||||||
|
if (!isLoggedIn) {
|
||||||
|
console.log("用户未登录,跳过处理");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
// 1. 获取接龙详情(新接口)
|
// 1. 获取接龙详情(新接口)
|
||||||
try {
|
try {
|
||||||
const detailRes = await getByJlIdApi({ jlId: noticeId.value });
|
const detailRes = await getByJlIdApi({ jlId: noticeId.value });
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import { defineStore } from "pinia";
|
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 { AUTH_KEY } from "@/config";
|
||||||
import { imagUrl } from "@/utils";
|
import { imagUrl } from "@/utils";
|
||||||
import { useWebSocket } from '@/utils/webSocket/webSocket'
|
import { useWebSocket } from '@/utils/webSocket/webSocket'
|
||||||
@ -135,6 +135,34 @@ export const useUserStore = defineStore({
|
|||||||
console.log(e)
|
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: 登录成功后的操作
|
* @description: 登录成功后的操作
|
||||||
*/
|
*/
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user