邓洁 : 下拉框筛选数据和重置数据

This commit is contained in:
dengj
2023-11-20 14:14:10 +08:00
parent 354369fba0
commit 33f2943eef
5 changed files with 218 additions and 23 deletions

View File

@@ -17,6 +17,10 @@
<view class="marginLR10">
<ShowShopList :showStyle="1" :shopInfoList="shopInfoList" />
</view>
<view v-if="showNull" class="showNull">
<text>没有符合条件的数据, 请下拉刷新重置数据~
</text>
</view>
</view>
</template>
@@ -33,26 +37,63 @@
pageNum: 1,
customQuery: {},
shopListLength: '',
showNull: false,
refresh: false
}
},
onPullDownRefresh() {
this.refresh=true
// if (this.showNull = true) {
const q = this.$u.queryParams({
type: 1,
pageSize: this.pageSize,
pageNum: 1,
})
// if(this.showNull=true){
// this.pageNum=1
// }
this.getShopList(q, "refresh")
// }
},
onReachBottom() {
if (this.shopInfoList.length !== 0) {
if (!this.refresh&&this.shopListLength !== 0) {
this.pageNum++
this.getShopList()
console.log("触底加载");
}else if(this.shopListLength == 0){
this.pageNum=1
}
},
onLoad() {
this.getShopList()
},
methods: {
getShopList(q) {
let query = this.getQueryInfo(q)
getShopList(q, type) {
let query = {}
if (type == "refresh") {
query = q
} else {
query = this.getQueryInfo(q)
}
console.log("listquery", query);
this.$api.getShopList(query).then(res => {
this.shopListLength = res.data.data.length
this.shopInfoList = [...this.shopInfoList, ...res.data.data]
if (query.includes('business') || query.includes('areatype') || query.includes('sortType') || query
.includes('region')||this.refresh) {
console.log('筛选');
// this.resetQuery(q)
this.shopInfoList = res.data.data
this.refresh=false
if (res.data.data.length == 0) {
this.showNull = true
} else {
this.showNull = false
}
} else {
console.log('查询');
this.shopInfoList = [...this.shopInfoList, ...res.data.data]
}
console.log(this.shopInfoList);
})
},
@@ -75,7 +116,13 @@
page {
background-color: #F8F8F8;
}
.showNull {
display: flex;
align-items: center;
justify-content: center;
height: 100rpx;
color: darkgray;
}
.marginLR10 {
margin: 0 10px;
}