修复一些问题,优化前后端交互接口格式,优化首页轮播图图的维护
This commit is contained in:
@@ -16,8 +16,14 @@
|
||||
<ShopOutlined class="shop-icon" />
|
||||
</div>
|
||||
<div class="shop-header-content">
|
||||
<h2 class="shop-name">{{ shopInfo.shopName }}</h2>
|
||||
<p class="shop-address">{{ shopInfo.address }}</p>
|
||||
<h2 class="shop-name" @click="copyToClipboard(shopInfo.shopName, '店名')" style="cursor: pointer;">
|
||||
{{ shopInfo.shopName }}
|
||||
<span class="copy-icon">📋</span>
|
||||
</h2>
|
||||
<p class="shop-address" @click="copyToClipboard(shopInfo.address, '地址')" style="cursor: pointer;">
|
||||
{{ shopInfo.address }}
|
||||
<span class="copy-icon">📋</span>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="shop-details">
|
||||
@@ -30,19 +36,27 @@
|
||||
<div class="detail-value">{{ shopInfo.description }}</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- 店铺环境图轮播 -->
|
||||
<div class="shop-images" v-if="shopImages.length > 0">
|
||||
<h3 class="section-title">店铺图片</h3>
|
||||
<div class="image-grid">
|
||||
<a-image
|
||||
v-for="(url, index) in shopImages"
|
||||
:key="index"
|
||||
:width="100"
|
||||
:height="100"
|
||||
:src="url"
|
||||
style="object-fit: cover; border-radius: 4px; margin: 4px;"
|
||||
/>
|
||||
<h3 class="section-title">店铺环境图</h3>
|
||||
<div class="image-carousel">
|
||||
<a-carousel autoplay :autoplay-speed="3000" effect="slide" dots>
|
||||
<div v-for="(url, index) in shopImages" :key="index" class="carousel-item" @click="showImageModal(url)">
|
||||
<img :src="url" :alt="`店铺环境图 ${index + 1}`" class="carousel-image" />
|
||||
</div>
|
||||
</a-carousel>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 图片查看模态框 -->
|
||||
<a-modal
|
||||
v-model:open="imageModalVisible"
|
||||
title="店铺环境图"
|
||||
:width="800"
|
||||
@cancel="handleCancel"
|
||||
>
|
||||
<img :src="selectedImage" alt="店铺环境图" class="modal-image" />
|
||||
</a-modal>
|
||||
</div>
|
||||
</a-card>
|
||||
</div>
|
||||
@@ -53,8 +67,9 @@
|
||||
import { ref, onMounted } from 'vue'
|
||||
import { useRouter, useRoute } from 'vue-router'
|
||||
import { LeftOutlined, ShopOutlined } from '@ant-design/icons-vue'
|
||||
import { message } from 'ant-design-vue'
|
||||
import { message, Modal } from 'ant-design-vue'
|
||||
import { shopApi, type ShopVO } from '@/api/shop'
|
||||
import { fileApi } from '@/api/file'
|
||||
|
||||
const router = useRouter()
|
||||
const route = useRoute()
|
||||
@@ -72,13 +87,72 @@ const shopInfo = ref<ShopVO>({
|
||||
|
||||
const shopImages = ref<string[]>([])
|
||||
|
||||
// 图片模态框
|
||||
const imageModalVisible = ref(false)
|
||||
const selectedImage = ref('')
|
||||
|
||||
const handleBackClick = () => {
|
||||
router.back()
|
||||
}
|
||||
|
||||
// 显示图片模态框
|
||||
const showImageModal = (imageUrl: string) => {
|
||||
selectedImage.value = imageUrl
|
||||
imageModalVisible.value = true
|
||||
}
|
||||
|
||||
// 关闭图片模态框
|
||||
const handleCancel = () => {
|
||||
imageModalVisible.value = false
|
||||
selectedImage.value = ''
|
||||
}
|
||||
|
||||
// 复制到剪贴板
|
||||
const copyToClipboard = async (text: string, type: string) => {
|
||||
try {
|
||||
await navigator.clipboard.writeText(text)
|
||||
message.success(`${type}已复制到剪贴板`)
|
||||
} catch (err) {
|
||||
console.error('复制失败:', err)
|
||||
message.error('复制失败,请手动复制')
|
||||
}
|
||||
}
|
||||
|
||||
const loadShopImages = async () => {
|
||||
// 由于ShopVO类型中没有imageFileIds属性,这里简化处理
|
||||
shopImages.value = []
|
||||
try {
|
||||
console.log('开始加载店铺环境图')
|
||||
const imageFileIds = shopInfo.value.imageFileIds
|
||||
console.log('imageFileIds:', imageFileIds)
|
||||
|
||||
if (imageFileIds) {
|
||||
const fileIds = imageFileIds.split(',').filter(id => id.trim())
|
||||
console.log('分割后的fileIds:', fileIds)
|
||||
|
||||
const fileIdPromises = fileIds.map(idStr => {
|
||||
const fileId = parseInt(idStr)
|
||||
console.log('处理fileId:', fileId)
|
||||
if (!isNaN(fileId)) {
|
||||
return fileApi.getSignedUrl(fileId).catch(err => {
|
||||
console.error('获取店铺环境图签名失败:', err)
|
||||
return null
|
||||
})
|
||||
}
|
||||
return null
|
||||
})
|
||||
|
||||
const results = await Promise.all(fileIdPromises)
|
||||
console.log('签名URL请求结果:', results)
|
||||
|
||||
const filteredResults = results.filter((url): url is string => url !== null).map(url => url.replace(/[`]/g, '').trim())
|
||||
console.log('过滤后结果:', filteredResults)
|
||||
console.log('过滤后数量:', filteredResults.length)
|
||||
|
||||
shopImages.value = filteredResults
|
||||
console.log('shopImages最终值:', shopImages.value)
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('加载店铺环境图失败:', error)
|
||||
}
|
||||
}
|
||||
|
||||
const fetchShopDetail = async () => {
|
||||
@@ -91,8 +165,12 @@ const fetchShopDetail = async () => {
|
||||
return
|
||||
}
|
||||
|
||||
console.log('请求店铺详情,shopId:', shopId)
|
||||
const response = await shopApi.getShopById(Number(shopId)) as any
|
||||
console.log('店铺详情响应:', response)
|
||||
|
||||
shopInfo.value = response || {}
|
||||
console.log('shopInfo.value:', shopInfo.value)
|
||||
|
||||
// 加载店铺图片
|
||||
await loadShopImages()
|
||||
@@ -219,6 +297,19 @@ onMounted(() => {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.copy-icon {
|
||||
font-size: 12px;
|
||||
margin-left: 6px;
|
||||
opacity: 0.6;
|
||||
transition: opacity 0.2s ease;
|
||||
}
|
||||
|
||||
.shop-name:hover .copy-icon,
|
||||
.shop-address:hover .copy-icon {
|
||||
opacity: 1;
|
||||
color: #667eea;
|
||||
}
|
||||
|
||||
.shop-details {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
@@ -250,9 +341,63 @@ onMounted(() => {
|
||||
margin: 0 0 12px 0;
|
||||
}
|
||||
|
||||
.image-grid {
|
||||
.image-carousel {
|
||||
margin: 12px 0;
|
||||
border-radius: 12px;
|
||||
overflow: hidden;
|
||||
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
|
||||
width: 100%;
|
||||
height: 200px;
|
||||
}
|
||||
|
||||
.carousel-item {
|
||||
width: 100%;
|
||||
height: 200px;
|
||||
cursor: pointer;
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 8px;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.carousel-image {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
transition: transform 0.3s ease;
|
||||
}
|
||||
|
||||
.carousel-item:hover .carousel-image {
|
||||
transform: scale(1.05);
|
||||
}
|
||||
|
||||
/* 轮播指示器样式 */
|
||||
.image-carousel :deep(.slick-dots) {
|
||||
bottom: 10px;
|
||||
}
|
||||
|
||||
.image-carousel :deep(.slick-dots li) {
|
||||
margin: 0 4px;
|
||||
}
|
||||
|
||||
.image-carousel :deep(.slick-dots li button) {
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
border-radius: 50%;
|
||||
background: rgba(0, 0, 0, 0.4);
|
||||
}
|
||||
|
||||
.image-carousel :deep(.slick-dots li.slick-active button) {
|
||||
width: 20px;
|
||||
border-radius: 4px;
|
||||
background: #667eea;
|
||||
}
|
||||
|
||||
.modal-image {
|
||||
width: 100%;
|
||||
max-height: 600px;
|
||||
object-fit: contain;
|
||||
border-radius: 8px;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user