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.

coupon.js 3.4KB

5 vuotta sitten
5 vuotta sitten
5 vuotta sitten
5 vuotta sitten
5 vuotta sitten
5 vuotta sitten
5 vuotta sitten
5 vuotta sitten
5 vuotta sitten
5 vuotta sitten
5 vuotta sitten
5 vuotta sitten
5 vuotta sitten
5 vuotta sitten
5 vuotta sitten
5 vuotta sitten
5 vuotta sitten
5 vuotta sitten
5 vuotta sitten
5 vuotta sitten
5 vuotta sitten
5 vuotta sitten
5 vuotta sitten
5 vuotta sitten
5 vuotta sitten
5 vuotta sitten
5 vuotta sitten
5 vuotta sitten
5 vuotta sitten
5 vuotta sitten
5 vuotta sitten
5 vuotta sitten
5 vuotta sitten
5 vuotta sitten
5 vuotta sitten
5 vuotta sitten
5 vuotta sitten
5 vuotta sitten
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. // pages/coupon/coupon.js
  2. const app = getApp()
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. type: 2, //1券码核销 2手机号核销
  9. user_phone: '', //手机号
  10. state: 0, //0核销未完成 1核销中 2核销已完成
  11. totalNums: 50, //总数量
  12. nums: 1, //核销数量
  13. coupon_name: '', //优惠券名称
  14. couponTime: '', //优惠券购买时间
  15. code_num: '', //核销短信验证码
  16. },
  17. /**
  18. * 验证码修改
  19. */
  20. changeCode(event) {
  21. this.setData({
  22. code_num: event.detail.value
  23. })
  24. },
  25. /**
  26. * 核销
  27. */
  28. writeOff: function() {
  29. if (this.data.state == 1) {
  30. return
  31. }
  32. if (this.data.code_num.length != 6) {
  33. wx.showToast({
  34. title: '验证码错误',
  35. icon: 'none',
  36. duration: 2000
  37. })
  38. } else {
  39. this.setData({
  40. state: 1
  41. })
  42. var data = {
  43. check_type: 2,
  44. user_phone: this.data.user_phone,
  45. code_num: this.data.code_num,
  46. coupon_sell_id: app.globalData.couponData.coupon_sell_id,
  47. coupon_code: '',
  48. check_num: this.data.nums
  49. }
  50. app.requestPost('couponbuy/check', data, res => {
  51. var state;
  52. if (res.code == 200) {
  53. state = 2;
  54. wx.switchTab({
  55. url: '../record/record'
  56. })
  57. } else {
  58. state = 0;
  59. wx.showToast({
  60. title: res.message,
  61. icon: 'none',
  62. duration: 2000
  63. })
  64. }
  65. this.setData({
  66. state: state
  67. })
  68. })
  69. }
  70. },
  71. /**
  72. * 添加优惠券
  73. */
  74. addCoupon() {
  75. if (this.data.nums + 1 <= this.data.totalNums) {
  76. this.setData({
  77. nums: this.data.nums + 1
  78. })
  79. }
  80. },
  81. /**
  82. * 减少优惠券
  83. */
  84. reduceCoupon() {
  85. if (this.data.nums - 1 > 0) {
  86. this.setData({
  87. nums: this.data.nums - 1
  88. })
  89. }
  90. },
  91. /**
  92. * 生命周期函数--监听页面加载
  93. */
  94. onLoad: function(options) {
  95. wx.hideShareMenu();
  96. var code = options.code;
  97. var pohone = options.phone;
  98. if (code) { //券码查询
  99. this.setData({
  100. type: 1
  101. })
  102. }
  103. if (pohone) { //手机号查询
  104. console.log(app.globalData.couponData)
  105. var couponData = app.globalData.couponData;
  106. this.setData({
  107. type: 2,
  108. user_phone: pohone,
  109. totalNums: couponData.num,
  110. coupon_name: couponData.coupon_name,
  111. couponTime: couponData.cdate
  112. })
  113. /**
  114. * 发送验证码
  115. */
  116. app.requestGet('couponbuy/check/smscode', { user_phone: pohone},res=>{
  117. if(res.code==200){
  118. }else{
  119. wx.showToast({
  120. title: res.message,
  121. icon: 'none',
  122. duration: 2000
  123. })
  124. }
  125. })
  126. }
  127. },
  128. /**
  129. * 生命周期函数--监听页面初次渲染完成
  130. */
  131. onReady: function() {
  132. },
  133. /**
  134. * 生命周期函数--监听页面显示
  135. */
  136. onShow: function() {},
  137. /**
  138. * 生命周期函数--监听页面隐藏
  139. */
  140. onHide: function() {
  141. },
  142. /**
  143. * 生命周期函数--监听页面卸载
  144. */
  145. onUnload: function() {
  146. },
  147. /**
  148. * 页面相关事件处理函数--监听用户下拉动作
  149. */
  150. onPullDownRefresh: function() {
  151. },
  152. /**
  153. * 页面上拉触底事件的处理函数
  154. */
  155. onReachBottom: function() {
  156. },
  157. /**
  158. * 用户点击右上角分享
  159. */
  160. onShareAppMessage: function() {
  161. }
  162. })