wszhyWx/pages/change_password/change_password.vue

139 lines
3.4 KiB
Vue

<template>
<view class="change_password">
<u-navbar :background="background" :is-back='true' back-icon-color='#FFFFFF' :border-bottom="false" title="修改密码"
title-color='#FFFFFF' :title-bold='true' title-size='32'></u-navbar>
<view class="content">
<view class="change_psw">
<u-field v-model="oldPassword" label="原密码" required :error-message="errorMessage1" placeholder="请输入原始密码"
:password='true' :clearable='false' label-width='163' input-align='right'
placeholder-style='color:#CCCCCC'>
</u-field>
<u-field v-model="newPassword" label="新密码" required :error-message="errorMessage2" placeholder="请输入新密码"
:password='true' :clearable='false' label-width='163' input-align='right'
placeholder-style='color:#CCCCCC'>
</u-field>
<u-field v-model="confirmNewPassword" label="确认新密码" required :error-message="errorMessage3"
placeholder="请再次输入新密码" :password='true' :clearable='false' label-width='163' input-align='right'
placeholder-style='color:#CCCCCC'>
</u-field>
</view>
<view class="submit" @click="submit_pwd">
</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
// 头部导航背景
background: {
backgroundColor: '#24B383',
},
oldPassword: '',
newPassword: '',
confirmNewPassword: '',
errorMessage1: '',
errorMessage2: '',
errorMessage3: '',
userid:''
};
},
onLoad(option) {
if(option.userid){
this.userid = option.userid
console.log(this.userid);
}
},
methods: {
// 密码提交
submit_pwd() {
if(this.oldPassword == '' || this.newPassword == '' || this.confirmNewPassword == ''){
uni.showToast({
icon: 'error',
title: '请输入密码!',
duration: 2000
})
}
if (this.newPassword != this.confirmNewPassword) {
uni.showToast({
icon: 'error',
title: '请输入新密码!',
duration: 2000
})
}
if (this.newPassword == this.confirmNewPassword) {
console.log(this.userid,this.oldPassword,this.newPassword);
this.$http({
url: this.api.user_update_pwd,
method: 'put',
data: {
"id": this.userid,
"oldPassword": this.oldPassword,
"password": this.newPassword
}
}).then(res=>{
console.log(res);
if(res.code == 200){
uni.showToast({
icon: 'success',
title: '修改密码成功!',
duration: 2000
})
uni.switchTab({
url:'/pages/userCenter/userCenter'
})
}
})
}
}
}
}
</script>
<style lang="scss" scoped>
.change_password {
width: 100%;
min-height: 100vh;
background-color: #F5F6FA;
.content {
box-sizing: border-box;
padding: 30rpx;
.change_psw {
width: 690rpx;
// height: 303rpx;
background: #FFFFFF;
box-shadow: 0rpx 4rpx 20rpx 0rpx rgba(153, 153, 153, 0.1);
border-radius: 20rpx;
box-sizing: border-box;
padding-left: 30rpx;
}
.submit {
width: 660rpx;
height: 110rpx;
background: linear-gradient(0deg, #57CFA6, #25B383);
box-shadow: 0rpx 3rpx 15rpx 0rpx rgba(36, 179, 131, 0.35);
border-radius: 15rpx;
font-size: 38rpx;
font-family: PingFang SC;
font-weight: bold;
color: #FFFFFF;
position: fixed;
bottom: 80rpx;
left: 45rpx;
text-align: center;
line-height: 110rpx;
}
}
}
</style>