收藏
回答

scroll-view实现一个上拉加载,触底时信息加载卡顿,需要下滑再上拉实现事件?

//加载商品

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)

}

}

})

},


回答关注问题邀请回答
收藏
登录 后发表内容