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.

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