C端小程序
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

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