修改密码

This commit is contained in:
@fawn-nine
2023-10-16 17:49:14 +08:00
parent 05829f5617
commit bd998074a3
4 changed files with 305 additions and 227 deletions

View File

@@ -431,7 +431,13 @@
previewImage(url) { previewImage(url) {
console.log(url) console.log(url)
uni.previewImage({ uni.previewImage({
urls: [url] urls: [url],
longPressActions:{
itemList:['很抱歉,暂不支持保存图片到本地'],
success:function(res){
// console.log(res,'+++++')
}
}
}); });
}, },
// 获取打卡参数 // 获取打卡参数

View File

@@ -1,8 +1,8 @@
<template> <template>
<view class="page"> <view class="page">
<z-nav-bar></z-nav-bar> <z-nav-bar></z-nav-bar>
<!-- 公共组件-每个页面必须引入 --> <!-- 公共组件-每个页面必须引入 -->
<public-module></public-module> <public-module></public-module>
<view class="title">忘记密码</view> <view class="title">忘记密码</view>
<view class="input_box"> <view class="input_box">
<text class="input_tit">手机号</text> <text class="input_tit">手机号</text>
@@ -15,239 +15,298 @@
</view> </view>
<view class="input_box"> <view class="input_box">
<text class="input_tit">密码</text> <text class="input_tit">密码</text>
<input type="password" v-model="password" placeholder="请输入密码" /> <input type="password" maxlength="8" v-model="password" placeholder="请输入密码" @input="inputMethod(password)" />
</view> </view>
<view class="" style="font-size: 28rpx; color: #999;">
<p v-if="note != ''">{{note}}</p>
<p v-html="str2" style="margin-top: 10rpx;"></p>
</view>
<view class="input_box"> <view class="input_box">
<text class="input_tit">确认密码</text> <text class="input_tit">确认密码</text>
<input type="password" v-model="confirmPassword" placeholder="请确认密码" /> <input type="password" maxlength="8" v-model="confirmPassword" placeholder="请确认密码" />
</view> </view>
<view class="btn_box"><button @click="onSubmit"> </button></view> <view class="btn_box"><button @click="onSubmit"> </button></view>
<music-play :playData="playData"></music-play> <music-play :playData="playData"></music-play>
</view> </view>
</template> </template>
<script> <script>
import musicPlay from '@/components/music.vue' import musicPlay from '@/components/music.vue'
import md5 from '@/plugins/md5'; import md5 from '@/plugins/md5';
var clear; // 密码验证的正则
export default { //1、密码为八位及以上并且字母数字特殊字符三项都包括
data() { var strongRegex = new RegExp("^(?=.{8,})(?=.*[A-Z])(?=.*[a-z])(?=.*[0-9])(?=.*\\W).*$", "g");
return { //2、密码为八位及以上并且字母、数字、特殊字符三项中有两项强度是中等
playData:{}, var mediumRegex = new RegExp(
//手机号账号 "^(?=.{8,})(((?=.*[A-Z])(?=.*[a-z]))|((?=.*[A-Z])(?=.*[0-9]))|((?=.*[a-z])(?=.*[0-9]))|((?=.*[a-z])(?=.*\\W))|((?=.*[0-9])(?=.*\\W))|((?=.*[A-Z])(?=.*\\W))).*$",
phone: '', "g");
// 密码 var enoughRegex = new RegExp("(?=.{8,}).*", "g");
password: '', var clear;
//验证码 export default {
code: '', data() {
//确认密码 return {
confirmPassword: '', playData: {},
//验证码 //手机号账号
codeText: '获取验证码', phone: '',
//验证码已发 // 密码
readonly: false password: '',
}; //验证码
}, code: '',
//第一次加载 //确认密码
onLoad(e) {}, confirmPassword: '',
//页面显示 //验证码
onShow() {}, codeText: '获取验证码',
components:{ //验证码已发
musicPlay readonly: false,
passwordOk:false,
}, note: '',
//方法 str2: '',
methods: { };
//获取验证码
getCode() {
if (this.readonly) {
uni.showToast({
title: '验证码已发送',
icon: 'none'
});
return;
}
if (!this.phone) {
uni.showToast({
title: '请输入手机号',
icon: 'none'
});
return;
}
if (!this.$base.phoneRegular.test(this.phone)) {
uni.showToast({
title: '请输入正确的手机号',
icon: 'none'
});
return;
}
this.$http
// .post('api/common/v1/send_sms', {
.post('book/user/sms/sendcode', {
phone: this.phone,
type: 3000
})
.then(res => {
this.getCodeState();
});
}, },
//验证码按钮文字状态 //第一次加载
getCodeState() { onLoad(e) {},
const _this = this; //页面显示
this.readonly = true; onShow() {},
this.codeText = '60S后重新获取'; components: {
var s = 60; musicPlay
clear = setInterval(() => {
s--; },
_this.codeText = s + 'S后重新获取'; //方法
if (s <= 0) { methods: {
clearInterval(clear); // 密码验证
_this.codeText = '获取验证码'; inputMethod(value) {
_this.readonly = false; this.passwordOk = false
// console.log('输入的值为:', value)
if (strongRegex.test(value)) {
//console.log('强密码-----',value)
this.str2 = "<span style='color:#18bc37'>密码强度很不错哦!</span>"
// this.note = '请至少使用大小写字母、数字、符号两种类型组合的密码长度至少为8位。'
this.note = ''
this.passwordOk = true
} else if (mediumRegex.test(value)) {
// console.log('中等密码-----',value)
this.note = '请至少使用大小写字母、数字、符号两种类型组合的密码长度为8位。'
this.str2 = "<span style='color:#2979ff'>密码强度中等!</span>"
this.passwordOk = true
} else if (enoughRegex.test(value)) {
// console.log('弱密码-----',value)
// this.str2 = "<span style='color:#f3a73f'>密码强度太弱!</span>"
this.note = '请至少使用大小写字母、数字、符号两种类型组合的密码长度为8位。'
}
else {
this.passwordOk = false
this.note = '请至少使用大小写字母、数字、符号两种类型组合的密码长度为8位。'
this.str2 = ""
//console.log('密码-----',value)
} }
}, 1000); },
}, //获取验证码
onSubmit() { getCode() {
if (!this.phone) { if (this.readonly) {
uni.showToast({ uni.showToast({
title: '请输入手机号', title: '验证码已发送',
icon: 'none' icon: 'none'
});
return;
}
if (!this.$base.phoneRegular.test(this.phone)) {
uni.showToast({
title: '请输入正确的手机号',
icon: 'none'
});
return;
}
if (!this.code) {
uni.showToast({
title: '请输入验证码',
icon: 'none'
});
return;
}
if (!this.password) {
uni.showToast({
title: '请输入密码',
icon: 'none'
});
return;
}
if (!this.confirmPassword) {
uni.showToast({
title: '请输入确认密码',
icon: 'none'
});
return;
}
if (this.confirmPassword != this.password) {
uni.showToast({
title: '两次密码不一致',
icon: 'none'
});
return;
}
if (!this.$base.passwordRegular.test(this.password)) {
uni.showToast({
title: '请输入不少于6位且包含数字和字母的密码',
icon: 'none'
});
return;
}
this.$http
// .post('api/common/v1/forget_password', {
.post('book/user/setPassword', {
phone: this.phone,
code:this.code,
// password: md5(this.password),
password: this.password
})
.then(res => {
uni.showModal({
title:"提示",
content:"密码修改成功!",
showCancel:false,
success: (res) => {
uni.navigateBack();
}
}); });
}); return;
}
if (!this.phone) {
uni.showToast({
title: '请输入手机号',
icon: 'none'
});
return;
}
if (!this.$base.phoneRegular.test(this.phone)) {
uni.showToast({
title: '请输入正确的手机号',
icon: 'none'
});
return;
}
this.$http
// .post('api/common/v1/send_sms', {
.post('book/user/sms/sendcode', {
phone: this.phone,
type: 3000
})
.then(res => {
this.getCodeState();
});
},
//验证码按钮文字状态
getCodeState() {
const _this = this;
this.readonly = true;
this.codeText = '60S后重新获取';
var s = 60;
clear = setInterval(() => {
s--;
_this.codeText = s + 'S后重新获取';
if (s <= 0) {
clearInterval(clear);
_this.codeText = '获取验证码';
_this.readonly = false;
}
}, 1000);
},
onSubmit() {
if(!this.passwordOk){
console.log('不满足密码格式',this.note)
uni.showToast({
title:this.note,
icon: 'none'
})
return
}
if (!this.phone) {
uni.showToast({
title: '请输入手机号',
icon: 'none'
});
return;
}
if (!this.$base.phoneRegular.test(this.phone)) {
uni.showToast({
title: '请输入正确的手机号',
icon: 'none'
});
return;
}
if (!this.code) {
uni.showToast({
title: '请输入验证码',
icon: 'none'
});
return;
}
if (!this.password) {
uni.showToast({
title: '请输入密码',
icon: 'none'
});
return;
}
if (!this.confirmPassword) {
uni.showToast({
title: '请输入确认密码',
icon: 'none'
});
return;
}
if (this.confirmPassword != this.password) {
uni.showToast({
title: '两次密码不一致',
icon: 'none'
});
return;
}
if (!this.$base.passwordRegular.test(this.password)) {
uni.showToast({
title: '请输入不少于6位且包含数字和字母的密码',
icon: 'none'
});
return;
}
this.$http
// .post('api/common/v1/forget_password', {
.post('book/user/setPassword', {
phone: this.phone,
code: this.code,
// password: md5(this.password),
password: this.password
})
.then(res => {
uni.showModal({
title: "提示",
content: "密码修改成功!",
showCancel: false,
success: (res) => {
uni.navigateBack();
}
});
});
}
},
//页面隐藏
onHide() {},
//页面卸载
onUnload() {},
//页面下来刷新
onPullDownRefresh() {},
//页面上拉触底
onReachBottom() {},
//用户点击分享
onShareAppMessage(e) {
return this.wxShare();
} }
}, };
//页面隐藏
onHide() {},
//页面卸载
onUnload() {},
//页面下来刷新
onPullDownRefresh() {},
//页面上拉触底
onReachBottom() {},
//用户点击分享
onShareAppMessage(e) {
return this.wxShare();
}
};
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
@import '@/style/mixin.scss'; @import '@/style/mixin.scss';
.page {
background-color: #ffffff; .page {
padding: 0 65rpx; background-color: #ffffff;
min-height: 100vh; padding: 0 65rpx;
min-height: 100vh;
.title {
padding: 60rpx 0 40rpx 0; .title {
font-size: 60rpx; padding: 60rpx 0 40rpx 0;
color: #333333; font-size: 60rpx;
} color: #333333;
.input_box { }
display: flex;
justify-content: space-between; .input_box {
height: 100rpx; display: flex;
padding-top: 30rpx; justify-content: space-between;
border-bottom: 1rpx solid #eeeeee; height: 100rpx;
padding-top: 30rpx;
border-bottom: 1rpx solid #eeeeee;
align-items: center; align-items: center;
text{
font-size: 30rpx; text {
width: 180rpx; font-size: 30rpx;
width: 180rpx;
}
input {
flex: 1;
height: 70rpx;
line-height: 70rpx;
font-size: 30rpx;
}
button {
height: 78rpx;
line-height: 78rpx;
font-size: 30rpx;
color: $themeColor;
&:active {
background-color: transparent;
}
}
} }
input {
flex: 1; .btn_box {
height: 70rpx; margin-top: 70rpx;
line-height: 70rpx;
font-size: 30rpx; button {
font-size: 32rpx;
@include theme('btn_bg') color: #fff;
height: 80rpx;
line-height: 80rpx;
border-radius: 50rpx;
}
} }
button {
height: 78rpx; .protocol {
line-height: 78rpx; font-size: 24rpx;
font-size: 30rpx; color: #999999;
color: $themeColor; text-align: center;
&:active { margin-top: 20rpx;
background-color: transparent;
text {
color: $themeColor;
} }
} }
} }
.btn_box { </style>
margin-top: 70rpx;
button {
font-size: 32rpx;
@include theme('btn_bg')
color: #fff;
height: 80rpx;
line-height: 80rpx;
border-radius: 50rpx;
}
}
.protocol {
font-size: 24rpx;
color: #999999;
text-align: center;
margin-top: 20rpx;
text {
color: $themeColor;
}
}
}
</style>

View File

@@ -64,7 +64,11 @@
<view class="qie_huan" style="display: flex; justify-content: center;"> <view class="qie_huan" style="display: flex; justify-content: center;">
<view style="width: 30%;" @click="type = 1000" v-if="type == 2000">密码登录</view> <view style="width: 30%;" @click="type = 1000" v-if="type == 2000">密码登录</view>
<view style="width: 30%;" @click="type = 2000" v-if="type == 1000">验证码登录</view> <view style="width:50%; display: flex; justify-content:space-between;" v-if="type == 1000">
<text @click="type = 2000">验证码登录</text>
<text v-if="type == 1000" @click="onPageJump('/pages/user/forget')">忘记密码</text>
<!-- <text @click="resetPassWord()">忘记密码</text> -->
</view>
</view> </view>
<z-popup v-model="HealthOpen" type="center" :hideOnBlur="false"> <z-popup v-model="HealthOpen" type="center" :hideOnBlur="false">
@@ -188,6 +192,13 @@
methods: { methods: {
...mapMutations(['setUserInfo']), ...mapMutations(['setUserInfo']),
...mapMutations(['setHealthMes']), ...mapMutations(['setHealthMes']),
// 修改密码
resetPassWord(){
console.log('重置密码')
uni.navigateTo({
url: "/pages/home/shop/goodsDetail"
})
},
// 显示协议 // 显示协议
showXieyi(str){ showXieyi(str){
if(str == 'user'){ if(str == 'user'){

View File

@@ -91,14 +91,14 @@
<u-popup :show="passwordShow" :round="10" @close="cancelPass"> <u-popup :show="passwordShow" :round="10" @close="cancelPass">
<view class="tanchu"> <view class="tanchu">
<view class="dp_title">请修改密码</view> <view class="dp_title">请修改密码</view>
<u--input v-model="userMes.password" placeholder="请输入新密码" :password="true" border="surround" clearable <u--input maxlength="8" v-model="userMes.password" placeholder="请输入新密码" :password="true" border="surround" clearable
@input="inputMethod(userMes.password)"> @input="inputMethod(userMes.password)">
</u--input> </u--input>
<view class="" style="font-size: 28rpx; color: #999;"> <view class="" style="font-size: 28rpx; color: #999;">
<p v-if="note != ''">{{note}}</p> <p v-if="note != ''">{{note}}</p>
<p v-html="str2" style="margin-top: 10rpx;"></p> <p v-html="str2" style="margin-top: 10rpx;"></p>
</view> </view>
<u--input v-model="userMes.Repassword" placeholder="请再确认密码" :password="true" border="surround" clearable <u--input maxlength="8" v-model="userMes.Repassword" placeholder="请再确认密码" :password="true" border="surround" clearable
style="margin-top: 20rpx;"></u--input> style="margin-top: 20rpx;"></u--input>
<u-button color="linear-gradient(to right, #72d386, #317e42)" text="确定" @click="chosePassword()" <u-button color="linear-gradient(to right, #72d386, #317e42)" text="确定" @click="chosePassword()"
style="margin-top: 50rpx;"></u-button> style="margin-top: 50rpx;"></u-button>
@@ -207,24 +207,26 @@
// 密码验证 // 密码验证
inputMethod(value) { inputMethod(value) {
this.passwordOk = false this.passwordOk = false
console.log('输入的值为:', value) // console.log('输入的值为:', value)
if (strongRegex.test(value)) { if (strongRegex.test(value)) {
//console.log('强密码-----',value) //console.log('强密码-----',value)
this.str2 = "<span style='color:#18bc37'>密码强度很不错哦!</span>" this.str2 = "<span style='color:#18bc37'>密码强度很不错哦!</span>"
// this.note = '请至少使用大小写字母、数字、符号两种类型组合的密码,长度至少为8位。' // this.note = '请至少使用大小写字母、数字、符号两种类型组合的密码长度为8位。'
this.note = '' this.note = ''
this.passwordOk = true this.passwordOk = true
} else if (mediumRegex.test(value)) { } else if (mediumRegex.test(value)) {
//console.log('中等密码-----',value) //console.log('中等密码-----',value)
this.note = '请至少使用大小写字母、数字、符号两种类型组合的密码,长度至少为8位。' this.note = '请至少使用大小写字母、数字、符号两种类型组合的密码长度为8位。'
this.str2 = "<span style='color:#2979ff'>密码强度中等!</span>" this.str2 = "<span style='color:#2979ff'>密码强度中等!</span>"
this.passwordOk = true this.passwordOk = true
} else if (enoughRegex.test(value)) { } else if (enoughRegex.test(value)) {
//console.log('弱密码-----',value) //console.log('弱密码-----',value)
this.str2 = "<span style='color:#f3a73f'>密码强度太弱!</span>" this.str2 = "<span style='color:#f3a73f'>密码强度太弱!</span>"
this.note = '请至少使用大小写字母、数字、符号两种类型组合的密码,长度至少为8位。' this.note = '请至少使用大小写字母、数字、符号两种类型组合的密码长度为8位。'
} else { } else {
this.note = '请至少使用大小写字母、数字、符号两种类型组合的密码长度至少为8位。' this.passwordOk = false
this.note = '请至少使用大小写字母、数字、符号两种类型组合的密码长度为8位。'
this.str2 = ""
//console.log('密码-----',value) //console.log('密码-----',value)
} }
}, },