C端小程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

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