revisePwd.vue
5.33 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
191
192
<template>
<view>
<view class="setting-content">
<!--<uni-list>-->
<!--<uni-list-item title="关于我们" clickable @click="toAboutOur" showArrow></uni-list-item>-->
<!--<uni-list-item title="修改登录密码" clickable @click="toAboutOur" showArrow></uni-list-item>-->
<!--<uni-list-item title="清除缓存" clickable @click="cleanStorage" ></uni-list-item>-->
<!--</uni-list>-->
<uni-section title="修改登录密码" type="line">
<view class="example" style="padding: 0 15px;">
<!-- 基础表单校验 -->
<uni-forms ref="valiForm" :rules="rules" :modelValue="valiFormData" label-width="100">
<uni-forms-item label="原登录密码" required name="oldPwd">
<uni-easyinput v-model="valiFormData.oldPwd" placeholder="请输入原登录密码"/>
</uni-forms-item>
<uni-forms-item label="新登录密码" required name="newPwd">
<uni-easyinput v-model="valiFormData.newPwd" placeholder="请输入新登录密码"/>
</uni-forms-item>
<uni-forms-item label="新登录密码" required name="newPwdAga">
<uni-easyinput v-model="valiFormData.newPwdAga" placeholder="请再次输入新登录密码"/>
</uni-forms-item>
</uni-forms>
</view>
</uni-section>
<view class="uni-padding-wrap uni-common-mt">
<button type="warn" @click="submit('valiForm')">确定修改</button>
</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
// 校验表单数据
valiFormData: {
oldPwd: '',
newPwd: '',
newPwdAga: '',
},
// 校验规则
rules: {
oldPwd: {
rules: [{
required: true,
errorMessage: '原密码不能为空'
}, {
minLength: 6,
errorMessage: '请输入大于六位数',
}
]
},
newPwd: {
rules: [{
required: true,
errorMessage: '新密码不能为空'
}, {
minLength: 6,
errorMessage: '请输入大于六位数',
}
]
},
newPwdAga: {
rules: [{
required: true,
errorMessage: '新密码不能为空'
}, {
minLength: 6,
errorMessage: '请输入大于六位数',
}
]
}
},
}
},
methods: {
submit(ref) {
let that = this;
this.$refs[ref].validate().then(res => {
if(this.valiFormData.newPwd !== this.valiFormData.newPwdAga){
uni.showToast({
icon:'none',
title: `两次输入的新密码不一样`
})
return
}
// uni.getStorageSync("indexInfo").userName
let changePassword = this.$common.changePassword;
let jsondata = {
userCode: uni.getStorageSync("indexInfo").userCode,
oldPassWord: this.valiFormData.oldPwd,
newPassWord: this.valiFormData.newPwdAga,
};
uni.request({
url: changePassword,
data: JSON.stringify(this.$common.requestSign(jsondata)),
dataType: "json",
method: "POST",
success: (res) => {
console.log(res)
if (res.data.code == 0) {
uni.showToast({
icon:'none',
title: `修改成功`
})
that.loginOut();
}else{
uni.showToast({
icon:'none',
title: res.data.message
})
}
}
})
}).catch(err => {
console.log('err', err);
})
},
toAboutOur() {
uni.navigateTo({
url: '../aboutOur/aboutOur'
});
},
cleanStorage() {
uni.clearStorageSync();
uni.showToast({
title: "清理缓存成功",
mask: false,
duration: 2000
})
},
loginOutAlert() {
let that = this;
uni.showModal({
title: '提示',
content: '是否确定退出登录?',
success: (res) => {
if (res.confirm) {
that.loginOut();
} else if (res.cancel) {
console.log('用户点击取消')
}
}
})
},
loginOut() {
let that = this;
that.$myRequest({
url: that.$common.userLoginout,
method: 'POST',
data: that.$common.requestSign()
}).then(res => {
// 获取真实数据之前,务必判断状态是否为200
console.log('退出:' + JSON.stringify(res));
if (res.code == 0) {
uni.clearStorageSync();
uni.reLaunch({
url: "../index/index"
})
uni.hideLoading();
} else {
uni.clearStorageSync();
uni.reLaunch({
url: "../index/index"
})
uni.hideLoading();
}
})
}
}
}
</script>
<style lang="scss">
.setting-content {
background-color: #f6f6f6;
height: 100vh;
}
</style>