C端小程序
Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

153 linhas
4.4 KiB

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