|
@@ -3,6 +3,9 @@ import {ref,reactive} from 'vue'
|
|
|
import {ElMessageBox,ElMessage} from 'element-plus'
|
|
|
import { useRouter } from 'vue-router';
|
|
|
import {CaretBottom} from '@element-plus/icons-vue'
|
|
|
+import {loginApi,registerApi,emailCodeSend} from '@/api/auth.js'
|
|
|
+
|
|
|
+import md5 from 'md5';
|
|
|
|
|
|
const router = useRouter()
|
|
|
const loginFormRef=ref(null)
|
|
@@ -12,9 +15,23 @@ import {CaretBottom} from '@element-plus/icons-vue'
|
|
|
const loginForm=reactive({
|
|
|
email:'',
|
|
|
phone:'',
|
|
|
- phonePre:'+86',
|
|
|
+ phonePre:'86',
|
|
|
password:'',
|
|
|
})
|
|
|
+ const telCodeArr=[
|
|
|
+ { value: '86', label: '+86' },
|
|
|
+ { value: '852', label: "+852" },
|
|
|
+ { value: '886', label: '+886' },
|
|
|
+ { value: '1', label: '+1' },
|
|
|
+ { value: '65', label: '+65' },
|
|
|
+ { value: '62', label: '+62' },
|
|
|
+ { value:'081',label: '+081' },
|
|
|
+ { value:'44',label: '+44' }
|
|
|
+ ]
|
|
|
+
|
|
|
+ // 隐私政策是否阅读
|
|
|
+ const hasChecked=ref(false)
|
|
|
+
|
|
|
const loginFormRules=reactive({
|
|
|
email:[{required: true, message:'邮箱不能为空', trigger: 'blur'},
|
|
|
{type:'email',message:'邮箱格式不正确', trigger: 'blur'}],
|
|
@@ -48,14 +65,27 @@ import {CaretBottom} from '@element-plus/icons-vue'
|
|
|
ElMessage.success('复制成功')
|
|
|
}
|
|
|
}
|
|
|
- console.log();
|
|
|
const login=()=>{
|
|
|
- loginFormRef.value.validate(valid=>{
|
|
|
+ loginFormRef.value.validate(valid =>{
|
|
|
if(valid){
|
|
|
- //TODO 登录接口对接
|
|
|
- // if(!loginForm.phonePre && loginType.value==2){
|
|
|
- // ElMessage.error('请选择手机区号')
|
|
|
- // }
|
|
|
+ if(!hasChecked.value){
|
|
|
+ ElMessage.warning('请勾选隐私政策')
|
|
|
+ return
|
|
|
+ }
|
|
|
+ let params={
|
|
|
+ Account:loginType.value==1?loginForm.email:loginForm.phone,
|
|
|
+ Type:loginType.value,
|
|
|
+ Password:md5(loginForm.password)
|
|
|
+ }
|
|
|
+ loginApi(params).then(res=>{
|
|
|
+ // console.log(res);
|
|
|
+ if(res.code == 200){
|
|
|
+ localStorage.setItem('yben_token',res.data.access_token)
|
|
|
+ let redirectPath=sessionStorage.getItem('login_redirect') || '/'
|
|
|
+ sessionStorage.removeItem('login_redirect')
|
|
|
+ router.replace(redirectPath)
|
|
|
+ }
|
|
|
+ })
|
|
|
// console.log(loginForm);
|
|
|
// if(Math.random()>0.75){
|
|
|
// ElMessageBox.confirm("您的账号未曾注册,请注册后登录", '提示',
|
|
@@ -81,10 +111,10 @@ import {CaretBottom} from '@element-plus/icons-vue'
|
|
|
// ElMessage.error('密码错误,请检查')
|
|
|
// }else if(Math.random()>0.2){
|
|
|
//TODO 登录成功,跳转
|
|
|
- localStorage.setItem('yben_token','FDSAFWRFEGGREGEe1')
|
|
|
- let redirectPath=sessionStorage.getItem('login_redirect') || '/'
|
|
|
- sessionStorage.removeItem('login_redirect')
|
|
|
- router.replace(redirectPath)
|
|
|
+ // localStorage.setItem('yben_token','FDSAFWRFEGGREGEe1')
|
|
|
+ // let redirectPath=sessionStorage.getItem('login_redirect') || '/'
|
|
|
+ // sessionStorage.removeItem('login_redirect')
|
|
|
+ // router.replace(redirectPath)
|
|
|
// }else{
|
|
|
// ElMessageBox.confirm("您的报告试用权限已超一个月,如需要延长试用期或其他帮助,请联系我们:XXXXXXXXXXXXXXXXXX","提示",
|
|
|
// {
|
|
@@ -158,18 +188,33 @@ import {CaretBottom} from '@element-plus/icons-vue'
|
|
|
})
|
|
|
|
|
|
const sendVerCode=()=>{
|
|
|
- codeInfo.isRequesting=true
|
|
|
- codeInfo.timeout--
|
|
|
- codeTimer=setInterval(()=>{
|
|
|
- if(codeInfo.timeout==1){
|
|
|
- codeInfo.isRequesting=false
|
|
|
- codeInfo.timeout=60
|
|
|
- codeTimer=null
|
|
|
+ registerFormRef.value.validateField(['userName','email']).then(res=>{
|
|
|
+ let codeParams={
|
|
|
+ Name:registerForm.userName,
|
|
|
+ Email:registerForm.email
|
|
|
+ }
|
|
|
+ emailCodeSend(codeParams).then(res=>{
|
|
|
+ if(res.code!=200) return
|
|
|
+ ElMessage.success('已发送验证码')
|
|
|
+ codeInfo.isRequesting=true
|
|
|
+ codeInfo.timeout--
|
|
|
+ codeTimer=setInterval(()=>{
|
|
|
+ if(codeInfo.timeout==1){
|
|
|
+ codeInfo.isRequesting=false
|
|
|
+ codeInfo.timeout=60
|
|
|
+ codeTimer=null
|
|
|
+ }
|
|
|
+ codeInfo.timeout--
|
|
|
+ },1000)
|
|
|
+ })
|
|
|
+ }).catch(err=>{
|
|
|
+ let errMessage=''
|
|
|
+ errMessage=err.userName?err.userName[0].message:
|
|
|
+ err.email?err.email[0].message:''
|
|
|
+ if(errMessage){
|
|
|
+ ElMessage.warning(errMessage)
|
|
|
}
|
|
|
- codeInfo.timeout--
|
|
|
- },1000)
|
|
|
- // TODO 发送验证码
|
|
|
- ElMessage.success('已发送验证码')
|
|
|
+ })
|
|
|
}
|
|
|
|
|
|
const register=()=>{
|
|
@@ -180,7 +225,24 @@ import {CaretBottom} from '@element-plus/icons-vue'
|
|
|
step.value=2
|
|
|
return
|
|
|
}
|
|
|
- console.log(registerForm);
|
|
|
+ if(!hasChecked.value){
|
|
|
+ ElMessage.warning('请勾选隐私政策')
|
|
|
+ return
|
|
|
+ }
|
|
|
+ let params={
|
|
|
+ CompanyName:registerForm.companyName,
|
|
|
+ Name:registerForm.userName,
|
|
|
+ Email:registerForm.email,
|
|
|
+ SmsCode:registerForm.verificationCode,
|
|
|
+ Password:md5(registerForm.password)
|
|
|
+ }
|
|
|
+ registerApi(params).then(res=>{
|
|
|
+ console.log(res.code);
|
|
|
+ if(res.code==200){
|
|
|
+ sessionStorage.setItem('transitionPageMessage','register')
|
|
|
+ router.replace('/transitionPage')
|
|
|
+ }
|
|
|
+ })
|
|
|
// if(Math.random()>0.75){
|
|
|
// ElMessageBox.confirm("您的邮箱已注册,请直接登录","提示",
|
|
|
// {
|
|
@@ -193,8 +255,8 @@ import {CaretBottom} from '@element-plus/icons-vue'
|
|
|
// }).catch(()=>{})
|
|
|
// }else if(Math.random()>0.25){
|
|
|
// //TODO 注册成功,跳转
|
|
|
- sessionStorage.setItem('transitionPageMessage','register')
|
|
|
- router.replace('/transitionPage')
|
|
|
+ // sessionStorage.setItem('transitionPageMessage','register')
|
|
|
+ // router.replace('/transitionPage')
|
|
|
// }else{
|
|
|
// ElMessageBox.confirm("您的报告试用权限已超一个月,如需要延长试用期或其他帮助,请联系我们:XXXXXXXXXXXXXXXXXX","提示",
|
|
|
// {
|
|
@@ -235,9 +297,7 @@ import {CaretBottom} from '@element-plus/icons-vue'
|
|
|
<el-form-item prop="phone" v-else >
|
|
|
<div class="phone-item">
|
|
|
<el-select v-model="loginForm.phonePre" style="max-width: 90px;margin-right: 10px;" placeholder="请选择" size="large">
|
|
|
- <el-option label="+86" value="+86" />
|
|
|
- <el-option label="101" value="101" />
|
|
|
- <el-option label="3" value="3" />
|
|
|
+ <el-option :label="item.label" :value="item.value" v-for="item in telCodeArr" />
|
|
|
</el-select>
|
|
|
<el-input v-model.trim="loginForm.phone" style="flex-grow: 1;" placeholder="请输入手机号" size="large">
|
|
|
</el-input>
|
|
@@ -256,6 +316,10 @@ import {CaretBottom} from '@element-plus/icons-vue'
|
|
|
</div>
|
|
|
</div>
|
|
|
<el-button class="submit-button" type="primary" size="large" @click="login">立即登录</el-button>
|
|
|
+ <div class="privacy-policy">
|
|
|
+ <el-checkbox v-model="hasChecked" label="我已阅读并同意" style="color:#333333"></el-checkbox>
|
|
|
+ <span @click="privacyPolicy" class="policy">弘则研报隐私政策</span>
|
|
|
+ </div>
|
|
|
<div class="login-hint">若有任何问题,请发邮件至xxxxxxxxxx</div>
|
|
|
</div>
|
|
|
</div>
|
|
@@ -288,9 +352,7 @@ import {CaretBottom} from '@element-plus/icons-vue'
|
|
|
<template #label>
|
|
|
<el-select v-model="loginForm.phonePre" :suffix-icon="CaretBottom"
|
|
|
style="max-width: 55px;" placeholder="请选择" size="large">
|
|
|
- <el-option label="+886" value="+86" />
|
|
|
- <el-option label="101" value="101" />
|
|
|
- <el-option label="3" value="3" />
|
|
|
+ <el-option :label="item.label" :value="item.value" v-for="item in telCodeArr" />
|
|
|
</el-select>
|
|
|
</template>
|
|
|
<el-input v-model.trim="loginForm.phone" style="flex-grow: 1;" placeholder="请输入手机号" size="large"></el-input>
|
|
@@ -304,6 +366,10 @@ import {CaretBottom} from '@element-plus/icons-vue'
|
|
|
<span @click="psdMissingPageGo">忘记密码?</span>
|
|
|
</div>
|
|
|
<el-button type="primary" class="submit-button" @click="login" size="large">立即登录</el-button>
|
|
|
+ <div class="privacy-policy">
|
|
|
+ <el-checkbox v-model="hasChecked" label="我已阅读并同意"></el-checkbox>
|
|
|
+ <span @click="privacyPolicy" class="policy">弘则研报隐私政策</span>
|
|
|
+ </div>
|
|
|
<div class="mobile-login-hint">若有任何问题,请发邮件至xxxxxxxxxx</div>
|
|
|
</div>
|
|
|
<!-- 注册 -->
|
|
@@ -337,6 +403,10 @@ import {CaretBottom} from '@element-plus/icons-vue'
|
|
|
</el-form>
|
|
|
<el-button type="primary" class="submit-button" @click="register" size="large" v-if="step==1">下一步</el-button>
|
|
|
<el-button type="primary" class="submit-button" size="large" v-if="step==2" @click="register">提交信息</el-button>
|
|
|
+ <div class="privacy-policy" v-if="step==2">
|
|
|
+ <el-checkbox v-model="hasChecked" label="我已阅读并同意" style="color:#333333" ></el-checkbox>
|
|
|
+ <span @click="privacyPolicy" class="policy">弘则研报隐私政策</span>
|
|
|
+ </div>
|
|
|
<div class="mobile-login-hint">若有任何问题,请发邮件至xxxxxxxxxx</div>
|
|
|
</div>
|
|
|
</div>
|
|
@@ -368,6 +438,19 @@ import {CaretBottom} from '@element-plus/icons-vue'
|
|
|
font-weight: 600;
|
|
|
}
|
|
|
}
|
|
|
+ .privacy-policy{
|
|
|
+ font-weight: 400;
|
|
|
+ font-size: 14px;
|
|
|
+ line-height: 22px;
|
|
|
+ margin-top: 25px;
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ .policy{
|
|
|
+ color: #1856A7;
|
|
|
+ cursor: pointer;
|
|
|
+ margin-left: 12px;
|
|
|
+ }
|
|
|
+ }
|
|
|
.submit-button{
|
|
|
margin-top: 26px;
|
|
|
width: 100%;
|
|
@@ -398,7 +481,7 @@ import {CaretBottom} from '@element-plus/icons-vue'
|
|
|
.login-container-right{
|
|
|
background-color: white;
|
|
|
width: 600px;
|
|
|
- height: 500px;
|
|
|
+ height: 550px;
|
|
|
opacity: 0.95;
|
|
|
border: 1px solid #DCDFE6;
|
|
|
border-radius: 8px;
|
|
@@ -445,12 +528,12 @@ import {CaretBottom} from '@element-plus/icons-vue'
|
|
|
color: #333333;;
|
|
|
cursor: pointer;
|
|
|
}
|
|
|
- }
|
|
|
+ }
|
|
|
.login-hint{
|
|
|
font-size: 14px;
|
|
|
line-height: 20px;
|
|
|
color: #999999;
|
|
|
- margin-top: 26px;
|
|
|
+ margin-top: 25px;
|
|
|
}
|
|
|
}
|
|
|
}
|