coupon.js 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. var app = getApp();
  2. // pages/coupon/coupon.js
  3. // var fileData = require('../../utils/util.js'); //暴露的接口;
  4. Page({
  5. data: {
  6. url: app.globalData.urlImages,
  7. _active:0,
  8. headerArray: ['全部', '未使用', '已使用','已过期'],
  9. couponArray:"",
  10. userstatus:"",
  11. title:"正在加载中..."
  12. },
  13. headertaps:function(e){
  14. this.setData({
  15. _active: e.target.dataset.idx
  16. });
  17. },
  18. onLoad: function (options) {
  19. app.setBarColor();
  20. app.setUserInfo();
  21. var header = {
  22. 'content-type': 'application/x-www-form-urlencoded',
  23. };
  24. var that = this;
  25. //flag = 1{0表示正常,1未使用,2已使用,3已过期,4新增券}
  26. var flag = this.data._active;
  27. setTimeout(function(){
  28. wx.request({
  29. url: app.globalData.url + '/routine/auth_api/get_use_coupons?uid=' + app.globalData.uid,
  30. data:{types:0},
  31. method: 'GET',
  32. header: header,
  33. success: function (res) {
  34. if (res.data.code==200){
  35. that.setData({
  36. couponArray: res.data.data,
  37. title: "没有数据了",
  38. loadinghidden: true
  39. })
  40. } else{
  41. that.setData({
  42. couponArray: [],
  43. title: "没有数据了",
  44. loadinghidden: false
  45. })
  46. }
  47. }
  48. })
  49. },1000)
  50. },
  51. headertap:function(e){
  52. var that = this;
  53. // console.log(e);
  54. var header = {
  55. 'content-type': 'application/x-www-form-urlencoded',
  56. };
  57. var $type=e.target.dataset.idx
  58. wx.request({
  59. url: app.globalData.url + '/routine/auth_api/get_use_coupons?uid=' + app.globalData.uid,
  60. data: {types:$type},
  61. method: 'GET',
  62. header: header,
  63. success: function (res) {
  64. if (res.data.code==200){
  65. that.setData({
  66. couponArray: res.data.data,
  67. title: "没有数据了",
  68. loadinghidden: true,
  69. _active: $type
  70. })
  71. }else{
  72. that.setData({
  73. couponArray: [],
  74. title: "没有数据了",
  75. loadinghidden: false,
  76. _active: ''
  77. })
  78. }
  79. }
  80. })
  81. }
  82. })