产品列表, 按上架时间和点赞量排序

This commit is contained in:
clay
2023-01-06 18:25:12 +08:00
parent 7e594aa3cb
commit a02de3a20f
3 changed files with 61 additions and 17 deletions

View File

@@ -43,9 +43,17 @@
productList: [],
pageNum: 1, // 当前页
pageSize: 4, // 每页条数
sortType: ''
}
},
created() {
uni.$on("getCurrent", data => {
if (data == 0) {
this.sortType = 1
} else if (data == 1) {
this.sortType = 2
}
})
this.getProducts()
this.imgUrl = uni.getStorageSync('img_url')
},
@@ -53,21 +61,21 @@
//获取产品列表
getProducts() {
this.$apiServe.getProducts({
sortType: this.sortType,
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.$emit("getChild", tags.length);
// 为数据赋值:通过展开运算符的形式,进行新旧数据的拼接
this.productList = [...this.productList, ...res.data.data]
// this.$emit("getChild", tags.length);
// 用于触底刷新 为数据赋值:通过展开运算符的形式,进行新旧数据的拼接
// this.productList = [...this.productList, ...res.data.data]
//这用于上架时间和点赞量的数据切换
this.productList = res.data.data
}).finally(_ => {
})