|
|
@@ -14,13 +14,13 @@
|
|
|
<el-form-item label="参观展馆">
|
|
|
<div class="vr-ex-flex">
|
|
|
<div
|
|
|
- v-for="item in museumList"
|
|
|
+ v-for="item in MUSEUM_LIST"
|
|
|
:key="item.id"
|
|
|
:class="[
|
|
|
'vr-ex-flex__item',
|
|
|
form.exhibitionName === item.name && 'active',
|
|
|
]"
|
|
|
- :style="{ background: `url(${item.thumb})` }"
|
|
|
+ :style="{ backgroundImage: `url(${item.bg})` }"
|
|
|
@click="handleExhibition(item)"
|
|
|
>
|
|
|
<span>{{ item.name }}</span>
|
|
|
@@ -137,13 +137,16 @@
|
|
|
</template>
|
|
|
|
|
|
<script lang="ts" setup>
|
|
|
-import { getExhibitListApi, reservationVenueApi } from "@/api";
|
|
|
-import { CityMuseumItemType } from "@/api/types";
|
|
|
+import { reservationVenueApi } from "@/api";
|
|
|
import { BackBtn, SvgIcon } from "@/components";
|
|
|
import { formatDate } from "@/utils";
|
|
|
import { FormInstance, FormRules } from "element-plus";
|
|
|
import { computed, onActivated, onMounted, reactive, ref, watch } from "vue";
|
|
|
import { useRouter } from "vue-router";
|
|
|
+import NJImg from "./imgs/img_nanjing.jpg";
|
|
|
+import DYHImg from "./imgs/img_yangzhou.jpg";
|
|
|
+import SZImg from "./imgs/img_suzhou.jpg";
|
|
|
+
|
|
|
import "./index.scss";
|
|
|
|
|
|
type DateType = {
|
|
|
@@ -153,7 +156,6 @@ type DateType = {
|
|
|
|
|
|
let visitorId = 0;
|
|
|
const router = useRouter();
|
|
|
-const DEFAULT_MUSEUM_ID = [1, 2, 3];
|
|
|
const curExhibitionId = ref(0);
|
|
|
const venues = computed(() => {
|
|
|
const str = window.museum[curExhibitionId.value];
|
|
|
@@ -174,6 +176,23 @@ const DEFAULT_VISITOR = {
|
|
|
idcard: "",
|
|
|
phone: "",
|
|
|
};
|
|
|
+const MUSEUM_LIST = [
|
|
|
+ {
|
|
|
+ id: 1,
|
|
|
+ name: "南京博物院",
|
|
|
+ bg: NJImg,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ id: 2,
|
|
|
+ name: "中国大运河博物馆",
|
|
|
+ bg: DYHImg,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ id: 3,
|
|
|
+ name: "苏州博物馆",
|
|
|
+ bg: SZImg,
|
|
|
+ },
|
|
|
+];
|
|
|
const visitorList = reactive<
|
|
|
{
|
|
|
id: number;
|
|
|
@@ -187,7 +206,6 @@ const visitorList = reactive<
|
|
|
},
|
|
|
]);
|
|
|
const dateList = ref<DateType[]>([]);
|
|
|
-const museumList = ref<CityMuseumItemType[]>([]);
|
|
|
const bookDay = ref("");
|
|
|
const form = reactive({ ...DEFAULT_FORM });
|
|
|
const rules = reactive<FormRules>({
|
|
|
@@ -198,22 +216,19 @@ const formRef = ref<FormInstance>();
|
|
|
|
|
|
onMounted(() => {
|
|
|
initDate();
|
|
|
- getExhibitList();
|
|
|
});
|
|
|
|
|
|
onActivated(() => {
|
|
|
// 清除缓存数据
|
|
|
- if (museumList.value.length) {
|
|
|
- Object.assign(form, {
|
|
|
- ...DEFAULT_FORM,
|
|
|
- bookDay: dateList.value[0].value,
|
|
|
- venues: venues.value[0],
|
|
|
- exhibitionName: museumList.value[0].name,
|
|
|
- });
|
|
|
- visitorList.length = 0;
|
|
|
- visitorList.push({ ...DEFAULT_VISITOR });
|
|
|
- curExhibitionId.value = museumList.value[0].id;
|
|
|
- }
|
|
|
+ Object.assign(form, {
|
|
|
+ ...DEFAULT_FORM,
|
|
|
+ bookDay: dateList.value[0].value,
|
|
|
+ venues: venues.value[0],
|
|
|
+ exhibitionName: MUSEUM_LIST[0].name,
|
|
|
+ });
|
|
|
+ visitorList.length = 0;
|
|
|
+ visitorList.push({ ...DEFAULT_VISITOR });
|
|
|
+ curExhibitionId.value = MUSEUM_LIST[0].id;
|
|
|
});
|
|
|
|
|
|
watch(venues, (list) => {
|
|
|
@@ -226,26 +241,6 @@ const disabledDate = (time: Date) => {
|
|
|
return time.getTime() < today.getTime();
|
|
|
};
|
|
|
|
|
|
-const getExhibitList = async () => {
|
|
|
- loading.value = true;
|
|
|
- try {
|
|
|
- const { data } = await getExhibitListApi({
|
|
|
- pageNum: 0,
|
|
|
- pageSize: 0,
|
|
|
- });
|
|
|
- museumList.value = data.records
|
|
|
- .filter((item) => DEFAULT_MUSEUM_ID.includes(item.id))
|
|
|
- .map((item) => ({
|
|
|
- ...item,
|
|
|
- thumb: process.env.VUE_APP_BACKEND_URL + item.thumb,
|
|
|
- }));
|
|
|
- curExhibitionId.value = museumList.value[0].id;
|
|
|
- form.exhibitionName = museumList.value[0].name;
|
|
|
- } finally {
|
|
|
- loading.value = false;
|
|
|
- }
|
|
|
-};
|
|
|
-
|
|
|
const addVisitor = () => {
|
|
|
visitorList.push({
|
|
|
id: ++visitorId,
|
|
|
@@ -306,7 +301,7 @@ const submit = async () => {
|
|
|
}
|
|
|
};
|
|
|
|
|
|
-const handleExhibition = (item: CityMuseumItemType) => {
|
|
|
+const handleExhibition = (item: (typeof MUSEUM_LIST)[0]) => {
|
|
|
form.exhibitionName = item.name;
|
|
|
curExhibitionId.value = item.id;
|
|
|
};
|