63 lines
1.1 KiB
JavaScript
Executable File
63 lines
1.1 KiB
JavaScript
Executable File
|
|
const api = require("../../api/api")
|
|
const app = getApp()
|
|
|
|
Page({
|
|
data: {
|
|
mealArr: [],
|
|
page : 1,
|
|
meta : {},
|
|
isLogin: false
|
|
},
|
|
onLoad() {
|
|
my.showLoading();
|
|
this.getList()
|
|
},
|
|
// 隐藏返回首页按钮
|
|
onReady() {
|
|
if (my.canIUse('hideBackHome')) {
|
|
my.hideBackHome();
|
|
}
|
|
},
|
|
getList(){
|
|
api.request({
|
|
url : "goods/lists",
|
|
method : "POST",
|
|
header : {
|
|
"Authorization": app.globalData.token
|
|
},
|
|
data : {
|
|
page: this.data.page
|
|
}
|
|
}).then(res=>{
|
|
let atArr = this.data.mealArr,
|
|
newArr = []
|
|
|
|
newArr = atArr.concat(res.data)
|
|
|
|
this.setData({
|
|
mealArr : newArr,
|
|
meta : res.meta,
|
|
isLogin : false
|
|
})
|
|
my.hideLoading()
|
|
})
|
|
},
|
|
// 分页
|
|
onReachBottom(){
|
|
let meta = this.data.meta,
|
|
atPage = this.data.page
|
|
|
|
this.setData({
|
|
isLogin: true
|
|
})
|
|
|
|
if(meta.current_page < meta.last_page){
|
|
this.setData({
|
|
page: atPage + 1
|
|
})
|
|
this.getList()
|
|
}
|
|
}
|
|
});
|