C端小程序
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

136 行
3.0 KiB

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