From e459fd740a6ea293cb3f18509c70fc591af23254 Mon Sep 17 00:00:00 2001 From: qiuyuan Date: Mon, 28 Jul 2025 16:40:33 +0800 Subject: [PATCH] =?UTF-8?q?=E5=91=A8=E8=BE=B9=E6=9C=8D=E5=8A=A1=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/aroundDetail/index.vue | 586 ++++++++++++++++++++++++++++++----- pages/neighbor/index.vue | 407 ++++++++++++------------ 2 files changed, 718 insertions(+), 275 deletions(-) diff --git a/pages/aroundDetail/index.vue b/pages/aroundDetail/index.vue index dc8d5d4..308b21f 100644 --- a/pages/aroundDetail/index.vue +++ b/pages/aroundDetail/index.vue @@ -1,19 +1,123 @@ @@ -22,90 +126,416 @@ import { get, post } from '@/utils/request'; import { IMAGE_BASE_URL, BASE_URL } from '@/utils/config'; import { formatTime, formatRelativeTime } from '@/utils/timeFormat'; + export default { data() { return { - formatTime, - IMAGE_BASE_URL, - Id:null, - detailInfo: {}, - local:null, + formatTime, + IMAGE_BASE_URL, + Id: null, + defaultCover: '/static/images/default-store-cover.png', + detailInfo: { + storeName: '', + storeCover: '', + storeAddress: '', + openAt: '', + content: '', + labels: [], + remark: '', + detailImages: [], + id: '', + createdAt: '', + updatedAt: '', + deletedAt: 0, + createdId: '', + deletedId: '', + typeId: '', + longitude: '', + latitude: '', + price: 0, + sequence: 0, + link: '', + status: 1 + }, + local: null, + } + }, + computed: { + statusText() { + const statusMap = { + 1: '营业中', + 2: '已关闭', + 3: '即将开业', + 0: '未知状态' + }; + return statusMap[this.detailInfo.status] || `状态: ${this.detailInfo.status}`; + }, + statusClass() { + const statusMap = { + 1: 'status-open', + 2: 'status-closed', + 3: 'status-soon' + }; + return statusMap[this.detailInfo.status] || 'status-default'; + }, + statusIcon() { + const iconMap = { + 1: 'home-fill', + 2: 'close-circle-fill', + 3: 'clock-fill' + }; + return iconMap[this.detailInfo.status] || 'question-circle-fill'; } }, onLoad(options) { - if (options && options.Id && options.local) { - this.Id = options.Id; - this.local = options.local; - } + if (options && options.Id && options.local) { + this.Id = options.Id; + this.local = options.local; + } }, - mounted(){ - this.getAroundDetail(); + mounted() { + this.getAroundDetail(); }, methods: { - async getAroundDetail(){ - try { - const res = await get(`/api/v1/apps/surrounding/${this.Id}`); - if (!res || !res.success) { - throw new Error('获取详情失败'); - } - res.data.storeCover = IMAGE_BASE_URL + res.data.storeCover; - this.detailInfo = {...res.data}; - } catch (err) { - console.error('获取详情失败:', err); - } - - } + formatDistance(distance) { + if (!distance) return '未知距离'; + if (distance < 1000) { + return `${distance}米`; + } else { + return `${(distance / 1000).toFixed(1)}公里`; + } + }, + + async getAroundDetail() { + try { + const res = await get(`/api/v1/apps/surrounding/${this.Id}`); + if (!res || !res.success) { + throw new Error('获取详情失败'); + } + + if (res.data.storeCover) { + res.data.storeCover = res.data.storeCover.startsWith('http') ? res.data.storeCover : IMAGE_BASE_URL + res.data.storeCover; + } + + this.detailInfo = {...this.detailInfo, ...res.data}; + } catch (err) { + console.error('获取详情失败:', err); + uni.showToast({ + title: '获取详情失败', + icon: 'none' + }); + } + }, + + openMap() { + const { latitude, longitude, storeName, storeAddress } = this.detailInfo; + if (latitude && longitude) { + uni.openLocation({ + latitude: Number(latitude), + longitude: Number(longitude), + name: storeName, + address: storeAddress, + success: () => { + console.log('打开地图成功'); + }, + fail: (err) => { + console.error('打开地图失败:', err); + uni.showToast({ + title: '打开地图失败', + icon: 'none' + }); + } + }); + } else { + uni.showToast({ + title: '暂无位置信息', + icon: 'none' + }); + } + }, + + previewImage(index) { + if (!this.detailInfo.detailImages || !this.detailInfo.detailImages.length) return; + + uni.previewImage({ + current: index, + urls: this.detailInfo.detailImages.map(img => img.startsWith('http') ? img : IMAGE_BASE_URL + img) + }); + }, + + handleShare() { + uni.showActionSheet({ + itemList: ['分享到微信', '分享到朋友圈', '复制链接'], + success: (res) => { + uni.showToast({ + title: `已选择: ${res.tapIndex === 0 ? '微信' : res.tapIndex === 1 ? '朋友圈' : '复制链接'}`, + icon: 'none' + }); + } + }); + } } } - \ No newline at end of file