C端小程序
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

133 rader
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. wx.hideTabBarRedDot({
  41. index:2
  42. })
  43. },
  44. //点击跳转到券详情页面
  45. gotouse: function (e) {
  46. console.log(e.currentTarget.dataset.couponorderstatus);
  47. if (this.data.mystatus == '' || this.data.mystatus == 'undefined') {
  48. var mystatus = e.currentTarget.dataset.couponorderstatus;
  49. } else {
  50. var mystatus = this.data.mystatus;
  51. }
  52. wx.navigateTo({
  53. url: `/pages/couponorder/detail/index?quancode=${
  54. e.currentTarget.dataset.quancode}&couponorderstatus=${mystatus}`
  55. });
  56. },
  57. getList(key, pageNum) {
  58. var that = this;
  59. if (that.data.allow_load) {
  60. that.setData({
  61. loading: true,
  62. content: "小主,我在玩命加载中...",
  63. });
  64. Http.get({
  65. url: config.api.couponOrderList,
  66. data: {
  67. pageNum: pageNum,
  68. pageSize: 6,
  69. couponOrderStatus: key
  70. }
  71. }).then(res => {
  72. console.log(res);
  73. res.data.list.map(file => {
  74. file.expiredTime = util.fmtDate(file.expiredTime);
  75. });
  76. setTimeout(function () {
  77. that.setData({
  78. loading: false
  79. });
  80. }, 1400);
  81. console.log(pageNum);
  82. if (pageNum >= res.data.pages) {
  83. that.setData({
  84. allow_load: false
  85. });
  86. }
  87. if (pageNum == 1) {
  88. that.setData({
  89. list: []
  90. })
  91. }
  92. var tmpArr = that.data.list;
  93. tmpArr.push.apply(tmpArr, res.data.list);
  94. that.setData({
  95. list: tmpArr
  96. })
  97. });
  98. } else {
  99. that.setData({
  100. loading: true,
  101. content: "——— 再拉裤子就掉了啦 ———"
  102. });
  103. setTimeout(function () {
  104. that.setData({
  105. loading: false
  106. });
  107. }, 1400);
  108. }
  109. },
  110. handleChangeScroll({
  111. detail
  112. }) {
  113. this.setData({
  114. list: [],
  115. allow_load: true,
  116. current_scroll: detail.key,
  117. page:1,
  118. });
  119. this.getList(detail.key, 1);
  120. },
  121. onReachBottom: function () {
  122. var that = this;
  123. that.data.page++;
  124. that.setData({
  125. page: that.data.page
  126. });
  127. console.log(that.data.page+"页数");
  128. console.log(that.data.current_scroll+"点击的tab数")
  129. that.getList(that.data.current_scroll, that.data.page);
  130. }
  131. });