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.

155 lines
3.5 KiB

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