Files
sykl-hy/pages/mall/mallOrder/index.js

92 lines
2.0 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*
* 手太欠
* 愿这世界都如故事里一样 美好而动人~
*/
Page({
/**
* 页面的初始数据
*/
data: {
listType : 'paid', //paid待发货delivered已发货signed已签收
orderArr : [], //订单列表
page : {}, //下一页
lodingStats : false,//加载状态
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
this.setData({
listType: options.listType
})
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
// 获取订单列表
this.ordersInfo();
},
/**
* 订单列表
*/
ordersInfo(page) {
wx.$api.user.orders({
state: this.data.listType,
type : 'score',
page : page
}).then(res => {
let listArr = this.data.orderArr,
newData = []
if(page == 1 || page == undefined) listArr = []
newData = listArr.concat(res.data.data)
this.setData({
orderArr : newData,
page : res.data.page,
lodingStats : false
})
wx.stopPullDownRefresh()
}).catch(err => {})
},
/**
* 状态筛选
*/
onTabs(val){
if(this.data.listType === val) return
this.setData({
listType: val.currentTarget.dataset.type
})
// 商品详情数据
this.ordersInfo();
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
// 获取订单列表
this.ordersInfo();
},
/**
* 上拉加载
*/
onReachBottom(){
this.setData({
lodingStats: true
})
let pageNumber = this.data.page.current
if(this.data.page.has_more){
pageNumber++
// 获取订单列表
this.ordersInfo(pageNumber);
}
}
})