changePwd.vue
5.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
<template>
<view>
<view class="lz-status_bar" :style="{ height: menuButtonInfo + 'px' }">
<view class="lz-top_view"></view>
</view>
<!--#ifdef MP-WEIXIN-->
<view class="index-head">
<view class="index-head-top">
<view class="index-head-l" @tap="$navigateBack">
<view class="iconfont icon-youjiantou"></view>
</view>
<view class="index-head-m">修改密码</view>
</view>
</view>
<!--#endif-->
<view class="login-content">
<view class="login">
<!--#ifdef H5-->
<view class="login-title">修改密码</view>
<!--#endif-->
<view class="input-group">
<view class="input-row border input-flex">
<input type="text" focus clearable v-model="oldpassword" placeholder="请输入原始密码"
style="width: auto">
</view>
<view class="input-row border"><input type="text" displayable v-model="newpassword"
placeholder="请输入新密码"></view>
<view class="input-row"><input type="text" displayable v-model="newpassword_check"
placeholder="请再次确认新密码"></view>
</view>
<view class="login-button">
<button type="primary" class="primary" @tap="submit()">提交</button>
</view>
</view>
</view>
</view>
</template>
<script>
import {mapState} from 'vuex'
export default {
data() {
return {
oldpassword: '',
newpassword: '',
newpassword_check: '',
}
},
computed: {
...mapState(['userInfo', 'loginStatus', 'loginInfo',"menuButtonInfo"]),
},
onLoad(ops) {
},
onShow() {
if (this.userInfo.token == undefined) {
this.loginOut();
}
},
methods: {
loginOut() {
this.$lib.$store.commit('clearUserInfo')
uni.reLaunch({
url: '/pages/login/index'
})
},
async submit() {
if (this.newpassword != this.newpassword_check) {
uni.showModal({
title: '提示',
content: '两次输入的密码不一致',
success: function (res) {
if (res.confirm) {
console.log('用户点击确定');
} else if (res.cancel) {
console.log('用户点击取消');
}
}
});
return
}
let res = await this.$lib.$http.post({
url: this.$lib.$urlMap.resetpwd,
data: {
oldpassword: this.oldpassword,
newpassword: this.newpassword,
},
needLogin: true
})
if (res.code == 1) {
uni.showToast({
title: '修改成功',
icon: "success"
})
this.$lib.$store.commit('clearUserInfo')
setTimeout(function () {
uni.reLaunch({
url: "/pages/login/index"
})
}, 2000)
} else {
uni.showToast({
title: res.msg,
icon: "none"
});
}
},
}
}
</script>
<style>
input {
border: 1px solid #000000
}
.login-title {
color: #5d5d5d;
font-size: 22px;
padding: 20px 0 12px;
font-weight: bold;
}
.login-content {
width: 100%;
margin: 0 auto;
background: #fff;
}
.input-group::after,
.input-row.border::after {
left: 0 !important;
height: 1px !important;
background-color: #f6f7f9 !important;
}
.login {
margin: 0 20px;
}
.input-row {
display: flex;
flex-direction: row;
position: relative;
}
.input-row.border::after {
position: absolute;
right: 0;
bottom: 0;
left: 15 upx;
height: 1 upx;
content: '';
background-color: #c8c7cc;
}
.input-flex {
align-items: center;
justify-content: space-between
}
.input-row input {
border: none;
padding: 12px 0;
}
.input-group {
margin-top: 0;
}
.input-group::before {
background-color: #fff !important;
}
.primary {
background: #4d72ff !important;
box-shadow: 0 2px 11px rgb(0 56 216 / 15%);
color: #fff !important;
border-radius: 30px;
font-size: 18px;
padding: 2px;
}
.login-button {
margin-top: 7px;
}
.input-row uni-input {
padding: 16px 0;
}
</style>