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.

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