191 lines
6.3 KiB
Vue
Raw Normal View History

2025-06-06 03:08:19 +08:00
<template>
<view class="page">
2025-06-10 02:14:24 +08:00
<uni-nav-bar @clickLeft="goto(1, 1)" left-icon="back" :border="false" :shadow="false" :fixed="true"
:title="$t('signup.title')" backgroundColor="#fff"></uni-nav-bar>
<view style="width: 92%; margin: auto; padding: 30rpx 20rpx;">
<view style="font-size: 64rpx; color: #333; font-weight: 700;">{{$t('signup.title')}}</view>
<view style="color: #6C7278; font-weight: 500; font-size: 28rpx; margin-bottom: 40rpx; margin-top: 20rpx;">{{$t('signup.text1')}}</view>
<uni-forms label-position="top" label-width="180rpx" :modelValue="signupModel" :rules="rules" ref="signupModel">
2025-06-06 03:08:19 +08:00
<uni-forms-item label="Email" name="email" label-width="400rpx">
2025-06-08 02:12:24 +08:00
<uni-easyinput type="text" v-model="signupModel.email" :placeholder="$t('signup.text2')"></uni-easyinput>
2025-06-06 03:08:19 +08:00
</uni-forms-item>
2025-06-08 02:12:24 +08:00
<uni-forms-item :label="$t('signup.text3')" name="code" label-width="400rpx">
<uni-easyinput type="number" v-model="signupModel.code" :placeholder="$t('signup.text4')">
2025-06-06 03:08:19 +08:00
<template #right>
<button type="primary"
:disabled="isSend"
@click="sendCode()"
2025-06-10 02:14:24 +08:00
style="font-size: 28rpx; padding: auto 20rpx; width: 220rpx;">{{sendText}}</button>
2025-06-06 03:08:19 +08:00
</template>
</uni-easyinput>
</uni-forms-item>
2025-06-08 02:12:24 +08:00
<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')" />
2025-06-06 03:08:19 +08:00
</uni-forms-item>
2025-06-08 02:12:24 +08:00
<uni-forms-item :label="$t('signup.text6')" name="trade_password" label-width="400rpx">
2025-06-10 02:14:24 +08:00
<uni-easyinput type="password" :passwordIcon="true" v-model="signupModel.trade_password" :placeholder="$t('signup.text7')" />
2025-06-06 03:08:19 +08:00
</uni-forms-item>
2025-06-08 02:12:24 +08:00
<uni-forms-item :label="$t('signup.text11')" name="invite_code" label-width="400rpx">
2025-06-10 02:14:24 +08:00
<uni-easyinput type="text" v-model="signupModel.invite_code" :placeholder="$t('signup.text9')"></uni-easyinput>
2025-06-06 03:08:19 +08:00
</uni-forms-item>
</uni-forms>
2025-06-10 02:14:24 +08:00
<view class="f">{{$t('login.text6')}}</view>
2025-06-08 02:12:24 +08:00
<button type="primary" round style="width: 100%;" @click="signup">{{$t('signup.title')}}</button>
2025-06-06 03:08:19 +08:00
</view>
2025-06-10 02:14:24 +08:00
<view style="bottom: 0rpx; width:100vw; height: 60rpx;">
<view style="font-size: 24rpx; color: #6C7278; font-weight: 500; text-align: center;">
2025-06-08 02:12:24 +08:00
{{$t('signup.text13')}}
2025-06-10 02:14:24 +08:00
<span style="color: #4D81E7; margin-left: 20rpx;" @click="onPageJump('/pages/mine/login')">{{$t('forgot.text16')}}</span>
2025-06-06 03:08:19 +08:00
</view>
</view>
</view>
</template>
<script>
import {
mapState,
mapMutations
} from 'vuex';
export default {
data() {
return {
2025-06-08 02:12:24 +08:00
sendText: this.$t('setPasswork.text8'),
2025-06-06 03:08:19 +08:00
isSend: false,
signupModel:{
email:"",
code:"",
password:"",
invite_code:"",
trade_password:"",
},
rules: {
2025-06-08 02:12:24 +08:00
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')}]},
2025-06-06 03:08:19 +08:00
trade_password:{
2025-06-08 02:12:24 +08:00
rules:[{required: true,errorMessage: this.$t('putforward.text5')},
{minLength: 6, maxLength: 6, errorMessage: this.$t('putforward.text6') }],
2025-06-06 03:08:19 +08:00
},
2025-06-10 02:14:24 +08:00
invite_code: {rules:[{required: true,errorMessage: this.$t('putforward.text9')}]}
},
2025-06-06 03:08:19 +08:00
};
},
computed: {
...mapState(['userInfo'])
},
//第一次加载
onLoad(e) {
},
//页面显示
onShow() {},
//方法
methods: {
...mapMutations(['setUserInfo']),
onPageJump(url) {
uni.navigateTo({
url: url
});
},
2025-06-10 02:14:24 +08:00
goto(url, type) {
if (type == 2) {
return uni.switchTab({ url: url })
}
if (type == 1) {
return uni.navigateBack({ delta: url });
}
uni.navigateTo({
url: url
})
2025-06-06 03:08:19 +08:00
},
sendCode(){
this.isSend = true;
if (this.signupModel.email == '') {
2025-06-08 02:12:24 +08:00
uni.showToast({title: this.$t('forgot.text19'), icon:'error'});
2025-06-10 02:14:24 +08:00
this.isSend = false;
2025-06-06 03:08:19 +08:00
return;
}
if (!this.$base.mailRegular.test(this.signupModel.email)) {
2025-06-08 02:12:24 +08:00
uni.showToast({title: this.$t('forgot.text20'), icon:'error'});
2025-06-10 02:14:24 +08:00
this.isSend = false;
2025-06-06 03:08:19 +08:00
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'});
2025-06-08 02:12:24 +08:00
this.sendText = this.$t('forgot.text4',{par: s});
2025-06-06 03:08:19 +08:00
let intervalId = setInterval(() => {
s = s-1;
if (s == 0) {
clearInterval(intervalId);
this.isSend = false;
this.sendText = "Get code";
}
else{
2025-06-08 02:12:24 +08:00
this.sendText = this.$t('forgot.text4',{par: s});
2025-06-06 03:08:19 +08:00
}
}, 1000);
}
});
},
signup(){
2025-06-10 02:14:24 +08:00
this.$refs.signupModel.validate().then(res=>{
if (!this.$base.mailRegular.test(this.signupModel.email)) {
uni.showToast({title:this.$t('signup.text12'),icon:'error'});
2025-06-06 03:08:19 +08:00
return;
2025-06-10 02:14:24 +08:00
}
if(!this.$base.passwordRegular.test(this.signupModel.password)){
uni.showToast({title:this.$t('signup.text14'),icon:'error'});
return;
}
2025-06-06 03:08:19 +08:00
let data = {
email: this.signupModel.email,
code: this.signupModel.code,
password: this.signupModel.password,
2025-06-10 02:14:24 +08:00
invite_code: this.signupModel.invite_code,
trade_password: this.signupModel.trade_password,
2025-06-06 03:08:19 +08:00
}
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{
2025-06-10 02:14:24 +08:00
font-weight: 400;font-size: 32rpx;color: #999999;line-height: 46rpx; text-align: center; margin-top: 60rpx;
2025-06-06 03:08:19 +08:00
}
.rechargeNet{
2025-06-10 02:14:24 +08:00
font-weight: 600;font-size: 40rpx;color: #333;line-height: 46rpx; text-align: center; margin-top: 40rpx;
2025-06-06 03:08:19 +08:00
}
.txt{
2025-06-10 02:14:24 +08:00
font-size: 28rpx; color:#999; font-weight: 500;
2025-06-06 03:08:19 +08:00
}
.cell_right{
2025-06-10 02:14:24 +08:00
font-size: 28rpx; color:#333; font-weight: 500;
2025-06-06 03:08:19 +08:00
}
.f{
2025-06-10 02:14:24 +08:00
font-size: 24rpx; color:#4D81E7; font-weight: 500; text-align: right; margin-bottom: 60rpx;
2025-06-06 03:08:19 +08:00
}
</style>