Pārlūkot izejas kodu

📦 节庆日历显示农历

快乐的梦鱼 2 dienas atpakaļ
vecāks
revīzija
ec95bc0522
3 mainītis faili ar 29 papildinājumiem un 5 dzēšanām
  1. 4 4
      package-lock.json
  2. 1 1
      package.json
  3. 24 0
      src/pages/fusion/index.vue

+ 4 - 4
package-lock.json

@@ -9,7 +9,7 @@
       "version": "0.0.0",
       "dependencies": {
         "@ant-design-vue/nuxt": "^1.4.6",
-        "@imengyu/imengyu-utils": "^0.0.14",
+        "@imengyu/imengyu-utils": "^0.0.19",
         "@imengyu/js-request-transform": "^0.3.5",
         "@imengyu/vue-dynamic-form": "^0.1.1",
         "@imengyu/vue-scroll-rect": "^0.1.3",
@@ -1063,9 +1063,9 @@
       "license": "MIT"
     },
     "node_modules/@imengyu/imengyu-utils": {
-      "version": "0.0.14",
-      "resolved": "https://registry.npmjs.org/@imengyu/imengyu-utils/-/imengyu-utils-0.0.14.tgz",
-      "integrity": "sha512-V/W1Te95958soeDFrK71hafr2HUi23HDED3h+hhJswvXun3AsVIibO1E9p56EaLp/epM7rBxXPSCvN29BdbgOw==",
+      "version": "0.0.19",
+      "resolved": "https://registry.npmmirror.com/@imengyu/imengyu-utils/-/imengyu-utils-0.0.19.tgz",
+      "integrity": "sha512-McRfq8JksU1rjkji21eB2G0xffSiJcKsVvOwMPWUdEQzXy5qPRZzsWrB+e/Irm86Qj+pA789pA9VA93gW6ALSw==",
       "license": "MIT",
       "dependencies": {
         "@imengyu/js-request-transform": "^0.3.6"

+ 1 - 1
package.json

@@ -15,7 +15,7 @@
   },
   "dependencies": {
     "@ant-design-vue/nuxt": "^1.4.6",
-    "@imengyu/imengyu-utils": "^0.0.17",
+    "@imengyu/imengyu-utils": "^0.0.19",
     "@imengyu/js-request-transform": "^0.3.5",
     "@imengyu/vue-dynamic-form": "^0.1.1",
     "@imengyu/vue-scroll-rect": "^0.1.3",

+ 24 - 0
src/pages/fusion/index.vue

@@ -45,10 +45,12 @@
               @click="monthChange(month.month)"
             >
               <h3>{{ month.month }}月</h3>
+              <p>{{ month.desc }}</p>
               <div class="tags">
                 <span
                   v-for="(holiday, index) in month.holidays"
                   :key="index"
+                  :title="holiday.title"
                 >
                   {{ holiday.title }}
                 </span>
@@ -85,6 +87,7 @@ import ThreeImageList from '@/components/parts/ThreeImageList.vue';
 import CalendarContent from '@/api/fusion/CalendarContent';
 import { GetContentListItem, GetContentListParams } from '@/api/CommonContent';
 import { ScrollRect } from '@imengyu/vue-scroll-rect';
+import { CalendarUtils, DateUtils } from '@imengyu/imengyu-utils';
 
 const router = useRouter();
 const carouselConfig = {
@@ -138,54 +141,67 @@ const { data: monthData } = await useAsyncData('funCalendarContent2', async () =
 
   const monthData : {
     month: number;
+    desc: string,
     holidays: GetContentListItem[];
   }[] = [
     {
       month: 1,
+      desc: '',
       holidays: []
     },
     {
       month: 2,
+      desc: '',
       holidays: []
     },
     {
       month: 3,
+      desc: '',
       holidays: []
     },
     {
       month: 4,
+      desc: '',
       holidays: []
     },
     {
       month: 5,
+      desc: '',
       holidays: []
     },
     {
       month: 6,
+      desc: '',
       holidays: []
     },
     {
       month: 7,
+      desc: '',
       holidays: []
     },
     {
       month: 8,
+      desc: '',
       holidays: []
     },
     {
       month: 9,
+      desc: '',
       holidays: []
     },
     {
       month: 10,
+      desc: '',
       holidays: []
     },
     {
       month: 11,
+      desc: '',
       holidays: []
     },
     {
       month: 12,
+      desc: '',
       holidays: []
     },
   ];
@@ -198,6 +214,11 @@ const { data: monthData } = await useAsyncData('funCalendarContent2', async () =
     item.title = item.title.substring(0, 10);
   });
 
+  for (let i = 0; i < monthData.length; i++) {
+    const startDay = CalendarUtils.solar2lunar(year, i + 1, 1);
+    const endDay = CalendarUtils.solar2lunar(year, i + 1, DateUtils.getMonthDays(year, i + 1));
+    monthData[i].desc = `${startDay.IMonthCn}${startDay.IDayCn} - ${endDay.IMonthCn}${endDay.IDayCn}`;
+  }
   res.list.forEach(item => {
     monthData[item.dateMonth - 1]?.holidays?.push(item.toJSON() as any)
   })
@@ -245,6 +266,9 @@ function monthChange(month: number) {
       h3 {
         font-size: 18px;
       }
+      p {
+        font-size: 14px;
+      }
       .tags {
         display: flex;
         flex-direction: row;