Files
sgy-web/pages/mall/list/list.js
2023-06-21 17:14:39 +08:00

63 lines
1.4 KiB
JavaScript

/*
* 手太欠
* 愿这世界都如故事里一样 美好而动人~
*/
Page({
data: {
goodsArr : [], // 商品列表
page : {}, // 分页信息
lodingStats : false, // 加载状态
},
onLoad(options) {
},
onShow() {
// 获取产品列表
this.mallInfo();
},
/**
* 获取产品列表
*/
mallInfo (page){
wx.$api.mall.mallList({page : page || 1}).then(res => {
let listArr = this.data.goodsArr,
newData = []
if(page == 1 || page == undefined) listArr = []
newData = listArr.concat(res.data.data)
this.setData({
goodsArr : newData,
page : res.data.page,
lodingStats : false
})
wx.stopPullDownRefresh()
}).catch(err => { })
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
// 获取产品列表
this.mallInfo();
},
/**
* 上拉加载
*/
onReachBottom(){
this.setData({
lodingStats: true
})
let pageNumber = this.data.page.current
if(this.data.page.has_more){
pageNumber++
// 获取产品列表
this.mallInfo(pageNumber);
}
}
})