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
<template>
<div class="edit-psd-conatiner">
<Header title="修改密码" />
<div class="edit-container">
<van-form @submit="onSubmit">
<div class="input-box">
<van-field
label="当前账号"
readonly
v-model="form.username"
placeholder="请输入当前账号"
input-align="right"
/>
<van-field
label="当前密码"
type="password"
v-model="form.oldPassWord"
placeholder="请输入当前密码"
input-align="right"
:rules="[
{ required: true }
]"
/>
<van-field
label="新密码"
type="password"
v-model="form.password"
placeholder="请输入新密码"
input-align="right"
:rules="[
{ required: true },
{ pattern: /(?=.*([a-zA-Z].*))(?=.*[0-9].*)[a-zA-Z0-9-_@*]{8}$/, message: '密码至少包括数字和字母,可以有-_@特殊字符,长度8位'}
]"
/>
<van-field
label="再次输入新密码"
type="password"
v-model="form.againPsd"
placeholder="请再次输入新密码"
input-align="right"
:rules="[
{ required: true }
]"
/>
</div>
<div class="admin-detail-button">
<van-button type="default" native-type="submit">提交</van-button>
</div>
</van-form>
</div>
<my-tabbar active="3"></my-tabbar>
</div>
</template>
<script>
import util from "@/utils/index.js";
import Header from "@/components/Header/index.vue";
export default {
components: { Header },
data() {
return {
form: {
username: JSON.parse(sessionStorage.getItem("userInfo")).userName,
},
};
},
mounted() {
// 查询管理员信息
},
methods: {
// 提交数据
onSubmit() {
if (this.form.password !== this.form.againPsd) {
this.$toast("两次输入的密码不一致");
return false;
}
let vm = this;
let param = {
password: util.encrypt(this.form.password),
oldPassWord: util.encrypt(this.form.oldPassWord),
};
vm.$https(
{
url: "tUser/editPwd",
method: "put",
authType: this.backToken,
},
vm.$qs.stringify(param)
)
.then((res) => {
if (res.data.resultCode === "200") {
sessionStorage.removeItem("token");
sessionStorage.removeItem("userInfo");
this.$router.replace({
path: "/success",
query: {
txt: "密码已修改,请用新密码重新登录系统",
url: "/login",
},
});
} else {
this.$toast(res.data.message);
}
})
.catch(function (err) {
console.log(err);
});
},
},
};
</script>
<style lang="scss" scoped>
.edit-psd-conatiner {
width: 100%;
height: 100vh;
padding: 50px 24px 60px;
display: flex;
flex-direction: column;
box-sizing: border-box;
.input-box {
padding-bottom: 32px;
.van-cell {
line-height: 40px;
padding-left: 0;
padding-right: 0;
border-bottom: 1px solid #eee;
}
.van-cell:after {
display: none;
}
}
.admin-detail-button {
padding: 0 24px;
box-sizing: border-box;
width: 100%;
margin: 0 auto;
text-align: center;
.van-button--normal {
background: #a4151d;
border-radius: 4px;
height: 40px;
width: 100%;
color: #fff;
border: none;
font-size: 16px;
&:first-child {
margin-right: 5%;
}
}
.van-button--plain {
background: rgba(164, 21, 29, 0.1);
border: 1px solid #b40011;
border-radius: 4px;
color: #b40011;
}
}
::v-deep .van-field__label {
width: 7.2em;
}
.van-field__control,
.van-cell__value {
color: #333;
}
}
</style>