C端小程序
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

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