C端小程序
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

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