8 changed files with 268 additions and 3 deletions
@ -0,0 +1,123 @@ |
|||
var api = require('../../utils/api.js') |
|||
// pages/editPassword/editPassword.js
|
|||
Page({ |
|||
|
|||
/** |
|||
* 页面的初始数据 |
|||
*/ |
|||
data: { |
|||
form:{ |
|||
oldPassword:'', |
|||
newPassword:'', |
|||
checkPassword:'' |
|||
} |
|||
}, |
|||
|
|||
/** |
|||
* 生命周期函数--监听页面加载 |
|||
*/ |
|||
onLoad(options) { |
|||
|
|||
}, |
|||
|
|||
/** |
|||
* 生命周期函数--监听页面初次渲染完成 |
|||
*/ |
|||
onReady() { |
|||
|
|||
}, |
|||
|
|||
/** |
|||
* 生命周期函数--监听页面显示 |
|||
*/ |
|||
onShow() { |
|||
|
|||
}, |
|||
|
|||
/** |
|||
* 生命周期函数--监听页面隐藏 |
|||
*/ |
|||
onHide() { |
|||
|
|||
}, |
|||
|
|||
/** |
|||
* 生命周期函数--监听页面卸载 |
|||
*/ |
|||
onUnload() { |
|||
|
|||
}, |
|||
|
|||
/** |
|||
* 页面相关事件处理函数--监听用户下拉动作 |
|||
*/ |
|||
onPullDownRefresh() { |
|||
|
|||
}, |
|||
|
|||
/** |
|||
* 页面上拉触底事件的处理函数 |
|||
*/ |
|||
onReachBottom() { |
|||
|
|||
}, |
|||
|
|||
/** |
|||
* 用户点击右上角分享 |
|||
*/ |
|||
onShareAppMessage() { |
|||
|
|||
}, |
|||
bindOldPassword(e){ |
|||
this.setData({ |
|||
'form.oldPassword':e.detail.value |
|||
}) |
|||
console.log(this.data.form); |
|||
}, |
|||
bindNewPassword(e){ |
|||
this.setData({ |
|||
'form.newPassword':e.detail.value |
|||
}) |
|||
}, |
|||
bindCheckPassword(e){ |
|||
this.setData({ |
|||
'form.checkPassword':e.detail.value |
|||
}) |
|||
}, |
|||
submit(){ |
|||
if(!this.data.form.oldPassword){ |
|||
wx.showToast({ |
|||
title: '请输入原密码', |
|||
icon:'none' |
|||
}) |
|||
return false |
|||
} |
|||
if(!this.data.form.newPassword){ |
|||
wx.showToast({ |
|||
title: '请输入新密码', |
|||
icon:'none' |
|||
}) |
|||
return false |
|||
} |
|||
if(this.data.form.checkPassword != this.data.form.newPassword){ |
|||
wx.showToast({ |
|||
title: '两次密码不一致', |
|||
icon:'none' |
|||
}) |
|||
return false |
|||
} |
|||
delete this.data.form.checkPassword |
|||
api.editPassword(this.data.form).then(res=>{ |
|||
if(res.code === 0){ |
|||
wx.removeStorage({ |
|||
key: 'token', |
|||
}) |
|||
wx.reLaunch({ |
|||
url: '/pages/login/login', |
|||
}) |
|||
} |
|||
}).catch(err=>{ |
|||
console.log(err); |
|||
}) |
|||
} |
|||
}) |
@ -0,0 +1,4 @@ |
|||
{ |
|||
"usingComponents": {}, |
|||
"navigationBarTitleText": "修改密码" |
|||
} |
@ -0,0 +1,43 @@ |
|||
<view class="container"> |
|||
<view class="basic-info"> |
|||
<view class="list-item "> |
|||
<view class="left"> |
|||
<text class="must">*</text> |
|||
<view class="title">原密码</view> |
|||
</view> |
|||
<view class="right" readonly> |
|||
<input confirm-type="next" |
|||
password |
|||
bindblur="bindOldPassword" bindinput="bindOldPassword" value="{{form.oldPassword}}" placeholder-class="placeholder-style" placeholder="请输入" /> |
|||
</view> |
|||
</view> |
|||
<view class="list-item "> |
|||
<view class="left"> |
|||
<text class="must">*</text> |
|||
<view class="title">新密码</view> |
|||
</view> |
|||
<view class="right"> |
|||
<input confirm-type="next" bindblur="bindNewPassword" |
|||
password |
|||
bindinput="bindNewPassword" value="{{form.newPassword}}" placeholder-class="placeholder-style" placeholder="请输入" /> |
|||
</view> |
|||
</view> |
|||
<view class="list-item "> |
|||
<view class="left"> |
|||
<text class="must">*</text> |
|||
<view class="title">确认密码</view> |
|||
</view> |
|||
<view class="right"> |
|||
<input confirm-type="next" bindblur="bindCheckPassword" |
|||
password |
|||
bindinput="bindCheckPassword" value="{{form.checkPassword}}" placeholder-class="placeholder-style" placeholder="请输入" /> |
|||
</view> |
|||
</view> |
|||
</view> |
|||
<view class="buttons fixed"> |
|||
|
|||
<button hover-class="hover-class" class="btn2" bindtap="submit">确定</button> |
|||
<!-- <button hover-class="hover-class" class="btn2" open-type="getUserInfo" bindgetuserinfo="bindGetUserInfo">进入首页</button> --> |
|||
</view> |
|||
</view> |
|||
|
@ -0,0 +1,75 @@ |
|||
|
|||
.container{ |
|||
height: calc(100vh - 100rpx); |
|||
overflow-y: scroll ; |
|||
overflow-x: hidden; |
|||
} |
|||
/* .gray{ |
|||
background-color: #fafafa; |
|||
} */ |
|||
.gray-font{ |
|||
color:#808080 ; |
|||
} |
|||
.basic-info { |
|||
width: 95%; |
|||
background: #fff; |
|||
border-radius: 16rpx; |
|||
box-sizing: border-box; |
|||
padding: 0 20rpx; |
|||
margin: 20rpx auto; |
|||
|
|||
} |
|||
.basic-info:nth-child(eveb){ |
|||
background-color: #fafafa !important; |
|||
} |
|||
.basic-info .list-item { |
|||
width: 100%; |
|||
height: 100rpx; |
|||
display: flex; |
|||
align-items: center; |
|||
justify-content: space-between; |
|||
} |
|||
.basic-info .list-item .left .must { |
|||
color: #F61616; |
|||
font-size: 30rpx; |
|||
} |
|||
.basic-info .list-item .left .title { |
|||
color: #3333338a; |
|||
font-size: 34rpx; |
|||
} |
|||
.basic-info .list-item .left { |
|||
display: flex; |
|||
align-items: center; |
|||
height: 100rpx; |
|||
} |
|||
.basic-info .list-item .right { |
|||
height: 100%; |
|||
display: flex; |
|||
align-items: center; |
|||
justify-content: flex-end; |
|||
flex: 1; |
|||
} |
|||
|
|||
.basic-info .list-item .right input{ |
|||
text-align: right; |
|||
} |
|||
.fixed{ |
|||
position: fixed; |
|||
bottom: 20rpx; |
|||
} |
|||
.buttons .btn2 { |
|||
background: linear-gradient(to right, #f51212, #ff4c4c); |
|||
height:84rpx; |
|||
line-height: 84rpx; |
|||
text-align:center; |
|||
color: #fff; |
|||
font-size: 36rpx; |
|||
border-radius: 16rpx; |
|||
padding: 0; |
|||
margin: 0; |
|||
outline: 0; |
|||
font-weight: normal; |
|||
} |
|||
.buttons .hover-class { |
|||
background:red; |
|||
} |
Loading…
Reference in new issue