diff --git a/package.json b/package.json index 779f77f..c7de61e 100644 --- a/package.json +++ b/package.json @@ -12,6 +12,7 @@ "ant-design-vue": "^2.0.0-beta.9", "axios": "^0.20.0", "core-js": "^3.6.5", + "dayjs": "^1.9.1", "postcss-pxtorem": "^5.1.1", "vue": "^3.0.0-0", "vue-router": "^4.0.0-0", diff --git a/src/router/index.ts b/src/router/index.ts index 0cf92c0..e06afcf 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -92,6 +92,10 @@ const routes: Array = [ { path: "liveing", component: () => import("../views/regime/Liveing.vue") + }, + { + path: "date", + component: () => import("../views/regime/date.vue") } ] }, diff --git a/src/utils/date.ts b/src/utils/date.ts new file mode 100644 index 0000000..3b25b44 --- /dev/null +++ b/src/utils/date.ts @@ -0,0 +1,42 @@ +import dayjs from 'dayjs' + +export function getdate(){ + let now = dayjs() + const day = now.date() // 当前天 + now = now.date(1) + const week = now.day(); // 第一天是星期几 + now = now.month(now.month() + 1); + now = now.date(0); + const month = now.date(); // 当前月有几天 + + + console.log(day,week,month) + let i = 0; + let w = 0; + + interface Date{ + day?: number; + list?: Array; + } + const date: Array> = [[]]; + + while(i < month){ + + for(w = 0; w < week; w++){ + date[0][w] = {}; + } + i++; + w = w == 0 ? 1 : w; + const zhou = Math.floor((i + w - 1) / 7) + const d = { + day: i + } + if(date[zhou] == undefined){ + date[zhou] = [] + } + date[zhou].push(d) + } + console.log(date) + return date; +} + diff --git a/src/views/regime/date.vue b/src/views/regime/date.vue new file mode 100644 index 0000000..0c1c89a --- /dev/null +++ b/src/views/regime/date.vue @@ -0,0 +1,201 @@ + + + \ No newline at end of file diff --git a/yarn.lock b/yarn.lock index 207f96c..9ff7b28 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3321,6 +3321,11 @@ dashdash@^1.12.0: dependencies: assert-plus "^1.0.0" +dayjs@^1.9.1: + version "1.9.1" + resolved "https://registry.npm.taobao.org/dayjs/download/dayjs-1.9.1.tgz?cache=0&sync_timestamp=1601296772816&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fdayjs%2Fdownload%2Fdayjs-1.9.1.tgz#201a755f7db5103ed6de63ba93a984141c754541" + integrity sha1-IBp1X321ED7W3mO6k6mEFBx1RUE= + debug@2.6.9, debug@^2.2.0, debug@^2.3.3: version "2.6.9" resolved "https://registry.npm.taobao.org/debug/download/debug-2.6.9.tgz?cache=0&sync_timestamp=1600502826356&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fdebug%2Fdownload%2Fdebug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f"