TicketPurchase.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. <script setup>
  2. import { ref, reactive, onMounted, watch } from "vue";
  3. // FullCalendar
  4. import FullCalendar from "@fullcalendar/vue3";
  5. import dayGridPlugin from "@fullcalendar/daygrid";
  6. import interactionPlugin from "@fullcalendar/interaction";
  7. import zhTwLocale from "@fullcalendar/core/locales/zh-tw";
  8. let dialog = ref(false);
  9. // 日期選擇器設定
  10. const calendarOptions = ref({
  11. editable: true,
  12. selectable: true,
  13. locale: zhTwLocale,
  14. plugins: [dayGridPlugin, interactionPlugin],
  15. initialView: "dayGridMonth",
  16. headerToolbar: {
  17. start: "prev",
  18. center: "title",
  19. end: "next",
  20. },
  21. selectAllow: function (info) {
  22. return info.start >= getDateWithoutTime(new Date()); // 過去日期設為禁用
  23. },
  24. dayCellContent: function (args) {
  25. const dayText = args.dayNumberText.trim();
  26. const cleanedText = dayText.replace("日", ""); // 移除 "日"
  27. return cleanedText;
  28. },
  29. datesSet: function (arg) {
  30. console.log("切換日期:", arg.startStr, arg.endStr);
  31. // 其他處理
  32. },
  33. // validRange: function (nowDate) {
  34. // console.log("nowDate", nowDate);
  35. // return {
  36. // start: nowDate,
  37. // };
  38. // },
  39. });
  40. function getDateWithoutTime(dt) {
  41. dt.setHours(0, 0, 0, 0);
  42. return dt;
  43. }
  44. </script>
  45. <template>
  46. <v-btn class="mt-5 ms-5" @click="dialog = true"> 購票測試介面 </v-btn>
  47. <v-dialog v-model="dialog" width="600">
  48. <v-card class="py-5">
  49. <v-card-title>【台北101觀景台】2024快速通行門票 </v-card-title>
  50. <v-card-text>
  51. <img
  52. class="w-100 mb-7"
  53. src="https://cdn.fontrip.com/fontour/file/show/3m3RR/1024x684.jpg"
  54. alt=""
  55. />
  56. <p class="pt-5 mb-3 border-t-sm font-weight-bold">請選擇預約日期</p>
  57. <!-- 日期選擇器 -->
  58. <FullCalendar :options="calendarOptions" />
  59. <p class="mb-5 font-weight-bold">可預約時段 (尚餘數量)</p>
  60. <v-menu class="time-menu">
  61. <template v-slot:activator="{ props }">
  62. <v-btn v-bind="props">
  63. 請選擇預約時段
  64. <v-icon icon="mdi-menu-down" size="x-large" class="ms-1"></v-icon
  65. ></v-btn>
  66. </template>
  67. <v-list>
  68. <v-list-item v-for="(item, index) in 6" :key="index" :value="index">
  69. <v-list-item-title class="d-flex justify-space-between">
  70. <span>
  71. <p>平日</p>
  72. <small class="time">0{{ item }}:30</small>
  73. </span>
  74. <p class="quota">393</p>
  75. </v-list-item-title>
  76. </v-list-item>
  77. </v-list>
  78. </v-menu>
  79. <p class="mt-10 mb-5 font-weight-bold">請選擇商品規格數量或參與人數</p>
  80. </v-card-text>
  81. <v-card-actions>
  82. <v-btn class="ms-auto" text="Ok" @click="dialog = false"></v-btn>
  83. </v-card-actions>
  84. </v-card>
  85. </v-dialog>
  86. </template>
  87. <style lang="scss">
  88. .time-menu {
  89. .time {
  90. display: block;
  91. margin-top: -5px;
  92. color: #969696;
  93. }
  94. .quota {
  95. font-size: 12px;
  96. color: #b28850;
  97. }
  98. }
  99. </style>