C端小程序
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

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