| | |
| | | // pages/purchaseRecords/index.js |
| | | var util = require('../../utils/util.js'); |
| | | Page({ |
| | | |
| | | /** |
| | | * 页面的初始数据 |
| | | */ |
| | | data: { |
| | | currentIndex:0 |
| | | currentIndex: 0, |
| | | orderList:[], |
| | | limit:10, |
| | | offset:0, |
| | | refresh:false, |
| | | orderShow:false, |
| | | noMore:false, |
| | | }, |
| | | |
| | | /** |
| | | * 生命周期函数--监听页面加载 |
| | | */ |
| | | onLoad: function (options) { |
| | | |
| | | }, |
| | | |
| | | /** |
| | | * 生命周期函数--监听页面初次渲染完成 |
| | | */ |
| | | onReady: function () { |
| | | |
| | | }, |
| | | |
| | | /** |
| | | * 生命周期函数--监听页面显示 |
| | | */ |
| | | onShow: function () { |
| | | |
| | | }, |
| | | |
| | | /** |
| | | * 生命周期函数--监听页面隐藏 |
| | | */ |
| | | onHide: function () { |
| | | |
| | | }, |
| | | |
| | | /** |
| | | * 生命周期函数--监听页面卸载 |
| | | */ |
| | | onUnload: function () { |
| | | |
| | | // wx.reLaunch({ |
| | | // url: '../customerCenter/customerCenter' |
| | | // }) |
| | | }, |
| | | |
| | | /** |
| | | * 页面相关事件处理函数--监听用户下拉动作 |
| | | */ |
| | | onPullDownRefresh: function () { |
| | | |
| | | onLoad: function (options) { |
| | | var status = options.status; |
| | | if (status!=undefined){ |
| | | this.setData({ |
| | | currentIndex: status |
| | | }) |
| | | } |
| | | this.getOrderInfo(this.data.currentIndex); |
| | | this.goTap(); |
| | | }, |
| | | |
| | | /** |
| | | * 页面上拉触底事件的处理函数 |
| | | */ |
| | | onReachBottom: function () { |
| | | |
| | | onShow:function(){ |
| | | if(this.data.refresh){ |
| | | this.getOrderInfo(this.data.currentIndex); |
| | | } |
| | | }, |
| | | |
| | | /** |
| | | * 用户点击右上角分享 |
| | | */ |
| | | onShareAppMessage: function () { |
| | | |
| | | //获取滚动条当前位置 |
| | | 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 |
| | | currentIndex:index, |
| | | offset: 0 |
| | | }) |
| | | this.setData({ |
| | | noMore:false |
| | | }); |
| | | this.getOrderInfo(index); |
| | | }, |
| | | toDetail(){ |
| | | wx.navigateTo({ |
| | | url: '/pages/purchaseRecords/detail' |
| | | |
| | | // 根据状态获取订单信息 |
| | | 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 |
| | | }); |
| | | }}); |
| | | }, |
| | | |
| | | |
| | | |
| | | |
| | | }) |