diff --git a/pages/user/Change_phone/Change_phone.js b/pages/user/Change_phone/Change_phone.js
index 2ab1acd..8882266 100644
--- a/pages/user/Change_phone/Change_phone.js
+++ b/pages/user/Change_phone/Change_phone.js
@@ -1,5 +1,5 @@
-
var a = getApp(),
+ o = a.globalData,
r = a.globalData.setting,
t = a.request,
s = require("../../../utils/common.js"),
@@ -11,68 +11,203 @@ Page({
*/
data: {
iurl: r.imghost,
- inputxphone:false,
- phone:0,
+ inputxphone: 0,
+ mobile: 17359580658, //旧手机号码
+ currentTime: "", //验证码发送倒计时
+ getvcode: "获取验证码",
+ wxopenid: "2",
+ isver: 0, //是否有发送验证码
+ code: "", //验证码
+ url: "", //确认更换手机号码跳转路径
+ change_phone: "", //新手机号码
},
/**
* 生命周期函数--监听页面加载
*/
- onLoad: function (options) {
- this.setData({
- phone: options.mobile
+ onLoad: function(options) {
+ this.setData({
+ // mobile: options.mobile,
+ //wxOpneId: options.openid
+ })
+ },
+ //获取手机验证码
+ Ver_phone: function() {
+ var th = this;
+ var mobile = th.data.mobile;
+ var wxopenid = th.data.wxopenid;
+ var change_phone = th.data.change_phone;
+ var isver = th.data.isver;
+ console.log("iiiiiiiiiiiiii" + change_phone + mobile);
+ var myreg = /^(((13[0-9]{1})|(15[0-9]{1})|(18[0-9]{1})|(17[0-9]{1}))+\d{8})$/;
+ if (mobile.length < 11) {
+ getApp().my_warnning("请输入11位的手机号码", 0, th);
+ } else if (!myreg.test(mobile)) {
+ getApp().my_warnning("手机号有误", 0, th);
+ return false;
+ }
+ if (change_phone == mobile) {
+ getApp().my_warnning("新手机号码和旧手机号码不能一样", 0, th);
+ return false;
+ }
+ if (change_phone != "") {
+ mobile = change_phone;
+ }
+ if (isver == 0) {
+ th.setData({
+ isver: 1
+ })
+ } else {
+ return false
+ }
+ getApp().request.post("/api/weshop/smslog/sendsms", {
+ data: {
+ store_id: r.stoid,
+ scene: 1, //发送类型(1短信 2语音)
+ mobile: mobile,
+ wxopenid: wxopenid
+ },
+ success: function(res) {
+ if (res.data.code == 0) {
+ th.setData({
+ isver: 0,
+ getvcode: 60,
+ currentTime: setInterval(th.gettime, 1000),
+ })
+ } else {
+ getApp().my_warnning(res.data.msg, 0, th);
+ th.setData({
+ isver: 0,
+ getvcode: "重新获取"
+ })
+ return false;
+ }
+ }
+ })
+
+ },
+ gettime: function() {
+ var that = this;
+ if (that.data.getvcode == 1) {
+ //清除js定时器
+ clearInterval(that.data.currentTime);
+ that.setData({
+ getvcode: "重新获取",
+ });
+ } else {
+ that.setData({
+ getvcode: --that.data.getvcode,
+ });
+ }
+ },
+ change_phone: function() {
+ var th = this;
+ var code = th.data.code;
+ var mobile = th.data.mobile;
+ if (th.ver_code() == false) return false;
+ getApp().request.put("/api/weshop/users/updateMobile/" + r.stoid + '/' + o.user_id + '/' + code + '/' + mobile, {
+ success: function(res) {
+ if (res.data.code == 0) {
+ getApp().my_warnning("更换成功", 0, th);
+ // th.setData({
+ // url: "/pages/user/userinfo/userinfo?change_phone" + change_phone
+ // })
+ } else {
+ getApp().my_warnning("更换失败", 0, th);
+ return false;
+ }
+ }
+ })
+
+ },
+ //判断验证码是否正确
+ ver_code: function(e) {
+ var th = this;
+ var code = th.data.code,
+ mobile = th.data.mobile,
+ wxopenid = th.data.wxopenid,
+ getvcode = th.data.getvcode,
+ chang_phone = th.data.change_phone;
+ if (code.length < 3 && code == "") {
+ getApp().my_warnning("请输入正确的验证码", 0, th);
+ return false;
+ } else if (getvcode.length<3){
+ getApp().my_warnning("验证超时", 0, th);
+ return false;
+ }else {
+ getApp().request.put("/api/weshop/users/updateMobileFirst/" + r.stoid + '/' + o.user_id + '/' + code, {
+ success: function(res) {
+ if (res.data.code == 0) {
+ th.setData({
+ inputxphone: 1,
+ getvcode: "获取验证码",
+ code: ""
+ })
+ clearInterval(th.data.currentTime);
+ } else {
+ getApp().my_warnning(res.data.msg, 0, th);
+ return false;
+ }
+ }
})
+ }
},
- go: function (e) {
+ getCodeValue: function(e) {
this.setData({
- inputxphone: true
+ code: e.detail.value
+ })
+ },
+ getphoneValue: function(e) {
+ var th = this;
+ th.setData({
+ change_phone: e.detail.value,
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
- onReady: function () {
+ onReady: function() {
},
/**
* 生命周期函数--监听页面显示
*/
- onShow: function () {
+ onShow: function() {
},
/**
* 生命周期函数--监听页面隐藏
*/
- onHide: function () {
+ onHide: function() {
},
/**
* 生命周期函数--监听页面卸载
*/
- onUnload: function () {
+ onUnload: function() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
- onPullDownRefresh: function () {
+ onPullDownRefresh: function() {
},
/**
* 页面上拉触底事件的处理函数
*/
- onReachBottom: function () {
+ onReachBottom: function() {
},
/**
* 用户点击右上角分享
*/
- onShareAppMessage: function () {
+ onShareAppMessage: function() {
}
})
\ No newline at end of file
diff --git a/pages/user/Change_phone/Change_phone.json b/pages/user/Change_phone/Change_phone.json
index 501ef05..8003812 100644
--- a/pages/user/Change_phone/Change_phone.json
+++ b/pages/user/Change_phone/Change_phone.json
@@ -1,4 +1,6 @@
{
"navigationBarTitleText": "更换手机",
- "usingComponents": {}
+"usingComponents": {
+ "warn": "/components/long_warn/long_warn"
+}
}
\ No newline at end of file
diff --git a/pages/user/Change_phone/Change_phone.wxml b/pages/user/Change_phone/Change_phone.wxml
index 12aaeb9..96da9ff 100644
--- a/pages/user/Change_phone/Change_phone.wxml
+++ b/pages/user/Change_phone/Change_phone.wxml
@@ -8,20 +8,25 @@
-
- {{phone}}
+
+ {{mobile}}
-
+
-
+
- 获取验证码
+
+ {{getvcode}}
+
+
+ {{getvcode}}s
+
@@ -37,16 +42,19 @@
-
-
-
- 下一步
-
-
- 确定更换
-
-
+
+
+
+ 下一步
+
+
+
+
+ 确定更换
+
+
-
\ No newline at end of file
+
+
\ No newline at end of file