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.

166 lines
3.8 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 =[];
  113. tmpArr = that.data.list
  114. // Object.assign(tmpArr, res.data.list);
  115. if(pageNum==1){
  116. console.log(res.data.list)
  117. that.setData({
  118. list: res.data.list
  119. })
  120. }else{
  121. tmpArr = [...tmpArr,...res.data.list]
  122. that.setData({
  123. list: tmpArr
  124. })
  125. }
  126. })
  127. .catch(err => {
  128. wx.showModal({
  129. title: '提示',
  130. content: err.errMsg,
  131. showCancel:false
  132. })
  133. })
  134. } else {
  135. that.setData({
  136. loading: true,
  137. content: "——— 再拉裤子就掉了啦 ———"
  138. });
  139. setTimeout(function () {
  140. that.setData({
  141. loading: false
  142. });
  143. }, 1400);
  144. }
  145. },
  146. handleChangeScroll({
  147. detail
  148. }) {
  149. this.setData({
  150. list: [],
  151. allow_load: true,
  152. current_scroll: detail.key,
  153. page:1,
  154. });
  155. this.getList(detail.key, 1);
  156. },
  157. onReachBottom: function () {
  158. var that = this;
  159. that.data.page++;
  160. that.setData({
  161. page: that.data.page
  162. });
  163. that.getList(that.data.current_scroll, that.data.page);
  164. }
  165. });