C端小程序
Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.

137 righe
2.9 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. {
  9. key: "all",
  10. name: "全部"
  11. },
  12. {
  13. key: 0,
  14. name: "待付款"
  15. },
  16. {
  17. key: 1,
  18. name: "已完成"
  19. }
  20. ],
  21. list: [],
  22. current: "",
  23. current_scroll: "1",
  24. page: 1,
  25. allow_load: true
  26. },
  27. onLoad(e) {
  28. this.getList(e.id, 1);
  29. this.setData({
  30. current_scroll: e.id
  31. });
  32. },
  33. gotopay:function(e){
  34. console.log("orderId"+e.currentTarget.dataset.id);
  35. wx.navigateTo({
  36. url: `/pages/order/detail/index?orderId=${e.currentTarget.dataset.id}&flag='pay'`,
  37. success: function(res){
  38. // success
  39. },
  40. fail: function() {
  41. // fail
  42. },
  43. complete: function() {
  44. // complete
  45. }
  46. })
  47. },
  48. getList(key, pageNum) {
  49. let that = this;
  50. console.log(key);
  51. /**
  52. * key==0
  53. * 不发送该字段
  54. */
  55. if (key == 'all') {
  56. var variable = {
  57. pageNum: pageNum,
  58. pageSize: 5,
  59. paymentType:0
  60. };
  61. } else {
  62. var variable = {
  63. pageNum: pageNum,
  64. pageSize: 5,
  65. orderStatus: key,
  66. paymentType:0
  67. };
  68. }
  69. if (that.data.allow_load) {
  70. wx.showLoading({
  71. title: "加载中"
  72. });
  73. Http.get({
  74. url: config.api.orderList,
  75. data: variable
  76. }).then(res => {
  77. console.log(res);
  78. console.log("姐姐的订单列表");
  79. setTimeout(function() {
  80. wx.hideLoading();
  81. }, 1200);
  82. if (pageNum >= res.data.pages) {
  83. that.setData({
  84. allow_load: false
  85. });
  86. }
  87. /**
  88. * 先赋值后渲染页面
  89. * concat 不会改变原数组值
  90. * push 会改变原数组值,但不会一条一条插入,而是整个数组插入
  91. */
  92. that.data.list = that.data.list.concat(res.data.list);
  93. that.setData({
  94. list: that.data.list
  95. });
  96. for(let i=0; i<that.data.list.length; i++){
  97. console.log(i);
  98. that.setData({
  99. createDate:util.fmtDate(that.data.list[i].createDate)
  100. })
  101. }
  102. });
  103. } else {
  104. console.log("加载完成allow_load设置成false");
  105. }
  106. },
  107. handleChange({ detail }) {
  108. this.setData({
  109. current: detail.key
  110. });
  111. },
  112. handleChangeScroll({ detail }) {
  113. this.setData({
  114. list:[],
  115. allow_load: true,
  116. current_scroll: detail.key
  117. })
  118. this.getList(detail.key, 1);
  119. },
  120. onReachBottom: function() {
  121. var that = this;
  122. console.log(that.data.page);
  123. that.data.page++;
  124. console.log(that.data.page);
  125. that.setData({
  126. page: that.data.page
  127. });
  128. console.info("after++ " + that.data.page);
  129. that.getList(that.data.current_scroll, that.data.page);
  130. }
  131. });