You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

725 lines
22 KiB
Vue

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<script setup>
import DraggableButton from "@/pages/components/goHome.vue";
/**
* name
* useryytjsj
* date2024年9月25日 10:25:00
*/
import { ref, onBeforeUnmount } from "vue";
import { $api, $response, $image } from "@/api";
import { onShow } from "@dcloudio/uni-app";
import { useStore } from "@/store";
const $store = useStore();
let date_list = ref(false);
let time_list = ref(false);
let currentDate = ref(0);
let currentTime = ref(0);
let buyInfo = ref({}); // 购买信息
let yytjInfo = ref({}); // 购买信息
let groupInfo = ref({});
let comboInfo = ref({});
let itemsInfo = ref({});
let truePrice = ref(0); // 总价
let nmrIndex = ref(0); // 当前选中项目索引
let time = ref(""); // 时分
let timeIndex = ref(null); // 当前选中时间索引
let status = ref(0); // 1点了确定 2未点确定
let calendarShow = ref(false); // 日历显示
const rl_list = ref(false); //日历插槽
let isClickDoctor = ref(0); // 是否点击了医生
const mountedAction = async () => {
uni.showLoading({
title: "加载中",
});
console.log($store.getYytjInfo(), "swsw");
console.log($store.getBuyInfo(), "tyuiopiuytr");
yytjInfo.value = $store.getYytjInfo();
buyInfo.value = $store.getBuyInfo();
await getnmrList();
};
onBeforeUnmount(() => {
if (!status.value) {
$store.setYytjInfo(uni.getStorageSync("yytjInfoS"));
}
});
const getnmrList = async () => {
// 获取项目列表
const response = await $api("BuyInfo", buyInfo.value);
$response(response, () => {
if (buyInfo.value.group_id && response.data.group_info.length) {
// 团检
groupInfo.value = response.data.group_info[0];
}
comboInfo.value = response.data.combo_info;
itemsInfo.value = response.data.items_info;
truePrice.value = response.data.true_price;
currentDate.value = getToday(); //huo获取今天的日期
if (!yytjInfo.value?.nmr_list?.length) {
yytjInfo.value.nmr_list = response.data.nmr_list.map((val) => {
return {
...val,
time: "",
id: "",
};
});
yytjInfo.value.nmr_list.push({
item_id: -1,
name: "体检时间",
time: "",
id: "",
});
}
console.log(yytjInfo.value.nmr_list[0]);
xmmcClick(yytjInfo.value.nmr_list[0], 0);
uni.hideLoading();
});
};
const moreTime = async (m, status) => {
isClickDoctor.value = status;
// 日历
const [year, month, day] = currentDate.value.split("-");
let dqmonth = m || `${year}-${month}`; //年 月份
let obj = {};
let methods = "";
obj = {
hospital: buyInfo.value.hospital,
person_id: buyInfo.value.person_id,
month: dqmonth, //月份
use_type: buyInfo.value.group_id ? 2 : 1,
checkup_type_id: buyInfo.value.group_id
? $store.getGroupInfo()?.checkup_type_id
: $store.getCheckupTypeId()?.id,
amount: truePrice.value,
};
if (yytjInfo.value.nmr_list?.length > 1) {
if (nmrIndex.value) {
// 体检
methods = "GetMonthPlanCount";
} else {
// 核磁
methods = "NMRGetMonthPlanCount";
obj = {
hospital: buyInfo.value.hospital,
month: dqmonth, //月份
};
}
} else {
methods = "GetMonthPlanCount";
}
const response = await $api(methods, obj);
$response(response, () => {
console.log(response.data.list, "response.data.list");
let rlArr = [];
response.data.list.forEach((item) => {
let o = {
date: item.date,
info: "余号" + item.count,
};
rlArr.push(o);
});
console.log(rlArr);
rl_list.value = rlArr;
calendarShow.value = true;
});
};
const monthSwitch = (givenDate) => {
const currentYear = new Date().getFullYear();
const currentMonth = new Date().getMonth() + 1;
// 获取当前日期
if (
givenDate.year < currentYear ||
(givenDate.year === currentYear && givenDate.month < currentMonth)
) {
// uni.$lu.toast("不能选择过去时间");
return false;
} else {
let str = `${givenDate.year}-${givenDate.month}`;
moreTime(str, 0);
}
};
const getToday = () => {
// 获取当前日期
var today = new Date();
// 获取年、月、日
var year = today.getFullYear(); // 年
var month = (today.getMonth() + 1).toString().padStart(2, "0"); // 月月份是从0开始的所以要+1并使用padStart补零
var day = today.getDate().toString().padStart(2, "0"); // 日使用padStart补零
// 拼接日期字符串
return year + "-" + month + "-" + day;
};
const getTjTimeList = async (val) => {
console.log($store.getCheckupTypeId());
console.log(val);
// 获取 体检号源
let obj = {};
let apiText = "";
if (val.item_id == -1) {
obj = {
hospital: buyInfo.value.hospital,
person_id: buyInfo.value.person_id,
date: currentDate.value, //currentDate.value
use_type: buyInfo.value.group_id ? 2 : 1,
checkup_type_id: buyInfo.value.group_id
? $store.getGroupInfo()?.checkup_type_id
: $store.getCheckupTypeId()?.id,
amount: truePrice.value,
};
apiText = "GetDayPlanList";
} else {
obj = {
hospital_id: buyInfo.value.hospital,
date: currentDate.value,
};
apiText = "NMRGetDayPlanList";
}
uni.showLoading({
title: "加载中",
});
const response = await $api(apiText, obj);
$response(response, () => {
console.log(response, "response");
// currentXmmcObj.value["sj"] = ""; //每次请求新的时间时间置空
currentTime.value = "";
date_list.value = response.data.weeklist;
time_list.value = response.data.list;
time_list.value.forEach((item) => {
console.log(item.date);
item.newTime = item.time.slice(0, 5);
item.date = currentDate.value;
});
date_list.value.forEach((item) => {
console.log(item);
item.item_id = val.item_id;
const [year, month, day] = item.date.split("-");
item.newMonthDate = `${month}/${day}`; //月份日期
item.newWeek = item.xingqi.replace("星期", "周");
});
if (val.time) {
timeIndex.value = time_list.value.findIndex(
(item) => item.newTime == val.time.split(" ")[1]
);
}
uni.hideLoading();
});
};
const changerl = (e) => {
// 选中某天日期
console.log(e, "changerl");
let num = e.extraInfo.info ? e.extraInfo.info.substring(2) : 0;
if (num == 0) {
uni.$lu.toast("当前余号剩余0");
} else if (num > 0) {
if (isClickDoctor.value == 1) {
// 点击医生进入的
status.value = 0;
// yytjInfo.value.nmr_list[yytjInfo.value.nmr_list.length - 1].time =
// e.fulldate;
yytjInfo.value.doctor_date = e.fulldate;
$store.setYytjInfo(yytjInfo.value);
uni.navigateTo({
url: `/pages/main/selectDoctor/selectDoctor?date=${e.fulldate}`,
});
}
if (date_list.value[3]?.date == e.fulldate) {
calendarShow.value = false;
return;
}
// uni.showLoading({
// title: "加载中",
// });
currentDate.value = e.fulldate;
time.value = "";
timeIndex.value = null;
yytjInfo.value.nmr_list[nmrIndex.value].time = "";
yytjInfo.value.nmr_list[nmrIndex.value].id = "";
yytjInfo.value.doctor_name = ""; // 每次切换都清空医生
getTjTimeList(yytjInfo.value.nmr_list[nmrIndex.value]);
calendarShow.value = false;
}
};
const getCurrentClick = (item, i) => {
// 选择日期
console.log(item, i); //当前日期和星期
if (new Date(item.date).getTime() < new Date(getToday()).getTime()) {
uni.$lu.toast("不能选择过去时间");
return;
}
if (item.count < 0) {
uni.$lu.toast("该日期已满,请选择其他日期");
return;
}
if (i != 3) {
if (yytjInfo.value.nmr_list.length > 1 && nmrIndex.value == 0) {
yytjInfo.value.nmr_list = yytjInfo.value.nmr_list.map((val) => {
return {
...val,
time: "",
id: "",
};
});
}
time.value = "";
timeIndex.value = null;
yytjInfo.value.nmr_list[nmrIndex.value].time = "";
yytjInfo.value.nmr_list[nmrIndex.value].id = "";
yytjInfo.value.doctor_name = ""; // 每次切换都清空医生
yytjInfo.value.doctor_date = ""; // 每次切换都清空医生
$store.setYytjInfo(yytjInfo.value);
status.value = 0;
currentDate.value = item.date;
getTjTimeList(item); //带着选中的日期重新选择
}
};
const getCurrentTime = (item, index) => {
// 选择时分
if (item.status == 2) {
uni.$lu.toast("该号源已被其他人预约");
return;
}
console.log(item);
timeIndex.value = index;
yytjInfo.value.nmr_list[nmrIndex.value].time = item.date + " " + item.newTime;
yytjInfo.value.nmr_list[nmrIndex.value].id = item.id;
status.value = 0;
$store.setYytjInfo(yytjInfo.value);
};
const xmmcClick = (val, index, status) => {
if (nmrIndex.value == index && status) {
return;
}
// 选择项目
if (
yytjInfo.value.nmr_list.length > 1 &&
index != 0 &&
yytjInfo.value.nmr_list[0].time == ""
) {
uni.$lu.toast("请先选择" + yytjInfo.value.nmr_list[0].name + "时间");
return;
}
nmrIndex.value = index;
time.value = "";
timeIndex.value = null;
if (val.time) {
currentDate.value = val.time.split(" ")[0];
} else {
if (
((yytjInfo.value.nmr_list.length > 1 &&
index == yytjInfo.value.nmr_list.length - 1) ||
(yytjInfo.value.nmr_list.length == 1 && index == 0)) &&
yytjInfo.value.doctor_date
) {
currentDate.value = yytjInfo.value.doctor_date;
} else {
currentDate.value = getToday();
}
}
// 体检号源
getTjTimeList(val);
};
const clickDoctor = () => {
//选择医生
if (
yytjInfo.value.nmr_list.length > 1 &&
yytjInfo.value.nmr_list[0].time == ""
) {
uni.$lu.toast("请先选择" + yytjInfo.value.nmr_list[0].name + "时间");
return;
}
if (yytjInfo.value.nmr_list[yytjInfo.value.nmr_list.length - 1].time == "") {
nmrIndex.value = yytjInfo.value.nmr_list?.length - 1;
moreTime(null, 1);
return;
}
status.value = 0;
let date =
yytjInfo.value.nmr_list[yytjInfo.value.nmr_list.length - 1].time?.split(
" "
)[0];
yytjInfo.value.doctor_date = date;
$store.setYytjInfo(yytjInfo.value);
uni.navigateTo({
url: `/pages/main/selectDoctor/selectDoctor?date=${date}`,
});
};
const comfrimyy = () => {
console.log(yytjInfo.value);
status.value = 1;
uni.navigateBack({
delta: 1,
});
};
const config_ref = ref(null);
const configRef = (e) => {
if (!config_ref.value) {
config_ref.value = e;
mountedAction();
}
};
onShow(() => {
if (!!config_ref.value) {
mountedAction();
}
});
</script>
<template>
<DraggableButton />
<view>
<view v-if="!!$store.config">
<view :ref="configRef"></view>
</view>
<view class="h-38rpx bg-#239EA3 pl-20rpx pr-20rpx box-border">
<view
style="box-shadow: 0rpx 0rpx 10rpx 0rpx rgba(0, 0, 0, 0.04)"
class="p-16rpx pb-20rpx pt-30rpx rounded-15rpx bg-#fff"
>
<view
class="flex w-full b-0 b-solid b-b-1 b-#E1ECEE pb-25rpx mb-7rpx"
v-if="!buyInfo.group_id && comboInfo?.items?.length"
>
<!-- 1 个检套餐 显示套餐信息 -->
<image
v-if="comboInfo.img"
:src="$image(comboInfo.img)"
class="w-190rpx h-190rpx mr-37rpx"
mode="widthFix"
/>
<view class="flex flex-col grow">
<text>{{ comboInfo.combo_name }}</text>
<view class="mt-13rpx mb-18rpx">
<uni-tag
v-for="(val, i) in comboInfo.tags"
:key="i"
size="small"
:inverted="true"
:text="val.text"
class="mr-8rpx"
:custom-style="
'background-color:' +
val.color +
';border-color:' +
val.color +
'; color:' +
val.text_color +
';'
"
/>
</view>
<view v-if="comboInfo.tags2?.length">
<text
v-for="(val, i) in comboInfo.tags2"
:key="i"
class="text-#8B8B8B text-20rpx line-height-[1] px-5rpx b-0 b-solid b-#8B8B8B"
:class="i == comboInfo.tags2?.length - 1 ? 'b-r-0' : 'b-r-2'"
>{{ val }}</text
>
</view>
<view class="mt-20rpx w-full flex items-end">
<text class="text-18rpx text-#EC3D15">¥</text>
<text class="text-38rpx text-#EC3D15 mx-10rpx -mb-8rpx">{{
comboInfo.price
}}</text>
<text class="text-18rpx text-#878787 line-through">{{
comboInfo.original_price
}}</text>
<text class="text-18rpx text-#878787 ml-auto mr-55rpx"
>已售{{ comboInfo.sale_count }}</text
>
</view>
</view>
</view>
<view
v-if="buyInfo.group_id"
class="b-0 b-solid b-#E1ECEE pb-25rpx mb-7rpx"
:class="{
'b-b-1': itemsInfo?.items?.length,
}"
>
<!-- 3团检套餐 4团检自选 都要显示头像和名字 -->
<view class="flex items-center">
<image
src="@/static/assets/userm.png"
class="w-70rpx h-70rpx mr-35rpx"
/>
<view class="flex items-center grow">
<text class="text-#707070 text-24rpx">您好,</text>
<text class="text-#0E0E0E text-32rpx">{{ groupInfo.name }}</text>
</view>
</view>
<view class="text-24rpx mt-40rpx">
<!-- 3团检套餐 4团检自选 都要显示单位部门等信息 -->
<view class="pb-30rpx">
<text class="text-#8B8B8B">单位名称:</text>
<text>{{ groupInfo.group_name }}</text>
</view>
<view class="pb-30rpx">
<text class="text-#8B8B8B">部门名称:</text>
<text>{{ groupInfo.bumen_name }}</text>
</view>
<view
class="pb-30rpx"
v-if="groupInfo.combo_name || comboInfo?.combo_name"
>
<text class="text-#8B8B8B">套餐名称:</text>
<text>{{ groupInfo?.combo_name || comboInfo?.combo_name }}</text>
</view>
<view>
<text class="text-#8B8B8B">体检额度:</text>
<text>{{ groupInfo.tongshou_xiane }}</text>
</view>
</view>
</view>
<view class="pt-15rpx" v-if="itemsInfo?.items?.length">
<view class="text-30rpx text-#0E0E0E pb-30rpx"> 自选项目 </view>
<view class="text-#8B8B8B text-24rpx">
<view
class="flex mb-20rpx"
v-for="(val, index) in itemsInfo?.items.length > 3
? 3
: itemsInfo?.items"
:key="index"
>
<text class="whitespace-nowrap"
>{{ itemsInfo?.items[index]?.keshi_name }} -
</text>
<view class="line-clamp-2">
<text
class="ml-10rpx text-#0E0E0E"
v-for="(v, i) in itemsInfo?.items[index]?.children"
:key="i"
>{{ v.name }}</text
>
</view>
</view>
</view>
</view>
<view class="center mt-20rpx text-#8B8B8B text-24rpx">
<text>体检医生 - </text>
<text
class="ml-10rpx text-#0E0E0E center mr-auto"
@click="clickDoctor"
>
{{ yytjInfo?.doctor_name || "请选择" }}
<uni-icons type="right" size="14"></uni-icons>
</text>
</view>
</view>
<view
style="box-shadow: 0rpx 0rpx 10rpx 0rpx rgba(0, 0, 0, 0.04)"
class="p-16rpx pb-20rpx pt-30rpx rounded-15rpx bg-#fff mt-15rpx ylrl"
v-if="calendarShow"
>
<uni-calendar
:selected="rl_list"
:startDate="getToday()"
:showMonth="false"
:insert="true"
:date="currentDate"
@change="changerl"
@monthSwitch="monthSwitch"
/>
</view>
<template v-else>
<view
style="box-shadow: 0rpx 0rpx 10rpx 0rpx rgba(0, 0, 0, 0.04)"
class="p-16rpx pb-20rpx pt-30rpx rounded-15rpx bg-#fff mt-15rpx"
v-if="date_list"
>
<view class="">
<view
class="text-30rpx text-#0E0E0E pb-34rpx font-500"
v-if="yytjInfo.nmr_list[nmrIndex].name"
>
{{ yytjInfo.nmr_list[nmrIndex].name }}
</view>
<view class="flex mb-30rpx items-center">
<view
class="flex-1 text-center text-18rpx"
v-for="(item, index) in date_list"
:key="index"
>
<view
@click="getCurrentClick(item, index)"
:class="{
activeTime: 3 == index,
'bg-#efefef text-#aaa8a8':
item.count < 0 ||
new Date(item.date).getTime() <
new Date(getToday()).getTime(),
}"
class="rounded-12rpx pt-10rpx pb-10rpx ml-10rpx mr-10rpx mb-6rpx"
>
<view> {{ item.newMonthDate }} </view>
<view class="text-26rpx font-500"> {{ item.newWeek }} </view>
</view>
<view class="ma" v-if="item.count > -1">
<text
:class="{
'text-#239EA3 !bg-#E1F4F8': 3 == index,
}"
class="bg-#EFEFEF rounded-10rpx h-28rpx pl-10rpx pr-10rpx"
>余{{ item.count }}</text
>
</view>
</view>
<view
class="flex-1 col center text-#239EA3 text-20rpx bs b-#E7E7E7 b-l-1 h-80rpx"
@click="moreTime(null, 0)"
>
<uni-icons
type="calendar"
size="30"
color="#239EA3"
></uni-icons>
<text>更多</text>
</view>
</view>
<view
class="flex flex-wrap pt-30rpx pb-30rpx b-0 b-t-1 b-solid b-#E1ECEE"
v-if="time_list.length"
>
<view
class="w-20% text-center box-border p-20rpx"
v-for="(item, index) in time_list"
:key="index"
:class="{
'text-red': item.status == 2,
}"
@click="getCurrentTime(item, index)"
>
<view
class="text-24rpx rounded-12rpx h-54rpx flex flex-items-center flex-justify-center"
:class="timeIndex == index ? 'activeTime' : ''"
>
{{ item.newTime }}
</view>
</view>
</view>
</view>
</view>
<view
style="box-shadow: 0rpx 0rpx 10rpx 0rpx rgba(0, 0, 0, 0.04)"
class="p-30rpx pl-10rpx pr-10rpx rounded-15rpx bg-#fff mt-15rpx text-#101010 text-28rpx"
>
<view class="bg-#F7F7F7 pl-20rpx pr-20rpx pt-23rpx pb-25rpx">
<text>{{
buyInfo.group_id
? $store.getGroupInfo()?.name
: $store.getUser()?.name
}}</text>
<view
class="bg-#EFEFEF rounded-15rpx p-10rpx pb-15rpx pt-15rpx mt-20rpx"
>
<view
v-for="(item, index) in yytjInfo.nmr_list"
:key="index"
@click="xmmcClick(item, index, 1)"
:class="nmrIndex == index ? 'acitvetc' : ''"
class="flex flex-justify-around p-20rpx pl-10rpx pr-10rpx rounded-15rpx"
>
<view class="flex-col flex flex-1 line-clamp-1">
<text v-for="(v, i) in item.name?.split('/')" :key="i">{{
v
}}</text>
</view>
<view class="center">
{{ item.time }}
</view>
</view>
</view>
</view>
</view>
<view class="pb-100rpx">
<view
@click="comfrimyy"
class="text-#fff text-32rpx rounded-45rpx bg-#239EA3 mt-40rpx ma w-520rpx h-90rpx flex flex-items-center flex-justify-center"
>
确定
</view>
</view>
</template>
</view>
</view>
</template>
<style scoped lang="scss">
.activeTime {
background-color: #239ea3;
color: #fff;
}
.acitvetc {
background-color: #e0f1f2;
}
::v-deep .ylrl {
.uni-calendar__header,
.uni-calendar__weeks-day {
border: none;
}
.uni-calendar-item--checked {
background-color: transparent;
.uni-calendar-item__weeks-box-item {
background-color: #239ea3 !important;
border-radius: 12rpx;
.uni-calendar-item--extra {
color: #fff !important;
}
}
}
.uni-calendar-item--isDay {
background-color: #239ea3 !important;
border-radius: 12rpx;
color: #fff !important;
}
.uni-calendar-item--extra {
color: #239ea3;
}
.uni-calendar-item__weeks-box {
// padding: 10rpx;
box-sizing: border-box;
}
.uni-calendar-item__weeks-box-circle {
background-color: rgba(0, 0, 0, 0);
}
.uni-calendar-item--isDay-text {
color: #333;
}
.uni-calendar-item__weeks-box-text {
font-size: 26rpx;
}
.uni-calendar-item__weeks-lunar-text {
font-size: 16rpx;
}
.uni-calendar-item__weeks-box-item {
width: 100%;
}
.uni-calendar__backtoday {
display: none;
}
.uni-calendar-item--disable {
.uni-calendar-item__weeks-lunar-text {
display: none;
}
}
}
</style>