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.

172 line
4.0 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: false, //"上拉加载"的变量,默认false,隐藏
  38. content: "",
  39. mystatus: '',
  40. showPage: false,
  41. goHomeUrl: "",
  42. },
  43. onLoad() {
  44. this.setData({
  45. goHomeUrl: app.globalData.goHomeUrl
  46. })
  47. this.getList(0, 1);
  48. },
  49. onShow: function () {
  50. let that = this;
  51. wx.setStorage({
  52. key: 'couponNum',
  53. data: "couponNum1",
  54. })
  55. // wx.hideTabBarRedDot({
  56. // index:2
  57. // })
  58. },
  59. goback: function () {
  60. let this_ = this
  61. wx.switchTab({
  62. url: this_.data.goHomeUrl,
  63. })
  64. },
  65. //点击跳转到券详情页面
  66. gotouse: function (e) {
  67. if (this.data.mystatus == '' || this.data.mystatus == 'undefined') {
  68. var mystatus = e.currentTarget.dataset.couponorderstatus;
  69. } else {
  70. var mystatus = this.data.mystatus;
  71. }
  72. wx.navigateTo({
  73. url: `/pages/couponorder/detail/index?quancode=${e.currentTarget.dataset.quancode}&couponorderstatus=${mystatus}`
  74. });
  75. },
  76. getList(key, pageNum) {
  77. var that = this;
  78. if (that.data.allow_load) {
  79. that.setData({
  80. loading: true,
  81. content: "小主,我在玩命加载中...",
  82. });
  83. Http.get({
  84. url: config.api.couponOrderList,
  85. data: {
  86. pageNum: pageNum,
  87. pageSize: 10,
  88. couponOrderStatus: key
  89. }
  90. })
  91. .then(res => {
  92. if (res.code == 200) {
  93. that.setData({
  94. showPage: true
  95. })
  96. setTimeout(() => {
  97. that.setData({
  98. loading: false
  99. });
  100. }, 1400);
  101. }
  102. res.data.list.map(file => {
  103. file.expiredTimeStr = util.fmtDate(Number(file.expiredTime));
  104. console.log(file.expiredTime, file.expiredTimeStr)
  105. });
  106. if (pageNum >= res.data.pages) {
  107. that.setData({
  108. allow_load: false
  109. });
  110. }
  111. if (pageNum == 1) {
  112. that.setData({
  113. list: []
  114. })
  115. }
  116. var tmpArr = [];
  117. tmpArr = that.data.list
  118. // Object.assign(tmpArr, res.data.list);
  119. if (pageNum == 1) {
  120. console.log(res.data.list)
  121. that.setData({
  122. list: res.data.list
  123. })
  124. } else {
  125. tmpArr = [...tmpArr, ...res.data.list]
  126. that.setData({
  127. list: tmpArr
  128. })
  129. }
  130. })
  131. .catch(err => {
  132. wx.showModal({
  133. title: '提示',
  134. content: err.errMsg,
  135. showCancel: false
  136. })
  137. })
  138. } else {
  139. that.setData({
  140. loading: true,
  141. content: "——— 再拉裤子就掉了啦 ———"
  142. });
  143. setTimeout(function () {
  144. that.setData({
  145. loading: false
  146. });
  147. }, 1400);
  148. }
  149. },
  150. handleChangeScroll({
  151. detail
  152. }) {
  153. this.setData({
  154. list: [],
  155. allow_load: true,
  156. current_scroll: detail.key,
  157. page: 1,
  158. });
  159. this.getList(detail.key, 1);
  160. },
  161. onReachBottom: function () {
  162. var that = this;
  163. that.data.page++;
  164. that.setData({
  165. page: that.data.page
  166. });
  167. that.getList(that.data.current_scroll, that.data.page);
  168. }
  169. });