|
@@ -3,7 +3,7 @@
|
|
|
<tui-skeleton v-if="isRequest" :loadingType="3" :isLoading="true"></tui-skeleton>
|
|
|
<view class="sticky-top">
|
|
|
<!-- 搜索框 -->
|
|
|
- <cm-simple-search @search="onSearch" @cancel="onCancel" v-model="keyword"></cm-simple-search>
|
|
|
+ <cm-simple-search @search="onSearch" @cancel="onCancel" v-model="listQuery.name"></cm-simple-search>
|
|
|
<!-- 筛选 -->
|
|
|
<goods-filter @filter="onFilter"></goods-filter>
|
|
|
</view>
|
|
@@ -14,9 +14,11 @@
|
|
|
</view>
|
|
|
</view>
|
|
|
<!-- 加载更多 -->
|
|
|
- <cm-loadmore :hasNextPage="hasNextPage" :isLoading="isLoading" :visiable="!isRequest"></cm-loadmore>
|
|
|
+ <cm-loadmore :hasNextPage="hasNextPage" :isLoading="isLoading" :visiable="!hideLoadmore"></cm-loadmore>
|
|
|
<!-- 回到顶部 -->
|
|
|
<tui-scroll-top :scrollTop="scrollTop" :bottom="30" :duration="600"></tui-scroll-top>
|
|
|
+ <!-- 安全区域 -->
|
|
|
+ <cm-safe-area-bottom v-if="hideLoadmore"></cm-safe-area-bottom>
|
|
|
</view>
|
|
|
</template>
|
|
|
|
|
@@ -30,7 +32,6 @@ export default {
|
|
|
return {
|
|
|
isRequest: true,
|
|
|
scrollTop: 0,
|
|
|
- keyword: '',
|
|
|
listQuery: makeQuery(),
|
|
|
navInfo: {},
|
|
|
productList: [],
|
|
@@ -40,7 +41,10 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
computed: {
|
|
|
- ...mapGetters(['userId'])
|
|
|
+ ...mapGetters(['userId']),
|
|
|
+ hideLoadmore() {
|
|
|
+ return this.isRequest || this.productList.length <= this.listQuery.pageSize
|
|
|
+ }
|
|
|
},
|
|
|
onPageScroll(e) {
|
|
|
this.scrollTop = e.scrollTop
|
|
@@ -52,10 +56,31 @@ export default {
|
|
|
this.initQueryList()
|
|
|
},
|
|
|
methods: {
|
|
|
- onSearch() {},
|
|
|
- onCancel() {},
|
|
|
+ // 搜索商品
|
|
|
+ onSearch() {
|
|
|
+ this.filterProductList()
|
|
|
+ },
|
|
|
+
|
|
|
+ // 取消搜索
|
|
|
+ onCancel() {
|
|
|
+ this.listQuery.name = ''
|
|
|
+ this.filterProductList()
|
|
|
+ },
|
|
|
+
|
|
|
+ // 筛选商品
|
|
|
onFilter(e) {
|
|
|
- console.log(e)
|
|
|
+ const { current, sort } = e
|
|
|
+ if (current === 0) {
|
|
|
+ // 综合排序
|
|
|
+ this.listQuery.sortType = 1
|
|
|
+ } else if (current === 1) {
|
|
|
+ // 价格高低
|
|
|
+ this.listQuery.sortType = sort === 'desc' ? 3 : 2
|
|
|
+ } else {
|
|
|
+ // 最新上架
|
|
|
+ this.listQuery.sortType = 4
|
|
|
+ }
|
|
|
+ this.filterProductList()
|
|
|
},
|
|
|
|
|
|
// 初始化查询参数
|
|
@@ -65,14 +90,15 @@ export default {
|
|
|
if (this.navInfo.type === 'navbar') {
|
|
|
// 从金刚区菜单进入
|
|
|
this.listQuery.homeTypeId = this.navInfo.id
|
|
|
- this.listType = 2
|
|
|
+ this.listQuery.listType = 2
|
|
|
} else if (this.navInfo.type === 'floor') {
|
|
|
// 从楼层进入
|
|
|
- this.homeFloorId = this.navInfo.id
|
|
|
- this.listType = 3
|
|
|
+ this.listQuery.homeFloorId = this.navInfo.id
|
|
|
+ this.listQuery.listType = 3
|
|
|
} else if (this.navInfo.type === 'second') {
|
|
|
// 从二级菜单进入
|
|
|
- this.smallTypeId = this.navInfo.id
|
|
|
+ this.listQuery.smallTypeId = this.navInfo.id
|
|
|
+ this.listQuery.listType = 4
|
|
|
}
|
|
|
this.fetchProductList()
|
|
|
},
|
|
@@ -80,6 +106,14 @@ export default {
|
|
|
// 加载更多
|
|
|
loadMore() {
|
|
|
if (!this.hasNextPage) return
|
|
|
+ this.isLoading = true
|
|
|
+ this.fetchProductList()
|
|
|
+ },
|
|
|
+
|
|
|
+ // 搜索商品
|
|
|
+ filterProductList() {
|
|
|
+ this.productList = []
|
|
|
+ this.listQuery.pageNum = 1
|
|
|
this.fetchProductList()
|
|
|
},
|
|
|
|
|
@@ -92,6 +126,7 @@ export default {
|
|
|
this.total = resultProductData.data.totalRecord
|
|
|
this.listQuery.pageNum++
|
|
|
this.isRequest = false
|
|
|
+ this.isLoading = false
|
|
|
} catch (e) {
|
|
|
console.log('获取商品列表失败')
|
|
|
}
|
|
@@ -105,16 +140,11 @@ export default {
|
|
|
box-sizing: border-box;
|
|
|
min-height: 100vh;
|
|
|
.product-list {
|
|
|
- // @extend .cm-flex-between;
|
|
|
- // flex-wrap: wrap;
|
|
|
display: grid;
|
|
|
grid-template-columns: repeat(3, 1fr);
|
|
|
- // grid-template-rows: repeat(2, 1fr);
|
|
|
- grid-row-gap: 12rpx;
|
|
|
- padding: 0 24rpx;
|
|
|
- .product-item {
|
|
|
- width: 224rpx;
|
|
|
- }
|
|
|
+ grid-row-gap: 16rpx;
|
|
|
+ grid-column-gap: 16rpx;
|
|
|
+ padding: 16rpx 24rpx;
|
|
|
}
|
|
|
}
|
|
|
</style>
|