dengjie commit : 首页产品列表下拉刷新分页展示产品

This commit is contained in:
clay
2022-12-29 00:13:33 +08:00
parent b3b0b620bf
commit 0c3e8de069
5 changed files with 144 additions and 132 deletions

View File

@@ -41,28 +41,41 @@
imgUrl: '',
tagsArray: [],
productList: [],
pageNum: 1, // 当前页
pageSize: 4, // 每页条数
}
},
created() {
this.getProducts()
this.imgUrl = uni.getStorageSync('img_url')
},
methods: {
//获取产品列表
getProducts() {
// console.log("子组件的获取产品列表方法====");
this.$apiServe.getProducts().then(res => {
// console.log(res.data.data)
this.$apiServe.getProducts({
pageSize: this.pageSize,
pageNum: this.pageNum
}).then(res => {
let tags = res.data.data
for (const item of tags) {
let tag = item.tags
this.tagsArray = tag.split(',')
item.tags = this.tagsArray[0]
}
this.productList = res.data.data
}).finally(_ => {})
// if (res.data.data.length == 0) {
// requestTask.abort()
// }
console.log(res);
// 为数据赋值:通过展开运算符的形式,进行新旧数据的拼接
this.productList = [...this.productList, ...res.data.data]
}).finally(_ => {
})
},
//点击图片跳转到详情页
toDetailPage(item) {