You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

5 年之前
5 年之前
5 年之前
5 年之前
5 年之前
5 年之前
5 年之前
5 年之前
5 年之前
5 年之前
5 年之前
5 年之前
5 年之前
5 年之前
5 年之前
5 年之前
5 年之前
5 年之前
5 年之前
5 年之前
5 年之前
5 年之前
5 年之前
5 年之前
5 年之前
5 年之前
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. // pages/register/register.js
  2. const app = getApp()
  3. let time;
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. yesSend:false,//是否发送验证码
  10. minter: 60,//发送验证码60秒后才可再次发送
  11. num:60,
  12. phone: "",//手机号
  13. phoneCode: "",//验证码
  14. },
  15. /**
  16. * 生命周期函数--监听页面加载
  17. */
  18. onLoad: function (options) {
  19. },
  20. /**
  21. * 生命周期函数--监听页面初次渲染完成
  22. */
  23. onReady: function () {
  24. },
  25. /**
  26. * 生命周期函数--监听页面显示
  27. */
  28. onShow: function () {
  29. },
  30. /**
  31. * 生命周期函数--监听页面隐藏
  32. */
  33. onHide: function () {
  34. },
  35. /**
  36. * 生命周期函数--监听页面卸载
  37. */
  38. onUnload: function () {
  39. },
  40. /**
  41. * 页面相关事件处理函数--监听用户下拉动作
  42. */
  43. onPullDownRefresh: function () {
  44. },
  45. /**
  46. * 页面上拉触底事件的处理函数
  47. */
  48. onReachBottom: function () {
  49. },
  50. /**
  51. * 用户点击右上角分享
  52. */
  53. onShareAppMessage: function () {
  54. },
  55. yesCodeFn:function(){//验证码接口
  56. app.wxRequest(app.globalData.httpUrl + 'smscode', { user_phone: this.data.phone }, e => {
  57. console.log(e)
  58. if (e.code == 200) {
  59. wx.showToast({
  60. title: e.message,
  61. icon: 'success',
  62. duration: 500
  63. })
  64. }
  65. }, this)
  66. },
  67. sendTouch:function(){//发送验证码
  68. if (!(/^1[3456789]\d{9}$/.test(this.data.phone))) {
  69. wx.showToast({
  70. title: '手机号错误',
  71. icon: 'none',
  72. duration: 500
  73. })
  74. return;
  75. }
  76. this.setData({
  77. yesSend: true,
  78. })
  79. if (this.data.yesSend) {
  80. time = setInterval(this.setIntervalFn,1000)
  81. }
  82. if (app.globalData.openid) {
  83. this.yesCodeFn();
  84. } else {
  85. this.globalData.openidSuccessFuc = this.yesCodeFn;
  86. }
  87. },
  88. setIntervalFn:function(){//定时器
  89. if (this.data.num > 0) {
  90. this.data.num--;
  91. if (this.data.num == 0) {
  92. this.setData({
  93. yesSend: false,
  94. })
  95. if (!this.data.yesSend){
  96. this.setData({
  97. num: 60,
  98. minter: 60,
  99. })
  100. }
  101. clearInterval(time);
  102. }
  103. }
  104. this.setData({
  105. minter: this.data.num
  106. })
  107. console.log(this.data.minter)
  108. },
  109. registerBtn:function(){//点击按钮注册
  110. if (app.globalData.openid) {
  111. this.registerFn();
  112. } else {
  113. this.globalData.openidSuccessFuc = this.registerFn;
  114. }
  115. },
  116. registerFn:function(){//注册接口
  117. app.wxRequest(app.globalData.httpUrl + 'register', { user_phone: this.data.phone, code_num: this.data.phoneCode }, e => {
  118. console.log(e)
  119. if (e.code == 200) {
  120. clearInterval(time);
  121. app.globalData.userInfo = e.data.user_phone
  122. this.setData({
  123. minter: 60,
  124. num: 60
  125. })
  126. wx.showToast({
  127. title: '注册成功',
  128. icon: 'success',
  129. duration: 500
  130. })
  131. setTimeout(function () {
  132. if (app.globalData.present_id){
  133. wx.reLaunch({
  134. url: '/pages/receiveTicket/receiveTicket?shareId=' + app.globalData.present_id + "&number=" + app.globalData.number
  135. })
  136. } else {
  137. wx.switchTab({
  138. url: '../index/index'
  139. })
  140. }
  141. }, 1000)
  142. }else{
  143. wx.showToast({
  144. title: e.message,
  145. duration:500
  146. })
  147. }
  148. }, this,"POST")
  149. },
  150. getPhone: function (e) {//获取手机号
  151. console.log(e.detail.value);
  152. this.setData({
  153. phone: e.detail.value
  154. })
  155. },
  156. getCode: function (e) {//获取验证码
  157. console.log(e.detail.value);
  158. this.setData({
  159. phoneCode: e.detail.value
  160. })
  161. },
  162. })