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.

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