C端小程序
25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.

142 satır
4.0 KiB

  1. // pages/forgetpwd/forgetpwd.js
  2. let config = require('../../config/config.js')
  3. let Http = require('../../utils/HttpBasics')
  4. const app = getApp()
  5. Page({
  6. data: {
  7. phone: '',
  8. yzm: '',
  9. retry: false,
  10. time: 60,
  11. couponChannelId: null,
  12. couponId:null,
  13. path:null,
  14. paramData: null
  15. },
  16. onLoad: function (options) {
  17. if(options.path=='index'){
  18. this.path = options.path
  19. }
  20. this.setData({
  21. paramData: options
  22. })
  23. var that = this;
  24. that.setData({
  25. couponChannelId: options.couponChannelId,
  26. couponId: options.couponId,
  27. })
  28. },
  29. getYZM(e) {
  30. this.setData({
  31. phone: e.detail.value.phone,
  32. yzm: e.detail.value.yzm
  33. })
  34. },
  35. next() {
  36. var that = this
  37. Http.get({
  38. url: config.api.validationCode,
  39. data: {
  40. phone: that.data.phone,
  41. code: that.data.yzm,
  42. type: 1,
  43. appid: app.globalData.appId
  44. }
  45. })
  46. .then(res => {
  47. /**
  48. * 来自拼团详情
  49. */
  50. if (that.data.path == 'spell') {
  51. if (that.data.paramData.avatarUrl) {
  52. wx.redirectTo({
  53. url: `/pages/joinFrDpell/index?couponId=${that.data.paramData.couponId}&orderGroupId=${that.data.paramData.orderGroupId}&couponChannelId=${that.data.paramData.couponChannelId}&orderId=${that.data.paramData.orderId}&avatarUrl=${that.data.paramData.avatarUrl}&nickName=${that.data.paramData.nickName}`
  54. })
  55. } else {
  56. wx.redirectTo({
  57. url: `pages/spellGroup/mySpellGroup/index?couponId=${that.data.paramData.couponId}&couponChannelId=${that.data.paramData.couponChannelId}`
  58. })
  59. }
  60. }
  61. if (that.path != 'index'){
  62. wx.redirectTo({
  63. url: "/pages/game/index?url=" + that.data.paramData.url + "&id=" + that.data.paramData.id + "&gameId=" + that.data.paramData.gameId,
  64. })
  65. }else{
  66. /**
  67. * cuserId若存在来自卡转赠
  68. */
  69. if (this.data.paramData.cuserId){
  70. wx.reLaunch({
  71. url: "/pages/coupon/detail/index?cuserId=" + that.data.paramData.cuserId + '&couponChannelId=' + that.data.paramData.couponChannelId + '&couponId=' + that.data.paramData.couponId + '&coverImg=' + that.data.paramData.coverImg + '&avatarUrl=' + that.data.paramData.avatarUrl + '&userName=' + that.data.paramData.userName + '&couponOrderId=' + that.data.paramData.couponOrderId + "&updateDate=" + that.data.paramData.updateDate
  72. })
  73. }else{
  74. wx.redirectTo({
  75. url: '/pages/coupon/detail/index?couponChannelId=' + that.data.couponChannelId + '&couponId=' + that.data.couponId + "&flag=pay",
  76. })
  77. }
  78. }
  79. })
  80. .catch(err => {
  81. wx.showToast({
  82. title: err.errMsg,
  83. icon: 'none',
  84. duration: 2000,
  85. mask: false
  86. });
  87. })
  88. },
  89. //计时器
  90. timerInfo() {
  91. var timer = setInterval(() => {
  92. this.data.time--
  93. this.setData({
  94. time: this.data.time
  95. })
  96. if (this.data.time == 0) {
  97. clearInterval(timer)
  98. this.setData({
  99. flag: true,
  100. retry: false,
  101. time: 60
  102. })
  103. }
  104. }, 1000)
  105. },
  106. send() {
  107. var phoneReg = /(^1[3|4|5|7|8]\d{9}$)|(^09\d{8}$)/;
  108. if (phoneReg.test(this.data.phone)) {
  109. this.setData({
  110. retry: true
  111. })
  112. Http.get({
  113. url: config.api.sendValidationCode,
  114. data: {
  115. phone: this.data.phone,
  116. code: this.data.yzm,
  117. type: 1,
  118. appid: app.globalData.appId
  119. }
  120. })
  121. .then(res => {
  122. console.log(res)
  123. that.timerInfo()
  124. if (res.code == 200) {
  125. } else {
  126. wx.showToast({
  127. title: res.message
  128. })
  129. }
  130. })
  131. .catch(err => {
  132. wx.showToast({
  133. title: err.errMsg,
  134. icon: 'none',
  135. duration: 2000,
  136. mask: false
  137. });
  138. })
  139. }
  140. }
  141. })