fix:未选店铺时提示选择,不静默显示空记录

This commit is contained in:
ShenQiLun 2026-07-01 09:51:39 +08:00
parent d64c9aad01
commit bba26b1578

View File

@ -53,7 +53,12 @@
<!-- 记录列表 --> <!-- 记录列表 -->
<scroll-view class="record-scroll" scroll-y :refresher-enabled="true" :refresher-triggered="isRefreshing" @refresherrefresh="onRefresh" @scrolltolower="loadMore"> <scroll-view class="record-scroll" scroll-y :refresher-enabled="true" :refresher-triggered="isRefreshing" @refresherrefresh="onRefresh" @scrolltolower="loadMore">
<view class="record-list"> <view class="empty-hint" v-if="!hasShopSelected">
<text class="empty-hint-icon">👆</text>
<text class="empty-hint-text">请在上方选择一个店铺</text>
<text class="empty-hint-desc">选择店铺后即可查看该店铺的上书记录</text>
</view>
<view class="record-list" v-else>
<view class="record-item" v-for="(item, index) in recordList" :key="index"> <view class="record-item" v-for="(item, index) in recordList" :key="index">
<view class="record-main"> <view class="record-main">
<!-- 图片 --> <!-- 图片 -->
@ -119,7 +124,7 @@
</view> </view>
<!-- 空状态 --> <!-- 空状态 -->
<view class="empty-state" v-if="recordList.length === 0 && !isLoading"> <view class="empty-state" v-if="recordList.length === 0 && !isLoading && hasShopSelected">
<text class="empty-icon">📭</text> <text class="empty-icon">📭</text>
<text class="empty-text">暂无上书记录</text> <text class="empty-text">暂无上书记录</text>
</view> </view>
@ -160,7 +165,12 @@ export default {
onLoad() { onLoad() {
uni.setNavigationBarTitle({ title: '上书记录' }) uni.setNavigationBarTitle({ title: '上书记录' })
this.loadShopList() this.loadShopList()
this.fetchRecords() },
computed: {
hasShopSelected() {
return this.shopIndex > 0
}
}, },
methods: { methods: {
@ -223,15 +233,13 @@ export default {
// //
async fetchRecords() { async fetchRecords() {
if (this.isLoading || this.loadingMore) return if (this.isLoading || this.loadingMore) return
if (!this.hasShopSelected) {
this.isLoading = false
return
}
this.isLoading = true this.isLoading = true
try { try {
const shopId = this.getSelectedShopId() const shopId = this.getSelectedShopId()
if (!shopId) {
this.isLoading = false
this.recordList = []
this.hasMore = false
return
}
const params = { const params = {
page: this.page, page: this.page,
page_size: this.pageSize, page_size: this.pageSize,
@ -609,6 +617,33 @@ export default {
100% { transform: rotate(360deg); } 100% { transform: rotate(360deg); }
} }
/* 提示选择店铺 */
.empty-hint {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
padding: 160rpx 40rpx;
}
.empty-hint-icon {
font-size: 60rpx;
margin-bottom: 24rpx;
}
.empty-hint-text {
font-size: 30rpx;
color: #4e5969;
font-weight: 500;
margin-bottom: 12rpx;
}
.empty-hint-desc {
font-size: 26rpx;
color: #909399;
text-align: center;
}
/* 空状态 */ /* 空状态 */
.empty-state { .empty-state {
display: flex; display: flex;