reset_password.js 2.7 KB

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