修复套餐对比取消和删除混乱的bug

main
刘佳宇 1 year ago
parent a273f01a5a
commit 67c639f892

@ -11,10 +11,12 @@ import { onShow } from "@dcloudio/uni-app";
import { useStore } from "@/store"; import { useStore } from "@/store";
const $store = useStore(); const $store = useStore();
let comboIds = ref([]); let comboIds = ref([]); //
let newComboIds = ref([]); //
const mountedAction = () => { const mountedAction = () => {
comboIds.value = $store.getComboContrast() || []; comboIds.value = $store.getComboContrast() || [];
newComboIds.value = $store.getComboContrast() || [];
getdbAxios(); getdbAxios();
}; };
const comboInfo = ref(false); const comboInfo = ref(false);
@ -34,7 +36,7 @@ const getdbAxios = async () => {
}; };
const clickdb = async () => { const clickdb = async () => {
$store.setComboContrast(comboIds.value); $store.setComboContrast(comboIds.value);
uni.navigateTo({ uni.navigateTo({
url: "/pages/buy/contrast/contrast", url: "/pages/buy/contrast/contrast",
}); });
}; };
@ -47,16 +49,21 @@ const configRef = (e) => {
}; };
const selectClick = (id, status) => { const selectClick = (id, status) => {
if (status) { console.log(comboIds.value.indexOf(id));
comboIds.value.splice(comboIds.value.indexOf(id), 1); if (status) {
$store.setComboContrast(comboIds.value); //
getdbAxios(); if (comboIds.value.indexOf(id) > -1) {
return comboIds.value.splice(comboIds.value.indexOf(id), 1);
} $store.setComboContrast(comboIds.value);
if (comboIds.value.includes(id)) { }
comboIds.value.splice(comboIds.value.indexOf(id), 1); getdbAxios();
return;
}
//
if (newComboIds.value.includes(id)) {
newComboIds.value.splice(newComboIds.value.indexOf(id), 1);
} else { } else {
comboIds.value.push(id); newComboIds.value.push(id);
} }
}; };
@ -83,7 +90,7 @@ onShow(() => {
<uni-icons <uni-icons
@click="selectClick(obj.combo_id)" @click="selectClick(obj.combo_id)"
:type=" :type="
comboIds.includes(obj.combo_id) ? 'checkbox-filled' : 'circle' newComboIds.includes(obj.combo_id) ? 'checkbox-filled' : 'circle'
" "
color="#239EA3" color="#239EA3"
size="30" size="30"

Loading…
Cancel
Save