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

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 === '面积') { } else if (this.type === '面积') {
this.queryInfo = { this.queryInfo = {
areaType: this.activeIndex + 1 areatype: this.activeIndex + 1
} }
} else if (this.type === '筛选') { } else if (this.type === '筛选') {
this.queryInfo = { this.queryInfo = {

View File

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

View File

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