审查视图

pages/forgetmima/forgetmima.js 4.0 KB
lihongjuan authored
1
// pages/forgetmima/forgetmima.js
lihongjuan authored
2
let interval = null;
lihongjuan authored
3 4 5 6 7 8 9 10 11 12
const app=getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    first:true,
    second:false,
    url:'',
lihongjuan authored
13 14 15 16 17 18 19 20
    phone:'',
    forgetshow:true,
    currentTime:60,
    time: '60秒后再次发送',
    disabled:false,
    yanzhengcode:'',
    newpassword:'',
    dengshow:false
lihongjuan authored
21 22 23 24 25 26 27 28 29
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.setData({
      url: app.globalData.url
    })
lihongjuan authored
30 31

   
lihongjuan authored
32 33 34 35 36 37
  },

  enterphone(e){
    this.setData({
      phone:e.detail.value
    })
lihongjuan authored
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195
    this.yanhzengphone()
    
  },

  yanhzengphone(){
    let value = this.data.phone
    if (value.length == 11) {
      this.setData({
        forgetshow: false
      })
    }else{
      this.setData({
        forgetshow: true
      })
    }
  },
  clearphone(){
    console.log(342)
    this.setData({
      phone:''
    })
  },

  next(){
    let reg = /^[1][3,4,5,6,7,8,9][0-9]{9}$/;
    if(!reg.test(this.data.phone)){
      wx.showToast({
        title: '请输入正确的手机号',
        icon:'none'
      })
    }else{
      this.setData({
        first:false,
        second:true
      })

      this.getcode()
    }

  },


  //获取验证码
  getcode() {
    let that = this;
    let currentTime = that.data.currentTime;
   
    that.setData({
      disabled: true
    })
    interval = setInterval(function () {
      currentTime--;
      that.setData({
        time: currentTime + 's后再次发送',

      })

      
      if (currentTime <= 0) {
        clearInterval(interval)
        that.setData({
          time: '60秒后再次发送',
          currentTime: 60,
          disabled: false
        })
      }
    }, 1000)


    var url = '/user/Profile/getCode';
    var params = {
      mobile: that.data.phone,

    }

    app.post(url, params).then((res) => {
      console.log(res);
      if (res.code) {

      }

    }).catch((err) => {
      console.log(err)
      wx.showToast({
        title: err.ResultMsg,
        icon: "none"
      })
    })
  },

  chongxin(){
    console.log(34378478)
    this.getcode();
  },

  yanzheng(){
    if (this.data.yanzhengcode.length > 0 && this.data.newpassword.length>0){
      this.setData({
        dengshow:true
      })
    }else{
      this.setData({
        dengshow:false
      })
    }
  },

  shuruyanzheng(e){
    this.setData({
      yanzhengcode:e.detail.value
    })
    this.yanzheng()
  },

  setnewmima(e){
    this.setData({
      newpassword:e.detail.value
    })
    this.yanzheng()
  },

  //登陆
  denglu(){
    console.log(47832342789);
    let that = this;
    console.log(that.data.newpassword.length)
    if (that.data.newpassword.length < 6 || that.data.newpassword.length>20){
      wx.showToast({
        title: '请输入6-20位的密码',
        icon:'none'
      })
    }else{
      let url = 'user/Profile/reset_password', params = {
        mobile: that.data.phone,
        verification_code: that.data.yanzhengcode,
        password: that.data.newpassword

      }
      app.post(url, params).then((res) => {
        console.log(res);
        // wx.switchTab({
        //   url: '/pages/homapage/homepage',
        // })
        wx.navigateTo({
          url: '/pages/login/login',
        })



      }).catch((err) => {
        wx.showToast({
          title: err.data.msg,
          icon: "none"
        })
      })
    }
   
lihongjuan authored
196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})