C端小程序
25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.

140 satır
3.1 KiB

  1. const navigationBarHeight = (getApp().statusBarHeight + 44) + 'px'
  2. const format = require("../../../utils/util.js");
  3. const config = require("../../../config/config.js");
  4. const app = getApp();
  5. const Http = require("../../../utils/HttpBasics");
  6. const imgurl = require("../../../utils/imgurl");
  7. Page({
  8. data: {
  9. navigationBarHeight,
  10. noCoupon:imgurl.noCoupon.url,
  11. couponUrl: imgurl.coupon.url,
  12. linessUrl: imgurl.liness.url,
  13. loadingUrl: imgurl.loading.url,
  14. tabs: [
  15. {
  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. goHomeUrl: "",
  38. },
  39. onLoad() {
  40. this.setData({
  41. goHomeUrl: app.globalData.goHomeUrl
  42. })
  43. this.getList(0, 1);
  44. },
  45. //点击跳转到券详情页面
  46. gotouse: function (e) {
  47. wx.navigateTo({
  48. url: `/pages/passCar/couponDetail/couponDetail?quancode=${
  49. e.currentTarget.dataset.quancode
  50. }`,
  51. success: function (res) {
  52. // success
  53. },
  54. fail: function () {
  55. // fail
  56. },
  57. complete: function () {
  58. // complete
  59. }
  60. });
  61. },
  62. getList(key, pageNum) {
  63. var that = this;
  64. if (that.data.allow_load) {
  65. wx.showLoading({
  66. title: "加载中"
  67. });
  68. Http.get({
  69. url: config.api.couponOrderCarList + "?type=5",
  70. data: {
  71. pageNum: pageNum,
  72. pageSize: 8,
  73. couponOrderStatus: key
  74. }
  75. }).then(res => {
  76. res.data.list.map(file => {
  77. file.expiredTime = format.formatTime(
  78. file.expiredTime,
  79. "yyyy-MM-dd hh:mm:ss"
  80. );
  81. });
  82. setTimeout(function () {
  83. wx.hideLoading();
  84. }, 1200);
  85. if (pageNum > res.data.pages) {
  86. that.setData({
  87. allow_load: false
  88. });
  89. }
  90. /**
  91. * 先赋值后渲染页面
  92. * concat 不会改变原数组值
  93. * push 会改变原数组值,但不会一条一条插入,而是整个数组插入
  94. */
  95. that.data.list = that.data.list.concat(res.data.list);
  96. that.setData({
  97. list: that.data.list
  98. });
  99. })
  100. .catch(err => {
  101. setTimeout(function () {
  102. wx.hideLoading();
  103. }, 1200);
  104. wx.showToast({
  105. title: err.errMsg,
  106. icon: 'none',
  107. duration: 2000,
  108. mask: false
  109. });
  110. })
  111. } else {
  112. }
  113. },
  114. handleChange({ detail }) {
  115. this.setData({
  116. current: detail.key
  117. });
  118. },
  119. handleChangeScroll({ detail }) {
  120. this.setData({
  121. list: [],
  122. allow_load: true,
  123. current_scroll: detail.key
  124. });
  125. this.getList(detail.key, 1);
  126. this.setData({
  127. current_scroll: detail.key
  128. });
  129. },
  130. onReachBottom: function () {
  131. var that = this;
  132. that.data.page++;
  133. that.setData({
  134. page: that.data.page
  135. });
  136. that.getList(that.data.current_scroll, that.data.page);
  137. }
  138. });