index.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. // pages/retrieve_password/index.js
  2. import { phoneRegisterReset, registerVerify } from '../../api/api.js';
  3. let app = getApp();
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. cloneIner: null,
  10. loading: false,
  11. errorSum: 0,
  12. errorNum: 3,
  13. disabled: false,
  14. active: false,
  15. timetext: '获取验证码',
  16. userInfo: {},
  17. phone: '', //手机号
  18. parameter: {
  19. 'navbar': '1',
  20. 'return': '1',
  21. 'title': '登录',
  22. 'color': true,
  23. 'class': '6'
  24. },
  25. },
  26. /**
  27. * 生命周期函数--监听页面加载
  28. */
  29. onLoad: function (options) {
  30. },
  31. getPhoneValue: function (e) {
  32. this.setData({
  33. phone: e.detail.value
  34. })
  35. },
  36. /**
  37. * 发送验证码
  38. *
  39. */
  40. code: function () {
  41. let that = this;
  42. if (!that.data.phone) return app.Tips({ title: '请先输入手机号' });
  43. var type = 'reset';
  44. registerVerify(that.data.phone, type).then(res => {
  45. return app.Tips({ title: '发送成功' }, function () {
  46. that.setData({ disabled: true, active: true });
  47. let n = 60;
  48. let run = setInterval(function () {
  49. n--;
  50. if (n < 0) {
  51. clearInterval(run);
  52. that.setData({ disabled: false, active: false, timetext: '重新获取' })
  53. } else {
  54. that.setData({ timetext: "剩余 " + n + "s" })
  55. }
  56. }, 1000);
  57. });
  58. }).catch(err => {
  59. return app.Tips({ title: err });
  60. });
  61. },
  62. close() {
  63. let pages = getCurrentPages();
  64. let currPage = pages[pages.length - 1];
  65. if (this.data.isGoIndex) {
  66. wx.switchTab({ url: '/pages/index/index' });
  67. this.setData({
  68. ihidden: true
  69. });
  70. } else {
  71. this.setData({
  72. iShidden: true,
  73. ihidden: true
  74. });
  75. if (currPage && currPage.data.iShidden != undefined) {
  76. currPage.setData({ iShidden: true, ihidden: true });
  77. }
  78. }
  79. },
  80. loginSubmit: function (e) {
  81. var that = this, data = {};
  82. var datainfo = e.detail.value;
  83. phoneRegisterReset(datainfo).then(res => {
  84. wx.setStorageSync('userid', res.data.id);
  85. var userid = wx.getStorageSync('userid');
  86. that.setData({
  87. ihidden: false
  88. })
  89. return app.Tips({ title: '修改成功', icon: 'success' }, function(){
  90. wx.navigateBack({ delta: 1 });
  91. });
  92. console.log(userid);
  93. }).catch(err => {
  94. return app.Tips({ title: err });
  95. })
  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. })