Commit cf3c25d8d49570b121718cf5f46b684ef3e12164

Authored by 后端研发-倪永富
1 parent 3ae5a2e5

小程序更改新手机,去掉旧手机验证码

pages/user/Change_phone/Change_phone.js
@@ -11,7 +11,7 @@ Page({ @@ -11,7 +11,7 @@ Page({
11 */ 11 */
12 data: { 12 data: {
13 iurl: r.imghost, 13 iurl: r.imghost,
14 - inputxphone: 0, 14 + inputxphone: 1,
15 mobile: null, //旧手机号码 15 mobile: null, //旧手机号码
16 currentTime: "", //验证码发送倒计时 16 currentTime: "", //验证码发送倒计时
17 getvcode: "获取验证码", //显示文字 17 getvcode: "获取验证码", //显示文字
@@ -53,12 +53,22 @@ Page({ @@ -53,12 +53,22 @@ Page({
53 var isver = th.data.isver; 53 var isver = th.data.isver;
54 var send = th.data.send; 54 var send = th.data.send;
55 var myreg = /^(((13[0-9]{1})|(15[0-9]{1})|(18[0-9]{1})|(17[0-9]{1}))+\d{8})$/; 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 if (change_phone == mobile) { 72 if (change_phone == mobile) {
63 getApp().my_warnning("新手机号码和旧手机号码不能一样", 0, th); 73 getApp().my_warnning("新手机号码和旧手机号码不能一样", 0, th);
64 return false; 74 return false;
@@ -122,6 +132,12 @@ Page({ @@ -122,6 +132,12 @@ Page({
122 if (change_phone.length > 1) { 132 if (change_phone.length > 1) {
123 mobile = change_phone 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 getApp().request.put("/api/weshop/users/updateMobile/" + r.stoid + '/' + o.user_id + '/' + code + '/' + mobile, { 141 getApp().request.put("/api/weshop/users/updateMobile/" + r.stoid + '/' + o.user_id + '/' + code + '/' + mobile, {
126 success: function(res) { 142 success: function(res) {
127 if (res.data.code == 0) { 143 if (res.data.code == 0) {
@@ -230,4 +246,4 @@ Page({ @@ -230,4 +246,4 @@ Page({
230 onShareAppMessage: function() { 246 onShareAppMessage: function() {
231 247
232 } 248 }
233 -})  
234 \ No newline at end of file 249 \ No newline at end of file
  250 +})