| | |
| | | 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 |
| | | ajaxPost('/patient/info/wechatLogin2',`mobile=${username.value}&password=${password.value}`,config).then((re:any)=>{ |
| | | const openid='odFja56xfwSZDHhAEMn-JotSzlRc' |
| | | ajaxPost('/patient/info/wechatLogin2',`mobile=${username.value}&password=${password.value}&openId=${openid}`,config).then((re:any)=>{ |
| | | console.log(re) |
| | | if (re===''){ |
| | | Toast('登录失败,请重新登录') |
| | | } else { |
| | | console.log('得到tokeng') |
| | | Session.set('token', re) |
| | | Toast('登录成功。。。。。') |
| | | router.push('/') |
| | | Toast('登录成功') |
| | | getUserinfo() |
| | | } |
| | | }).finally(()=>{ |
| | | loadingBUt.value=false |
| | |
| | | if (re===false){ |
| | | Toast('登录失败,请重新登录') |
| | | } else { |
| | | console.log(re) |
| | | Session.set('token', re) |
| | | Toast('登录成功') |
| | | getUserinfo() |
| | | } |
| | | }) |
| | | } |
| | |
| | | if (code){ // 得到code换取openid |
| | | ajaxGet('wechat/code',{code}).then((re:any)=>{ |
| | | console.log(re,'获取openid') |
| | | userInfo.setUserInfo({openid:re.openid,nickname:re.nickname,headimgurl:re.headimgurl}) |
| | | 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('请填写表单登录。。') |
| | | Toast('请填写表单登录') |
| | | } else { |
| | | console.log() |
| | | Session.set('token', re) |
| | | Toast('登录成功。。。。。') |
| | | router.push('/') |
| | | Toast('登录成功') |
| | | getUserinfo() |
| | | } |
| | | }) |
| | | } |