changePhone.vue
5.0 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
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
<template>
<view>
<view class="topLine"></view>
<view class="phoneWrap">
<view class="phoneItem">
<view class="phoneLeft">
{{handleType == 'resetPwd' ? '手机号' : '绑定手机号'}}
</view>
<view class="phoneCenter">
<input type="text" v-model="param.mobile" placeholder="请输入手机号" placeholder-class="centerInp"/>
</view>
</view>
<view class="phoneItem">
<view class="phoneLeft">
验证码
</view>
<view class="phoneCenter">
<input type="text" v-model="param.captcha" placeholder="请输入验证码" placeholder-class="centerInp"/>
</view>
<view class="getCodeBtn" @click="getCode">
{{codeTxt}}
</view>
</view>
<!-- <view style="padding: 32rpx 0;" v-if="handleType == 'resetPwd'">
<wakary-input type="bottom" @finish="finish"></wakary-input>
</view> -->
</view>
<view class="bottomBtnWrap">
<view class="bottomBtn" @click="editPhone">
确定
</view>
</view>
</view>
</template>
<script>
import wakaryInput from '@/components/wakary-input.vue'
export default{
data(){
return{
userInfo:{},
handleType:'',
codeFlag:true,
codeTxt:"获取验证码",
param:{
type:'2',//重置支付密码-1=密码验证,2=手机验证
pwd:'',//重置支付密码-新密码
mobile:'',
event:'resetpaypwd',
captcha:''
}
}
},
components:{
wakaryInput
},
onReady() {
let navTitle
if(this.handleType == 'resetPwd'){
navTitle = '重置支付密码'
}else{
navTitle = '修改手机号'
}
uni.setNavigationBarTitle({
title:navTitle
})
},
onLoad(option) {
if(option.handleType != undefined){
this.handleType = option.handleType
}
//获取用户信息
this.$request('/user/info').then((res)=>{
this.userInfo = res.data
})
},
methods:{
editPhone(){
if(!this.check.telphone(this.param.mobile)){return;}
if(this.param.captcha == ''){
uni.showToast({
title:'请输入验证码',
icon:'none'
})
return
}
/* if(this.handleType == 'resetPwd' && this.param.pwd == ''){
uni.showToast({
title:'请输入新密码',
icon:'none'
})
return
} */
let url
let retMsg
if(this.handleType == 'resetPwd'){
if(this.userInfo.mobile != this.param.mobile){
uni.showToast({
title:'手机号不正确',
icon:'none'
})
return
}
url = '/sms/check'
retMsg = '验证手机号'
}else{
url = '/user/changemobile'
retMsg = '修改手机号'
}
this.$request(url,this.param).then((res)=>{
console.log(retMsg,res)
if(res.code == 1){
if(this.handleType == 'resetPwd'){
uni.navigateTo({
url:'confirmPayPassword?handleType=resetPwd&mobile='+this.param.mobile+'&captcha='+this.param.captcha
})
}else{
uni.navigateBack({
delta:1
})
setTimeout(()=>{
uni.showToast({
title:'修改成功'
})
},500)
}
}else{
uni.showToast({
title:res.msg,
icon:'none'
})
}
})
},
getCode(){
if(!this.check.telphone(this.param.mobile)){return;}
if(this.codeFlag==false){
return;
}
this.sendMessage()
},
sendMessage(){
uni.request({
url:this.apiUrl+"/sms/send",
method:"GET",
data:{
mobile:this.param.mobile,
event:this.handleType == 'resetPwd' ? 'resetpaypwd' : 'changemobile'
},
success: (res) => {
console.log('发送验证码',res)
if(res.data.code != 1){
uni.showToast({
title:res.data.msg,
icon:'none'
})
}else{
this.codeFlag=false;
var time = 60
this.codeTxt="重新获取"+time;
var timer=setInterval(()=>{
if(time==1){
this.codeTxt="获取验证码"
this.codeFlag=true
clearInterval(timer)
}else{
time--
this.codeTxt="重新获取"+time;
}
},1000)
}
}
})
},
finish(e){
this.param.pwd = e
},
}
}
</script>
<style lang="scss" scoped>
page{background: #f8f8f9;}
.topLine{height: 2rpx;background: rgba(25,24,51,0.06);}
.phoneWrap{
padding: 0 32rpx;
font-size: 28rpx;
background: #fff;
.phoneItem{
display: flex;
justify-content: space-between;
align-items: center;
height: 88rpx;
.phoneLeft{
width: 180rpx;
}
.phoneCenter{
flex: 1;
.centerInp{
font-size: 28rpx;
}
}
.getCodeBtn{
width: 174rpx;
height: 70rpx;
border: 1rpx solid #35655f;
border-radius: 11rpx;
text-align: center;
line-height: 70rpx;
color: #35655f;
}
}
}
.bottomBtnWrap{
position: fixed;
width: 100%;
height: 88rpx;
bottom: 0;
background: #fff;
display: flex;
align-items: center;
justify-content: center;
box-shadow: 0rpx -14rpx 44rpx 0rpx rgba(85,123,218,0.08);
.bottomBtn{
width: 680rpx;
height:75rpx;
background: #35655f;
text-align: center;
line-height: 75rpx;
color: #fff;
border-radius: 50rpx;
}
}
</style>