1
jyy
2021-01-16 37c344f7b5c767c6a87e08a0c8a9698d8610fbfc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
var util = require('../../utils/util.js');
Page({ 
  data: {
    currentIndex: 0,
    orderList:[],
    limit:10,
    offset:0,
    refresh:false,
    orderShow:false,
    noMore:false,
  },
  onUnload: function () {  
    // wx.reLaunch({
    //   url: '../customerCenter/customerCenter'
    // })
  },
  onLoad: function (options) {
    var status = options.status;
    if (status!=undefined){
      this.setData({
        currentIndex: status
      })
    } 
    this.getOrderInfo(this.data.currentIndex);
    this.goTap();
  },
  onShow:function(){
    if(this.data.refresh){
      this.getOrderInfo(this.data.currentIndex);
    }
  },
  //获取滚动条当前位置
  onPageScroll: function (e) {
    // console.log(e)
    if (e.scrollTop > 400) {
      this.setData({
        floorstatus: true
      });
    } else {
      this.setData({
        floorstatus: false
      });
    }
  },
  //一键回到顶部
  goTap(){
    util.goTap();
  },
  onTabsItemEvent(e){
    var index = e.currentTarget.dataset.index;
    this.setData({
      currentIndex:index,
      offset: 0
    })
    this.setData({
      noMore:false
    });
    this.getOrderInfo(index);
  },
 
  // 根据状态获取订单信息
  getOrderInfo:function(status){
    var _this = this;
    var limit = _this.data.limit;
    var offset = _this.data.offset;
    util.request({ 
    api:"/wxapi/erpOrder/findUserOrderList",
    data: { "limit": limit, "orderStatus": status, "offset": offset},
    callback: function (data) {
      console.log("订单信息")
      console.log(data.rows)
      _this.setData({
        orderList: data.rows,
        currentIndex: status
      });
      var orderList = _this.data.orderList;
      console.log(orderList)
      if (orderList.length == 0) {
        _this.setData({
          orderShow: true,
        })
      } else {
        _this.setData({
          orderShow: false
        })
      }
    }});
  },
  toDetail(e){
    var id = e.currentTarget.dataset.id
    console.log(id)
    wx.navigateTo({
      url: '../purchaseRecords/detail?id='+id,
    })
  },
      
 
  // 上拉加载
  onReachBottom: function () {
 
    var _this = this;
    var offset = _this.data.offset;
    var limit = _this.data.limit;
    var orderList = _this.data.orderList;
    var status = _this.data.currentIndex;
    _this.setData({
      offset: offset + limit
    });
    offset = _this.data.offset;
 
    util.request({api:"/wxapi/erpOrder/findUserOrderList",data: { "limit": limit, "orderStatus": status, "offset": offset },
    callback: function (data) {
 
      if(data.rows.length>0){
        _this.setData({
          noMore:false
        });
      }else{
        _this.setData({
          noMore:true
        });
      }
 
      for (var i = 0; i < data.rows.length; i++) {
        orderList.push(data.rows[i]);
      }
      _this.setData({
        orderList: orderList
      });
    }});
  },
 
 
  
  
})