Files
aida_front/src/component/HomePage/bindEmail.vue

771 lines
21 KiB
Vue
Raw Normal View History

2024-12-19 13:47:55 +08:00
<template>
2025-02-11 10:43:20 +08:00
<div ref="register" class="bindEmail"></div>
2024-12-19 13:47:55 +08:00
<a-modal
class="register generalModel"
:get-container="() => $refs.register"
v-model:visible="registerModel"
:footer="null"
:width="pageWidth"
2025-02-11 13:14:26 +08:00
:height="bindType == 'Modify'?'60rem':'80rem'"
2024-12-19 13:47:55 +08:00
:maskClosable="false"
:centered="true"
:closable="false"
:mask="registerModelMask"
:keyboard="false"
:destroyOnClose="true"
>
2025-01-02 11:47:09 +08:00
<div class="generalModel_btn" v-if="bindType == 'Modify'">
2024-12-23 16:23:18 +08:00
<div class="generalModel_closeIcon" @click.stop="cancelDsign()">
2025-08-22 10:27:48 +08:00
<svg width="100%" height="100%" viewBox="0 0 46 46" fill="none" xmlns="http://www.w3.org/2000/svg">
2025-01-16 10:21:15 +08:00
<circle cx="23" cy="23" r="23" fill="white" fill-opacity="0.3"/>
<rect x="32.5063" y="12" width="3" height="29" rx="1.5" transform="rotate(45 32.5063 12)" fill="white"/>
<rect x="34.6274" y="32.5059" width="3" height="29" rx="1.5" transform="rotate(135 34.6274 32.5059)" fill="white"/>
</svg>
</div>
</div>
<div class="generalModel_btn back" v-if="bindType != 'Modify'">
<div class="generalModel_closeIcon" @click.stop="setBack()">
<span></span>
2025-08-22 10:27:48 +08:00
<span class="back_text">{{ $t('account.logOut') }}</span>
2024-12-23 16:23:18 +08:00
</div>
</div>
2024-12-19 13:47:55 +08:00
<div class="login_page">
<div class="page_content">
<!-- 账号密码和邮箱登录 start-->
<div class="login_content" >
<div class="login_content_left">
<div class="login_type_list">
<div
:class="[
'login_type_item','username_login_item',
'login_active',
]"
>
2025-02-07 17:34:23 +08:00
<span v-if="bindType == 'Modify'">{{ $t('account.ModifyEmail') }}</span>
<span v-else>{{ $t('account.information') }}</span>
2024-12-19 13:47:55 +08:00
</div>
</div>
<!-- 账号密码登录 start -->
2025-01-02 11:47:09 +08:00
<!-- v-show="login$props.Type == 'username'" -->
2024-12-19 13:47:55 +08:00
<div >
<div class="login_form_content" :state="emailStap">
2025-02-11 10:43:20 +08:00
<div class="login_form_title marign_top30">{{ $t('account.Email') }} <span class="must">*</span></div>
2024-12-19 13:47:55 +08:00
<input
class="login_form_input"
2025-01-20 14:20:26 +08:00
:class="{active:(userDetail.email !== '-------------') && bindType != 'Modify'}"
2025-02-07 17:34:23 +08:00
:placeholder="$t('account.plaseEmail')"
2024-12-19 13:47:55 +08:00
v-model="email"
2025-01-20 14:20:26 +08:00
:disabled="(userDetail.email !== '-------------') && bindType != 'Modify'"
2024-12-19 13:47:55 +08:00
@keydown.enter="submitPerLogin()"
/>
2025-02-07 17:34:23 +08:00
2025-01-14 11:02:02 +08:00
<div v-if="bindType != 'Modify'">
2025-02-11 13:14:26 +08:00
<div class="login_form_title marign_top30">{{ $t('account.Name') }}<span class="must">*</span></div>
2025-02-07 17:34:23 +08:00
<div style="display: flex;justify-content: space-between;">
<a-select
class="gallerySelect"
v-model:value="selectSex"
2025-02-11 13:14:26 +08:00
:disabled="!!userDetail.title"
2025-02-07 17:34:23 +08:00
size="large"
optionFilterProp="label"
style="width: 30%;"
:options="sexList"
:placeholder="$t('account.plaseSelectSex')"
allowClear
show-search
></a-select>
2025-02-11 13:14:26 +08:00
<input class="login_form_input" style="width: 30%;" :class="{active:!!userDetail.surname}" :disabled="!!userDetail.surname" type="text" :placeholder="$t('account.plaseFirst')" v-model="surname">
<input class="login_form_input" style="width: 30%;" :class="{active:!!userDetail.givenName}" :disabled="!!userDetail.givenName" type="text" :placeholder="$t('account.plaseLast')" v-model="givenName">
</div>
2025-02-11 10:43:20 +08:00
<div class="login_form_title marign_top30">{{$t('account.Country')}}:<span class="must">*</span></div>
2025-01-14 11:02:02 +08:00
<div class="login_form_select">
<a-select
class="gallerySelect"
v-model:value="Country"
:disabled="!!userDetail.country"
size="large"
optionFilterProp="label"
style="width: 100%;"
:options="countryList"
2025-08-22 10:27:48 +08:00
:field-names="{ label: locale == 'CHINESE_SIMPLIFIED'?'labelCn':'label' }"
2025-02-07 17:34:23 +08:00
:placeholder="$t('account.plaseCountry')"
2025-01-14 11:02:02 +08:00
allowClear
show-search
></a-select>
</div>
2025-02-11 10:43:20 +08:00
<div class="login_form_title marign_top30">{{$t('account.CompanyName')}}:<span class="must">*</span></div>
2025-02-12 12:06:02 +08:00
<input class="login_form_input" :class="{active:!!userDetail.occupation}" :disabled="!!userDetail.occupation" type="text" :placeholder="$t('account.plaseCompanyName')" v-model="CompanyName">
2025-01-14 11:02:02 +08:00
</div>
2024-12-19 13:47:55 +08:00
<!-- 邮箱登录 start -->
<div class="login_form_email" :class="{active:emailStap===2}">
<div v-show="emailStap === 2" class="email_last_step">
2025-08-22 10:27:48 +08:00
<!-- <div class="email_last_step_block" >
<span class="email_last_step_content"
2025-06-26 15:41:08 +08:00
>Verify using a one-time verification code</span
>
<i class="fi fi-br-cross email_last_step_block_icon" @click="emailLastStepFun()"></i>
2025-08-22 10:27:48 +08:00
</div> -->
<div class="email_last_step_bottom">
<div class="email_last_step_des">
<div class="sent_email_content">
Sent to {{ email }}
</div>
<div class="tip_content">
<span v-show="time">{{ time }}s</span>
<span v-show="!time" @click="emailNextStepFun()"
>Resend</span
>
</div>
</div>
<VerificationCodeInput
:ct="emailCode"
@sendCaptcha="submitEmailLogin($event)"
></VerificationCodeInput>
2024-12-19 13:47:55 +08:00
<div class="email_last_step_des">
<div class="sent_email_content email_tip_content">
2025-06-26 15:41:08 +08:00
If you haven't received the code, please check your junk or spam folder.
</div>
</div>
2024-12-19 13:47:55 +08:00
</div>
</div>
</div>
</div>
<div
class="login_submit_button marign_top40"
style="width: 100%;"
:state="emailStap"
@click="submitPerLogin()"
>
2025-01-02 11:47:09 +08:00
<span v-if="bindType == 'Modify'">Modify Email</span>
<span v-else>Submit</span>
2024-12-19 13:47:55 +08:00
</div>
</div>
<!-- 账号密码登录 end -->
</div>
<!-- 邮箱登录 end -->
</div>
</div>
</div>
</a-modal>
</template>
<script lang="ts">
2025-02-05 10:50:35 +08:00
import { defineComponent,watch,reactive,toRefs ,computed, onMounted} from "vue";
2024-12-19 13:47:55 +08:00
import { Https } from "@/tool/https";
import { isEmail } from "@/tool/util";
import { setCookie ,WriteCookie } from "@/tool/cookie";
import { message } from "ant-design-vue";
import VerificationCodeInput from "@/component/LoginPage/verificationCodeInput.vue";
import { useStore } from "vuex";
import { useI18n } from "vue-i18n";
import { setLang } from "@/tool/guide";
import { country } from "@/tool/country";
2025-01-16 10:21:15 +08:00
import { useRouter } from "vue-router";
2024-12-19 13:47:55 +08:00
export default defineComponent({
components: {
VerificationCodeInput,
},
2025-01-02 11:47:09 +08:00
setup(prop, { emit }){
const bindType = ''
2025-01-16 10:21:15 +08:00
const router = useRouter()
2024-12-19 13:47:55 +08:00
let timer:any = 0;
2025-02-07 17:34:23 +08:00
const {locale,t} = useI18n()
2024-12-19 13:47:55 +08:00
const store = useStore();
let userDetail:any= computed(()=>{
return store.state.UserHabit.userDetail
})
2025-02-05 10:50:35 +08:00
let userCountry = computed(()=>{
return store.state.UserHabit.userDetail.country
})
let userCompanyName = computed(()=>{
return store.state.UserHabit.userDetail.occupation
})
let userEmail = computed(()=>{
return store.state.UserHabit.userDetail.email
})
2025-02-07 17:34:23 +08:00
let userSex = computed(()=>{
2025-02-11 13:14:26 +08:00
return store.state.UserHabit.userDetail.title
2025-02-07 17:34:23 +08:00
})
let userSurname = computed(()=>{
2025-02-11 13:14:26 +08:00
return store.state.UserHabit.userDetail.surname
2025-02-07 17:34:23 +08:00
})
let userGivenName = computed(()=>{
2025-02-11 13:14:26 +08:00
return store.state.UserHabit.userDetail.givenName
2025-02-07 17:34:23 +08:00
})
2024-12-19 13:47:55 +08:00
let register = reactive({
2024-12-31 11:40:40 +08:00
registerModel:computed(()=>{
2025-01-02 11:47:09 +08:00
return store.state.UserHabit.bindEmail.isBindEmail
}),
2025-09-08 14:50:59 +08:00
// registerModel:true,
2025-01-02 11:47:09 +08:00
bindType:computed(()=>{
return store.state.UserHabit.bindEmail.type
2024-12-31 11:40:40 +08:00
}),
2024-12-19 13:47:55 +08:00
registerModelMask:true,
pageWidth:'45%',
2025-02-07 17:34:23 +08:00
Country:null,
CompanyName:'',
countryList:country,
email:'',
sexList:computed(()=> {
return [
{label:t('account.Mr'),value:'Mr'},
{label:t('account.Ms'),value:'Ms'},
{label:t('account.Miss'),value:'Miss'},
]
}),
2025-02-11 13:14:26 +08:00
selectSex:null,
2025-02-07 17:34:23 +08:00
surname:'',
givenName:'',
})
2025-02-05 10:50:35 +08:00
watch(userCountry,(newValue,oldValue)=>{
register.Country = newValue
})
watch(userCompanyName,(newValue,oldValue)=>{
register.CompanyName = newValue
})
watch(userEmail,(newValue:any,oldValue)=>{
register.email = newValue == '-------------'?'':newValue
2024-12-19 13:47:55 +08:00
})
2025-02-11 10:43:20 +08:00
watch(userSex,(newValue,oldValue)=>{
2025-02-11 13:14:26 +08:00
register.selectSex = newValue
2025-02-11 10:43:20 +08:00
})
watch(userSurname,(newValue,oldValue)=>{
register.surname = newValue
})
watch(userGivenName,(newValue,oldValue)=>{
register.givenName = newValue
})
2024-12-19 13:47:55 +08:00
return{
2025-01-16 10:21:15 +08:00
router,
2024-12-19 13:47:55 +08:00
store,
timer,
userDetail,
2024-12-19 13:47:55 +08:00
...toRefs(register),
locale
}
2024-12-19 13:47:55 +08:00
},
data() {
return {
checked:false,
emailStap: 1, // 邮箱登录步骤
emailCode: ["", "", "", "", "", ""], //邮箱验证码
emailNextStep: true,
frogetPasswordStep: 1, //忘记密码的步骤
forgetPasswordEmail: "",
forgetEmailCode: ["", "", "", "", "", ""], //忘记密码的邮箱验证码
forgetEmailValue: "", //忘记密码的邮箱验证码保存值
newPassword: "", //新密码
isCheckRobot: false,
time: 60, //60秒倒计时
passwordType:'password',
userId:'',
loginTime:true
};
},
methods: {
2025-01-02 11:47:09 +08:00
init(type:any){
let data = {
type,
isBindEmail:true
}
this.store.commit('setIsBindEmail', data)
2024-12-19 13:47:55 +08:00
this.emailLastStepFun()
},
//邮箱登录的下一步
emailNextStepFun() {
if (!isEmail(this.email)) {
message.info("The email format is incorrect");
return;
}
let data = {
email: this.email,
operationType: "LOGIN",
};
Https.axiosPost(Https.httpUrls.accountSendEmail, data).then(
(rv: any) => {
if (rv) {
this.emailStap = 2;
this.time = 60;
this.emailCode = ["", "", "", "", "", ""]
this.createTimer();
}
}
);
},
//邮箱登录的上一步
emailLastStepFun() {
this.emailStap = 1;
this.email = "";
this.checked=false,
(this.emailCode = ["", "", "", "", "", ""]), this.clearTimer();
},
//改变勾选是否是机器人
checkRobot() {
this.isCheckRobot = !this.isCheckRobot;
},
//提交账号密码预先登录
submitPerLogin() {
//输入账号密码
if(this.emailStap>=2){
return;
}else{
//输入邮箱
if (!this.email) {
message.info("Please enter your email address");
return;
}
//判断邮箱格式是否正确
if (!isEmail(this.email)) {
message.info("The email format is incorrect");
return;
}
2025-01-14 11:02:02 +08:00
if (!this.CompanyName && this.bindType != 'Modify') {
message.info("Please enter occupation");
return;
}
2025-01-14 11:02:02 +08:00
if (!this.Country && this.bindType != 'Modify') {
message.info("Please select a country");
return;
}
2025-02-11 13:14:26 +08:00
if (!this.selectSex && this.bindType != 'Modify') {
message.info("Please select a title");
return;
}
if (!this.surname && this.bindType != 'Modify') {
message.info("Please select a surname");
return;
}
if (!this.givenName && this.bindType != 'Modify') {
message.info("Please select a givenName");
return;
}
let type = 'BIND_MAILBOX'
2025-01-14 11:02:02 +08:00
if(this.email == this.userDetail.email && this.bindType != 'Modify')type = 'UPDATE_USERINFO'
2024-12-19 13:47:55 +08:00
let data = {
"email": this.email,
"ip": "",
"operationType": type,
occupation:this.CompanyName,
2025-02-07 17:34:23 +08:00
country:this.Country,
2025-02-11 13:14:26 +08:00
title:this.selectSex,
surname:this.surname,
givenName:this.givenName,
2025-09-23 22:59:53 +08:00
userId:this.userDetail?.userId,
2024-12-19 13:47:55 +08:00
};
if(this.loginTime){
this.loginTime = false
Https.axiosPost(Https.httpUrls.accountSendEmail, data).then(
(rv: any) => {
if(type == 'UPDATE_USERINFO')this.setSuccessLogin(rv)
2024-12-19 13:47:55 +08:00
this.emailStap = 2;
if (rv) {
this.userId = rv.userId
this.time = 60;
this.emailCode = ["", "", "", "", "", ""]
this.createTimer();
}
}
).catch(res=>{
this.emailStap = 1;
});
setTimeout(() => {
this.loginTime = true
}, 2000);
}
}
},
changePasswordType(){
this.passwordType = this.passwordType === 'password' ? 'text' : 'password'
},
setSuccessLogin(rv:any){
if (rv) {
let value = {
email:this.email,
occupation:this.CompanyName,
country:this.Country,
2024-12-19 13:47:55 +08:00
}
this.store.commit("upUserDetail", value)
window.location.reload();
this.cancelDsign()
}
},
//邮箱登录提交
submitEmailLogin(emailVerifyCode: any) {
let data = {
2024-12-19 17:59:00 +08:00
userEmail: this.email,
2024-12-19 13:47:55 +08:00
emailVerifyCode: emailVerifyCode,
};
Https.axiosPost(Https.httpUrls.accountBindEmail, data).then(
(rv: any) => {
2025-02-04 13:49:07 +08:00
if(rv.token)setCookie("token", rv.token);
2025-02-04 14:07:23 +08:00
this.setSuccessLogin(rv)
2024-12-19 13:47:55 +08:00
}
).catch(res=>{
});
},
//创建定时器
createTimer() {
clearInterval(this.timer);
this.time = 60;
2024-12-19 13:47:55 +08:00
this.timer = setInterval(() => {
this.time--;
if (!this.time) {
clearInterval(this.timer);
}
}, 1000);
},
//清除定时器
clearTimer() {
this.time = 60;
if (this.timer) {
clearInterval(this.timer);
}
},
cancelDsign(){
2025-01-02 11:47:09 +08:00
this.store.commit('setIsBindEmail', false)
2025-08-22 10:27:48 +08:00
this.emailStap = 1
2025-01-16 10:21:15 +08:00
},
setBack(){
this.router.push({path:'/login'})
2024-12-19 13:47:55 +08:00
}
},
});
</script>
<style lang="less" scoped>
:deep(.register){
@media (max-width: 768px) {
// box-shadow: none;
// height: 100%;
margin: 0;
max-width: 95%;
&.generalModel{
.ant-modal-content{
// height: 100%;
}
.ant-modal-body{
padding: 6rem 4rem;
// height: 100%;
}
}
}
}
</style>
<style lang="less" scoped>
2025-02-11 10:43:20 +08:00
.bindEmail{
:deep(.ant-modal-mask){
background: #666666db;
}
}
2025-01-16 10:21:15 +08:00
.generalModel_btn{
&.back{
.generalModel_closeIcon{
border-radius: 0;
right: auto;
left: 0;
border: none;
font-size: 2rem;
font-weight: 600;
transform: translate(100%, 100%);
.back_text{
text-decoration: underline;
white-space: nowrap;
2025-01-16 10:21:15 +08:00
}
span{
margin-right: .5rem;
}
}
}
}
2024-12-19 13:47:55 +08:00
.login_page {
width: 100%;
height: 100%;
2025-01-16 10:21:15 +08:00
2024-12-19 13:47:55 +08:00
.page_content {
// position: relative;
.login_content {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%,-50%);
// width: 60rem;
width: 80%;
background: #FFFFFF;
// box-shadow: -0.3rem 2rem 5.9rem 0px rgba(200,200,200,0.3);
border-radius: 1rem;
padding: 3rem 6rem 6.5rem;
box-sizing: border-box;
display: flex;
justify-content: space-between;
align-items: center;
@media (max-width: 768px) {
padding: 0;
}
.login_content_left{
width: 100%;
.login_form_email{
position: absolute;
left: 0;
width: 100%;
height: 100%;
top: 0;
background: #fff;
transform: scale(0);
transition: .3s all;
2025-08-22 10:27:48 +08:00
// border: 2px solid;
// border-radius: 20px;
2024-12-19 13:47:55 +08:00
.email_last_step{
width: 100%;
height: 100%;
#app{
height: auto;
}
}
}
.active{
transform: scale(1);
}
}
.login_type_list {
width: 100%;
display: flex;
.login_type_item {
text-align: center;
font-size: 3.6rem;
font-weight: bold;
color: #D7D7D7;
cursor: pointer;
height: 4rem;
line-height: 4rem;
&.login_active {
color: #030303;
}
}
}
.login_form_title {
2025-08-22 10:27:48 +08:00
font-size: 1.8rem;
2024-12-19 13:47:55 +08:00
// color: #666666;
2025-08-22 10:27:48 +08:00
font-weight: 500;
2024-12-19 13:47:55 +08:00
color: #000;
display: flex;
justify-content: space-between;
box-sizing: border-box;
2025-02-11 10:43:20 +08:00
> .must{
color: red;
margin-right: auto;
margin-left: 2px;
margin-top: -1%;
}
2024-12-19 13:47:55 +08:00
label{
display: flex;
span{
font-size: 1.6rem;
margin-left: 10px;
font-weight: normal;
}
&.active{
pointer-events:none;
input{
pointer-events:none;
}
}
}
}
.login_form_content {
margin-top: 4rem;
position: relative;
&[state="2"]{
2024-12-19 17:59:00 +08:00
height: 30rem;
2024-12-19 13:47:55 +08:00
>*{
opacity: 0;
}
.login_form_email{
opacity: 1;
}
}
.password_input_block{
position: relative;
.password_show_icon{
position: absolute;
font-size: 2.4rem;
right: 2rem;
2025-08-22 10:27:48 +08:00
top: 3.3rem;
2024-12-19 13:47:55 +08:00
cursor: pointer;
}
}
.gallerySelect{
margin-top: 1rem;
:deep(.ant-select-selector){
height: 5rem;
border: 0.1rem solid #dfdfdf;
border-radius: 2.5rem;
2025-02-07 17:34:23 +08:00
align-items: center;
}
:deep(.ant-select-selector):hover{
border: 0.1rem solid #000;
}
}
2024-12-19 13:47:55 +08:00
.login_form_input {
width: 100%;
2025-08-22 10:27:48 +08:00
// height: 6.75rem;
height: 5rem;
margin-top: 1rem;
2024-12-19 13:47:55 +08:00
border: 0.1rem solid #dfdfdf;
2025-08-22 10:27:48 +08:00
border-radius: 4.2rem;
2024-12-19 13:47:55 +08:00
padding-left: 2.1rem;
line-height: 5rem;
2025-08-22 10:27:48 +08:00
font-size: 1.6rem;
2024-12-19 13:47:55 +08:00
box-sizing: border-box;
outline: none;
transition: all .3s;
2025-01-13 17:10:41 +08:00
&.active{
color: #b8b8b8;
background: #F9FAFA;
2025-01-13 17:10:41 +08:00
}
2024-12-19 13:47:55 +08:00
&:hover{
border: 0.1rem solid #000;
}
&::placeholder {
color: #a5b0c2;
}
}
}
.email_last_step {
// margin-top: 4rem;
2025-08-22 10:27:48 +08:00
2024-12-19 13:47:55 +08:00
.email_last_step_block{
padding: 10px;
2025-08-22 10:27:48 +08:00
// border-bottom: 2px solid;
2024-12-19 13:47:55 +08:00
box-sizing: border-box;
display: flex;
align-items: center;
justify-content: space-between;
.email_last_step_content {
margin-left: 1rem;
font-size: 2.2rem;
font-weight: bold;
color: #030303;
}
.email_last_step_block_icon{
cursor: pointer;
margin-right: 1rem;
height: 20px;
}
}
.fi-br-arrow-left {
font-size: 2.5rem;
font-weight: bold;
color: #030303;
transform: translateY(1rem);
display: inline-block;
}
}
.login_submit_button {
height: 5rem;
background: #000;
border-radius: 2.5rem;
line-height: 5rem;
text-align: center;
font-size: 1.8rem;
font-weight: 500;
color: #ffffff;
cursor: pointer;
transition: all .3s;
&:hover{
background: #3C3C3C;
}
&[state="2"] {
cursor: not-allowed;
}
}
.login_text {
font-size: 1.6rem;
margin-top: 4rem;
color: #151515;
display: flex;
justify-content: flex-end;
.forget_password_text{
cursor: pointer;
}
}
}
}
.marign_top20 {
margin-top: 2rem;
}
.marign_top22 {
margin-top: 2.2rem;
}
.marign_top30 {
margin-top: 3rem;
}
.marign_top40 {
margin-top: 4rem;
}
.thirdPartyLogin{
display: flex;
justify-content: flex-start;
>div{
margin-right: 1rem;
}
}
.tip_content {
font-size: 1.3rem;
font-weight: bold;
2025-06-03 14:57:18 +08:00
color: #000;
2024-12-19 13:47:55 +08:00
cursor: pointer;
}
.email_last_step_des {
display: flex;
align-items: center;
justify-content: space-between;
margin-top: 4rem;
margin-bottom: 2rem;
.sent_email_content {
font-size: 1.8rem;
font-weight: bold;
color: #a5b0c2;
}
.email_tip_content{
font-size: 1.4rem;
color: #030303;
}
}
}
</style>