| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192 | 
							- var api = require('../../../config/api.js');
 
- var util = require('../../../utils/util.js');
 
- var app = getApp();
 
- Page({
 
-   /**
 
-    * 页面的初始数据
 
-    */
 
-   data: {
 
-     phone: '',
 
-     smscode: '',
 
-     second: '发送验证码',
 
-     disabled: false,
 
-     disabledUpdate: false
 
-   },
 
-   clearPhone(){
 
-     this.setData({
 
-       phone: ''
 
-     });
 
-   },
 
-   clearCode(){
 
-     this.setData({
 
-       smscode: ''
 
-     });
 
-   },
 
-   bindPhoneInput: function (e) {
 
-     this.setData({
 
-       phone: e.detail.value
 
-     });
 
-   },
 
-   bindSmscodeInput: function (e) {
 
-     this.setData({
 
-       smscode: e.detail.value
 
-     });
 
-   },
 
-   /**
 
-   * 用户领券
 
-   */
 
-   getCoupon: function () {
 
-     var that = this;
 
-     let regular = /^1[3|4|5|7|8]\d{9}$/;
 
-     if (!regular.test(that.data.phone)) {
 
-       util.showErrorToast('手机格式不正确')
 
-       return false;
 
-     }
 
-     if (that.data.smscode.length == 0) {
 
-       util.showErrorToast('验证码不能为空')
 
-       return false;
 
-     }
 
-     util.request(api.newUserCoupn, {
 
-       smscode: that.data.smscode,
 
-       phone: that.data.phone
 
-     }, 'POST').then(function (res) {
 
-       if (res.errno === 0) {
 
-         wx.showToast({
 
-           title: '手机号绑定成功'
 
-         });
 
-         wx.redirectTo({ url: '/pages/ucenter/coupon/coupon' });
 
-       } else if (res.errno === 1) {
 
-         util.showErrorToast(res.errmsg);
 
-         // wx.showModal({
 
-         //   title: '提示信息',
 
-         //   content: res.errmsg,
 
-         //   showCancel: false
 
-         // });
 
-       }
 
-     });
 
-   },
 
-   /**
 
-    * 发送短信
 
-    */
 
-   smscode: function () {
 
-     var that = this;
 
-     let regular = /^1[3|4|5|7|8]\d{9}$/;
 
-     if (!regular.test(that.data.phone)) {
 
-       util.showErrorToast('手机格式不正确')
 
-       return false;
 
-     }
 
-     util.request(api.smscodeSend, {
 
-       phone: that.data.phone
 
-     }, 'POST').then(function (res) {
 
-       let n = 59;
 
-       var timer = setInterval(function () {
 
-         if (n == 0) {
 
-           clearInterval(timer);
 
-           that.setData({
 
-             second: '发送验证码',
 
-             disabled: false
 
-           });
 
-         } else {
 
-           that.setData({
 
-             second: n-- +'s后重新获取',
 
-             disabled: true
 
-           });
 
-         }
 
-       }, 1000);
 
-       if (res.errno == 0) {
 
-         wx.showToast({
 
-           title: '短信发送成功'
 
-         })
 
-       } else{
 
-         util.showErrorToast('发送失败');
 
-         clearInterval(timer);
 
-         that.setData({
 
-           second: '发送验证码',
 
-           disabled: false
 
-         });
 
-         return false;
 
-       }
 
-     });
 
-   },
 
-   /**
 
-    * 生命周期函数--监听页面加载
 
-    */
 
-   onLoad: function (options) {
 
-     this.checkActivit();
 
-   },
 
-   /**
 
-    * 生命周期函数--监听页面初次渲染完成
 
-    */
 
-   onReady: function () {
 
-   },
 
-   /**
 
-    * 生命周期函数--监听页面显示
 
-    */
 
-   onShow: function () {
 
-   },
 
-   /**
 
-    * 生命周期函数--监听页面隐藏
 
-    */
 
-   onHide: function () {
 
-   },
 
-   /**
 
-    * 生命周期函数--监听页面卸载
 
-    */
 
-   onUnload: function () {
 
-   },
 
-   /**
 
-    * 页面相关事件处理函数--监听用户下拉动作
 
-    */
 
-   onPullDownRefresh: function () {
 
-   },
 
-   /**
 
-    * 页面上拉触底事件的处理函数
 
-    */
 
-   onReachBottom: function () {
 
-   },
 
-   /**
 
-    * 用户点击右上角分享
 
-    */
 
-   onShareAppMessage: function () {
 
-   },
 
-   checkActivit() {
 
-     let that = this;
 
-     util.request(api.checkActivit).then(function (res) {
 
-       if (res.errno === 2) {
 
-         wx.showModal({
 
-           title: '',
 
-           content: res.errmsg,
 
-           showCancel: false,
 
-           success: function (res) {
 
-             if (res.confirm) {
 
-               wx.switchTab({
 
-                 url: '/pages/index/index'
 
-               });
 
-             }
 
-           }
 
-         });
 
-         that.setData({
 
-           disabled: true,
 
-           disabledUpdate: true
 
-         });
 
-       }
 
-     });
 
-   }
 
- })
 
 
  |