From 62235ef6fb5955e757cbce6d91226529c22d75c6 Mon Sep 17 00:00:00 2001 From: qiuyuan Date: Mon, 28 Jul 2025 10:40:48 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E8=81=94=E7=B3=BB=E7=A4=BE=E5=8C=BA?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/mine/index.vue | 1740 ++++++++++++++++++++++-------------------- 1 file changed, 898 insertions(+), 842 deletions(-) diff --git a/pages/mine/index.vue b/pages/mine/index.vue index 7f8aee2..4231e67 100644 --- a/pages/mine/index.vue +++ b/pages/mine/index.vue @@ -1,843 +1,899 @@ - - - - - \ No newline at end of file From 7a3a2d50daf59dd1b19bcd848b2fce843afa8bf4 Mon Sep 17 00:00:00 2001 From: qiuyuan Date: Mon, 28 Jul 2025 12:03:59 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BA=92=E5=8A=A9?= =?UTF-8?q?=E8=AF=A6=E6=83=85=E8=AF=84=E8=AE=BA=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/index/index.vue | 4 +- pages/neighborDetail/index.vue | 702 ++++++++++++++++++--------------- 2 files changed, 383 insertions(+), 323 deletions(-) diff --git a/pages/index/index.vue b/pages/index/index.vue index 2683ef8..8656f72 100644 --- a/pages/index/index.vue +++ b/pages/index/index.vue @@ -87,7 +87,7 @@ + style="width: 76rpx;height: 76rpx; bottom: 32rpx;" > @@ -503,7 +503,7 @@ width: 90rpx; height: 90rpx; right: 24rpx; - bottom: 24rpx; + bottom: 20rpx; transition: all 0.3s ease; } diff --git a/pages/neighborDetail/index.vue b/pages/neighborDetail/index.vue index 8867a8b..631c108 100644 --- a/pages/neighborDetail/index.vue +++ b/pages/neighborDetail/index.vue @@ -55,8 +55,7 @@ - {{ foldedComments.includes(comment.id) ? '展开' : '折叠' }} - {{ getChildCount(comment) }}条回复 + {{ getChildCount(comment) }}条回复{{ foldedComments.includes(comment.id) ? '展开' : '折叠' }} @@ -84,234 +83,269 @@ - \ No newline at end of file From e459fd740a6ea293cb3f18509c70fc591af23254 Mon Sep 17 00:00:00 2001 From: qiuyuan Date: Mon, 28 Jul 2025 16:40:33 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E5=91=A8=E8=BE=B9=E6=9C=8D=E5=8A=A1?= =?UTF-8?q?=E4=BF=AE=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 From a2dda03fdbb9739f50976fcbc8aec2f8c66f005f Mon Sep 17 00:00:00 2001 From: qiuyuan Date: Mon, 28 Jul 2025 16:40:53 +0800 Subject: [PATCH 4/5] 12 --- static/imgs/index/nav.png | Bin 4738 -> 2042 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/static/imgs/index/nav.png b/static/imgs/index/nav.png index d4f4a5f2b15c9967f73c5a2a96f5c70e62febe1a..3b657bb78813c677277127c77614740ee4a48860 100644 GIT binary patch literal 2042 zcmVPx+v`IukRCr$PozZU9I1q-DgLXyX282XaY4@UwM8#9IJQ?kiQJw;U1ijdmsv;q{ zVT%@VvYJ!5gpkBzd&ZuzhZ~TNPZIn8=J(7b@RQ&^vHQN?0WoZcSMc|Cvpug767>K$ zvF~(uUc?CP17Z3(fZ?Dxda{2S`h98RRRRE_=Mo$x*wCG6bqF;8h!cH@jG;Tz0MKmI3oIS80|4T0hRw@nBYth-1>7Jj0A~3J z>@!1<4S=^7A6`~j+95Oz9Rl|oo*q7a9{RnQ@mT;c@x!Ib1pzAnw%>;fKmEqG-#+KO z4b29CiJvaMI|3&JEC87JbmDVEKn{S3PcJ?v1mpm`d4DzVErA{R=&yZJ%}5Vs**-s@ z)YSnQ046@a`0fmp5Rd?19lm_x-=2x6W0(wpbn)-q{e4!Qf4}}$KsDM^Qj~}300>R` z9zDF@J$i5-wc^)bzjY3X>+2u?Mt!;Ppwy%=2>{8_50U@J!Gmad92C-lNX-YL0gx;{ zs2<_~K1v)6A3uHZ4K4F|LOu`=fKcmq3Oqf0%p%6e&tE!;AjIYaQ2b%El?XxXRuBw;Wbr{9uE?L#1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j z5#n_@`V+_4z4?jqX(u=bJ-q=U76b;n4s+ROK26v0BW(Qn&p5dM1s=KgSM+tAKm`VS z2iSVwZ%Eqn+4Zaa$Z!eD)vV$XcaEOn7tXxv zA7r?%m&5zINYyXKvmT8z3iPz@B-2uX$)uwGSsYHGGoQfoeBwYl?%jOpIiLRQ>oLAc z^P{rv?CTC0XI49L+v^gJafu==tEaN{{<}H6dk-T+L-@X+62(R`ZW-w5L4z=Alu>e3 zHN5o$moskSR4ON}#7ku8?QLcL^5tCmvCq-7vlm-(l)GvShRSq_Y}{xj!ROxy{0%if zD)%3_Eirr~{90`?ykSxzVGO7ZlJjHw;LD)mgDyfu5rpja5 zyqP?=^#w?@poH|b@8ycGe28o^OJ7$fzxv@nGjZ+AXu_-p#I>pD`b$<`zxmIx{l!lM zA9?Ist825|-ZSDB3_DBfeY=pKZG z$)+;|C_8@hOO6M7N!C{eAh%~+>?>!Vk`CWUUe|42DQnNZ_VJcQ*DMlrJ!1D1M;ys) z4O*VzMD^3Dk0(K`C6TQmmabxSl4h+LJFz{4Im=fE$F?8-i7G7@t-9vgzZ4waGHrADJi^+5FSOkZCoy~lR4;ie5# Date: Mon, 28 Jul 2025 18:51:47 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BA=92=E5=8A=A9?= =?UTF-8?q?=E8=AF=A6=E6=83=85=E8=AF=84=E8=AE=BA=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/aroundDetail/index.vue | 192 +++++++++++++++++--- pages/aroundList/index.vue | 328 ++++++++++++++++++++--------------- pages/neighbor/index.vue | 13 +- 3 files changed, 366 insertions(+), 167 deletions(-) diff --git a/pages/aroundDetail/index.vue b/pages/aroundDetail/index.vue index 308b21f..5c41b9d 100644 --- a/pages/aroundDetail/index.vue +++ b/pages/aroundDetail/index.vue @@ -113,12 +113,22 @@ 导航前往 - + + + @@ -158,6 +168,10 @@ export default { status: 1 }, local: null, + showLocationModal: false, + locationModalContent: '我们需要获取您的位置信息,以便提供更精准的服务', + userLocation: null, + isRequestingLocation: false } }, computed: { @@ -188,10 +202,17 @@ export default { } }, onLoad(options) { - if (options && options.Id && options.local) { - this.Id = options.Id; - this.local = options.local; + if (options?.Id) { + this.Id = options.Id; + this.local = options.local || null; + this.getAroundDetail(); } + + // 启用分享功能 + wx.showShareMenu({ + withShareTicket: true, + menus: ['shareAppMessage', 'shareTimeline'] + }); }, mounted() { this.getAroundDetail(); @@ -207,26 +228,147 @@ export default { }, 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' - }); - } + try { + const res = await get(`/api/v1/apps/surrounding/${this.Id}`); + if (res?.success) { + this.detailInfo = { + ...this.detailInfo, + ...res.data, + storeCover: res.data.storeCover?.startsWith('http') + ? res.data.storeCover + : IMAGE_BASE_URL + res.data.storeCover + }; + } + } catch (error) { + console.error('获取详情失败:', error); + uni.showToast({ title: '获取详情失败', icon: 'none' }); + } }, - + + // 处理分享按钮点击 + async handleShareClick() { + this.isRequestingLocation = true; + try { + await this.checkLocationPermission(); + } catch (error) { + console.error('位置授权异常:', error); + } finally { + this.isRequestingLocation = false; + } + }, + + // 检查位置权限 + async checkLocationPermission() { + const status = await this.getPermissionStatus(); + if (status === 'granted') { + await this.getUserLocation(); + return; + } + + if (status === 'none') { + // 首次请求授权 + this.requestLocationPermission(); + } else { + // 已拒绝过,显示提示 + this.showLocationModal = true; + } + }, + + // 获取权限状态 + getPermissionStatus() { + return new Promise((resolve) => { + uni.getSetting({ + success: (res) => { + if (res.authSetting['scope.userLocation'] === undefined) { + resolve('none'); + } else if (res.authSetting['scope.userLocation']) { + resolve('granted'); + } else { + resolve('denied'); + } + }, + fail: () => resolve('none') + }); + }); + }, + + // 请求位置授权 + requestLocationPermission() { + uni.authorize({ + scope: 'scope.userLocation', + success: () => this.getUserLocation(), + fail: (err) => { + console.error('授权失败:', err); + this.showLocationModal = true; + } + }); + }, + + // 获取用户位置 + getUserLocation() { + return new Promise((resolve, reject) => { + uni.getLocation({ + type: 'wgs84', + success: (res) => { + this.userLocation = { + latitude: res.latitude, + longitude: res.longitude + }; + resolve(res); + }, + fail: (err) => { + console.error('获取位置失败:', err); + reject(err); + } + }); + }); + }, + + // 处理授权确认 + handleAuthConfirm() { + uni.openSetting({ + success: (res) => { + if (res.authSetting['scope.userLocation']) { + this.getUserLocation().catch(() => { + uni.showToast({ title: '获取位置失败', icon: 'none' }); + }); + } + this.showLocationModal = false; + } + }); + }, + + // 处理授权取消 + handleAuthCancel() { + this.showLocationModal = false; + uni.showToast({ title: '已取消位置授权', icon: 'none' }); + }, + + // 微信分享好友 + onShareAppMessage() { + return { + title: this.detailInfo.storeName || '发现一个好地方', + path: `/pages/surrounding/detail?Id=${this.Id}`, + imageUrl: this.detailInfo.storeCover, + success: () => { + this.logShareEvent(); + }, + fail: (err) => { + console.error('分享失败:', err); + } + }; + }, + + // 朋友圈分享 + onShareTimeline() { + return { + title: this.detailInfo.storeName || '发现一个好地方', + query: `Id=${this.Id}`, + imageUrl: this.detailInfo.storeCover + }; + }, + + openMap() { const { latitude, longitude, storeName, storeAddress } = this.detailInfo; if (latitude && longitude) { diff --git a/pages/aroundList/index.vue b/pages/aroundList/index.vue index d195d64..4a86a73 100644 --- a/pages/aroundList/index.vue +++ b/pages/aroundList/index.vue @@ -1,147 +1,195 @@ - - - - - \ No newline at end of file diff --git a/pages/neighbor/index.vue b/pages/neighbor/index.vue index 8f3fe39..f598ef4 100644 --- a/pages/neighbor/index.vue +++ b/pages/neighbor/index.vue @@ -3,7 +3,7 @@ - + {{item.label}} @@ -38,7 +38,9 @@ data() { return { IMAGE_BASE_URL, - aroundList:[] + aroundList:[], + longitude:null, + latitude:null, } }, onLoad() {}, @@ -51,6 +53,11 @@ url: `/pages/aroundDetail/index?Id=${id}&local=${local}`, }); }, + goPage(id){ + uni.navigateTo({ + url: `/pages/aroundList/index?Id=${id}&latitude=${this.latitude}&longitude=${this.longitude}`, + }); + }, formatDistance(distance) { if (!distance) return '未知距离'; if (distance < 1000) { @@ -61,6 +68,8 @@ }, async surroundingList() { const position = await this.getCurrentPosition(); + this.latitude = position.latitude; + this.longitude = position.longitude; let params = { current: 1, pageSize: 10,