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.

146 lines
3.2 KiB

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