C端小程序
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

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