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.

84 lines
2.1 KiB

2 years ago
<style lang="scss">
.container{
padding:30rpx 0;
background:#f6f6f6;
min-height:100%;
.card{
padding-bottom:100rpx;
input{
background:#F7F7F7;
height:80rpx;
border-radius: 24rpx;
font-size:25rpx;
padding:0 28rpx;
&+input{
margin-top:28rpx;
}
}
}
}
</style>
<template>
<view class="container">
<d-navbar text="修改密码" isBack style="--bg:#10C176;--c:#fff;">
2 years ago
<button slot="right" class="cu-btn round" @click="submit">保存</button>
2 years ago
</d-navbar>
<view class="card">
2 years ago
<input placeholder="请输入旧密码" type="password" v-model="formData.oldpassword"/>
2 years ago
<input placeholder="请输入新密码(6-20位字母和数字的组合)" type="password" v-model="formData.password"/>
2 years ago
<input placeholder="再次输入新密码" type="password" v-model="formData.confirmpassword"/>
2 years ago
</view>
</view>
</template>
<script>
import request from '@/common/request'
export default{
data(){
return{
formData:{
2 years ago
confirmpassword: "",
2 years ago
password: "",
2 years ago
oldpassword:"",
2 years ago
username: this.$store.getters['userInfo'].username,
}
}
},
methods:{
check(){
2 years ago
if(!this.formData.oldpassword){
uni.showToast({title:"请输入旧密码!",icon:"none"})
return false
}else if(!this.formData.password){
2 years ago
uni.showToast({title:"请输入密码!",icon:"none"})
return false
}else if(!/^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{6,20}$/.test(this.formData.password)){
uni.showToast({title:"密码格式为6-20位字母和数字的组合!",icon:"none"})
return false
2 years ago
}else if(this.formData.confirmpassword!=this.formData.password){
2 years ago
uni.showToast({title:"输入密码不一致!",icon:"none"})
return false
}
return true
},
async submit(){
if(this.check()){
2 years ago
var res=await request("/sys/user/updatePassword",{
2 years ago
method:"put",
body: this.formData
})
if(res.statu){
uni.navigateBack()
}else{
uni.showModal({
title:"提示",
content:res.msg||"修改失败!",
showCancel:false,
})
}
}
},
}
}
</script>