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.

130 lines
3.0 KiB

  1. const util = require("../../../utils/util.js");
  2. const config = require("../../../config/config.js");
  3. const Http = require("../../../utils/HttpBasics");
  4. Page({
  5. data: {
  6. tabs: [{
  7. key: 0,
  8. name: "未使用"
  9. },
  10. {
  11. key: 1,
  12. name: "已使用"
  13. },
  14. {
  15. key: 2,
  16. name: "已过期"
  17. },
  18. {
  19. key: 3,
  20. name: "已退款"
  21. }
  22. ],
  23. list: [],
  24. current: "0",
  25. current_scroll: "0",
  26. page: 1,
  27. allow_load: true,
  28. loading: true, //"上拉加载"的变量,默认false,隐藏
  29. content: "",
  30. mystatus: ''
  31. },
  32. onLoad() {
  33. this.getList(0, 1);
  34. },
  35. onShow: function () {
  36. wx.setStorage({
  37. key: 'couponNum',
  38. data: "couponNum1",
  39. })
  40. },
  41. //点击跳转到券详情页面
  42. gotouse: function (e) {
  43. console.log(e.currentTarget.dataset.couponorderstatus);
  44. if (this.data.mystatus == '' || this.data.mystatus == 'undefined') {
  45. var mystatus = e.currentTarget.dataset.couponorderstatus;
  46. } else {
  47. var mystatus = this.data.mystatus;
  48. }
  49. wx.navigateTo({
  50. url: `/pages/couponorder/detail/index?quancode=${
  51. e.currentTarget.dataset.quancode}&couponorderstatus=${mystatus}`
  52. });
  53. },
  54. getList(key, pageNum) {
  55. var that = this;
  56. if (that.data.allow_load) {
  57. that.setData({
  58. loading: true,
  59. content: "小主,我在玩命加载中...",
  60. });
  61. Http.get({
  62. url: config.api.couponOrderList,
  63. data: {
  64. pageNum: pageNum,
  65. pageSize: 6,
  66. couponOrderStatus: key
  67. }
  68. }).then(res => {
  69. console.log(res);
  70. res.data.list.map(file => {
  71. file.expiredTime = util.fmtDate(file.expiredTime);
  72. });
  73. setTimeout(function () {
  74. that.setData({
  75. loading: false
  76. });
  77. }, 1400);
  78. console.log(pageNum);
  79. if (pageNum >= res.data.pages) {
  80. that.setData({
  81. allow_load: false
  82. });
  83. }
  84. if (pageNum == 1) {
  85. that.setData({
  86. list: []
  87. })
  88. }
  89. var tmpArr = that.data.list;
  90. tmpArr.push.apply(tmpArr, res.data.list);
  91. that.setData({
  92. list: tmpArr
  93. })
  94. });
  95. } else {
  96. that.setData({
  97. loading: true,
  98. content: "——— 在拉裤子就掉了啦 ———"
  99. });
  100. setTimeout(function () {
  101. that.setData({
  102. loading: false
  103. });
  104. }, 1400);
  105. }
  106. },
  107. handleChangeScroll({
  108. detail
  109. }) {
  110. this.setData({
  111. list: [],
  112. allow_load: true,
  113. current_scroll: detail.key,
  114. page:1,
  115. });
  116. this.getList(detail.key, 1);
  117. },
  118. onReachBottom: function () {
  119. var that = this;
  120. that.data.page++;
  121. that.setData({
  122. page: that.data.page
  123. });
  124. console.log(that.data.page+"页数");
  125. console.log(that.data.current_scroll+"点击的tab数")
  126. that.getList(that.data.current_scroll, that.data.page);
  127. }
  128. });