| | |
| | | <script lang="ts" setup> |
| | | import { Dialog } from 'vant' |
| | | import { useRouter } from 'vue-router' |
| | | import { ref } from 'vue' |
| | | // import { Session } from '@/utils/storage' |
| | | import { Toast } from 'vant' |
| | | import { ref,onMounted } from 'vue' |
| | | import {useRoute,useRouter} from 'vue-router' |
| | | import { ajaxGet ,ajaxPost} from '@/utils/axios' |
| | | import { Session } from '@/utils/storage' |
| | | import { Dialog ,Toast } from 'vant' |
| | | import { userInfoStore } from '@/stores/userInfo' |
| | | import logo from 'assets/logo.png' |
| | | import shoujiLogin from 'assets/yijianLogin.png' |
| | | import pswdLogin from 'assets/pswdLogin.png' |
| | | const config={ |
| | | headers: { |
| | | 'Content-Type': 'application/x-www-form-urlencoded' |
| | | } |
| | | } |
| | | const userInfo = userInfoStore() |
| | | const route = useRoute() |
| | | const router=useRouter() |
| | | const username = ref('') |
| | | const password = ref('') |
| | | const visible=ref(1) |
| | | const visible=ref(3) |
| | | const seconds=ref(60) |
| | | const loadingBUt=ref(false) |
| | | const router = useRouter() |
| | | const ruleForm2=ref({ |
| | | newPassword:'', |
| | | pass:'', |
| | |
| | | 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) |
| | | router.push('/') |
| | | // const str=`user_no=${username.value}&user_password=${password.value}` |
| | | loadingBUt.value=true |
| | | // signIn(str).then((res:any)=>{ |
| | | // Session.set('token', res.data) |
| | | // router.push('/') |
| | | // }) |
| | | // }).catch(()=>{ |
| | | // loadingBUt.value=false |
| | | // }) |
| | | 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('登录成功') |
| | | getUserinfo() |
| | | } |
| | | }).finally(()=>{ |
| | | loadingBUt.value=false |
| | | }) |
| | | } |
| | | const onSubmit2=(values:any)=>{ |
| | | console.log('提交表单',ruleForm2.value) |
| | |
| | | }) |
| | | } |
| | | const onSubmit3=(values:any)=>{ |
| | | console.log('提交表单',ruleForm3.value) |
| | | console.log(values) |
| | | userInfo.info.openid='odFja56xfwSZDHhAEMn-JotSzlRc' |
| | | if (userInfo.info.openid===''){ |
| | | Toast('没有获取到openid33') |
| | | return |
| | | } |
| | | console.log('提交表单',ruleForm3.value,values) |
| | | 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 { |
| | | Session.set('token', re) |
| | | Toast('登录成功') |
| | | getUserinfo() |
| | | } |
| | | }) |
| | | } |
| | | const sendCode=()=>{ |
| | | if (ruleForm2.value.userPhone===''){ |
| | | if (ruleForm3.value.userPhone===''){ |
| | | Toast('手机号码不能为空') |
| | | return |
| | | } |
| | | // sendValidateCode('mobileNo='+ruleForm2.value.userPhone).then(re=>{ |
| | | // console.log(re) |
| | | // const timer= setInterval(() => { |
| | | // if (seconds.value > 0) { |
| | | // seconds.value-- |
| | | // } else { |
| | | // seconds.value = 60 |
| | | // clearInterval(timer) |
| | | // } |
| | | // }, 1000) |
| | | // }) |
| | | 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-- |
| | | } else { |
| | | seconds.value = 60 |
| | | clearInterval(timer) |
| | | } |
| | | }, 1000) |
| | | }) |
| | | } |
| | | const wjmm=()=>{ |
| | | visible.value=2 |
| | |
| | | ruleForm3.value.userPhone='' |
| | | ruleForm3.value.validateCode='' |
| | | } |
| | | const isWechat = () => { |
| | | return String(navigator.userAgent.toLowerCase().match(/MicroMessenger/i)) === 'micromessenger' |
| | | } |
| | | onMounted(()=>{ |
| | | // userInfo.setInfo({openid:'odFja56xfwSZDHhAEMn-JotSzlRc',nickname:'大橙子',headimgurl:'https://thirdwx.qlogo.cn/mmopen/vi_32/Q0j4TwGTfTJB…ibLYic7qC9cm0Yjia3VkHRPVa12N0OK6dgdz984biceWg/132'}) |
| | | // Session.set('token', 'eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJQQVRfU0ZfUEFUOTE0MzE2NDAyMTk1N0pOcUMiLCJhdXRoIjpbeyJhdXRob3JpdHkiOiJhZG1pbiJ9XSwiaWF0IjoxNzQwNzM2Nzg2LCJleHAiOjE3NDEwOTY3ODZ9.stAHeAJ_pB4qWL4W-1rv0UUnBV3Wn2vsSH-td2j26cw') |
| | | // getUserinfo() |
| | | Session.remove('token') |
| | | if (isWechat()){ |
| | | console.log('初始化',route) |
| | | const queryInfo=route.query |
| | | const {code}=queryInfo |
| | | console.log(code) |
| | | if (code){ // 得到code换取openid |
| | | ajaxGet('wechat/code',{code}).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 { |
| | | Session.set('token', re) |
| | | Toast('登录成功') |
| | | getUserinfo() |
| | | } |
| | | }) |
| | | } |
| | | |
| | | }) |
| | | } |
| | | else { // 没有code 就重新进入微信url获取code |
| | | const appid = 'wx790bd67db6206070' // 微信APPid |
| | | const local = window.location.href |
| | | window.location.href = |
| | | 'https://open.weixin.qq.com/connect/oauth2/authorize?appid=' + |
| | | appid + |
| | | '&redirect_uri=' + |
| | | encodeURIComponent(local) + |
| | | '&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect' |
| | | |
| | | } |
| | | } else { |
| | | console.log('不是微信浏览器') |
| | | Dialog.alert({ |
| | | title: '提示', |
| | | message: '请在微信中打开浏览', |
| | | }).then(() => { |
| | | // on close |
| | | }) |
| | | } |
| | | }) |
| | | </script> |
| | | |
| | | <template> |
| | |
| | | placeholder="请输入登录名" |
| | | :rules="[{ required: true, message: '请输入登录名' }]" |
| | | /> |
| | | <!-- :rules="[{ required: true, message: '请填写密码' }]" --> |
| | | <van-field |
| | | v-model="password" |
| | | type="password" |
| | | name="密 码" |
| | | label="密  码" |
| | | placeholder="6-16位数字或者字母组合" |
| | | :rules="[{ required: true, message: '请填写密码' }]" |
| | | |
| | | > |
| | | <template #button> |
| | | <van-button size="small" type="default" @click="wjmm">忘记密码</van-button> |
| | | </template> |
| | | </van-field> |
| | | </van-cell-group> |
| | | <div style="margin: 16px;text-align:center;"> |
| | | <div class="tss"><van-icon name="circle" /> 登录即视为已经阅读并同意<b style="color: #769AFF;">网站服务条款、法律声明及隐私权政策</b></div> |
| | | <div style="margin: 16px;text-align: center;"> |
| | | <div class="tss"><van-icon name="circle" /> 登录即视为已经阅读并同意<b style="color: #769aff;">网站服务条款、法律声明及隐私权政策</b></div> |
| | | <van-button :loading="loadingBUt" round block type="primary" native-type="submit"> |
| | | 登 录 |
| | | </van-button> |
| | |
| | | </template> |
| | | </van-field> |
| | | </van-cell-group> |
| | | <div style="margin: 16px;text-align:center;"> |
| | | <div class="tss"><van-icon name="circle" /> 登录即视为已经阅读并同意<b style="color: #769AFF;">网站服务条款、法律声明及隐私权政策</b></div> |
| | | <div style="margin: 16px;text-align: center;"> |
| | | <div class="tss"><van-icon name="circle" /> 登录即视为已经阅读并同意<b style="color: #769aff;">网站服务条款、法律声明及隐私权政策</b></div> |
| | | <van-button :loading="loadingBUt" round block type="primary" native-type="submit"> |
| | | 登 录 |
| | | </van-button> |
| | | </div> |
| | | </van-form> |
| | | <van-row class="loginType"> |
| | | <van-row class="logintype"> |
| | | <div class="toptype"> |
| | | <van-divider |
| | | :style="{ color: '#1989fa', borderColor: '#1989fa', padding: '0 16px' }" |
| | |
| | | </div> |
| | | </template> |
| | | <style lang="scss"> |
| | | .login{ |
| | | .login { |
| | | width: 100%; |
| | | min-height: 900px; |
| | | } |
| | | .logintt{ |
| | | |
| | | .logintt { |
| | | text-align: center; |
| | | } |
| | | .loginwenz{ |
| | | |
| | | .loginwenz { |
| | | font-size: 12px; |
| | | font-weight: 400; |
| | | color: #AAAAAA; |
| | | color: #aaa; |
| | | } |
| | | .loginType{ |
| | | |
| | | .logintype { |
| | | width: 100%; |
| | | margin-top: 120px; |
| | | text-align: center; |
| | | font-size: 11px; |
| | | font-weight: 400; |
| | | color: #AAAAAA; |
| | | color: #aaa; |
| | | |
| | | // background: black; |
| | | .toptype{ |
| | | .toptype { |
| | | width: 100%; |
| | | } |
| | | } |
| | | .titlebiaoti{ |
| | | |
| | | .titlebiaoti { |
| | | padding-top: 70px; |
| | | text-align:center; |
| | | text-align: center; |
| | | padding-left: 30px; |
| | | |
| | | // border: 1px solid black; |
| | | font-size: 15px; |
| | | padding-bottom: 70px; |
| | | } |
| | | .tss{ |
| | | |
| | | .tss { |
| | | font-size: 10px; |
| | | font-weight: 400; |
| | | color: #AAAAAA; |
| | | color: #aaa; |
| | | height: 50px; |
| | | |
| | | // line-height: 50px; |
| | | } |
| | | </style> |