C端小程序
Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

134 Zeilen
2.9 KiB

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