You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
zhishifufei_uniapp/pages/forgotPwd/index.vue

285 lines
8.0 KiB

<template>
<BaseContainer>
<view class="forgot-pwd-box">
<NavBar title="" />
<view class="page-box">
<view class="info">
<view class="info-title">重置密码</view>
<view class="info-sub-title">重置/找回密码</view>
</view>
<view class="base-form">
<view class="phone-box pos flex flex-center-x">
<image mode="aspectFill" class="form-item-image" :src="require('../../static/images/phone.png')"></image>
<input v-model.trim="phone" class="flex-auto" type="tel" maxlength="11" placeholder="请填写手机号" placeholder-class="input-placeholder"/>
</view>
<view class="code-box pos flex flex-center-x">
<view class="flex flex-center-x flex-auto">
<image mode="aspectFill" class="form-item-image" :src="require('../../static/images/code.png')"></image>
<input v-model.trim="code" type="text" placeholder="请填写验证码" placeholder-class="input-placeholder"/>
</view>
<button :disabled="count >= 0" @click="getCode">
{{ count < 0 ? "获取验证码" : "重新获取(" + count + "s)" }} </button>
</view>
<view class="pwd-box pos flex flex-center-x">
<image mode="aspectFill" class="form-item-image" :src="require('../../static/images/pwd.png')"></image>
<input v-model.trim="pwd" :type="pwdShow ? 'text' : 'password'" maxlength="16" class="flex-auto" placeholder="请输入至少8位含数字、字母的新密码" placeholder-class="input-placeholder"/>
<!-- #ifndef MP-WEIXIN -->
<!-- <view class="pwd-show-image" :style="`background-image: url(../../static/images/pwd-${pwdShow ? 'show' : 'hide'}.png)`" @click.stop="togglePwdShow"></view> -->
<!-- #endif -->
<!-- #ifdef MP-WEIXIN -->
<!-- <image v-if="pwdShow" mode="aspectFill" class="pwd-show-image" :src="require('../../static/images/pwd-show.png')" @click.stop="pwdShow = false"></image> -->
<!-- <image v-else mode="aspectFill" class="pwd-show-image" :src="require('../../static/images/pwd-hide.png')" @click.stop="pwdShow = true"></image> -->
<!-- #endif -->
</view>
<view class="pwd-box pos flex flex-center-x">
<image mode="aspectFill" class="form-item-image" :src="require('../../static/images/pwd.png')"></image>
<input v-model.trim="pwd" :type="commitPwdShow ? 'text' : 'password'" maxlength="16" class="flex-auto" placeholder="请再次输入新密码" placeholder-class="input-placeholder"/>
<!-- #ifndef MP-WEIXIN -->
<!-- <view class="pwd-show-image" :style="`background-image: url(../../static/images/pwd-${commitPwdShow ? 'show' : 'hide'}.png)`" @click.stop="commitPwdShow = !commitPwdShow"></view> -->
<!-- #endif -->
<!-- #ifdef MP-WEIXIN -->
<!-- <image v-if="commitPwdShow" mode="aspectFill" class="pwd-show-image" :src="require('../../static/images/pwd-show.png')" @click.stop="commitPwdShow = false"></image> -->
<!-- <image v-else mode="aspectFill" class="pwd-show-image" :src="require('../../static/images/pwd-hide.png')" @click.stop="commitPwdShow = true"></image> -->
<!-- #endif -->
</view>
<view class="login-btn">
<button class="flex flex-center" type="button" @click="reset">
确认修改
</button>
</view>
</view>
</view>
</view>
</BaseContainer>
</template>
<script>
export default {
data() {
return {
phone: "",
code: "",
pwd: "",
commitPwd: "",
TIME_COUNT: 60,
count: -1,
pwdShow: false, // 密码显示隐藏
commitPwdShow: false, // 密码显示隐藏
};
},
9 months ago
onLoad(options) {
if (options.phone) {
this.phone = options.phone;
}
},
methods: {
// 获取验证码
async getCode() {
if (!this.phone) {
return this.$util.showMsg("请输入手机号");
}
if (!/^1[3456789]\d{9}$/.test(this.phone)) {
return this.$util.showMsg("手机号错误");
}
this.count = this.TIME_COUNT;
this.timer = setInterval(() => {
this.count--;
if (this.count < 0) {
clearInterval(this.timer);
this.timer = null;
}
}, 1000);
uni.showLoading({ mask: true });
try {
const { data } = await getAuthCode(this.phone);
uni.hideLoading();
this.$util.showMsg(data.Message);
} catch (err) {
uni.hideLoading();
this.$util.showMsg(err.msg);
if (this.timer) {
clearInterval(this.timer);
this.timer = null;
this.count = -1;
}
}
},
9 months ago
async reset() {
const app = getApp();
if (!this.phone) {
return this.$util.showMsg("请填写手机号");
}
if (!/^1[3456789]\d{9}$/.test(this.phone)) {
return this.$util.showMsg("手机号错误");
}
if (!this.code) {
return this.$util.showMsg("请填写验证码");
}
if (!/^\d{6}$/.test(this.code)) {
return this.$util.showMsg("验证码错误");
}
if (!this.pwd) {
return this.$util.showMsg("请填写密码");
}
if (!/^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{8,}$/.test(this.pwd)) {
return this.$util.showMsg("请填写至少8位含数字、字母的新密码");
}
if (this.commitPwd !== this.pwd) {
return this.$util.showMsg('两次密码不一致,请重新输入!');
}
if (this.timer) {
clearInterval(this.timer);
this.timer = null;
this.count = -1;
}
uni.showLoading({ mask: true });
try {
const { data, msg } = await registerAccount({
account: this.phone,
pwd: this.$util.hexMd5(this.pwd),
code: this.code,
agent_id: app.globalData.agent_id || 0
});
uni.hideLoading();
this.$util.showMsg(msg);
this.phone = "";
this.pwd = "";
this.code = "";
uni.navigateBack();
} catch (err) {
uni.hideLoading();
this.$util.showMsg(err.msg);
}
},
}
};
</script>
<style>
.input-placeholder {
color: #C8C9CC;
font-size: 26rpx;
}
</style>
<style scoped lang="scss">
.forgot-pwd-box {
position: fixed;
background-color: #F6F8FA;
width: 100%;
height: 100vh;
top: 0;
left: 0;
.nav-box {
background: transparent!important;
}
.info {
position: absolute;
top: 186rpx;
left: 50%;
transform: translateX(-50%);
display: flex;
flex-direction: column;
align-items: center;
.info-title {
font-size: 64rpx;
line-height: 64rpx;
color: #333;
}
.info-sub-title {
font-size: 30rpx;
color: #999999;
margin-top: 16rpx;
}
}
.base-form {
position: absolute;
top: 420rpx;
left: 31rpx;
width: calc(100% - 62rpx);
height: 848rpx;
z-index: 10;
border-radius: 20rpx;
box-sizing: border-box;
background: #fff;
display: flex;
flex-direction: column;
align-items: center;
padding-top: 76rpx;
.pwd-box,
.phone-box,
.code-box {
width: 590rpx;
height: 96rpx;
border-radius: 48rpx;
background: #F5F7F6;
margin-bottom: 40rpx;
padding-left: 36rpx;
padding-right: 30rpx;
display: flex;
align-items: center;
.form-item-image {
width: 44rpx;
height: 44rpx;
}
.pwd-show-image {
margin-left: 36rpx;
width: 44rpx;
height: 44rpx;
background-repeat: no-repeat;
background-position: center center;
background-size: cover;
}
input {
min-width: 0;
margin: 0 0 0 36rpx;
font-size: 30rpx;
height: 42rpx;
color: #282828;
flex: 1;
}
}
.code-box {
view {
min-width: 0;
}
button {
font-size: 26rpx;
line-height: 37rpx;
color: #2c8eff;
&::after {
border: none;
}
&:disabled {
color: #999999;
}
}
}
.login-btn {
width: 592rpx;
margin-top: 100rpx;
button {
width: 100%;
height: 88rpx;
border-radius: 44rpx;
background: linear-gradient(90deg, #4AA5FA 0%, #0F74BB 100%);
font-size: 32rpx;
color: #ffffff;
}
}
}
}
</style>