coupon.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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. // console.log(e);
  15. this.setData({
  16. _active: e.target.dataset.idx
  17. });
  18. },
  19. onLoad: function (options) {
  20. app.setBarColor();
  21. app.setUserInfo();
  22. var header = {
  23. 'content-type': 'application/x-www-form-urlencoded',
  24. };
  25. var that = this;
  26. //flag = 1{0表示正常,1未使用,2已使用,3已过期,4新增券}
  27. var flag = this.data._active;
  28. setTimeout(function(){
  29. wx.request({
  30. url: app.globalData.url + '/routine/auth_api/get_use_coupons?uid=' + app.globalData.uid,
  31. data:{types:0},
  32. method: 'GET',
  33. header: header,
  34. success: function (res) {
  35. if (res.data.code==200){
  36. that.setData({
  37. couponArray: res.data.data,
  38. title: "没有数据了",
  39. loadinghidden: true
  40. })
  41. } else{
  42. that.setData({
  43. couponArray: [],
  44. title: "没有数据了",
  45. loadinghidden: false
  46. })
  47. }
  48. }
  49. })
  50. },1000)
  51. },
  52. headertap:function(e){
  53. var that = this;
  54. // console.log(e);
  55. var header = {
  56. 'content-type': 'application/x-www-form-urlencoded',
  57. };
  58. var $type=e.target.dataset.idx
  59. wx.request({
  60. url: app.globalData.url + '/routine/auth_api/get_use_coupons?uid=' + app.globalData.uid,
  61. data: {types:$type},
  62. method: 'GET',
  63. header: header,
  64. success: function (res) {
  65. if (res.data.code==200){
  66. that.setData({
  67. couponArray: res.data.data,
  68. title: "没有数据了",
  69. loadinghidden: true,
  70. _active: $type
  71. })
  72. }else{
  73. that.setData({
  74. couponArray: [],
  75. title: "没有数据了",
  76. loadinghidden: false,
  77. _active: ''
  78. })
  79. }
  80. }
  81. })
  82. }
  83. })