邓洁 : 店铺转让下拉刷新重置数据

This commit is contained in:
dengj
2023-11-20 13:34:16 +08:00
parent 7dd511513a
commit 495cd0dc07
3 changed files with 80 additions and 21 deletions

View File

@@ -49,7 +49,7 @@
}
} else if (this.type === '面积') {
this.queryInfo = {
areaType: this.activeIndex + 1
areatype: this.activeIndex + 1
}
} else if (this.type === '筛选') {
this.queryInfo = {

View File

@@ -36,7 +36,7 @@
"navigationBarTitleText": "店铺转让",
"navigationBarTextStyle": "white",
"navigationBarBackgroundColor": "#339967",
"enablePullDownRefresh": false
"enablePullDownRefresh": true
}
},
{
@@ -45,7 +45,7 @@
"navigationBarTitleText": "找店地址",
"navigationBarTextStyle": "white",
"navigationBarBackgroundColor": "#339967",
"enablePullDownRefresh": false
"enablePullDownRefresh": true
}
},
{

View File

@@ -1,19 +1,22 @@
<template>
<view class="root">
<InputAndSwiper></InputAndSwiper>
<view>
<view class="dropdown-bug">
</view>
<view class="marginLR10">
<DropDown @getQueryInfo = "getShopList"></DropDown>
<DropDown @getQueryInfo="getShopList"></DropDown>
</view>
<view class="marginLR10">
<ShowShopList :showStyle="1" :shopInfoList="shopInfoList"></ShowShopList>
</view>
</view>
<view v-if="showNull" class="showNull">
<text>没有符合条件的数据, 请下拉刷新重置数据~
</text>
</view>
<TabBar :current-page="1"></TabBar>
</view>
</template>
@@ -26,42 +29,88 @@
},
data() {
return {
pageSize: 5,
pageSize: 3,
pageNum: 1,
shopInfoList: [],
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
}
},
methods: {
getShopList(q){
let query = this.getQueryInfo(q)
console.log("listquery",query);
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);
})
},
getQueryInfo(query){
console.log("getQueryInfo",query);
getQueryInfo(query) {
console.log('this.',this.refresh);
const q = this.$u.queryParams({
type: 1,
pageSize: this.pageSize,
pageNum: this.pageNum,
...query
})
this.customQuery = q
return q
},
// resetQuery(query){
// console.log('ddd',query);
// const q = this.$u.queryParams({
// type: 1,
// pageSize: 5,
// pageNum: 1,
// ...query
// })
// }
},
created() {
this.getShopList()
@@ -73,9 +122,19 @@
page {
background-color: $uni-bg-color-grey;
}
.root{
.showNull {
display: flex;
align-items: center;
justify-content: center;
height: 100rpx;
color: darkgray;
}
.root {
position: relative;
}
.dropdown-bug {
position: absolute;
background-color: $uni-bg-color-grey;
@@ -84,8 +143,8 @@
transform: translateY(-20rpx);
z-index: 2;
}
.marginLR10{
.marginLR10 {
margin: 0 10px;
}
</style>
</style>