Files
sykl-mall/pages/stock/index.js
2023-07-22 19:01:37 +08:00

109 lines
2.3 KiB
JavaScript

/*
* 手太欠
* 愿这世界都如故事里一样 美好而动人~
*/
Page({
/**
* 页面的初始数据
*/
data: {
stockData: '', //数据
address : '', //地址
listArr : [], //提货列表数据
avatar : '', //头像
identity : '', //身份
page : {}, //下一页
lodingStats : false,//加载状态
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
// 获取用户信息
this.userInfo();
// 获取提货前置
this.pickInfo();
// 获取提货列表
this.pickList();
},
/**
* 用户信息
*/
userInfo() {
wx.$api.user.home().then(res => {
this.setData({
avatar : res.data.avatar,
identity : res.data.identity
})
}).catch(err => {})
},
/**
* 提货前置
*/
pickInfo (){
wx.$api.stock.pick().then(res => {
this.setData({
stockData : res.data.stockData,
address : res.data.address
})
}).catch(err => {})
},
/**
* 提货列表
*/
pickList (page){
wx.$api.stock.list({
page: page
}).then(res => {
let listArr = this.data.listArr,
newData = []
if(page == 1 || page == undefined) listArr = []
newData = listArr.concat(res.data.data)
this.setData({
listArr : newData,
page : res.data.page,
lodingStats : false
})
wx.stopPullDownRefresh()
}).catch(err => {})
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
// 获取提货列表
this.pickList();
},
/**
* 上拉加载
*/
onReachBottom(){
this.setData({
lodingStats: true
})
let pageNumber = this.data.page.current
if(this.data.page.has_more){
pageNumber++
// 获取提货列表
this.pickList(pageNumber);
}
}
})