C端小程序
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

141 linhas
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: "未使用"
  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. // wx.getScreenBrightness({
  46. // success:function(res){
  47. // app.globalData.sight = res.value;
  48. // }
  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. }).then(res => {
  78. res.data.list.map(file => {
  79. file.expiredTime = util.fmtDate(file.expiredTime);
  80. });
  81. setTimeout(function () {
  82. that.setData({
  83. loading: false
  84. });
  85. }, 1400);
  86. if (pageNum >= res.data.pages) {
  87. that.setData({
  88. allow_load: false
  89. });
  90. }
  91. if (pageNum == 1) {
  92. that.setData({
  93. list: []
  94. })
  95. }
  96. var tmpArr = that.data.list;
  97. tmpArr.push.apply(tmpArr, res.data.list);
  98. that.setData({
  99. list: tmpArr
  100. })
  101. })
  102. .catch(err => {
  103. wx.showToast({
  104. title: err.errMsg,
  105. icon: 'none',
  106. duration: 2000,
  107. mask: false
  108. });
  109. })
  110. } else {
  111. that.setData({
  112. loading: true,
  113. content: "——— 再拉裤子就掉了啦 ———"
  114. });
  115. setTimeout(function () {
  116. that.setData({
  117. loading: false
  118. });
  119. }, 1400);
  120. }
  121. },
  122. handleChangeScroll({
  123. detail
  124. }) {
  125. this.setData({
  126. list: [],
  127. allow_load: true,
  128. current_scroll: detail.key,
  129. page:1,
  130. });
  131. this.getList(detail.key, 1);
  132. },
  133. onReachBottom: function () {
  134. var that = this;
  135. that.data.page++;
  136. that.setData({
  137. page: that.data.page
  138. });
  139. that.getList(that.data.current_scroll, that.data.page);
  140. }
  141. });