setpaypwd.js 2.0 KB
// pages/main/rewardpoint/setpaypwd/setpaypwd.js
Page({

  /**
   * Page initial data
   */
  data: {
    verifyCode: "",
    verifyCodeTime: "获取验证码",
    buttonDisable: false
  },

  /**
   * Lifecycle function--Called when page load
   */
  onLoad: function (options) {

  },

  /**
   * Lifecycle function--Called when page is initially rendered
   */
  onReady: function () {

  },

  /**
   * Lifecycle function--Called when page show
   */
  onShow: function () {

  },

  // 获取验证码
  getVerifyCode:function(){
    var timelength = 60

    var intervalId = setInterval(function () {
      timelength = timelength - 1;
      that.setData({
        verifyCodeTime: timelength + 's后重发',
        buttonDisable: true
      })
      if (timelength == 0) {
        clearInterval(intervalId);
        that.setData({
          verifyCodeTime: '获取验证码',
          buttonDisable: false
        })
      }
    }, 1000);
    that.requestCode();
  },

  requestCode:function(){
    var that = this;
    var Authorization = app.globalData.Authorization;
    wx.request({
      url: baseUrl + 'sms/v1/sms_codes',
      method: "POST",
      data: {
        // "mobile": mobile,
        // "type": "bindmobile",
        // "scope": "global_access:end_user"
      },
      header: {
        'content-type': 'application/json', // 默认值
        "Authorization": Authorization
      },
      success: function (res) {
        console.log(res.data)
      },
      fail(res) {
        console.log(res.data)
      }
    })
  },

  /**
   * Lifecycle function--Called when page hide
   */
  onHide: function () {

  },

  /**
   * Lifecycle function--Called when page unload
   */
  onUnload: function () {

  },

  /**
   * Page event handler function--Called when user drop down
   */
  onPullDownRefresh: function () {

  },

  /**
   * Called when page reach bottom
   */
  onReachBottom: function () {

  },

  /**
   * Called when user click on the top right corner to share
   */
  onShareAppMessage: function () {

  }
})