coupon.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. // pages/coupon/coupon.js
  2. var app = getApp()
  3. Page({
  4. data: {
  5. frameShow: false,//兑换码弹框
  6. couponList: [],
  7. status: 1,//优惠券状态// status=0 已过期 2已使用 1未使用
  8. tabList: [
  9. {
  10. id: 1,
  11. name: '未使用'
  12. },
  13. {
  14. id: 2,
  15. name: '已使用'
  16. },
  17. {
  18. id: 0,
  19. name: '已过期'
  20. }]
  21. },
  22. couponCode: function () {
  23. this.setData({
  24. frameShow: true
  25. })
  26. },
  27. closeFrame: function () {
  28. let that = this
  29. that.setData({
  30. frameShow: false
  31. })
  32. },
  33. sureSubmit: function () {
  34. let that = this
  35. that.setData({
  36. frameShow: false
  37. })
  38. },
  39. onLoad: function (options) {
  40. var that = this;
  41. that.getCoupon()
  42. },
  43. //获取优惠券列表
  44. getCoupon: function () {
  45. let that=this
  46. // status=0 已过期 2已使用 1未使用
  47. my.showLoading({
  48. content: '加载中...',
  49. mask: true
  50. })
  51. let data={
  52. status:that.data.status
  53. }
  54. app.request('/coupon', data, 'GET').then(res => {
  55. //已使用
  56. console.log(res)
  57. that.setData({ couponList: res.data.data })
  58. my.hideLoading()
  59. })
  60. },
  61. //当前选中tab
  62. currentTab:function(e){
  63. let that=this
  64. console.log(e.currentTarget.dataset.id,'tab')
  65. that.setData({
  66. status:e.currentTarget.dataset.id
  67. })
  68. that.getCoupon()
  69. },
  70. onReady: function () {
  71. },
  72. onShow: function () {
  73. },
  74. onHide: function () {
  75. },
  76. onUnload: function () {
  77. },
  78. onPullDownRefresh: function () {
  79. },
  80. onReachBottom: function () {
  81. },
  82. onShareAppMessage: function () {
  83. }
  84. })