diff --git a/components/products/products.vue b/components/productsByThumb/productsByThumb.vue
similarity index 82%
rename from components/products/products.vue
rename to components/productsByThumb/productsByThumb.vue
index 5246bb9..5d92239 100644
--- a/components/products/products.vue
+++ b/components/productsByThumb/productsByThumb.vue
@@ -43,25 +43,24 @@
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()
+ // uni.$on("getCurrent", data => {
+ // if (data == 0) {
+ // this.sortType = 1
+ // } else if (data == 1) {
+ // this.sortType = 2
+ // }
+ // })
+ this.getProductsByThumb()
this.imgUrl = uni.getStorageSync('img_url')
},
methods: {
- //获取产品列表
- getProducts() {
+ //获取按点赞量排列的产品列表
+ getProductsByThumb() {
this.$apiServe.getProducts({
- sortType: this.sortType,
+ sortType: 2,
pageSize: this.pageSize,
pageNum: this.pageNum
}).then(res => {
@@ -71,11 +70,11 @@
this.tagsArray = tag.split(',')
item.tags = this.tagsArray[0]
}
- // this.$emit("getChild", tags.length);
+ this.$emit("getThumbLength", tags.length);
// 用于触底刷新 为数据赋值:通过展开运算符的形式,进行新旧数据的拼接
- // this.productList = [...this.productList, ...res.data.data]
+ this.productList = [...this.productList, ...res.data.data]
//这用于上架时间和点赞量的数据切换
- this.productList = res.data.data
+ // this.productList = res.data.data
}).finally(_ => {
})
diff --git a/components/productsByTime/productsByTime.vue b/components/productsByTime/productsByTime.vue
new file mode 100644
index 0000000..827eaea
--- /dev/null
+++ b/components/productsByTime/productsByTime.vue
@@ -0,0 +1,95 @@
+
+
+
+
+
+
+
+
+
+
+
+ {{item.cate_name}}
+
+
+
+ {{item.name}}
+
+
+
+ {{item.title}}
+
+
+
+
+ 发布日期:
+ {{item.pub_time_str}}
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/pages/index/index.vue b/pages/index/index.vue
index 531fe7b..1dfb68d 100644
--- a/pages/index/index.vue
+++ b/pages/index/index.vue
@@ -34,7 +34,10 @@
-
+
+
+
+
没有更多数据了
@@ -60,15 +63,16 @@
imgUrl: '',
swiperList: [],
reachBottomLength: '',
- productList: [],
- pageNum: 1,
- sortType: ''
}
},
onReachBottom() {
- this.pageNum += 1
- if (this.reachBottomLength !== 0) {
- this.getNewProducts()
+ if (this.tabCurrent == 0 && this.reachBottomLength !== 0) {
+ this.$refs.productsByTime.pageNum++
+ this.$refs.productsByTime.getProductsByTime()
+ }
+ if (this.tabCurrent == 1 && this.reachBottomLength !== 0) {
+ this.$refs.productsByThumb.pageNum++
+ this.$refs.productsByThumb.getProductsByThumb()
}
},
onLoad() {
@@ -78,36 +82,23 @@
this.imgUrl = uni.getStorageSync('img_url')
},
methods: {
+ //获取按上架时间排列的产品列表length
+ getTimeLength(e) {
+ this.reachBottomLength = e
+ },
+ //获取按点赞量排列的产品列表length
+ getThumbLength(e) {
+ this.reachBottomLength = e
+ },
//点击上架时间和点赞量切换页面
tabChange(data) {
this.tabCurrent = data.index
- uni.$emit("getCurrent", data.index);
if (data.index == 0) {
- this.sortType = 1
+ this.$refs.productsByTime.getProductsByTime()
} else if (data.index == 1) {
- this.$refs.getProductsByTime.getProducts()
- this.sortType = 2
+ this.$refs.productsByThumb.getProductsByThumb()
}
},
- //下拉刷新获取新数据
- getNewProducts() {
- this.$apiServe.getProducts({
- sortType: this.sortType,
- pageSize: 4,
- 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]
- }
- if (tags.length === 0) {
- this.reachBottomLength = tags.length
- }
- this.$refs.getProductsByTime.productList.push(...res.data.data)
- })
- },
//获取一级分类
getCategories() {
this.$apiServe.getCategories().then(res => {
diff --git a/pages/report/report.vue b/pages/report/report.vue
index 4b1833f..8e96b33 100644
--- a/pages/report/report.vue
+++ b/pages/report/report.vue
@@ -28,7 +28,7 @@
新品发布
-
+