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/api/index.ts b/src/api/index.ts index 54cd233..d3600a0 100644 --- a/src/api/index.ts +++ b/src/api/index.ts @@ -37,7 +37,7 @@ export async function userinfo(){ const user = await get('personalInfo'); // console.log(user.data?.img) if(user.code == 1001){ - router.push("/") + // router.push("/") return '未登录'; } return { 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..58b3640 --- /dev/null +++ b/src/utils/date.ts @@ -0,0 +1,50 @@ +import dayjs from 'dayjs' + +export function getdate(yue?: number){ + let now = dayjs() + if(yue != undefined){ + now = now.month(now.month() + yue); + } + yue = now.month() + 1; + const day = now.date() // 当前天 + const zhou = now.day(); // 当前周 + now = now.date(1) + const week = now.day(); // 第一天是星期几 + now = now.month(now.month() + 1); + now = now.date(0); + const month = now.date(); // 当前月有几天 + const year = now.year() + + 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++; + const zhou = Math.floor((i + w - 1) / 7) + const d = { + day: i + } + if(date[zhou] == undefined){ + date[zhou] = [] + } + date[zhou].push(d) + } + while(date[date.length - 1].length < 7){ + date[date.length - 1].push({}) + } + console.log(date) + + return {date, year, yue, day, zhou}; +} + diff --git a/src/views/regime/date.vue b/src/views/regime/date.vue new file mode 100644 index 0000000..afbbd55 --- /dev/null +++ b/src/views/regime/date.vue @@ -0,0 +1,218 @@ + + + \ 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"