微信小程序> 微信小程序之找回密码

微信小程序之找回密码

浏览量:826 时间: 来源:ssh456

小程序

第一步:根据学号和绑定的邮箱来进行密码的找回

小程序

第二步:输入想要设定的新密码,并输入邮箱收到的验证码

wxml代码如下:

!--pages/forgotpwd/forgotpwd.wxml--!-- textpages/forgotpwd/forgotpwd.wxml/text --view class='content'  form bindsubmit='submit_email' wx:if="{{form_index ==0}}"    label找回密码:第一步/label    view class="sections"      input name="no" type='number' placeholder-class='small'  placeholder='请输入学号' /    /view    view class="sections"      input name="email" placeholder-class='small' placeholder='请输入绑定的邮箱' /    /view      button type='primary' placeholder-class='small' formType="submit" 下一步/button  /form  form bindsubmit='submit_password' wx:else    label找回密码:第二步/label    view class="section"      view class="left"        input name="pwd" password="{{mask}}" placeholder-class='small' placeholder='输入新密码' /      /view      view class="right"        switch   bindchange="switchChange"/      /view    /view    view class="section"      view class="left"        input name="validcode" type='number'  placeholder-class='small' placeholder='输入邮件中的验证码'/      /view      view class="right"          text style="color:#aaa"剩余:{{second}}秒/text      /view    /view      button type='primary' placeholder-class='small' formType="submit" disabled="{{disabled}}"提交/button  /form/view

调用的js代码

const app=getApp();//倒计时function countdown(that) {  var second = that.data.second  if (second == 0) {    that.setData({      disabled: true    });    return;  }  var time = setTimeout(function () {    that.setData({      second: second - 1    });    countdown(that);  }    , 1000)}Page({  /**   * 页面的初始数据   */  data: {  no:null,  form_index:0,  second: 30,  disabled: false,  mask: true  },  switchChange: function (e) {    // console.log(e.detail.value)    this.setData({ mask: !e.detail.value })  },  submit_email:function(e){  // console.log(e);  var no=e.detail.value.no;  var email=e.detail.value.email;  if(email==null||email==''){    wx.showToast({      title: '请输入邮箱',      icon: 'none',      duration: 2000    })    return;  }  wx.showLoading({    title: '加载中...',  })  wx.request({    url: app.globalData.url.forgotpwd,    method: 'POST',    data: {      no: no,      email: email    },    header: {      'content-type': 'application/x-www-form-urlencoded'    },    success: (res) = {      wx.hideLoading();      console.log(res.data);      if(res.data.error){        wx.showToast({          title: res.data.msg,          icon: 'none',          duration: 2000        })      }else{        this.setData({ no: no, second: res.data.expire });        countdown(this);        wx.showToast({          title: res.data.msg,          icon: 'none',          duration: 2000        })        setTimeout(() = {          this.setData({ form_index: 1 });        }, 2000)      }    }  })  },//重设密码  submit_password:function(e){  // console.log(e);  var pwd=e.detail.value.pwd;  var validcode = e.detail.value.validcode;  if (validcode == '' || validcode == null || pwd == '' || pwd == null) {    wx.showToast({      title: '验证码和密码不能为空',      icon: 'none',      duration: 2000    })  } else {  wx.request({    url: app.globalData.url.initpassword,    method: 'POST',    data: {      no: this.data.no,      pwd: pwd,      validcode: validcode    },    header: {      'content-type': 'application/x-www-form-urlencoded'    },    success: (res) = {      // wx.hideLoading();      console.log(res.data);      if (res.data.error) {        wx.showToast({          title: res.data.msg,          icon: 'none',          duration: 2000        })      } else {        wx.showToast({          title: res.data.msg,          icon: 'success',          duration: 2000        })        setTimeout(() = {          wx.navigateBack({            delta: 1          })        }, 2000)      }    }  })  }},  /**   * 生命周期函数--监听页面加载   */  onLoad: function (options) {    },  /**   * 生命周期函数--监听页面初次渲染完成   */  onReady: function () {    },  /**   * 生命周期函数--监听页面显示   */  onShow: function () {    },  /**   * 生命周期函数--监听页面隐藏   */  onHide: function () {    },  /**   * 生命周期函数--监听页面卸载   */  onUnload: function () {    },  /**   * 页面相关事件处理函数--监听用户下拉动作   */  onPullDownRefresh: function () {    },  /**   * 页面上拉触底事件的处理函数   */  onReachBottom: function () {    },  /**   * 用户点击右上角分享   */  onShareAppMessage: function () {    }})


版权声明

即速应用倡导尊重与保护知识产权。如发现本站文章存在版权问题,烦请提供版权疑问、身份证明、版权证明、联系方式等发邮件至197452366@qq.com ,我们将及时处理。本站文章仅作分享交流用途,作者观点不等同于即速应用观点。用户与作者的任何交易与本站无关,请知悉。

产品经理

手机 : 13312967497

擅长 : 小程序流量变现

扫码领取礼包

热门模板

  • 头条
  • 搜狐
  • 微博
  • 百家
  • 一点资讯
  • 知乎