|
@@ -1,12 +1,174 @@
|
|
-import { Component } from '@angular/core';
|
|
|
|
-import { RouterModule } from '@angular/router';
|
|
|
|
|
|
+// page-mine.component.ts
|
|
|
|
+import { Component, OnInit } from '@angular/core';
|
|
|
|
|
|
@Component({
|
|
@Component({
|
|
selector: 'app-page-mine',
|
|
selector: 'app-page-mine',
|
|
- imports: [RouterModule],
|
|
|
|
templateUrl: './page-mine.html',
|
|
templateUrl: './page-mine.html',
|
|
- styleUrl: './page-mine.scss'
|
|
|
|
|
|
+ styleUrls: ['./page-mine.scss']
|
|
})
|
|
})
|
|
-export class PageMine {
|
|
|
|
|
|
+export class PageMineComponent implements OnInit {
|
|
|
|
+ weekdays = ['周日', '周一', '周二', '周三', '周四', '周五', '周六'];
|
|
|
|
+ currentYear: number;
|
|
|
|
+ currentMonth: number;
|
|
|
|
+ calendarDays: any[] = [];
|
|
|
|
+
|
|
|
|
+ venues = [
|
|
|
|
+ { name: '九州厅', status: 'booked', date: '7月5日' },
|
|
|
|
+ { name: '奥斯卡厅', status: 'available' },
|
|
|
|
+ { name: '星空之镜', status: 'available' },
|
|
|
|
+ { name: '塞纳花园', status: 'available' },
|
|
|
|
+ { name: '海洋之心', status: 'hold' },
|
|
|
|
+ { name: '冰雪奇缘', status: 'booked', date: '7月12日' },
|
|
|
|
+ { name: '暮光之城', status: 'booked', date: '7月19日' },
|
|
|
|
+ { name: '月光礼堂', status: 'booked', date: '7月26日' }
|
|
|
|
+ ];
|
|
|
|
+
|
|
|
|
+ eventVenues = ['九州厅', '奥斯卡厅', '星空之镜', '塞纳花园', '海洋之心', '冰雪奇缘', '暮光之城', '月光礼堂'];
|
|
|
|
+ eventNames = ['张先生婚礼', '李小姐婚礼', '王先生婚礼', '赵小姐婚礼', '陈先生婚礼', '刘小姐婚礼'];
|
|
|
|
+
|
|
|
|
+ constructor() {
|
|
|
|
+ const today = new Date();
|
|
|
|
+ this.currentYear = today.getFullYear();
|
|
|
|
+ this.currentMonth = today.getMonth();
|
|
|
|
+ }
|
|
|
|
|
|
-}
|
|
|
|
|
|
+ ngOnInit(): void {
|
|
|
|
+ this.generateCalendar();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ generateCalendar(): void {
|
|
|
|
+ this.calendarDays = [];
|
|
|
|
+
|
|
|
|
+ // 获取当月第一天和最后一天
|
|
|
|
+ const firstDay = new Date(this.currentYear, this.currentMonth, 1);
|
|
|
|
+ const lastDay = new Date(this.currentYear, this.currentMonth + 1, 0);
|
|
|
|
+
|
|
|
|
+ // 获取第一天是星期几(0=周日,1=周一...)
|
|
|
|
+ const firstDayIndex = firstDay.getDay();
|
|
|
|
+
|
|
|
|
+ // 获取当月天数
|
|
|
|
+ const daysInMonth = lastDay.getDate();
|
|
|
|
+
|
|
|
|
+ // 获取今天日期
|
|
|
|
+ const today = new Date();
|
|
|
|
+ const isCurrentMonth = today.getMonth() === this.currentMonth && today.getFullYear() === this.currentYear;
|
|
|
|
+
|
|
|
|
+ // 生成空白日期(上个月)
|
|
|
|
+ for (let i = 0; i < firstDayIndex; i++) {
|
|
|
|
+ this.calendarDays.push({ isEmpty: true });
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 生成当月日期
|
|
|
|
+ for (let day = 1; day <= daysInMonth; day++) {
|
|
|
|
+ const dateObj = new Date(this.currentYear, this.currentMonth, day);
|
|
|
|
+ const weekday = this.weekdays[dateObj.getDay()];
|
|
|
|
+
|
|
|
|
+ // 简化版农历日期
|
|
|
|
+ const lunarDate = this.getLunarDate(day);
|
|
|
|
+
|
|
|
|
+ // 判断是否是今天
|
|
|
|
+ const isToday = isCurrentMonth && day === today.getDate();
|
|
|
|
+
|
|
|
|
+ // 生成随机事件
|
|
|
|
+ const events = this.generateRandomEvents(day);
|
|
|
|
+
|
|
|
|
+ this.calendarDays.push({
|
|
|
|
+ date: day,
|
|
|
|
+ lunarDate: lunarDate,
|
|
|
|
+ weekday: weekday,
|
|
|
|
+ isToday: isToday,
|
|
|
|
+ events: events,
|
|
|
|
+ isEmpty: false
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ getLunarDate(day: number): string {
|
|
|
|
+ // 简化版农历日期
|
|
|
|
+ const lunarMonths = ['一', '二', '三', '四', '五', '六', '七', '八', '九', '十', '冬', '腊'];
|
|
|
|
+ const lunarDays = ['初一', '初二', '初三', '初四', '初五', '初六', '初七', '初八', '初九', '初十',
|
|
|
|
+ '十一', '十二', '十三', '十四', '十五', '十六', '十七', '十八', '十九', '二十',
|
|
|
|
+ '廿一', '廿二', '廿三', '廿四', '廿五', '廿六', '廿七', '廿八', '廿九', '三十'];
|
|
|
|
+
|
|
|
|
+ // 随机生成农历月份(模拟)
|
|
|
|
+ const monthIndex = Math.floor(Math.random() * lunarMonths.length);
|
|
|
|
+ const dayIndex = Math.min(day - 1, lunarDays.length - 1);
|
|
|
|
+
|
|
|
|
+ return `${lunarMonths[monthIndex]}月${lunarDays[dayIndex]}`;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ generateRandomEvents(day: number): any[] {
|
|
|
|
+ const events = [];
|
|
|
|
+ const today = new Date();
|
|
|
|
+
|
|
|
|
+ // 如果是周末,增加事件数量
|
|
|
|
+ const dateObj = new Date(this.currentYear, this.currentMonth, day);
|
|
|
|
+ const isWeekend = dateObj.getDay() === 0 || dateObj.getDay() === 6;
|
|
|
|
+
|
|
|
|
+ // 如果是过去的日期,只显示已预订事件
|
|
|
|
+ const isPast = dateObj < today;
|
|
|
|
+
|
|
|
|
+ // 随机决定事件数量 (0-3)
|
|
|
|
+ let eventCount = Math.floor(Math.random() * (isWeekend ? 4 : 3));
|
|
|
|
+ if (isPast) eventCount = Math.min(eventCount, 2);
|
|
|
|
+
|
|
|
|
+ for (let i = 0; i < eventCount; i++) {
|
|
|
|
+ const venue = this.eventVenues[Math.floor(Math.random() * this.eventVenues.length)];
|
|
|
|
+
|
|
|
|
+ // 事件类型:30%空闲,30%咨询,40%已预订
|
|
|
|
+ const eventType = Math.random() < 0.3 ? 'available' :
|
|
|
|
+ Math.random() < 0.3 ? 'consult' : 'booked';
|
|
|
|
+
|
|
|
|
+ let title = '';
|
|
|
|
+ switch (eventType) {
|
|
|
|
+ case 'available':
|
|
|
|
+ title = '空闲';
|
|
|
|
+ break;
|
|
|
|
+ case 'consult':
|
|
|
|
+ title = '咨询';
|
|
|
|
+ break;
|
|
|
|
+ case 'booked':
|
|
|
|
+ title = this.eventNames[Math.floor(Math.random() * this.eventNames.length)];
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ events.push({
|
|
|
|
+ venue: venue,
|
|
|
|
+ type: eventType,
|
|
|
|
+ title: title
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return events;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ changeMonth(offset: number): void {
|
|
|
|
+ // 更改月份
|
|
|
|
+ this.currentMonth += offset;
|
|
|
|
+
|
|
|
|
+ // 处理年份变化
|
|
|
|
+ if (this.currentMonth > 11) {
|
|
|
|
+ this.currentMonth = 0;
|
|
|
|
+ this.currentYear++;
|
|
|
|
+ } else if (this.currentMonth < 0) {
|
|
|
|
+ this.currentMonth = 11;
|
|
|
|
+ this.currentYear--;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 重新生成日历
|
|
|
|
+ this.generateCalendar();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ getStatusText(status: string, date?: string): string {
|
|
|
|
+ switch (status) {
|
|
|
|
+ case 'available':
|
|
|
|
+ return '空闲';
|
|
|
|
+ case 'booked':
|
|
|
|
+ return `已预订 (${date})`;
|
|
|
|
+ case 'hold':
|
|
|
|
+ return '意向沟通中';
|
|
|
|
+ default:
|
|
|
|
+ return '';
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+}
|