优化代码
This commit is contained in:
@@ -62,7 +62,9 @@
|
||||
<view class="Nickname" @click="modifyPassword">
|
||||
<view class="avatarmodify-item">密码</view>
|
||||
<view class="NicknameInput">
|
||||
<view class="NicknameInput-name">{{ havaPassword == true ? "" : "未设置" }}</view>
|
||||
<view class="NicknameInput-name">{{
|
||||
havaPassword == true ? "" : "未设置"
|
||||
}}</view>
|
||||
<image
|
||||
class="more"
|
||||
src="https://vv-1317974657.cos.ap-shanghai.myqcloud.com/util/More.png"
|
||||
@@ -128,15 +130,15 @@ export default {
|
||||
uni.setStorageSync("userinfo", res.data);
|
||||
setTimeout(() => {
|
||||
uni.getStorage({
|
||||
key: "userinfo",
|
||||
success: (res) => {
|
||||
this.id = res.data.id;
|
||||
this.name = res.data.nickName;
|
||||
this.userinfo = this.useravatar = res.data.headerIcon;
|
||||
this.email = res.data.email;
|
||||
this.havaPassword = res.data.havaPassword;
|
||||
},
|
||||
});
|
||||
key: "userinfo",
|
||||
success: (res) => {
|
||||
this.id = res.data.id;
|
||||
this.name = res.data.nickName;
|
||||
this.userinfo = this.useravatar = res.data.headerIcon;
|
||||
this.email = res.data.email;
|
||||
this.havaPassword = res.data.havaPassword;
|
||||
},
|
||||
});
|
||||
}, 300);
|
||||
} else {
|
||||
console.log(res.msg);
|
||||
@@ -179,22 +181,39 @@ export default {
|
||||
method: "POST",
|
||||
data: {
|
||||
uuid: data.uuid,
|
||||
userId: this.id,
|
||||
id: this.id,
|
||||
},
|
||||
userInfo: true,
|
||||
})
|
||||
.then((res) => {
|
||||
if (res.code === 200) {
|
||||
uni.showToast({
|
||||
title: "登录成功",
|
||||
icon: "success",
|
||||
request({
|
||||
url: "user/confirm",
|
||||
method: "POST",
|
||||
data: {
|
||||
uuid: data.uuid,
|
||||
id: this.id,
|
||||
},
|
||||
userInfo: true,
|
||||
})
|
||||
.then((res) => {
|
||||
if (res.code === 200) {
|
||||
uni.showToast({
|
||||
title: "登录成功",
|
||||
icon: "success",
|
||||
});
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: res,
|
||||
icon: "none",
|
||||
});
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
uni.showToast({
|
||||
title: "登录失败",
|
||||
icon: "none",
|
||||
});
|
||||
});
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: res,
|
||||
icon: "none",
|
||||
});
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
uni.showToast({
|
||||
|
||||
@@ -24,7 +24,9 @@
|
||||
placeholder="请输入邮箱号"
|
||||
v-model="email"
|
||||
/>
|
||||
<text class="error" v-if="turnsoutemail == ''">第一次填写邮箱时请确保填写正确的邮箱地址,填写错误请联系客服</text>
|
||||
<text class="error" v-if="turnsoutemail == ''"
|
||||
>第一次填写邮箱时请确保填写正确的邮箱地址,填写错误请联系客服</text
|
||||
>
|
||||
<text class="error" v-if="error">请输入正确的邮箱地址</text>
|
||||
<view v-if="turnsoutemail != ''" class="Verificationcodebox">
|
||||
<input
|
||||
@@ -33,9 +35,16 @@
|
||||
placeholder="验证码"
|
||||
v-model="Verificationcode"
|
||||
/>
|
||||
<view class="Verificationcodebtn" @click="sendVerificationCode">获取验证码</view>
|
||||
<view class="Verificationcodebtn" @click="sendVerificationCode"
|
||||
:style="isCounting ? 'background-image: linear-gradient(0deg, #cccccc, #dddddd); cursor: not-allowed;' : ''"
|
||||
> {{ isCounting ? `${countdown}秒后重发` : '获取验证码' }}</view
|
||||
>
|
||||
</view>
|
||||
<text v-if="VerificationcodeSent && turnsoutemail != ''" class="VerificationcodeSent">验证码已发送至{{turnsoutemail}}邮箱,请注意查收</text>
|
||||
<text
|
||||
v-if="VerificationcodeSent && turnsoutemail != ''"
|
||||
class="VerificationcodeSent"
|
||||
>验证码已发送至{{ turnsoutemail }}邮箱,请注意查收</text
|
||||
>
|
||||
<!-- -->
|
||||
<view class="btn" @click="onSubmit">确认</view>
|
||||
|
||||
@@ -53,12 +62,15 @@ export default {
|
||||
data() {
|
||||
return {
|
||||
title: "Hello",
|
||||
email: "",//邮箱
|
||||
Verificationcode: "",//验证码
|
||||
id: "",//用户id
|
||||
error: false,//邮箱错误
|
||||
VerificationcodeSent: false,//验证码是否已发送
|
||||
turnsoutemail:'',//修改前的邮箱
|
||||
email: "", //邮箱
|
||||
Verificationcode: "", //验证码
|
||||
id: "", //用户id
|
||||
error: false, //邮箱错误
|
||||
VerificationcodeSent: false, //验证码是否已发送
|
||||
turnsoutemail: "", //修改前的邮箱
|
||||
countdown: 0, //验证码倒计时
|
||||
isCounting: false, //是否正在倒计时
|
||||
timer: null, //倒计时定时器
|
||||
};
|
||||
},
|
||||
onLoad(options) {
|
||||
@@ -66,14 +78,24 @@ export default {
|
||||
this.id = options.id;
|
||||
},
|
||||
methods: {
|
||||
// 倒计时
|
||||
startCountdown() {
|
||||
this.countdown = 60;
|
||||
this.isCounting = true;
|
||||
this.timer = setInterval(() => {
|
||||
this.countdown -- ;
|
||||
if (this.countdown <= 0) {
|
||||
this.isCounting = false;
|
||||
}
|
||||
}, 1000);
|
||||
},
|
||||
//提交验证
|
||||
onSubmit() {
|
||||
if (this.turnsoutemail == "") {
|
||||
this.setEmail()
|
||||
}else{
|
||||
this.hasEmail()
|
||||
this.setEmail();
|
||||
} else {
|
||||
this.hasEmail();
|
||||
}
|
||||
|
||||
},
|
||||
//有邮箱修改
|
||||
hasEmail() {
|
||||
@@ -129,6 +151,9 @@ export default {
|
||||
},
|
||||
//发送验证码
|
||||
sendVerificationCode() {
|
||||
if (this.isCounting) {
|
||||
return;
|
||||
}
|
||||
request({
|
||||
url: "user/sendUpdateMailConfirmMail",
|
||||
method: "POST",
|
||||
@@ -138,6 +163,7 @@ export default {
|
||||
userInfo: true,
|
||||
}).then((ress) => {
|
||||
this.VerificationcodeSent = true;
|
||||
this.startCountdown();
|
||||
});
|
||||
},
|
||||
//第一次提交
|
||||
@@ -209,7 +235,7 @@ export default {
|
||||
onCustomerService() {
|
||||
uni.navigateTo({
|
||||
url: "/pages/Mine/minecomponents/contact",
|
||||
})
|
||||
});
|
||||
},
|
||||
//返回上一页
|
||||
onBack() {
|
||||
@@ -296,7 +322,7 @@ export default {
|
||||
text-align: center;
|
||||
line-height: 80rpx;
|
||||
}
|
||||
.VerificationcodeSent{
|
||||
.VerificationcodeSent {
|
||||
color: #00afb2;
|
||||
font-size: 24rpx;
|
||||
margin-top: 40rpx;
|
||||
@@ -318,7 +344,7 @@ export default {
|
||||
color: red;
|
||||
font-size: 20rpx;
|
||||
}
|
||||
.forget{
|
||||
.forget {
|
||||
font-size: 24rpx;
|
||||
color: #00afb2;
|
||||
margin-top: 50rpx;
|
||||
|
||||
Reference in New Issue
Block a user