updatePass.vue
2.4 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
<template>
<view class="content">
<view style="padding-top: 16px;">
<view class="inputC">
<input type="text" value="" placeholder="当前密码" @input="oldPassInput" password="true" />
</view>
<view class="inputC">
<input type="text" value="" placeholder="新密码" @input="newPassInput" password="true" />
</view>
<view class="inputC">
<input type="text" value="" placeholder="确认密码" @input="confrimPassInput" password="true" />
</view>
</view>
<view style="margin: 90px 16px;" @click="saves">
<view class="saveBox"><text class="save">保存</text></view>
</view>
</view>
</template>
<script>
import request from '../../utils/request.js'
export default {
data() {
return {
oldPass: '',
newPass: '',
confrim: '',
}
},
methods: {
oldPassInput(e) {
this.oldPass = e.detail.value
},
newPassInput(e) {
this.newPass = e.detail.value
},
confrimPassInput(e) {
this.confrim = e.detail.value
},
saves() {
if (this.oldPass == '') {
uni.showToast({
title: '请输入原始密码',
icon: 'none'
})
} else if (this.newPass == '') {
uni.showToast({
title: '请输入新密码',
icon: 'none'
})
} else if (this.confrim == '') {
uni.showToast({
title: '请确认新密码',
icon: 'none'
})
} else if (this.newPass != this.confrim) {
uni.showToast({
title: '密码不一致',
icon: 'none'
})
} else {
request.post('/api/index/save_pass', {
password1: this.oldPass,
password2: this.newPass,
password3: this.confrim,
}).then(res => {
if (res.code == 1) {
uni.showToast({
title: '修改成功',
icon: 'none'
})
setTimeout(() => {
uni.redirectTo({
url: '/pages/index/me'
})
}, 1000)
} else {
uni.showToast({
title: err.msg,
icon: 'none'
})
}
}).catch(err => {
})
}
}
}
}
</script>
<style>
.inputC {
background: #ffffff;
height: 46px;
display: flex;
align-items: center;
margin-bottom: 16px;
padding: 0 16px;
}
.saveBox {
background: #4674c9;
border-radius: 8rpx;
height: 96rpx;
display: flex;
align-items: center;
justify-content: center;
}
.save {
color: #FFFFFF;
font-size: 32rpx;
}
.content {
background-color: #F2F3F5;
height: 100vh;
}
</style>