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.

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