C端小程序
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

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