From 968c330c27d403352d6ca31eb00960fdebd34cd4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E4=BD=B3=E5=AE=87?= <17601616548@163.com> Date: Fri, 13 Sep 2024 14:57:39 +0800 Subject: [PATCH] =?UTF-8?q?1.=E5=A2=9E=E5=8A=A0=E8=87=AA=E9=80=89=E9=A1=B9?= =?UTF-8?q?=E7=9B=AE=E4=BB=B7=E6=A0=BC=E8=AF=B4=E6=98=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/optionalProject/optionalProject.vue | 121 ++++++++++++++++-- 1 file changed, 111 insertions(+), 10 deletions(-) diff --git a/h5/pages/main/optionalProject/optionalProject.vue b/h5/pages/main/optionalProject/optionalProject.vue index e57e7c7..bba1ca0 100644 --- a/h5/pages/main/optionalProject/optionalProject.vue +++ b/h5/pages/main/optionalProject/optionalProject.vue @@ -5,17 +5,42 @@ * date:2024年9月11日 19:24:50 */ import { ref } from "vue"; -import { $api, $response } from "@/api"; +import { $api, $response, $image } from "@/api"; import { onShow } from "@dcloudio/uni-app"; import { useStore } from "@/store"; + +const $props = defineProps({ + hospital: { + type: String, + default: "", + }, + comboId: { + type: String, + default: "", + }, + itemIds: { + type: String, + default: "", + }, +}); + const $store = useStore(); let leftList = ref({}); // 左侧列表 let tabIndex = ref(""); // 默认选中 let rightLeft = ref([]); // 右侧列表 -let selectList = ref([]); // 选中列表 +let selectIds = ref([]); // 选中id列表 +let headImg = ref(""); // 头部图片 +let packagePrice = ref(0); //套餐折扣价格 +let packageOriginalPrice = ref(0); //套餐原始价格 +let optionalPrice = ref(0); //自选折扣价格 +let optionalOriginalPrice = ref(0); //自选原始价格 +let totalPrice = ref(0); // 总折扣价格 +let totalOriginalPrice = ref(0); // 总原始价格 +let total = ref(0); // 总项目数 const getAllItems = async (e) => { + // 获取全部项目 const response = await $api("GetAllItems", { search: e?.value, }); @@ -25,12 +50,32 @@ const getAllItems = async (e) => { let keys = Object.keys(leftList.value); tabIndex.value = keys[0]; rightLeft.value = leftList.value[keys[0]].children; + headImg.value = leftList.value[keys[0]].head_img; } }); }; +const getBuyInfo = async () => { + const response = await $api("BuyInfo", { + item_ids: selectIds.value, + hospital: $props.hospital, + combo_id: $props.comboId, + }); + $response(response, () => { + packagePrice.value = response.data.combo_info.price; + packageOriginalPrice.value = response.data.combo_info.original_price; + optionalPrice.value = response.data.items_info.price; + optionalOriginalPrice.value = response.data.items_info.original_price; + totalPrice.value = response.data.true_price; + totalOriginalPrice.value = response.data.original_price; + total.value = response.data.pay_item_count; + }); +}; + const mountedAction = () => { - getAllItems(); + selectIds.value = $props.itemIds?.split(",") || []; + getAllItems(); // 获取全部项目 + getBuyInfo(); // 获取购买信息 }; const config_ref = ref(null); @@ -72,12 +117,17 @@ onShow(() => { :class="{ 'bg-gradient-to-r from-#edf6f5 to-#bbdfe2': tabIndex == index, }" - @click="(tabIndex = index), (rightLeft = item.children)" + @click=" + (tabIndex = index), + (rightLeft = item.children), + (headImg = item.head_img) + " > {{ item.title }} + { class="flex justify-between center py-30rpx px-20rpx b-b-1px b-b-solid b-b-#e5e5e5" @click=" () => { - selectList.push(item.id); + if (selectIds.includes(item.id)) { + selectIds.splice(selectIds.indexOf(item.id), 1); + } else { + selectIds.push(item.id); + } + getBuyInfo(); } " > {{ item.title }} - - ¥ {{ item.price }} + ¥ {{ item.price }} + ¥ {{ item.original_price }} { + + + 您需付费 \n{{ total }}个项目 + + + + 套餐价格 + ¥ {{ packagePrice }} + ¥ {{ packageOriginalPrice }} + + + 自选项目价格 + ¥ {{ optionalPrice }} + ¥ {{ optionalOriginalPrice }} + + + 合计费用 + ¥ + {{ + totalPrice + }} + ¥ {{ totalOriginalPrice }} + + + +