|
|
@@ -46,7 +46,17 @@ onMounted(() => {
|
|
|
console.log(r.data.data)
|
|
|
// store.user = r.data.data
|
|
|
name.value = r.data.data.userName
|
|
|
- userInfo(r.data.data)
|
|
|
+ let isBjt = localStorage.getItem('isBjt')
|
|
|
+ let userid = localStorage.getItem('userid')
|
|
|
+ if(isBjt == 1){
|
|
|
+ localStorage.removeItem('isBjt')
|
|
|
+ localStorage.removeItem('userid')
|
|
|
+ setEduid(userid, r.data.data.eduId)
|
|
|
+ setStateUserinfo(userid)
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ userInfo(r.data.data)
|
|
|
+ }
|
|
|
}
|
|
|
})
|
|
|
} else {
|
|
|
@@ -160,7 +170,15 @@ const userInfo2 = (data) => {
|
|
|
// console.log('rrrrr', r)
|
|
|
axios.post(`https://beta.api.cocorobo.cn/api/user`, qs.stringify(params)).then(d => {
|
|
|
// store.user = top.US.userInfo
|
|
|
- setStateUserinfo(d.data[0][0].userid)
|
|
|
+ // setStateUserinfo(d.data[0][0].userid)
|
|
|
+ let userinfo = selectUser3(data.userId)
|
|
|
+ if(userinfo.eduid){
|
|
|
+ setStateUserinfo(d.data[0][0].userid)
|
|
|
+ }else {
|
|
|
+ localStorage.setItem('userid', userinfo.userid)
|
|
|
+ localStorage.setItem('isBjt', 1)
|
|
|
+ linkLogin()
|
|
|
+ }
|
|
|
})
|
|
|
}, [], { "type": "POST", "withCredentials": true });
|
|
|
|
|
|
@@ -258,6 +276,34 @@ const selectUser2 = (uid) => {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+const selectUser3 = async (uid) => {
|
|
|
+ // 拉取用户信息并处理
|
|
|
+ const requestUser = async () => {
|
|
|
+ try {
|
|
|
+ const res = await axios.get(`https://pbl.cocorobo.cn/api/pbl/selectUser?userid=${uid}`, { withCredentials: true });
|
|
|
+ console.log(res);
|
|
|
+ if (res && res.data && res.data.length && res.data[0].length && res.data[0][0].userid) {
|
|
|
+ // 拉取成功,存储用户信息
|
|
|
+ let userinfo = res.data[0][0];
|
|
|
+ return userinfo;
|
|
|
+ } else {
|
|
|
+ return await requestUser();
|
|
|
+ }
|
|
|
+ } catch (error) {
|
|
|
+ return await requestUser();
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ return await requestUser();
|
|
|
+}
|
|
|
+
|
|
|
+const setEduid = async (userid, eduId) => {
|
|
|
+ const res = await axios.get(`https://pbl.cocorobo.cn/api/pbl/setEduid?userid=${userid}&eduId=${eduId}`);
|
|
|
+ console.log(res);
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
const getUrlParam = (urlStr, urlKey) => {
|
|
|
const url = new URL(urlStr) // 字符串转换成url格式
|
|
|
const paramsStr = url.search.slice(1) // 获取'?'后面的参数字符串
|