mall-uniapp/pages/retrieve_password/index.vue

134 lines
3.9 KiB
Vue
Raw Normal View History

2020-08-13 08:12:57 +00:00
<template>
<view class="register absolute">
<view class="shading">
2023-08-19 15:12:19 +00:00
<view class="pictrue acea-row row-center-wrapper">
<image src="../../static/images/logo2.png" />
2020-08-13 08:12:57 +00:00
</view>
</view>
<view class="whiteBg">
<view class="title">找回密码</view>
<view class="list">
<view class="item">
<view class="acea-row row-middle">
2023-08-19 15:12:19 +00:00
<image src="/static/images/phone_1.png" />
<input type="text" placeholder="输入手机号码" placeholder-class="placeholder" v-model="mobile" class="input"/>
2020-08-13 08:12:57 +00:00
</view>
</view>
<view class="item">
2023-08-19 15:12:19 +00:00
<view class="align-left acea-row row-middle">
<image src="/static/images/code_2.png" />
2020-08-13 08:12:57 +00:00
<input type="text" placeholder="填写验证码" class="codeIput" v-model="captcha" placeholder-class="placeholder"/>
<button class="code" :disabled="disabled" :class="disabled === true ? 'on' : ''" @click="code">
{{ text }}
</button>
</view>
</view>
<view class="item">
<view class="acea-row row-middle">
2023-08-19 15:12:19 +00:00
<image src="/static/images/code_1.png" />
2020-08-13 08:12:57 +00:00
<input type="password" placeholder="填写您的登录密码" v-model="password" placeholder-class="placeholder" class="input"/>
</view>
</view>
</view>
<view class="logon" @click="registerReset"></view>
2023-08-19 15:12:19 +00:00
<navigator url="/pages/users/login/index" class="tip">
<text class="font-color">立即登录</text>
2020-08-13 08:12:57 +00:00
</navigator>
</view>
2023-08-19 15:12:19 +00:00
<view class="bottom" />
2020-08-13 08:12:57 +00:00
</view>
</template>
<script>
import sendVerifyCode from "@/mixins/SendVerifyCode";
2023-08-19 15:12:19 +00:00
import * as AuthUtil from '@/api/member/auth.js';
import * as UserApi from '@/api/member/user.js';
export default {
2020-08-13 08:12:57 +00:00
data() {
return {
2023-08-19 15:12:19 +00:00
mobile: "",
2020-08-13 08:12:57 +00:00
password: "",
captcha: ""
};
},
mixins: [sendVerifyCode],
methods: {
registerReset() {
2023-08-19 15:12:19 +00:00
if (!this.mobile) {
return this.$util.Tips({
title: '请填写手机号码'
});
}
if (!/^1(3|4|5|7|8|9|6)\d{9}$/i.test(this.mobile)) {
return this.$util.Tips({
title: '请输入正确的手机号码'
});
}
if (!this.captcha) {
return this.$util.Tips({
title: '请填写验证码'
});
}
if (!/^[\w\d]+$/i.test(this.captcha)) {
return this.$util.Tips({
title: '请输入正确的验证码'
});
}
if (!this.password) {
return this.$util.Tips({
title: '请填写密码'
});
}
if (!/^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{6,16}$/i.test(this.password)) {
return this.$util.Tips({
title: '您输入的密码过于简单'
});
}
UserApi.resetUserPassword({
mobile: this.mobile,
code: this.captcha,
password: this.password
}).then(res => {
return this.$util.Tips({
title: '密码找回成功',
icon: 'success'
}, {
tab: 5,
url: '/pages/users/login/index'
});
}).catch(res => {
this.$util.Tips({
title: res
});
});
2020-08-13 08:12:57 +00:00
},
2023-08-19 15:12:19 +00:00
async code() {
if (!this.mobile) {
return this.$util.Tips({
title: '请填写手机号码'
});
}
if (!/^1(3|4|5|7|8|9|6)\d{9}$/i.test(this.mobile)) {
return this.$util.Tips({
title: '请输入正确的手机号码'
});
}
AuthUtil.sendSmsCode(this.mobile, 4).then(res => {
this.$util.Tips({
title: res
});
this.sendCode();
}).catch(res => {
this.$util.Tips({
title: res
});
});
}
2020-08-13 08:12:57 +00:00
}
};
</script>
<style>
</style>