| | |
| | | const info = ref({ |
| | | openid:'', |
| | | headimgurl:'', |
| | | nickname:'' |
| | | nickname:'', |
| | | }) |
| | | function setUserInfo(userInfo:{openid:string, headimgurl:string,nickname:string}) { |
| | | // const patient=ref({ |
| | | // patientName:'', |
| | | // patientTelNo:'', |
| | | // id:0, |
| | | // code:'', |
| | | // }) |
| | | function setInfo(userInfo:{openid:string, headimgurl:string,nickname:string}) { |
| | | info.value.openid=userInfo.openid |
| | | info.value.headimgurl=userInfo.headimgurl |
| | | info.value.nickname=userInfo.nickname |
| | | } |
| | | // function setUser(userInfo:{openid:string, headimgurl:string,nickname:string}) { |
| | | // info.value.openid=userInfo.openid |
| | | // info.value.headimgurl=userInfo.headimgurl |
| | | // info.value.nickname=userInfo.nickname |
| | | // } |
| | | |
| | | return { info, setUserInfo } |
| | | return { info, setInfo } |
| | | }) |
| | |
| | | |
| | | // 前置拦截器(发起请求之前的拦截) |
| | | instance.interceptors.request.use((config: AxiosRequestConfig) => { |
| | | console.log('sss',config) |
| | | config.headers && (config.headers['Authorization'] = getToken()) |
| | | const controller = new AbortController() |
| | | config.signal = controller.signal |
| | |
| | | const asyncValidator = (val:any) =>{ |
| | | return val===ruleForm2.value.pass |
| | | } |
| | | const getUserinfo=()=>{ |
| | | ajaxPost('/patient/info/getPatientInfo','').then((re:any)=>{ |
| | | console.log(re) |
| | | router.push('/') |
| | | }) |
| | | } |
| | | const onSubmit = (values:any) => { |
| | | console.log('submit', values) |
| | | loadingBUt.value=true |
| | |
| | | console.log('得到tokeng') |
| | | Session.set('token', re) |
| | | Toast('登录成功。。。。。') |
| | | router.push('/') |
| | | getUserinfo() |
| | | } |
| | | }).finally(()=>{ |
| | | loadingBUt.value=false |
| | |
| | | } else { |
| | | Session.set('token', re) |
| | | Toast('登录成功。。。。。') |
| | | router.push('/') |
| | | 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() |
| | | Session.set('token', re) |
| | | Toast('登录成功。。。。。') |
| | | router.push('/') |
| | | getUserinfo() |
| | | } |
| | | }) |
| | | } |