//加载商品
getProducts: function (category_id, orderType, refresh) {
let _data = {};
let _url;
canLoadMore = false;
if (category_id == 'all') {
_url = `api/special_areas/${this.data.currentStore.id}/products`
} else {
_url = `api/special_areas/${this.data.currentStore.id}/category_products`
_data = {
category_id: category_id,
}
}
let key = `id_${category_id}`
let length = 0
if (this.data.products[key] != null) {
length = this.data.products[key].length
}
var page = Math.floor(length / getApp().globalData.perPage) + 1
if (refresh) { //if要刷新清空数据时
_data.page = 1
} else {
_data.page = page
}
if (orderType != null) {
_data.order = orderType
}
http.get({
url: _url,
data: _data,
success: res => {
if (res.data != null && res.data.constructor.name == 'Array') {
canLoadMore = true;
this.appendProduct(res.data, category_id)
}
}
})
},