C端小程序
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

126 行
2.8 KiB

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