C端小程序
Não pode escolher mais do que 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.

147 linhas
3.3 KiB

  1. const util = require("../../../utils/util.js");
  2. const config = require("../../../config/config.js");
  3. const Http = require("../../../utils/HttpBasics");
  4. Page({
  5. data: {
  6. tabs: [{
  7. key: 0,
  8. name: "未使用"
  9. },
  10. {
  11. key: 1,
  12. name: "已使用"
  13. },
  14. {
  15. key: 2,
  16. name: "已过期"
  17. },
  18. {
  19. key: 3,
  20. name: "已退款"
  21. }
  22. ],
  23. list: [],
  24. current: "0",
  25. current_scroll: "0",
  26. page: 1,
  27. allow_load: true,
  28. loading: true, //"上拉加载"的变量,默认false,隐藏
  29. content: "",
  30. mystatus: ''
  31. },
  32. onLoad() {
  33. this.getList(0, 1);
  34. },
  35. onShow: function () {
  36. let that = this;
  37. wx.setStorage({
  38. key: 'couponNum',
  39. data: "couponNum1",
  40. })
  41. wx.hideTabBarRedDot({
  42. index:2
  43. }),
  44. wx.getScreenBrightness({
  45. success:function(res){
  46. that.setData({
  47. sight:res.value
  48. })
  49. }
  50. });
  51. },
  52. //点击跳转到券详情页面
  53. gotouse: function (e) {
  54. console.log(e.currentTarget.dataset.couponorderstatus);
  55. if (this.data.mystatus == '' || this.data.mystatus == 'undefined') {
  56. var mystatus = e.currentTarget.dataset.couponorderstatus;
  57. } else {
  58. var mystatus = this.data.mystatus;
  59. }
  60. wx.navigateTo({
  61. url: `/pages/couponorder/detail/index?quancode=${
  62. e.currentTarget.dataset.quancode}&couponorderstatus=${mystatus}&sight=${this.data.sight}`
  63. });
  64. },
  65. getList(key, pageNum) {
  66. var that = this;
  67. if (that.data.allow_load) {
  68. that.setData({
  69. loading: true,
  70. content: "小主,我在玩命加载中...",
  71. });
  72. Http.get({
  73. url: config.api.couponOrderList,
  74. data: {
  75. pageNum: pageNum,
  76. pageSize: 6,
  77. couponOrderStatus: key
  78. }
  79. }).then(res => {
  80. console.log(res);
  81. res.data.list.map(file => {
  82. file.expiredTime = util.fmtDate(file.expiredTime);
  83. });
  84. setTimeout(function () {
  85. that.setData({
  86. loading: false
  87. });
  88. }, 1400);
  89. console.log(pageNum);
  90. if (pageNum >= res.data.pages) {
  91. that.setData({
  92. allow_load: false
  93. });
  94. }
  95. if (pageNum == 1) {
  96. that.setData({
  97. list: []
  98. })
  99. }
  100. var tmpArr = that.data.list;
  101. tmpArr.push.apply(tmpArr, res.data.list);
  102. that.setData({
  103. list: tmpArr
  104. })
  105. })
  106. .catch(err => {
  107. wx.showToast({
  108. title: err.errMsg,
  109. icon: 'none',
  110. duration: 2000,
  111. mask: 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. console.log(that.data.page+"页数");
  144. console.log(that.data.current_scroll+"点击的tab数")
  145. that.getList(that.data.current_scroll, that.data.page);
  146. }
  147. });