mdfpassword.js 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. // pages/ucenter/accountsecurity/mdfpassword/mdfpassword.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. let url = `/pages/ucenter/index/index`;
  36. wx.redirectTo({
  37. url
  38. });
  39. }
  40. }
  41. });
  42. },
  43. inputPassword(e) {
  44. this.setData({
  45. password: e.detail.value
  46. });
  47. this.checkAll();
  48. },
  49. inputRepassword(e) {
  50. this.setData({
  51. rePassword: e.detail.value
  52. });
  53. this.checkAll();
  54. },
  55. checkPassword() {
  56. if (!this.data.password || !this.data.rePassword || this.data.password != this.data.rePassword) {
  57. return false;
  58. }
  59. return true;
  60. },
  61. checkAll() {
  62. if (this.data.password && (this.data.password.length < 5 || this.data.password.length > 20)) {
  63. this.setData({
  64. errorMsg: '密码长度应为5-20'
  65. });
  66. this.setData({
  67. checkPass: false
  68. });
  69. return;
  70. }
  71. if (!this.checkPassword()) {
  72. this.setData({
  73. errorMsg: '两次密码输入不一致,请重新输入'
  74. });
  75. this.setData({
  76. checkPass: false
  77. });
  78. return;
  79. } else {
  80. this.setData({
  81. errorMsg: ''
  82. });
  83. }
  84. this.setData({
  85. checkPass: true
  86. });
  87. },
  88. /**
  89. * 生命周期函数--监听页面加载
  90. */
  91. onLoad(options) {
  92. let userInfo = wx.getStorageSync('userInfo');
  93. let isLogin = wx.getStorageSync('isLogin');
  94. // 页面显示
  95. if (userInfo && isLogin) {
  96. this.setData({
  97. phone: userInfo.phonenumber,
  98. });
  99. } else {
  100. //未登录信息
  101. this.setData({
  102. userInfo: {}
  103. });
  104. let url = `/pages/login/phone_login/phone_login`;
  105. wx.navigateTo({
  106. url
  107. });
  108. return;
  109. }
  110. },
  111. /**
  112. * 生命周期函数--监听页面初次渲染完成
  113. */
  114. onReady() {
  115. },
  116. /**
  117. * 生命周期函数--监听页面显示
  118. */
  119. onShow() {
  120. },
  121. /**
  122. * 生命周期函数--监听页面隐藏
  123. */
  124. onHide() {
  125. },
  126. /**
  127. * 生命周期函数--监听页面卸载
  128. */
  129. onUnload() {
  130. },
  131. /**
  132. * 页面相关事件处理函数--监听用户下拉动作
  133. */
  134. onPullDownRefresh() {
  135. },
  136. /**
  137. * 页面上拉触底事件的处理函数
  138. */
  139. onReachBottom() {
  140. },
  141. /**
  142. * 用户点击右上角分享
  143. */
  144. onShareAppMessage() {
  145. }
  146. })