增加新功能
This commit is contained in:
+79
-59
@@ -14,12 +14,12 @@
|
||||
<up-input
|
||||
placeholder="请输入验证码"
|
||||
border="surround"
|
||||
v-model="form.code"
|
||||
v-model="form.smsCode"
|
||||
:customStyle="inputCss"
|
||||
>
|
||||
<template #suffix style="margin-right: 10rpx;">
|
||||
<view v-if="countdown" class="code-warp">
|
||||
<up-count-down :time="60 * 1000" format="ss" @finish="getCode(false)"></up-count-down>
|
||||
<up-count-down :time="60 * 1000" format="ss" @finish="countdown = false"></up-count-down>
|
||||
<text style="margin-left: 10rpx;">s</text>
|
||||
</view>
|
||||
<view v-else @click="getMobileCode" class="code_msg">
|
||||
@@ -56,7 +56,7 @@
|
||||
</template>
|
||||
</up-input>
|
||||
</view>
|
||||
<view class="register_info_item">
|
||||
<!-- <view class="register_info_item">
|
||||
<up-input
|
||||
placeholder="请输入交易密码"
|
||||
border="surround"
|
||||
@@ -69,7 +69,7 @@
|
||||
<up-image v-else src="/static/login/hidden.png" width="20" height="20" bgColor="#f1f6ff00" @click="transactionCodeIsShow=true;"></up-image>
|
||||
</template>
|
||||
</up-input>
|
||||
</view>
|
||||
</view> -->
|
||||
<view class="register_info_item">
|
||||
<up-input
|
||||
placeholder="推荐码"
|
||||
@@ -80,7 +80,7 @@
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="login_comm_but login_comm_but_yes" @click="registerFun">
|
||||
<view class="login_comm_but login_comm_but_yes" @click="registerFun" :loading="butLoading">
|
||||
注册
|
||||
</view>
|
||||
<view class="policy_warp">
|
||||
@@ -106,12 +106,17 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { SMS_TYPE } from '@/utils/enumUtils.js';
|
||||
import { getUserList } from '@/api/common.js';
|
||||
import { register } from '@/api/auth.js';
|
||||
import { setStorageFun,TOKEN_NAME,USER_KEY,USER_DATA,USER_LOGIN_TIME } from '@/utils/auth.js';
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
form:{
|
||||
mobile:null,
|
||||
code:null,// 验证码
|
||||
smsCode:null,// 验证码
|
||||
loginPassword:null,
|
||||
loginPassword2:null,
|
||||
transactionCode:null,// 交易密码
|
||||
@@ -129,50 +134,48 @@
|
||||
loginPassword2IsShow:false,
|
||||
transactionCodeIsShow:false,// 交易密码
|
||||
isPolicy:false,
|
||||
butLoading:false,
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
registerFun(){
|
||||
const params = {
|
||||
...this.form,
|
||||
}
|
||||
console.log("params",params);
|
||||
if(!params.mobile){
|
||||
async registerFun(){
|
||||
const form = this.form;
|
||||
if(!form.mobile){
|
||||
this.$refs.uToastRef.show({
|
||||
type: 'error',
|
||||
message: "请输入手机号",
|
||||
});
|
||||
return;
|
||||
}
|
||||
if(!params.code){
|
||||
if(!form.smsCode){
|
||||
this.$refs.uToastRef.show({
|
||||
type: 'error',
|
||||
message: "请输入验证码",
|
||||
});
|
||||
return;
|
||||
}
|
||||
if(!params.loginPassword){
|
||||
if(!form.loginPassword){
|
||||
this.$refs.uToastRef.show({
|
||||
type: 'error',
|
||||
message: "请输入登录密码",
|
||||
});
|
||||
return;
|
||||
}
|
||||
if(!params.loginPassword2){
|
||||
if(!form.loginPassword2){
|
||||
this.$refs.uToastRef.show({
|
||||
type: 'error',
|
||||
message: "请输入二次确认密码",
|
||||
});
|
||||
return;
|
||||
}
|
||||
if(params.loginPassword !== params.loginPassword2){
|
||||
if(form.loginPassword !== form.loginPassword2){
|
||||
this.$refs.uToastRef.show({
|
||||
type: 'error',
|
||||
message: "两次输入的登录密码不一致",
|
||||
});
|
||||
return;
|
||||
}
|
||||
if(!params.referralCode){
|
||||
if(!form.referralCode){
|
||||
this.$refs.uToastRef.show({
|
||||
type: 'error',
|
||||
message: "请输入推荐码",
|
||||
@@ -186,54 +189,71 @@
|
||||
});
|
||||
return;
|
||||
}
|
||||
console.log("params",params);
|
||||
uni.switchTab({
|
||||
url: '/pages/home/home',
|
||||
})
|
||||
this.butLoading = true;
|
||||
const params = {
|
||||
mobile:form.mobile,
|
||||
smsCode:form.smsCode,
|
||||
password:form.loginPassword,
|
||||
inviteCode:form.referralCode,
|
||||
}
|
||||
const resp = await register(params);
|
||||
if(resp && resp.bizcode === 100){
|
||||
const data = resp.data;
|
||||
setStorageFun(TOKEN_NAME,data.token);
|
||||
// 用于无感登录
|
||||
setStorageFun(USER_KEY,'');
|
||||
const userInfo = {
|
||||
avatar:data.avatarUrl,
|
||||
name: data.name,
|
||||
userId: data.userId,
|
||||
grade:data.grade,
|
||||
inviteCode:data.inviteCode,
|
||||
};
|
||||
setStorageFun(USER_DATA,userInfo);
|
||||
// 当前登录得时间戳
|
||||
let currentTimeStamp = new Date().getTime();
|
||||
setStorageFun(USER_LOGIN_TIME,currentTimeStamp);
|
||||
this.$refs.uToastRef.show({
|
||||
type: 'success',
|
||||
message: resp.msg,
|
||||
});
|
||||
setTimeout(()=>{
|
||||
uni.switchTab({
|
||||
url: '/pages/home/home',
|
||||
})
|
||||
},2000);
|
||||
}
|
||||
this.butLoading = false;
|
||||
|
||||
},
|
||||
/**
|
||||
* 获取手机验证码
|
||||
*/
|
||||
getMobileCode(){
|
||||
async getMobileCode(){
|
||||
const form = this.form;
|
||||
if(!form.mobile){
|
||||
this.$refs.uToastRef.show({
|
||||
type: 'error',
|
||||
message: "请输入手机号码",
|
||||
});
|
||||
return;
|
||||
}
|
||||
this.countdown = true;
|
||||
// const form = this.form;
|
||||
// const params={
|
||||
// mobile:form.mobile,
|
||||
// type:SMS_TYPE.LOGIN,
|
||||
// }
|
||||
// const response = await uni.$http.post(smsCode,params);
|
||||
// if(response && response.code === 0){
|
||||
// this.startCountdown = true;
|
||||
// this.$refs.uToastRef.show({
|
||||
// type: 'success',
|
||||
// message: response.msg,
|
||||
// });
|
||||
// }else{
|
||||
// this.startCountdown = false;
|
||||
// }
|
||||
|
||||
const params={
|
||||
mobile:form.mobile,
|
||||
type:SMS_TYPE.REGISTER,
|
||||
}
|
||||
const response = await getUserList(params);
|
||||
if(response && response.bizcode === 100){
|
||||
this.$refs.uToastRef.show({
|
||||
type: 'success',
|
||||
message: response.msg,
|
||||
});
|
||||
}else{
|
||||
this.countdown = false;
|
||||
}
|
||||
},
|
||||
getCode(val){
|
||||
this.countdown = false;
|
||||
// const emptyCountdown = this.emptyCountdown;
|
||||
// if(val){
|
||||
// const codeNumber = this.codeNumberRef;
|
||||
// if(codeNumber){
|
||||
// this.$emit('getCode');
|
||||
// }else{
|
||||
// this.$refs.uToastRef.show({
|
||||
// type: 'error',
|
||||
// message: "请输入邮箱",
|
||||
// });
|
||||
// return;
|
||||
// }
|
||||
// }else{
|
||||
// this.$refs.uToastRef.show({
|
||||
// type: 'error',
|
||||
// message: "请输入邮箱",
|
||||
// });
|
||||
// }
|
||||
},
|
||||
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user