forget.js 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. // pages/forget/forget.js
  2. Page({
  3. /**
  4. * 页面的初始数据
  5. */
  6. data: {
  7. userName: null,
  8. phone: null,
  9. email: null,
  10. checkPass: false,
  11. errorMsg: ''
  12. },
  13. goNext(e){
  14. let that = this;
  15. let {
  16. userName: loginName,
  17. phone,
  18. email
  19. } = this.data;
  20. wx.request({
  21. url: getApp().globalData.postHeadAgreement + '/restapi/wechat/forget',
  22. data: {
  23. loginName,
  24. phonenumber: phone,
  25. email
  26. },
  27. method: 'POST',
  28. success(res) {
  29. //console.log(res);
  30. //console.log(res.data.code == 1);
  31. if (res.data.code == 1) {
  32. // that.setData({
  33. // errorMsg: res.data.msg
  34. // });
  35. wx.showModal({
  36. title: '提示',
  37. content: res.data.msg,
  38. showCancel: false,
  39. confirmColor: '#4359b5'
  40. });1
  41. } else {
  42. //跳转到下一步
  43. let url = `/pages/reset_password/reset_password?loginName=${loginName}`;
  44. wx.redirectTo({
  45. url
  46. });
  47. }
  48. }
  49. });
  50. },
  51. inputAccount(e) {
  52. this.setData({
  53. userName: e.detail.value
  54. });
  55. this.checkAll();
  56. },
  57. inputPhone(e) {
  58. this.setData({
  59. phone: e.detail.value
  60. });
  61. this.checkAll();
  62. },
  63. inputEmail(e) {
  64. this.setData({
  65. email: e.detail.value
  66. });
  67. this.checkAll();
  68. },
  69. checkPhone() {
  70. if (!(/^1[3456789]\d{9}$/.test(this.data.phone))) {
  71. return false;
  72. }
  73. return true;
  74. },
  75. checkMail() {
  76. if (!(/^[a-zA-Z0-9_.-]+@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*\.[a-zA-Z0-9]{2,6}$/.test(this.data.email))) {
  77. return false;
  78. }
  79. return true;
  80. },
  81. checkAll() {
  82. if (!this.data.userName || !this.data.userName.replace(/(^\s*)|(\s*$)/g, "")) {
  83. this.setData({
  84. errorMsg: '账号不能为空'
  85. });
  86. this.setData({
  87. checkPass: false
  88. });
  89. return;
  90. } else {
  91. this.setData({
  92. errorMsg: ''
  93. });
  94. }
  95. if (!this.checkPhone()) {
  96. this.setData({
  97. errorMsg: '手机号输入有误,请重新输入'
  98. });
  99. this.setData({
  100. checkPass: false
  101. });
  102. return;
  103. } else {
  104. this.setData({
  105. errorMsg: ''
  106. });
  107. }
  108. if (!this.checkMail()) {
  109. this.setData({
  110. errorMsg: '邮箱输入有误,请重新输入'
  111. });
  112. this.setData({
  113. checkPass: false
  114. });
  115. return;
  116. } else {
  117. this.setData({
  118. errorMsg: ''
  119. });
  120. }
  121. this.setData({
  122. checkPass: true
  123. });
  124. },
  125. /**
  126. * 生命周期函数--监听页面加载
  127. */
  128. onLoad: function(options) {
  129. },
  130. /**
  131. * 生命周期函数--监听页面初次渲染完成
  132. */
  133. onReady: function() {
  134. },
  135. /**
  136. * 生命周期函数--监听页面显示
  137. */
  138. onShow: function() {
  139. },
  140. /**
  141. * 生命周期函数--监听页面隐藏
  142. */
  143. onHide: function() {
  144. },
  145. /**
  146. * 生命周期函数--监听页面卸载
  147. */
  148. onUnload: function() {
  149. },
  150. /**
  151. * 页面相关事件处理函数--监听用户下拉动作
  152. */
  153. onPullDownRefresh: function() {
  154. },
  155. /**
  156. * 页面上拉触底事件的处理函数
  157. */
  158. onReachBottom: function() {
  159. },
  160. /**
  161. * 用户点击右上角分享
  162. */
  163. onShareAppMessage: function() {
  164. }
  165. })