From 67c639f892618314d41d2b432f55c4dc639938e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E4=BD=B3=E5=AE=87?= <17601616548@163.com> Date: Wed, 23 Oct 2024 15:39:08 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=A5=97=E9=A4=90=E5=AF=B9?= =?UTF-8?q?=E6=AF=94=E5=8F=96=E6=B6=88=E5=92=8C=E5=88=A0=E9=99=A4=E6=B7=B7?= =?UTF-8?q?=E4=B9=B1=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- h5/pages/main/combo/tcdb.vue | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/h5/pages/main/combo/tcdb.vue b/h5/pages/main/combo/tcdb.vue index 0695c5e..a3e5e3d 100755 --- a/h5/pages/main/combo/tcdb.vue +++ b/h5/pages/main/combo/tcdb.vue @@ -11,10 +11,12 @@ import { onShow } from "@dcloudio/uni-app"; import { useStore } from "@/store"; const $store = useStore(); -let comboIds = ref([]); +let comboIds = ref([]); // 未删除的 +let newComboIds = ref([]); // 未取消的 const mountedAction = () => { comboIds.value = $store.getComboContrast() || []; + newComboIds.value = $store.getComboContrast() || []; getdbAxios(); }; const comboInfo = ref(false); @@ -34,7 +36,7 @@ const getdbAxios = async () => { }; const clickdb = async () => { $store.setComboContrast(comboIds.value); - uni.navigateTo({ + uni.navigateTo({ url: "/pages/buy/contrast/contrast", }); }; @@ -47,16 +49,21 @@ const configRef = (e) => { }; const selectClick = (id, status) => { - if (status) { - comboIds.value.splice(comboIds.value.indexOf(id), 1); - $store.setComboContrast(comboIds.value); - getdbAxios(); - return - } - if (comboIds.value.includes(id)) { - comboIds.value.splice(comboIds.value.indexOf(id), 1); + console.log(comboIds.value.indexOf(id)); + if (status) { + // 删除 + if (comboIds.value.indexOf(id) > -1) { + comboIds.value.splice(comboIds.value.indexOf(id), 1); + $store.setComboContrast(comboIds.value); + } + getdbAxios(); + return; + } + // 取消选择 + if (newComboIds.value.includes(id)) { + newComboIds.value.splice(newComboIds.value.indexOf(id), 1); } else { - comboIds.value.push(id); + newComboIds.value.push(id); } }; @@ -83,7 +90,7 @@ onShow(() => {