杂务:整理文档并收口 YumiNail 修复

This commit is contained in:
xiaowang
2026-05-21 18:43:59 +08:00
parent 3797938616
commit 9227ec6175
362 changed files with 8358 additions and 19928 deletions
+228 -210
View File
@@ -1,6 +1,7 @@
<template>
<div class="shop-detail">
<div class="header-bg"></div>
<header class="header">
<a-button class="back-btn" type="text" @click="handleBackClick">
<LeftOutlined :style="{ fontSize: '20px' }" />
@@ -8,89 +9,99 @@
<h1>店铺详情</h1>
<div class="header-placeholder"></div>
</header>
<div class="shop-content">
<main class="shop-content">
<a-card :bordered="false" class="shop-card">
<div class="shop-info">
<div class="shop-header">
<div class="shop-icon-wrapper">
<ShopOutlined class="shop-icon" />
</div>
<div class="shop-header-content">
<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>
<p v-if="distanceText" class="shop-distance">{{ distanceText }}</p>
</div>
<section class="shop-header">
<div class="shop-icon-wrapper">
<ShopOutlined class="shop-icon" />
</div>
<div class="shop-details">
<div class="detail-item">
<div class="detail-label">营业时间</div>
<div class="detail-value">{{ shopInfo.businessHours }}</div>
</div>
<div class="detail-item">
<div class="detail-label">店铺描述</div>
<div class="detail-value">{{ shopInfo.description }}</div>
</div>
<div class="shop-header-content">
<h2 class="shop-name" @click="copyToClipboard(shopInfo.shopName, '店名')">
{{ shopInfo.shopName || '店铺' }}
<CopyOutlined class="copy-icon" />
</h2>
<p class="shop-address" @click="copyToClipboard(shopInfo.address, '地址')">
{{ shopInfo.address || '暂未设置详细地址' }}
<CopyOutlined v-if="shopInfo.address" class="copy-icon" />
</p>
<p v-if="distanceText" class="shop-distance">{{ distanceText }}</p>
</div>
<a-button class="contact-btn" type="primary" block @click="openManagerContact">
一键联系店长
</a-button>
<div v-if="hasLocation" class="map-actions">
</section>
<section class="shop-details">
<div class="detail-item">
<div class="detail-label">营业时间</div>
<div class="detail-value">{{ shopInfo.businessHours || '暂未设置' }}</div>
</div>
<div class="detail-item">
<div class="detail-label">店铺描述</div>
<div class="detail-value">{{ shopInfo.description || '暂无描述' }}</div>
</div>
</section>
<section class="action-area">
<a-button type="primary" block @click="openManagerContact">一键联系店长</a-button>
<template v-if="hasLocation">
<a-button block @click="openMapPreview">查看地图位置</a-button>
<a-button block @click="openNavigation('TENCENT')">腾讯地图导航</a-button>
<a-button block @click="openNavigation('AMAP')">高德地图导航</a-button>
</div>
<!-- 店铺环境图轮播 -->
<div class="shop-images" v-if="shopImages.length > 0">
<h3 class="section-title">店铺环境图</h3>
<div class="image-carousel">
<a-carousel autoplay :autoplay-speed="3000" 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 class="navigation-actions">
<a-button block @click="openNavigation('TENCENT')">腾讯地图导航</a-button>
<a-button block @click="openNavigation('AMAP')">高德地图导航</a-button>
</div>
</template>
<a-alert v-else type="info" show-icon message="店铺暂未设置地图位置" />
</section>
<section v-if="shopImages.length > 0" class="shop-images">
<h3 class="section-title">店铺环境图</h3>
<div class="image-carousel">
<a-carousel autoplay :autoplay-speed="3000" dots>
<div v-for="(url, index) in shopImages" :key="url" class="carousel-item" @click="showImageModal(url)">
<img :src="url" :alt="`店铺环境图 ${index + 1}`" class="carousel-image" />
</div>
</a-carousel>
</div>
<!-- 图片查看模态框 -->
<a-modal
v-model:open="imageModalVisible"
title="店铺环境图"
:width="800"
@cancel="handleCancel"
>
<img :src="selectedImage" alt="店铺环境图" class="modal-image" />
</a-modal>
<a-modal v-model:open="contactOpen" title="一键联系" :footer="null">
<div class="contact-box">
<p><strong>{{ contactInfo.contactName || contactInfo.roleLabel || '联系人' }}</strong></p>
<p>电话联系:{{ contactInfo.phoneAvailable ? contactInfo.phone : '暂无电话' }}</p>
<a-button v-if="contactInfo.phoneAvailable" type="primary" block :href="`tel:${contactInfo.phone}`">拨打电话</a-button>
<a-button block disabled>{{ contactInfo.platformContactText || '平台联系暂未接入' }}</a-button>
</div>
</a-modal>
</div>
</section>
</a-card>
</div>
</main>
<a-modal v-model:open="imageModalVisible" title="店铺环境图" :width="800" :footer="null" @cancel="handleImageCancel">
<img :src="selectedImage" alt="店铺环境图" class="modal-image" />
</a-modal>
<a-modal v-model:open="contactOpen" title="一键联系" :footer="null">
<div class="contact-box">
<p class="contact-name">{{ contactInfo.contactName || contactInfo.roleLabel || '联系人' }}</p>
<p>电话联系:{{ contactInfo.phoneAvailable ? contactInfo.phone : '暂无电话' }}</p>
<a-button v-if="contactInfo.phoneAvailable" type="primary" block :href="`tel:${contactInfo.phone}`">拨打电话</a-button>
<a-button block disabled>{{ contactInfo.platformContactText || '平台联系暂未接入' }}</a-button>
</div>
</a-modal>
<a-modal v-model:open="mapOpen" title="店铺位置" :width="900" :footer="null" class="map-modal">
<div class="map-panel">
<div class="map-summary">
<strong>{{ shopInfo.shopName }}</strong>
<span>{{ shopInfo.address }}</span>
<span v-if="distanceText">{{ distanceText }}</span>
</div>
<iframe v-if="mapPreviewUrl" class="map-frame" :src="mapPreviewUrl" title="店铺地图位置"></iframe>
<div class="navigation-actions">
<a-button type="primary" block @click="openNavigation('TENCENT')">腾讯地图导航</a-button>
<a-button block @click="openNavigation('AMAP')">高德地图导航</a-button>
</div>
</div>
</a-modal>
</div>
</template>
<script setup lang="ts">
/**
* ShopDetailView page script.
* Call guide: the template binds the reactive state below, and the methods are triggered by button clicks, lifecycle hooks, or router events.
*/
import { computed, ref, onMounted } from 'vue'
import { useRouter, useRoute } from 'vue-router'
import { LeftOutlined, ShopOutlined } from '@ant-design/icons-vue'
import { computed, onMounted, ref } from 'vue'
import { useRoute, useRouter } from 'vue-router'
import { CopyOutlined, LeftOutlined, ShopOutlined } from '@ant-design/icons-vue'
import { message } from 'ant-design-vue'
import { shopApi, type ShopVO } from '@/api/shop'
import { fileApi } from '@/api/file'
import { shopApi, type ShopVO } from '@/api/shop'
import { userApi, type ContactInfoVO } from '@/api/user'
import { toOptionalIdString } from '@/utils/id'
@@ -112,38 +123,30 @@ const shopInfo = ref<ShopVO>({
})
const shopImages = ref<string[]>([])
// 图片模态框
/** imageModalVisible is a reactive state variable used by the template and event handlers. */
const imageModalVisible = ref(false)
/** selectedImage is a reactive state variable used by the template and event handlers. */
const selectedImage = ref('')
/** contactOpen is a reactive state variable used by the template and event handlers. */
const contactOpen = ref(false)
const contactInfo = ref<ContactInfoVO>({})
const hasLocation = computed(() => Boolean(shopInfo.value.longitude && shopInfo.value.latitude))
const mapOpen = ref(false)
const distanceText = ref('')
/** handleBackClick is a local helper used by this page script. */
const hasLocation = computed(() => Boolean(shopInfo.value.longitude && shopInfo.value.latitude))
const mapPreviewUrl = computed(() => shopInfo.value.navigationUrls?.BROWSER || shopInfo.value.navigationUrls?.TENCENT || '')
const handleBackClick = () => {
router.back()
}
// 显示图片模态框
/** showImageModal is a local helper used by this page script. */
const showImageModal = (imageUrl: string) => {
selectedImage.value = imageUrl
imageModalVisible.value = true
}
// 关闭图片模态框
/** handleCancel is a local helper used by this page script. */
const handleCancel = () => {
const handleImageCancel = () => {
imageModalVisible.value = false
selectedImage.value = ''
}
/** openManagerContact is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
const openManagerContact = async () => {
try {
contactInfo.value = await userApi.getShopManagerContact(shopInfo.value.id)
@@ -154,12 +157,11 @@ const openManagerContact = async () => {
}
const openMapPreview = () => {
const url = shopInfo.value.navigationUrls?.BROWSER || shopInfo.value.navigationUrls?.TENCENT
if (!url) {
if (!mapPreviewUrl.value) {
message.warning('店铺暂未设置地图位置')
return
}
window.open(url, '_blank')
mapOpen.value = true
}
const openNavigation = (provider: 'TENCENT' | 'AMAP') => {
@@ -178,6 +180,7 @@ const calculateDistanceText = (currentLat: number, currentLng: number) => {
distanceText.value = ''
return
}
const toRad = (value: number) => value * Math.PI / 180
const earthRadius = 6371000
const dLat = toRad(shopLat - currentLat)
@@ -188,9 +191,7 @@ const calculateDistanceText = (currentLat: number, currentLng: number) => {
}
const loadCurrentDistance = () => {
if (!hasLocation.value || !navigator.geolocation) {
return
}
if (!hasLocation.value || !navigator.geolocation) return
navigator.geolocation.getCurrentPosition(
position => calculateDistanceText(position.coords.latitude, position.coords.longitude),
() => {
@@ -200,78 +201,55 @@ const loadCurrentDistance = () => {
)
}
// 复制到剪贴板
/** copyToClipboard is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
const copyToClipboard = async (text: string, type: string) => {
if (!text) return
try {
await navigator.clipboard.writeText(text)
message.success(`${type}已复制到剪贴板`)
} catch (err) {
console.error('复制失败:', err)
} catch {
message.error('复制失败,请手动复制')
}
}
/** loadShopImages is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
const loadShopImages = async () => {
try {
const imageFileIds = shopInfo.value.imageFileIds
if (imageFileIds) {
const fileIds = imageFileIds.split(',').filter(id => id.trim())
const fileIdPromises = fileIds.map(idStr => {
const fileId = idStr.trim()
if (!fileId) {
return null
}
return fileApi.getSignedUrl(fileId).catch(() => {
return null
})
})
const results = await Promise.all(fileIdPromises)
const filteredResults = results
.filter((url): url is any => url !== null)
.map(url => {
const urlStr = typeof url === 'string' ? url : String(url)
return urlStr.replace(/[`]/g, '').trim()
})
shopImages.value = filteredResults
}
} catch (error) {
if (!imageFileIds) return
const fileIds = imageFileIds.split(',').map(id => id.trim()).filter(Boolean)
const results = await Promise.all(fileIds.map(fileId => fileApi.getSignedUrl(fileId).catch(() => null)))
shopImages.value = results
.filter(Boolean)
.map(url => String(url).replace(/[`]/g, '').trim())
} catch {
shopImages.value = []
}
}
/** fetchShopDetail is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
const fetchShopDetail = async () => {
try {
// 从路由参数或本地存储获取店铺ID
const shopId = toOptionalIdString(route.params.id || localStorage.getItem('userShopId'))
if (!shopId) {
message.error('店铺ID不存在')
router.back()
return
}
const response = await shopApi.getShopById(shopId) as any
shopInfo.value = response || {}
// 加载店铺图片
shopInfo.value = await shopApi.getShopById(shopId)
await loadShopImages()
loadCurrentDistance()
} catch (error) {
message.error('获取店铺详情失败')
} catch (error: any) {
message.error(error?.message || '获取店铺详情失败')
}
}
onMounted(() => {
fetchShopDetail()
})
onMounted(fetchShopDetail)
</script>
<style scoped>
.shop-detail {
min-height: 100vh;
background: #f5f5f5;
background: var(--bg-color);
position: relative;
}
@@ -281,7 +259,7 @@ onMounted(() => {
left: 0;
right: 0;
height: 120px;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
background: var(--theme-gradient);
z-index: 0;
}
@@ -299,9 +277,13 @@ onMounted(() => {
color: white;
}
.back-btn {
.back-btn,
.header-placeholder {
width: 40px;
height: 40px;
}
.back-btn {
display: flex;
align-items: center;
justify-content: center;
@@ -310,15 +292,10 @@ onMounted(() => {
.header h1 {
font-size: 18px;
font-weight: bold;
font-weight: 700;
margin: 0;
}
.header-placeholder {
width: 40px;
height: 40px;
}
.shop-content {
padding: 100px 15px 20px;
position: relative;
@@ -326,21 +303,15 @@ onMounted(() => {
}
.shop-card {
border-radius: 20px;
border-radius: 16px;
overflow: hidden;
box-shadow: 0 8px 30px rgba(0, 0, 0, 0.08);
box-shadow: 0 10px 30px rgba(31, 41, 55, 0.08);
}
.shop-card :deep(.ant-card-body) {
padding: 24px;
}
.shop-info {
display: flex;
flex-direction: column;
gap: 20px;
}
.shop-header {
display: flex;
align-items: center;
@@ -348,9 +319,9 @@ onMounted(() => {
}
.shop-icon-wrapper {
width: 80px;
height: 80px;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
width: 76px;
height: 76px;
background: var(--theme-gradient);
border-radius: 16px;
display: flex;
align-items: center;
@@ -359,111 +330,110 @@ onMounted(() => {
}
.shop-icon {
font-size: 36px;
font-size: 34px;
color: white;
}
.shop-header-content {
min-width: 0;
flex: 1;
}
.shop-name {
font-size: 22px;
font-weight: 700;
margin: 0 0 8px 0;
color: #1a1a2e;
margin: 0 0 8px;
color: #172033;
cursor: pointer;
}
.shop-address {
font-size: 14px;
color: #8b8b9a;
color: #667085;
margin: 0;
line-height: 1.5;
cursor: pointer;
}
.shop-distance {
margin: 6px 0 0;
color: #7a5262;
color: var(--theme-primary);
font-size: 13px;
}
.copy-icon {
font-size: 12px;
font-size: 13px;
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;
color: #8a94a6;
}
.shop-details {
display: flex;
flex-direction: column;
display: grid;
gap: 16px;
}
.contact-btn {
margin-top: 18px;
border-radius: 8px;
}
.map-actions {
display: grid;
gap: 10px;
margin-top: 12px;
}
.contact-box {
display: grid;
gap: 12px;
}
.detail-item {
display: flex;
flex-direction: column;
gap: 6px;
margin-top: 22px;
}
.detail-label {
font-size: 13px;
color: #8b8b9a;
font-weight: 500;
color: #8a94a6;
font-weight: 600;
}
.detail-value {
margin-top: 6px;
font-size: 16px;
color: #1a1a2e;
line-height: 1.5;
color: #172033;
line-height: 1.55;
}
.action-area {
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
gap: 10px;
margin-top: 22px;
}
.action-area .navigation-actions {
display: contents;
}
.action-area :deep(.ant-btn) {
min-width: 0;
}
.action-area :deep(.ant-alert) {
grid-column: 1 / -1;
}
.navigation-actions {
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
gap: 10px;
}
.shop-images {
margin-top: 24px;
}
.section-title {
font-size: 16px;
font-weight: 600;
color: #1a1a2e;
margin: 0 0 12px 0;
font-weight: 700;
color: #172033;
margin: 0 0 12px;
}
.image-carousel {
margin: 12px 0;
border-radius: 12px;
overflow: hidden;
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
box-shadow: 0 4px 12px rgba(31, 41, 55, 0.12);
width: 100%;
height: 200px;
height: 220px;
}
.carousel-item {
width: 100%;
height: 200px;
height: 220px;
cursor: pointer;
position: relative;
overflow: hidden;
display: flex;
align-items: center;
justify-content: center;
}
.carousel-image {
@@ -474,29 +444,24 @@ onMounted(() => {
}
.carousel-item:hover .carousel-image {
transform: scale(1.05);
transform: scale(1.04);
}
/* 轮播指示器样式 */
.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);
background: rgba(255, 255, 255, 0.65);
}
.image-carousel :deep(.slick-dots li.slick-active button) {
width: 20px;
border-radius: 4px;
background: #667eea;
background: white;
}
.modal-image {
@@ -506,6 +471,59 @@ onMounted(() => {
border-radius: 8px;
}
.contact-box,
.map-panel {
display: grid;
gap: 14px;
}
.contact-name {
margin: 0;
font-weight: 700;
color: #172033;
}
.map-summary {
display: grid;
gap: 4px;
color: #475467;
}
.map-frame {
width: 100%;
height: 420px;
border: 0;
border-radius: 10px;
background: #eef2f7;
}
@media (max-width: 640px) {
.shop-card :deep(.ant-card-body) {
padding: 18px;
}
.shop-header {
align-items: flex-start;
}
.shop-icon-wrapper {
width: 60px;
height: 60px;
}
.shop-name {
font-size: 19px;
}
.navigation-actions {
grid-template-columns: 1fr;
}
.map-frame {
height: 320px;
}
}
@media (min-width: 992px) {
.shop-content {
max-width: 1040px;