C端小程序
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.

150 rivejä
4.2 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 == 'jifen') {
  51. wx.redirectTo({
  52. url: `/pages/joinFrDpell/index?couponChannelId=${that.data.paramData.couponChannelId}`
  53. })
  54. }
  55. /**
  56. * 来自拼团详情
  57. */
  58. if (that.data.path == 'spell') {
  59. if (that.data.paramData.avatarUrl) {
  60. wx.redirectTo({
  61. 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}`
  62. })
  63. } else {
  64. wx.redirectTo({
  65. url: `pages/spellGroup/mySpellGroup/index?couponId=${that.data.paramData.couponId}&couponChannelId=${that.data.paramData.couponChannelId}`
  66. })
  67. }
  68. }
  69. if (that.path != 'index'){
  70. wx.redirectTo({
  71. url: "/pages/game/index?url=" + that.data.paramData.url + "&id=" + that.data.paramData.id + "&gameId=" + that.data.paramData.gameId,
  72. })
  73. }else{
  74. /**
  75. * cuserId若存在来自卡转赠
  76. */
  77. if (this.data.paramData.cuserId){
  78. wx.reLaunch({
  79. 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
  80. })
  81. }else{
  82. wx.redirectTo({
  83. url: '/pages/coupon/detail/index?couponChannelId=' + that.data.couponChannelId + '&couponId=' + that.data.couponId + "&flag=pay",
  84. })
  85. }
  86. }
  87. })
  88. .catch(err => {
  89. wx.showToast({
  90. title: err.errMsg,
  91. icon: 'none',
  92. duration: 2000,
  93. mask: false
  94. });
  95. })
  96. },
  97. //计时器
  98. timerInfo() {
  99. var timer = setInterval(() => {
  100. this.data.time--
  101. this.setData({
  102. time: this.data.time
  103. })
  104. if (this.data.time == 0) {
  105. clearInterval(timer)
  106. this.setData({
  107. flag: true,
  108. retry: false,
  109. time: 60
  110. })
  111. }
  112. }, 1000)
  113. },
  114. send() {
  115. var phoneReg = /(^1[3|4|5|7|8]\d{9}$)|(^09\d{8}$)/;
  116. if (phoneReg.test(this.data.phone)) {
  117. this.setData({
  118. retry: true
  119. })
  120. Http.get({
  121. url: config.api.sendValidationCode,
  122. data: {
  123. phone: this.data.phone,
  124. code: this.data.yzm,
  125. type: 1,
  126. appid: app.globalData.appId
  127. }
  128. })
  129. .then(res => {
  130. console.log(res)
  131. that.timerInfo()
  132. if (res.code == 200) {
  133. } else {
  134. wx.showToast({
  135. title: res.message
  136. })
  137. }
  138. })
  139. .catch(err => {
  140. wx.showToast({
  141. title: err.errMsg,
  142. icon: 'none',
  143. duration: 2000,
  144. mask: false
  145. });
  146. })
  147. }
  148. }
  149. })