2025-06-08 02:12:24 +08:00

213 lines
7.8 KiB
Vue

<template>
<view class="page">
<nav-bar :title="$t('signup.title')" bgColor="#fff"></nav-bar>
<view style="width: 92%; margin: auto; padding: 15px 10px;" v-if="pageShow==1">
<view style="font-size: 32px; color: #333; font-weight: 700;">{{$t('signup.title')}}</view>
<view style="color: #6C7278; font-weight: 500; font-size: 14px; margin-bottom: 20px; margin-top: 10px;">{{$t('signup.text1')}}</view>
<uni-forms label-position="top" label-width="80px" :modelValue="signupModel" :rules="rules" ref="signupModel">
<uni-forms-item label="Email" name="email" label-width="400rpx">
<uni-easyinput type="text" v-model="signupModel.email" :placeholder="$t('signup.text2')"></uni-easyinput>
</uni-forms-item>
<uni-forms-item :label="$t('signup.text3')" name="code" label-width="400rpx">
<uni-easyinput type="number" v-model="signupModel.code" :placeholder="$t('signup.text4')">
<template #right>
<button type="primary"
:disabled="isSend"
@click="sendCode()"
style="font-size: 28rpx; padding: auto 20rpx; width: 200rpx;">{{sendText}}</button>
</template>
</uni-easyinput>
</uni-forms-item>
<uni-forms-item :label="$t('forgot.text11')" name="password" label-width="400rpx">
<uni-easyinput type="password" :passwordIcon="true" v-model="signupModel.password" :placeholder="$t('login.text5')" />
</uni-forms-item>
<uni-forms-item :label="$t('forgot.text13')" name="cpassword" label-width="400rpx">
<uni-easyinput type="password" :passwordIcon="true" v-model="signupModel.cpassword" :placeholder="$t('forgot.text14')" />
</uni-forms-item>
</uni-forms>
<view class="f">{{$t('login.text6')}}</view>
<button type="primary" round style="width: 100%;" @click="next">{{$t('signup.text5')}}</button>
</view>
<view style="width: 92%; margin: auto; padding: 15px 10px;" v-if="pageShow==2">
<view style="font-size: 32px; color: #333; font-weight: 700;">{{$t('signup.title')}}</view>
<view style="color: #6C7278; font-weight: 500; font-size: 14px; margin-bottom: 20px; margin-top: 10px;">{{$t('signup.text1')}}</view>
<uni-forms label-position="top" label-width="80px" :modelValue="signupModel1" :rules="rules1" ref="signupModel1">
<uni-forms-item :label="$t('signup.text6')" name="trade_password" label-width="400rpx">
<uni-easyinput type="password" :passwordIcon="true" v-model="signupModel1.trade_password" :placeholder="$t('signup.text7')" />
</uni-forms-item>
<uni-forms-item :label="$t('signup.text10')" name="ctrade_password" label-width="400rpx">
<uni-easyinput type="password" :passwordIcon="true" v-model="signupModel1.ctrade_password" :placeholder="$t('signup.text8')" />
</uni-forms-item>
<uni-forms-item :label="$t('signup.text11')" name="invite_code" label-width="400rpx">
<uni-easyinput type="text" v-model="signupModel1.invite_code" :placeholder="$t('signup.text9')"></uni-easyinput>
</uni-forms-item>
</uni-forms>
<view style="font-size: 12px; color:#4D81E7; font-weight: 500; text-align: right; margin-bottom: 30px;">{{$t('login.text6')}}</view>
<button type="primary" round style="width: 100%;" @click="signup">{{$t('signup.title')}}</button>
</view>
<view style="bottom: 0px; position: absolute; width:100vw; height: 60rpx;">
<view style="font-size: 12px; color: #6C7278; font-weight: 500; text-align: center;">
{{$t('signup.text13')}}
<span style="color: #4D81E7; margin-left: 10px;" @click="onPageJump('/pages/mine/login')">{{$t('forgot.text16')}}</span>
</view>
</view>
</view>
</template>
<script>
import {
mapState,
mapMutations
} from 'vuex';
export default {
data() {
return {
sendText: this.$t('setPasswork.text8'),
isSend: false,
pageShow: 1,
signupModel:{
email:"",
code:"",
password:"",
cpassword:"",
},
signupModel1:{
invite_code:"",
trade_password:"",
ctrade_password:"",
},
rules: {
email: {rules:[{required: true,errorMessage: this.$t('forgot.text2')}]},
code:{rules:[{required: true,errorMessage: this.$t('setPasswork.text12')}]},
password: {rules:[{required: true,errorMessage: this.$t('login.text10')}]},
cpassword: {rules:[{required: true,errorMessage: this.$t('setPasswork.text11')}]},
},
rules1: {
trade_password:{
rules:[{required: true,errorMessage: this.$t('putforward.text5')},
{minLength: 6, maxLength: 6, errorMessage: this.$t('putforward.text6') }],
},
ctrade_password: {rules:[{required: true,errorMessage: this.$t('putforward.text5')}]},
invite_code: {rules:[{required: true,errorMessage: this.$t('putforward.text9')}]}
}
};
},
computed: {
...mapState(['userInfo'])
},
//第一次加载
onLoad(e) {
},
//页面显示
onShow() {},
//方法
methods: {
...mapMutations(['setUserInfo']),
onPageJump(url) {
uni.navigateTo({
url: url
});
},
next(){
this.$refs.signupModel.validate().then(res=>{
if (!this.$base.mailRegular.test(this.signupModel.email)) {
uni.showToast({title:this.$t('signup.text12'),icon:'error'});
return;
}
if(!this.$base.passwordRegular.test(this.signupModel.password)){
uni.showToast({title:this.$t('signup.text14'),icon:'error'});
return;
}
if (this.signupModel.cpassword !== this.signupModel.password) {
uni.showToast({title:this.$t('signup.text15'),icon:'error'});
return;
}
this.pageShow = 2;
}).catch(err =>{})
},
sendCode(){
this.isSend = true;
if (this.signupModel.email == '') {
uni.showToast({title: this.$t('forgot.text19'), icon:'error'});
return;
}
if (!this.$base.mailRegular.test(this.signupModel.email)) {
uni.showToast({title: this.$t('forgot.text20'), icon:'error'});
return;
}
let s = 120;
let data = {
type: "email",
event: "register",
email: this.signupModel.email,
lang: this.$i18n.locale
}
this.$http.post('/api/common/captcha', data).then(res => {
if(res.code == 0){
uni.showToast({title: 'Successfully sent'});
this.sendText = this.$t('forgot.text4',{par: s});
let intervalId = setInterval(() => {
s = s-1;
if (s == 0) {
clearInterval(intervalId);
this.isSend = false;
this.sendText = "Get code";
}
else{
this.sendText = this.$t('forgot.text4',{par: s});
}
}, 1000);
}
});
},
signup(){
this.$refs.signupModel1.validate().then(res=>{
if (this.signupModel.trade_password !== this.signupModel.ctrade_password) {
uni.showToast({title:this.$t('setPin.text12'),icon:'error'});
return;
};
let data = {
email: this.signupModel.email,
code: this.signupModel.code,
password: this.signupModel.password,
invite_code: this.signupModel1.invite_code,
trade_password: this.signupModel1.trade_password,
}
this.$http.post('/api/common/register', data).then(res => {
if(res.code == 0){
this.setUserInfo(res.data.userinfo);
setTimeout(() => {
uni.switchTab({
url: '/pages/mine/index'
});
}, 1000);
}
});
}).catch(err =>{})
}
},
//页面卸载
onUnload() {},
};
</script>
<style lang="scss" scoped>
@import '@/style/mixin.scss';
body{background-color: #fff;}
.page{min-height: 100vh;position: relative;}
.rechargeTitle{
font-weight: 400;font-size: 16px;color: #999999;line-height: 23px; text-align: center; margin-top: 30px;
}
.rechargeNet{
font-weight: 600;font-size: 20px;color: #333;line-height: 23px; text-align: center; margin-top: 20px;
}
.txt{
font-size: 14px; color:#999; font-weight: 500;
}
.cell_right{
font-size: 14px; color:#333; font-weight: 500;
}
.f{
font-size: 12px; color:#4D81E7; font-weight: 500; text-align: right; margin-bottom: 30px;
}
</style>