C端小程序
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

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