C端小程序
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

129 行
2.7 KiB

  1. let config = require("../../../config/config.js");
  2. let Http = require("../../../utils/HttpBasics");
  3. let app = getApp();
  4. Page({
  5. data: {
  6. tabs: [
  7. {
  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. },
  26. onLoad(e) {
  27. this.getList(e.id, 1);
  28. this.setData({
  29. current_scroll: e.id
  30. });
  31. },
  32. gotopay:function(e){
  33. console.log("orderId"+e.currentTarget.dataset.id);
  34. wx.navigateTo({
  35. url: `/pages/order/detail/index?orderId=${e.currentTarget.dataset.id}`,
  36. success: function(res){
  37. // success
  38. },
  39. fail: function() {
  40. // fail
  41. },
  42. complete: function() {
  43. // complete
  44. }
  45. })
  46. },
  47. getList(key, pageNum) {
  48. let that = this;
  49. console.log(key);
  50. /**
  51. * key==0
  52. * 不发送该字段
  53. */
  54. if (key == 'all') {
  55. var variable = {
  56. pageNum: pageNum,
  57. pageSize: 5,
  58. paymentType:0
  59. };
  60. } else {
  61. var variable = {
  62. pageNum: pageNum,
  63. pageSize: 5,
  64. orderStatus: key,
  65. paymentType:0
  66. };
  67. }
  68. if (that.data.allow_load) {
  69. wx.showLoading({
  70. title: "加载中"
  71. });
  72. Http.get({
  73. url: config.api.orderList,
  74. data: variable
  75. }).then(res => {
  76. console.log(res);
  77. console.log("姐姐的订单列表");
  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. } else {
  97. console.log("加载完成allow_load设置成false");
  98. }
  99. },
  100. handleChange({ detail }) {
  101. this.setData({
  102. current: detail.key
  103. });
  104. },
  105. handleChangeScroll({ detail }) {
  106. this.setData({
  107. list:[],
  108. allow_load: true,
  109. current_scroll: detail.key
  110. })
  111. this.getList(detail.key, 1);
  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. });