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

156 行
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.expiredTimeStr = util.fmtDate(Number(file.expiredTime));
  95. console.log(file.expiredTime,file.expiredTimeStr)
  96. });
  97. setTimeout(function () {
  98. that.setData({
  99. loading: false
  100. });
  101. }, 1400);
  102. if (pageNum >= res.data.pages) {
  103. that.setData({
  104. allow_load: false
  105. });
  106. }
  107. if (pageNum == 1) {
  108. that.setData({
  109. list: []
  110. })
  111. }
  112. var tmpArr = that.data.list;
  113. Object.assign(tmpArr, res.data.list);
  114. that.setData({
  115. list: tmpArr
  116. })
  117. })
  118. .catch(err => {
  119. wx.showModal({
  120. title: '提示',
  121. content: err.errMsg,
  122. showCancel:false
  123. })
  124. })
  125. } else {
  126. that.setData({
  127. loading: true,
  128. content: "——— 再拉裤子就掉了啦 ———"
  129. });
  130. setTimeout(function () {
  131. that.setData({
  132. loading: false
  133. });
  134. }, 1400);
  135. }
  136. },
  137. handleChangeScroll({
  138. detail
  139. }) {
  140. this.setData({
  141. list: [],
  142. allow_load: true,
  143. current_scroll: detail.key,
  144. page:1,
  145. });
  146. this.getList(detail.key, 1);
  147. },
  148. onReachBottom: function () {
  149. var that = this;
  150. that.data.page++;
  151. that.setData({
  152. page: that.data.page
  153. });
  154. that.getList(that.data.current_scroll, that.data.page);
  155. }
  156. });