新增首页 AW炫彩回收入口,支持后台配置展示图

首页第三入口点击查看回收说明图;配置项 mobile.aw_recycle 可配标题/图片;aw-recycle 走公开文件链路,首页鉴权预览兼容旧私有地址。
This commit is contained in:
yml2213
2026-07-19 22:50:16 +08:00
parent dabcec45cb
commit 9b1ee445b7
14 changed files with 533 additions and 18 deletions
@@ -1,7 +1,6 @@
<script setup lang="ts">
import { computed, nextTick, onBeforeUnmount, onMounted, ref, watch } from 'vue'
import { onBeforeRouteLeave, RouterLink, useRoute, useRouter } from 'vue-router'
import { showToast } from 'vant'
import MobileBottomNav from '@/components/MobileBottomNav.vue'
import { ensureSupportChat, resolveSupportScene } from '@/features/chats/api/chats'
import { formatCent, formatMoney } from '@/shared/utils/money'
@@ -15,11 +14,15 @@ import {
type PublicListingQuery,
} from '@/features/listings/api/listings'
import {
defaultAWRecycleConfig,
defaultHomeAnnouncements,
defaultHomeBanners,
fetchMobileHomeConfig,
type AWRecycleConfig,
type HomeBannerSlide,
} from '@/features/listings/api/homeConfig'
import { showImagePreview, showToast } from 'vant'
import { fetchFileBlobByURL } from '@/shared/api/files'
import MobileHomeFilterSheet, { type FilterSection } from './MobileHomeFilterSheet.vue'
import {
clearStoredHomeQuery,
@@ -76,6 +79,7 @@ const refreshing = ref(false)
const searchValue = ref('')
const announcements = ref<string[]>(defaultHomeAnnouncements)
const bannerSlides = ref<HomeBannerSlide[]>(defaultHomeBanners)
const awRecycle = ref<AWRecycleConfig>({ ...defaultAWRecycleConfig })
const supportLoading = ref(false)
const showBackTop = ref(false)
const mobilePageSize = 10
@@ -457,6 +461,7 @@ async function loadHomeConfig() {
const config = await fetchMobileHomeConfig()
announcements.value = config.announcements
bannerSlides.value = config.banners
awRecycle.value = config.aw_recycle
publishOptions.value = config.publish_options
homeCache.saveHomeConfig({
announcements: config.announcements,
@@ -466,10 +471,39 @@ async function loadHomeConfig() {
} catch {
announcements.value = defaultHomeAnnouncements
bannerSlides.value = defaultHomeBanners
awRecycle.value = { ...defaultAWRecycleConfig }
publishOptions.value = emptyListingPublishOptions
}
}
async function openAWRecycle() {
const source = awRecycle.value.image_url
if (!source) {
showToast({ message: '回收说明图片尚未配置', icon: 'warning-o' })
return
}
try {
// 私有 /api/files/object 需带鉴权拉取;公开 /api/public/files 可直接预览
let previewURL = source
if (
source.includes('/api/files/object') ||
source.includes('/api/admin/files/object')
) {
const blob = await fetchFileBlobByURL(source)
previewURL = URL.createObjectURL(blob)
}
showImagePreview({
images: [previewURL],
closeable: true,
})
} catch {
showToast({
message: '图片加载失败,请在后台重新上传(需使用公开图)',
icon: 'cross',
})
}
}
async function onRefresh() {
refreshing.value = true
try {
@@ -477,6 +511,7 @@ async function onRefresh() {
const [, nextHomeConfig] = await Promise.all([loadListings(true), fetchMobileHomeConfig()])
announcements.value = nextHomeConfig.announcements
bannerSlides.value = nextHomeConfig.banners
awRecycle.value = nextHomeConfig.aw_recycle
publishOptions.value = nextHomeConfig.publish_options
homeCache.saveHomeConfig({
announcements: nextHomeConfig.announcements,
@@ -842,6 +877,15 @@ syncMobileHomeQuery()
<small>选购商品 · 一键找客服</small>
<em class="biz-entry-badge">NEW</em>
</RouterLink>
<button
v-if="awRecycle.enabled"
type="button"
class="biz-entry aw-recycle"
@click="openAWRecycle"
>
<strong>{{ awRecycle.title }}</strong>
<small>{{ awRecycle.subtitle }}</small>
</button>
</div>
<div class="zone-strip" aria-label="账号专区">