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.

127 righe
2.5 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: 0,
  9. name: "全部"
  10. },
  11. {
  12. key: 1,
  13. name: "待付款"
  14. },
  15. {
  16. key: 2,
  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(){
  33. console.log("000000");
  34. wx.navigateTo({
  35. url: '/pages/order/detail/index',
  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 == 0) {
  55. var variable = {
  56. pageNum: pageNum,
  57. pageSize: 5
  58. };
  59. } else {
  60. var variable = {
  61. pageNum: pageNum,
  62. pageSize: 5,
  63. orderStatus: key
  64. };
  65. }
  66. if (that.data.allow_load) {
  67. wx.showLoading({
  68. title: "加载中"
  69. });
  70. Http.get({
  71. url: config.api.orderList,
  72. data: variable
  73. }).then(res => {
  74. console.log(res);
  75. console.log("姐姐的订单列表");
  76. setTimeout(function() {
  77. wx.hideLoading();
  78. }, 1200);
  79. if (pageNum >= res.data.pages) {
  80. that.setData({
  81. allow_load: false
  82. });
  83. }
  84. /**
  85. * 先赋值后渲染页面
  86. * concat 不会改变原数组值
  87. * push 会改变原数组值,但不会一条一条插入,而是整个数组插入
  88. */
  89. that.data.list = that.data.list.concat(res.data.list);
  90. that.setData({
  91. list: that.data.list
  92. });
  93. });
  94. } else {
  95. console.log("加载完成allow_load设置成false");
  96. }
  97. },
  98. handleChange({ detail }) {
  99. this.setData({
  100. current: detail.key
  101. });
  102. },
  103. handleChangeScroll({ detail }) {
  104. this.setData({
  105. list:[],
  106. allow_load: true,
  107. current_scroll: detail.key
  108. })
  109. this.getList(detail.key, 1);
  110. },
  111. onReachBottom: function() {
  112. var that = this;
  113. console.log(that.data.page);
  114. that.data.page++;
  115. console.log(that.data.page);
  116. that.setData({
  117. page: that.data.page
  118. });
  119. console.info("after++ " + that.data.page);
  120. that.getList(that.data.current_scroll, that.data.page);
  121. }
  122. });