C端小程序
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

145 linhas
3.0 KiB

  1. let config = require("../../../config/config.js");
  2. let Http = require("../../../utils/HttpBasics");
  3. const util = require("../../../utils/util");
  4. let app = getApp();
  5. Page({
  6. data: {
  7. tabs: [{
  8. key: "all",
  9. name: "全部"
  10. },
  11. {
  12. key: 0,
  13. name: "待付款"
  14. },
  15. {
  16. key: 1,
  17. name: "已完成"
  18. }
  19. ],
  20. list: [],
  21. current: "",
  22. current_scroll: "1",
  23. page: 1,
  24. allow_load: true,
  25. loading: true, //"上拉加载"的变量,默认false,隐藏
  26. content: "",
  27. },
  28. onLoad(e) {
  29. this.getList(e.id, 1);
  30. this.setData({
  31. current_scroll: e.id
  32. });
  33. },
  34. gotopay: function (e) {
  35. console.log("orderId" + e.currentTarget.dataset.id);
  36. wx.navigateTo({
  37. url: `/pages/order/detail/index?orderId=${e.currentTarget.dataset.id}&flag='pay'`
  38. })
  39. },
  40. getList(key, pageNum) {
  41. let that = this;
  42. console.log(key);
  43. /**
  44. * key==0
  45. * 不发送该字段
  46. */
  47. if (key == 'all') {
  48. var variable = {
  49. pageNum: pageNum,
  50. pageSize: 5,
  51. paymentType: 0
  52. };
  53. } else {
  54. var variable = {
  55. pageNum: pageNum,
  56. pageSize: 5,
  57. orderStatus: key,
  58. paymentType: 0
  59. };
  60. }
  61. if (that.data.allow_load) {
  62. that.setData({
  63. loading: true,
  64. content: '小主,我在玩命加载中...'
  65. })
  66. Http.get({
  67. url: config.api.orderList,
  68. data: variable
  69. }).then(res => {
  70. console.log(res);
  71. if (pageNum >= res.data.pages) {
  72. that.setData({
  73. allow_load: false
  74. });
  75. setTimeout(function () {
  76. that.setData({
  77. loading: false,
  78. })
  79. }, 1400);
  80. }
  81. setTimeout(function () {
  82. that.setData({
  83. loading: false,
  84. })
  85. }, 1400);
  86. if (pageNum == 1) {
  87. that.setData({
  88. list: []
  89. })
  90. }
  91. var tmpArr = that.data.list;
  92. tmpArr.push.apply(tmpArr, res.data.list);
  93. that.setData({
  94. list: tmpArr
  95. })
  96. for (let i = 0; i < that.data.list.length; i++) {
  97. that.setData({
  98. createDate: util.fmtDate(that.data.list[i].createDate)
  99. })
  100. }
  101. });
  102. } else {
  103. console.log("加载完成allow_load设置成false");
  104. that.setData({
  105. loading: true,
  106. ccontent: "——— 在拉裤子就掉了啦 ———"
  107. })
  108. setTimeout(function () {
  109. that.setData({
  110. loading: false,
  111. })
  112. }, 1400)
  113. }
  114. },
  115. handleChange({
  116. detail
  117. }) {
  118. this.setData({
  119. current: detail.key
  120. });
  121. },
  122. handleChangeScroll({
  123. detail
  124. }) {
  125. this.setData({
  126. list: [],
  127. allow_load: true,
  128. current_scroll: detail.key,
  129. page:1
  130. })
  131. this.getList(detail.key, 1);
  132. },
  133. onReachBottom: function () {
  134. var that = this;
  135. that.data.page++;
  136. that.setData({
  137. page: that.data.page
  138. });
  139. that.getList(that.data.current_scroll, that.data.page);
  140. }
  141. });