reset_password.js 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. // pages/reset_password/reset_password.js
  2. Page({
  3. /**
  4. * 页面的初始数据
  5. */
  6. data: {
  7. phone: null,
  8. password: null,
  9. rePassword: null,
  10. checkPass: false,
  11. errorMsg: ''
  12. },
  13. resetPassword(e) {
  14. let that = this;
  15. let{
  16. phone : phonenumber,
  17. password
  18. } = this.data;
  19. wx.request({
  20. url: getApp().globalData.postHeadAgreement + '/restapi/wechat/resetPassword',
  21. data: {
  22. phonenumber,
  23. password
  24. },
  25. method: 'POST',
  26. success(res) {
  27. if (res.data.code == 1) {
  28. wx.showModal({
  29. title: '提示',
  30. content: res.data.msg,
  31. showCancel: false,
  32. confirmColor: '#4359b5'
  33. });
  34. } else {
  35. wx.navigateBack();
  36. }
  37. }
  38. });
  39. },
  40. inputPassword(e) {
  41. this.setData({
  42. password: e.detail.value
  43. });
  44. this.checkAll();
  45. },
  46. inputRepassword(e) {
  47. this.setData({
  48. rePassword: e.detail.value
  49. });
  50. this.checkAll();
  51. },
  52. checkPassword() {
  53. if (!this.data.password || !this.data.rePassword || this.data.password != this.data.rePassword) {
  54. return false;
  55. }
  56. return true;
  57. },
  58. checkAll() {
  59. if (this.data.password && (this.data.password.length < 5 || this.data.password.length > 20)) {
  60. this.setData({
  61. errorMsg: '密码长度应为5-20'
  62. });
  63. this.setData({
  64. checkPass: false
  65. });
  66. return;
  67. }
  68. if (!this.checkPassword()) {
  69. this.setData({
  70. errorMsg: '两次密码输入不一致,请重新输入'
  71. });
  72. this.setData({
  73. checkPass: false
  74. });
  75. return;
  76. } else {
  77. this.setData({
  78. errorMsg: ''
  79. });
  80. }
  81. this.setData({
  82. checkPass: true
  83. });
  84. },
  85. /**
  86. * 生命周期函数--监听页面加载
  87. */
  88. onLoad: function(options) {
  89. let {
  90. phone
  91. } = options;
  92. this.setData({
  93. phone: phone
  94. });
  95. //resetPassword
  96. },
  97. /**
  98. * 生命周期函数--监听页面初次渲染完成
  99. */
  100. onReady: function() {
  101. },
  102. /**
  103. * 生命周期函数--监听页面显示
  104. */
  105. onShow: function() {
  106. },
  107. /**
  108. * 生命周期函数--监听页面隐藏
  109. */
  110. onHide: function() {
  111. },
  112. /**
  113. * 生命周期函数--监听页面卸载
  114. */
  115. onUnload: function() {
  116. },
  117. /**
  118. * 页面相关事件处理函数--监听用户下拉动作
  119. */
  120. onPullDownRefresh: function() {
  121. },
  122. /**
  123. * 页面上拉触底事件的处理函数
  124. */
  125. onReachBottom: function() {
  126. },
  127. /**
  128. * 用户点击右上角分享
  129. */
  130. onShareAppMessage: function() {
  131. }
  132. })