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.

142 lines
3.1 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: "A卡"
  10. },
  11. {
  12. key: 1,
  13. name: "礼品卡"
  14. },
  15. {
  16. key: 2,
  17. name: "折扣卡"
  18. },
  19. {
  20. key: 3,
  21. name: "D卡"
  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. showPage: false
  33. },
  34. onLoad() {
  35. this.getList(0, 1);
  36. },
  37. onShow: function () {
  38. let that = this;
  39. wx.setStorage({
  40. key: 'couponNum',
  41. data: "couponNum1",
  42. })
  43. wx.hideTabBarRedDot({
  44. index: 2
  45. })
  46. },
  47. //点击跳转到券详情页面
  48. gotouse: function (e) {
  49. if (this.data.mystatus == '' || this.data.mystatus == 'undefined') {
  50. var mystatus = e.currentTarget.dataset.couponorderstatus;
  51. } else {
  52. var mystatus = this.data.mystatus;
  53. }
  54. wx.navigateTo({
  55. url: `/pages/couponorder/detail/index?quancode=${
  56. e.currentTarget.dataset.quancode}&couponorderstatus=${mystatus}`
  57. });
  58. },
  59. getList(key, pageNum) {
  60. var that = this;
  61. if (that.data.allow_load) {
  62. that.setData({
  63. loading: true,
  64. content: "小主,我在玩命加载中...",
  65. });
  66. Http.get({
  67. url: config.api.couponOrderList,
  68. data: {
  69. pageNum: pageNum,
  70. pageSize: 6,
  71. couponOrderStatus: key
  72. }
  73. })
  74. .then(res => {
  75. if (res.code == 200) {
  76. that.setData({
  77. showPage: true
  78. })
  79. }
  80. res.data.list.map(file => {
  81. file.expiredTime = util.fmtDate(file.expiredTime);
  82. });
  83. setTimeout(function () {
  84. that.setData({
  85. loading: false
  86. });
  87. }, 1400);
  88. if (pageNum >= res.data.pages) {
  89. that.setData({
  90. allow_load: false
  91. });
  92. }
  93. if (pageNum == 1) {
  94. that.setData({
  95. list: []
  96. })
  97. }
  98. var tmpArr = that.data.list;
  99. tmpArr.push.apply(tmpArr, res.data.list);
  100. that.setData({
  101. list: tmpArr
  102. })
  103. })
  104. .catch(err => {
  105. wx.showModal({
  106. title: '提示',
  107. content: err.errMsg,
  108. showCancel: false
  109. })
  110. })
  111. } else {
  112. that.setData({
  113. loading: true,
  114. content: "——— 再拉裤子就掉了啦 ———"
  115. });
  116. setTimeout(function () {
  117. that.setData({
  118. loading: false
  119. });
  120. }, 1400);
  121. }
  122. },
  123. handleChangeScroll({
  124. detail
  125. }) {
  126. this.setData({
  127. list: [],
  128. allow_load: true,
  129. current_scroll: detail.key,
  130. page: 1,
  131. });
  132. this.getList(detail.key, 1);
  133. },
  134. onReachBottom: function () {
  135. var that = this;
  136. that.data.page++;
  137. that.setData({
  138. page: that.data.page
  139. });
  140. that.getList(that.data.current_scroll, that.data.page);
  141. }
  142. });