From 0a0dbbe0aa2be52c0e78c1afe273dcbe3c9b6fd7 Mon Sep 17 00:00:00 2001
From: chenyc <501753378@qq.com>
Date: 星期五, 21 十月 2022 15:44:09 +0800
Subject: [PATCH] 34
---
src/views/login/index.vue | 37 ++++++++++++++++++++++++++-----------
1 files changed, 26 insertions(+), 11 deletions(-)
diff --git a/src/views/login/index.vue b/src/views/login/index.vue
index 0e1073e..f30bd9c 100644
--- a/src/views/login/index.vue
+++ b/src/views/login/index.vue
@@ -34,6 +34,13 @@
const asyncValidator = (val:any) =>{
return val===ruleForm2.value.pass
}
+ const getUserinfo=()=>{
+ ajaxPost('/patient/info/getPatientInfo','').then((re:any)=>{
+ console.log(re,'得到患者的信息getUserinfo')
+ userInfo.setPatient(re)
+ router.push('/')
+ })
+ }
const onSubmit = (values:any) => {
console.log('submit', values)
loadingBUt.value=true
@@ -45,7 +52,7 @@
console.log('得到tokeng')
Session.set('token', re)
Toast('登录成功。。。。。')
- router.push('/')
+ getUserinfo()
}
}).finally(()=>{
loadingBUt.value=false
@@ -63,13 +70,19 @@
})
}
const onSubmit3=(values:any)=>{
+ if (userInfo.info.openid===''){
+ Toast('没有获取到openid')
+ return
+ }
console.log('提交表单',ruleForm3.value,values)
- ajaxPost('patient/info/isValidCodeOK',`phoneNo=${ruleForm3.value.userPhone}&validCode=${ruleForm3.value.validateCode}`,config).then((re:any)=>{
+ ajaxPost('patient/info/isValidCodeOK',`phoneNo=${ruleForm3.value.userPhone}&validCode=${ruleForm3.value.validateCode}&openId=${userInfo.info.openid}`,config).then((re:any)=>{
console.log(re)
if (re===false){
Toast('登录失败,请重新登录')
} else {
- console.log(re)
+ Session.set('token', re)
+ Toast('登录成功。。。。。')
+ getUserinfo()
}
})
}
@@ -78,8 +91,11 @@
Toast('手机号码不能为空')
return
}
- ajaxPost('patient/info/sendValidCode','phoneNo='+ruleForm3.value.userPhone,config).then(re=>{
+ ajaxPost('patient/info/sendValidCode','phoneNo='+ruleForm3.value.userPhone,config).then((re:any)=>{
console.log(re)
+ if (re.code===200){
+ return
+ }
const timer= setInterval(() => {
if (seconds.value > 0) {
seconds.value--
@@ -113,19 +129,18 @@
console.log(code)
if (code){ // 得到code换取openid
ajaxGet('wechat/code',{code}).then((re:any)=>{
- console.log(re)
- userInfo.setUserInfo({openid:re.openid,nickname:re.nickname,headimgurl:re.headimgurl})
- const openid = re.openid
- if (openid) { // 检查登录
- ajaxPost('patient/info/wechatLogin',{openid},config).then((re:any)=>{
+ console.log(re,'获取openid')
+ userInfo.setInfo({openid:re.openid,nickname:re.nickname,headimgurl:re.headimgurl})
+ const openId = re.openid
+ if (openId) { // 检查登录
+ ajaxPost('patient/info/wechatLogin','openId='+openId,config).then((re:any)=>{
console.log('openid换的accesstoken=',re)
if (re===''){
Toast('请填写表单登录。。')
} else {
- console.log()
Session.set('token', re)
Toast('登录成功。。。。。')
- router.push('/')
+ getUserinfo()
}
})
}
--
Gitblit v1.8.0