From d55f7725a455f355f94ac8d0ca0d56199010fa20 Mon Sep 17 00:00:00 2001 From: LinCyJang Date: Thu, 26 Mar 2026 21:51:57 +0800 Subject: [PATCH] =?UTF-8?q?Fix=EF=BC=9A5003=20=E3=80=90=E5=95=86=E5=9F=8E?= =?UTF-8?q?=E5=B0=8F=E7=A8=8B=E5=BA=8F=E3=80=91=E4=BD=93=E9=AA=8C=E5=88=B8?= =?UTF-8?q?=E7=9A=84=E9=80=89=E4=B8=AD=E7=8A=B6=E6=80=81=E4=B8=8E=E4=B8=8A?= =?UTF-8?q?=E6=96=B9=E2=80=9C=E5=B7=B2=E9=80=89=E6=B8=85=E5=8D=95=E2=80=9D?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E4=B8=8D=E4=B8=80=E8=87=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg_product/views/experienceCoupon.vue | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/pkg_product/views/experienceCoupon.vue b/pkg_product/views/experienceCoupon.vue index 0f0cc5f..a883f2c 100644 --- a/pkg_product/views/experienceCoupon.vue +++ b/pkg_product/views/experienceCoupon.vue @@ -23,6 +23,7 @@ export default { ], activeCategoryId: 'all', experienceList: [], + selectedProjectIds: [], userLatitude: null, userLongitude: null } @@ -112,6 +113,7 @@ export default { const remain = coupon.remainNum != null ? coupon.remainNum : 0 this.remainNum = remain this.initialUsedCount = Math.max(this.totalCount - remain, 0) + this.selectedProjectIds = [] this.selectedCount = this.initialUsedCount this.startTime = coupon.startTime || '' this.endTime = coupon.endTime || '' @@ -173,6 +175,7 @@ export default { } getExperienceCouponItems(params).then(({ data }) => { const list = data || [] + const selectedSet = new Set(this.selectedProjectIds) this.experienceList = list.map(item => { const lat = Number(item.latitude || 0) const lon = Number(item.longitude || 0) @@ -181,8 +184,10 @@ export default { distance = this.calculateDistance(this.userLatitude, this.userLongitude, lat, lon) } + const id = item.id != null ? item.id : (item.projectId != null ? item.projectId : item.merId) + return { - id: item.id != null ? item.id : (item.projectId != null ? item.projectId : item.merId), + id, title: item.name || '', subTitle: item.projectName || item.intro || '', distance, @@ -192,9 +197,10 @@ export default { tags: item.intro || '', categoryId: this.activeCategoryId === 'all' ? 'all' : this.activeCategoryId, image: item.image || item.cover || '', - selected: false + selected: selectedSet.has(id) } }) + this.selectedCount = this.initialUsedCount + this.selectedProjectIds.length }).catch(() => { this.experienceList = [] }) @@ -215,8 +221,15 @@ export default { return } item.selected = !item.selected - const currentSelected = this.experienceList.filter(it => it.selected).length - this.selectedCount = this.initialUsedCount + currentSelected + const id = item.id + if (item.selected) { + if (!this.selectedProjectIds.includes(id)) { + this.selectedProjectIds.push(id) + } + } else { + this.selectedProjectIds = this.selectedProjectIds.filter(pid => pid !== id) + } + this.selectedCount = this.initialUsedCount + this.selectedProjectIds.length }, submitOrder() { if (!this.activeCouponId) { @@ -226,15 +239,14 @@ export default { }) return } - const selected = this.experienceList.filter(it => it.selected) - if (!selected.length) { + if (!this.selectedProjectIds.length) { uni.showToast({ title: '请先选择体验项目', icon: 'none' }) return } - const projectIds = selected.map(it => it.id) + const projectIds = this.selectedProjectIds.slice() const data = { couponId: this.activeCouponId, projectIds