Commit cf3c25d8d49570b121718cf5f46b684ef3e12164
1 parent
3ae5a2e5
小程序更改新手机,去掉旧手机验证码
Showing
1 changed file
with
23 additions
and
7 deletions
pages/user/Change_phone/Change_phone.js
| ... | ... | @@ -11,7 +11,7 @@ Page({ | 
| 11 | 11 | */ | 
| 12 | 12 | data: { | 
| 13 | 13 | iurl: r.imghost, | 
| 14 | - inputxphone: 0, | |
| 14 | + inputxphone: 1, | |
| 15 | 15 | mobile: null, //旧手机号码 | 
| 16 | 16 | currentTime: "", //验证码发送倒计时 | 
| 17 | 17 | getvcode: "获取验证码", //显示文字 | 
| ... | ... | @@ -53,12 +53,22 @@ Page({ | 
| 53 | 53 | var isver = th.data.isver; | 
| 54 | 54 | var send = th.data.send; | 
| 55 | 55 | var myreg = /^(((13[0-9]{1})|(15[0-9]{1})|(18[0-9]{1})|(17[0-9]{1}))+\d{8})$/; | 
| 56 | - if (mobile.length < 11) { | |
| 57 | - getApp().my_warnning("请输入11位的手机号码", 0, th); | |
| 58 | - } else if (!myreg.test(mobile)) { | |
| 59 | - getApp().my_warnning("手机号有误", 0, th); | |
| 60 | - return false; | |
| 56 | + if(change_phone){ | |
| 57 | + if (change_phone.length < 11) { | |
| 58 | + getApp().my_warnning("请输入11位的手机号码", 0, th); | |
| 59 | + } else if (!myreg.test(change_phone)) { | |
| 60 | + getApp().my_warnning("手机号有误", 0, th); | |
| 61 | + return false; | |
| 62 | + } | |
| 63 | + }else{ | |
| 64 | + if (mobile.length < 11) { | |
| 65 | + getApp().my_warnning("请输入11位的手机号码", 0, th); | |
| 66 | + } else if (!myreg.test(mobile)) { | |
| 67 | + getApp().my_warnning("手机号有误", 0, th); | |
| 68 | + return false; | |
| 69 | + } | |
| 61 | 70 | } | 
| 71 | + | |
| 62 | 72 | if (change_phone == mobile) { | 
| 63 | 73 | getApp().my_warnning("新手机号码和旧手机号码不能一样", 0, th); | 
| 64 | 74 | return false; | 
| ... | ... | @@ -122,6 +132,12 @@ Page({ | 
| 122 | 132 | if (change_phone.length > 1) { | 
| 123 | 133 | mobile = change_phone | 
| 124 | 134 | } | 
| 135 | + if(!change_phone){ | |
| 136 | + return getApp().my_warnning("请输入手机号", 0, th); | |
| 137 | + } | |
| 138 | + if(!code){ | |
| 139 | + return getApp().my_warnning("请输入验证码", 0, th); | |
| 140 | + } | |
| 125 | 141 | getApp().request.put("/api/weshop/users/updateMobile/" + r.stoid + '/' + o.user_id + '/' + code + '/' + mobile, { | 
| 126 | 142 | success: function(res) { | 
| 127 | 143 | if (res.data.code == 0) { | 
| ... | ... | @@ -230,4 +246,4 @@ Page({ | 
| 230 | 246 | onShareAppMessage: function() { | 
| 231 | 247 | |
| 232 | 248 | } | 
| 233 | -}) | |
| 234 | 249 | \ No newline at end of file | 
| 250 | +}) | ... | ... | 
