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
3.9 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. 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=${
  74. e.currentTarget.dataset.quancode}&couponorderstatus=${mystatus}`
  75. });
  76. },
  77. getList(key, pageNum) {
  78. var that = this;
  79. if (that.data.allow_load) {
  80. that.setData({
  81. loading: true,
  82. content: "小主,我在玩命加载中...",
  83. });
  84. Http.get({
  85. url: config.api.couponOrderList,
  86. data: {
  87. pageNum: pageNum,
  88. pageSize: 10,
  89. couponOrderStatus: key
  90. }
  91. })
  92. .then(res => {
  93. if(res.code == 200){
  94. that.setData({
  95. showPage:true
  96. })
  97. }
  98. res.data.list.map(file => {
  99. file.expiredTimeStr = util.fmtDate(Number(file.expiredTime));
  100. console.log(file.expiredTime,file.expiredTimeStr)
  101. });
  102. setTimeout(function () {
  103. that.setData({
  104. loading: false
  105. });
  106. }, 1400);
  107. if (pageNum >= res.data.pages) {
  108. that.setData({
  109. allow_load: false
  110. });
  111. }
  112. if (pageNum == 1) {
  113. that.setData({
  114. list: []
  115. })
  116. }
  117. var tmpArr =[];
  118. tmpArr = that.data.list
  119. // Object.assign(tmpArr, res.data.list);
  120. if(pageNum==1){
  121. console.log(res.data.list)
  122. that.setData({
  123. list: res.data.list
  124. })
  125. }else{
  126. tmpArr = [...tmpArr,...res.data.list]
  127. that.setData({
  128. list: tmpArr
  129. })
  130. }
  131. })
  132. .catch(err => {
  133. wx.showModal({
  134. title: '提示',
  135. content: err.errMsg,
  136. showCancel:false
  137. })
  138. })
  139. } else {
  140. that.setData({
  141. loading: true,
  142. content: "——— 再拉裤子就掉了啦 ———"
  143. });
  144. setTimeout(function () {
  145. that.setData({
  146. loading: false
  147. });
  148. }, 1400);
  149. }
  150. },
  151. handleChangeScroll({
  152. detail
  153. }) {
  154. this.setData({
  155. list: [],
  156. allow_load: true,
  157. current_scroll: detail.key,
  158. page:1,
  159. });
  160. this.getList(detail.key, 1);
  161. },
  162. onReachBottom: function () {
  163. var that = this;
  164. that.data.page++;
  165. that.setData({
  166. page: that.data.page
  167. });
  168. that.getList(that.data.current_scroll, that.data.page);
  169. }
  170. });