功能:完善门店能力与用户安全配置
This commit is contained in:
@@ -24,6 +24,7 @@
|
||||
{{ shopInfo.address }}
|
||||
<span class="copy-icon">📋</span>
|
||||
</p>
|
||||
<p v-if="distanceText" class="shop-distance">{{ distanceText }}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="shop-details">
|
||||
@@ -36,6 +37,14 @@
|
||||
<div class="detail-value">{{ shopInfo.description }}</div>
|
||||
</div>
|
||||
</div>
|
||||
<a-button class="contact-btn" type="primary" block @click="openManagerContact">
|
||||
一键联系店长
|
||||
</a-button>
|
||||
<div v-if="hasLocation" class="map-actions">
|
||||
<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>
|
||||
@@ -57,6 +66,14 @@
|
||||
>
|
||||
<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>
|
||||
</a-card>
|
||||
</div>
|
||||
@@ -64,12 +81,17 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, onMounted } from 'vue'
|
||||
/**
|
||||
* 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 { message } from 'ant-design-vue'
|
||||
import { shopApi, type ShopVO } from '@/api/shop'
|
||||
import { fileApi } from '@/api/file'
|
||||
import { userApi, type ContactInfoVO } from '@/api/user'
|
||||
import { toOptionalIdString } from '@/utils/id'
|
||||
|
||||
const router = useRouter()
|
||||
@@ -80,6 +102,9 @@ const shopInfo = ref<ShopVO>({
|
||||
shopName: '',
|
||||
description: '',
|
||||
address: '',
|
||||
mapProvider: 'TENCENT',
|
||||
longitude: '',
|
||||
latitude: '',
|
||||
businessHours: '',
|
||||
imageFileIds: '',
|
||||
createTime: '',
|
||||
@@ -89,26 +114,94 @@ 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 distanceText = ref('')
|
||||
|
||||
/** handleBackClick is a local helper used by this page script. */
|
||||
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 = () => {
|
||||
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)
|
||||
contactOpen.value = true
|
||||
} catch (error: any) {
|
||||
message.error(error?.message || '获取联系方式失败')
|
||||
}
|
||||
}
|
||||
|
||||
const openMapPreview = () => {
|
||||
const url = shopInfo.value.navigationUrls?.BROWSER || shopInfo.value.navigationUrls?.TENCENT
|
||||
if (!url) {
|
||||
message.warning('店铺暂未设置地图位置')
|
||||
return
|
||||
}
|
||||
window.open(url, '_blank')
|
||||
}
|
||||
|
||||
const openNavigation = (provider: 'TENCENT' | 'AMAP') => {
|
||||
const url = shopInfo.value.navigationUrls?.[provider]
|
||||
if (!url) {
|
||||
message.warning('店铺暂未设置地图位置')
|
||||
return
|
||||
}
|
||||
window.open(url, '_blank')
|
||||
}
|
||||
|
||||
const calculateDistanceText = (currentLat: number, currentLng: number) => {
|
||||
const shopLat = Number(shopInfo.value.latitude)
|
||||
const shopLng = Number(shopInfo.value.longitude)
|
||||
if (!Number.isFinite(currentLat) || !Number.isFinite(currentLng) || !Number.isFinite(shopLat) || !Number.isFinite(shopLng)) {
|
||||
distanceText.value = ''
|
||||
return
|
||||
}
|
||||
const toRad = (value: number) => value * Math.PI / 180
|
||||
const earthRadius = 6371000
|
||||
const dLat = toRad(shopLat - currentLat)
|
||||
const dLng = toRad(shopLng - currentLng)
|
||||
const a = Math.sin(dLat / 2) ** 2 + Math.cos(toRad(currentLat)) * Math.cos(toRad(shopLat)) * Math.sin(dLng / 2) ** 2
|
||||
const meters = 2 * earthRadius * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a))
|
||||
distanceText.value = meters >= 1000 ? `距你约 ${(meters / 1000).toFixed(1)} km` : `距你约 ${Math.round(meters)} m`
|
||||
}
|
||||
|
||||
const loadCurrentDistance = () => {
|
||||
if (!hasLocation.value || !navigator.geolocation) {
|
||||
return
|
||||
}
|
||||
navigator.geolocation.getCurrentPosition(
|
||||
position => calculateDistanceText(position.coords.latitude, position.coords.longitude),
|
||||
() => {
|
||||
distanceText.value = ''
|
||||
},
|
||||
{ enableHighAccuracy: false, timeout: 8000, maximumAge: 300000 }
|
||||
)
|
||||
}
|
||||
|
||||
// 复制到剪贴板
|
||||
/** 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) => {
|
||||
try {
|
||||
await navigator.clipboard.writeText(text)
|
||||
@@ -119,6 +212,7 @@ const copyToClipboard = async (text: string, type: string) => {
|
||||
}
|
||||
}
|
||||
|
||||
/** 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
|
||||
@@ -147,6 +241,7 @@ const loadShopImages = async () => {
|
||||
}
|
||||
}
|
||||
|
||||
/** fetchShopDetail is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
|
||||
const fetchShopDetail = async () => {
|
||||
try {
|
||||
// 从路由参数或本地存储获取店铺ID
|
||||
@@ -162,6 +257,7 @@ const fetchShopDetail = async () => {
|
||||
|
||||
// 加载店铺图片
|
||||
await loadShopImages()
|
||||
loadCurrentDistance()
|
||||
} catch (error) {
|
||||
message.error('获取店铺详情失败')
|
||||
}
|
||||
@@ -284,6 +380,12 @@ onMounted(() => {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.shop-distance {
|
||||
margin: 6px 0 0;
|
||||
color: #7a5262;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.copy-icon {
|
||||
font-size: 12px;
|
||||
margin-left: 6px;
|
||||
@@ -303,6 +405,22 @@ onMounted(() => {
|
||||
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;
|
||||
|
||||
Reference in New Issue
Block a user