From da8c001b440a2287a63f273f402661ec97c38913 Mon Sep 17 00:00:00 2001 From: luyuan <1162963624@qq.com> Date: Wed, 18 Nov 2020 10:51:03 +0800 Subject: [PATCH] =?UTF-8?q?=E6=97=B6=E5=8C=BA=E6=B8=B2=E6=9F=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/store/index.ts | 3 ++- src/utils/date.ts | 14 ++++++++++++-- src/views/regime/week.vue | 13 ++++++++++--- 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/src/store/index.ts b/src/store/index.ts index 339250c..51e3a2a 100644 --- a/src/store/index.ts +++ b/src/store/index.ts @@ -51,7 +51,8 @@ export default createStore({ willsayValue: [{name: "0", level: 0}], zoneStr: "中途岛GMT-11:00", zoneid: 1, - symbol: "$" + symbol: "$", + zoneValue:"" }, islogin: false, seting:{ diff --git a/src/utils/date.ts b/src/utils/date.ts index 9b73421..e58810e 100644 --- a/src/utils/date.ts +++ b/src/utils/date.ts @@ -64,8 +64,18 @@ export function getdate(yue?: number): GetDate{ } -export function getweek(time: string,zhou?: number){ - let now = dayjs((!time ? undefined : time)) +export function getweek(time: string, id: string,zhou?: number){ + /* eslint-disable */ + const utc = require('dayjs/plugin/utc') // dependent on utc plugin + /* eslint-disable */ + const timezone = require('dayjs/plugin/timezone') + dayjs.extend(utc) + dayjs.extend(timezone) + const days: any = dayjs; + console.log(id, 11111) + let now = days((!time ? undefined : time)).tz(id) + console.log(now, 11111) + if(zhou != undefined){ now = now.day(now.day() + (zhou * 6)); } diff --git a/src/views/regime/week.vue b/src/views/regime/week.vue index 0e917e3..ed65f15 100644 --- a/src/views/regime/week.vue +++ b/src/views/regime/week.vue @@ -259,7 +259,7 @@ export default defineComponent({ setup() { const zhou = ref(0); const time: any = useRoute().query.time; - const week = ref(getweek(time)); + const week = ref(getweek(time, store.state.userinfo.zoneValue)); const userid = store.state.userinfo.memberid; console.log(week.value); function getdates(userid: number){ @@ -291,7 +291,14 @@ export default defineComponent({ const times = ref(''); const xs = ref(0); setInterval(()=>{ - const now = dayjs(); + /* eslint-disable */ + const utc = require('dayjs/plugin/utc') // dependent on utc plugin + /* eslint-disable */ + const timezone = require('dayjs/plugin/timezone') + dayjs.extend(utc) + dayjs.extend(timezone) + const days: any = dayjs; + const now = days().tz(store.state.userinfo.zoneValue) const xiaoshi = now.hour() const fenzhong = now.minute() top.value = (xiaoshi + (fenzhong / 60)) * 0.63; @@ -300,7 +307,7 @@ export default defineComponent({ }, 2000) watch(zhou, (value) => { - week.value = getweek(time, value); + week.value = getweek(time, store.state.userinfo.zoneValue, value); console.log(week.value); getdates(userid) });