修复了刷新报错

This commit is contained in:
luyuan 2020-11-20 16:29:35 +08:00
parent b5edb78131
commit cf87e7e9f7
Signed by: theluyuan
GPG Key ID: A7972FD973317FF3
2 changed files with 17 additions and 8 deletions

View File

@ -52,7 +52,7 @@ export default createStore({
zoneStr: "中途岛GMT-11:00", zoneStr: "中途岛GMT-11:00",
zoneid: 1, zoneid: 1,
symbol: "$", symbol: "$",
zoneValue:"", zoneValue: "Atlantic/South_Georgia",
currencytag: 0 currencytag: 0
}, },
islogin: false, islogin: false,
@ -123,7 +123,7 @@ export default createStore({
const user = await userinfo(); const user = await userinfo();
if(user != '未登录'){ if(user != '未登录'){
saveValue("Lanvuage", user.languageValue); saveValue("Lanvuage", user.languageValue);
commit('setUserInfo', user); // commit('setUserInfo', user);
} else { } else {
const info = await getaddr(); const info = await getaddr();
commit("setLanguage", info) commit("setLanguage", info)

View File

@ -249,7 +249,7 @@
} }
</style> </style>
<script lang="ts"> <script lang="ts">
import { defineComponent, ref, watch } from "vue"; import { computed, defineComponent, ref, watch } from "vue";
import { getDay, gethour, getminute, gettime, getweek } from "@/utils/date"; import { getDay, gethour, getminute, gettime, getweek } from "@/utils/date";
import store from '@/store'; import store from '@/store';
import { getdatelist, userinfo } from '@/api'; import { getdatelist, userinfo } from '@/api';
@ -260,11 +260,12 @@ import { useRoute } from 'vue-router';
export default defineComponent({ export default defineComponent({
props: {}, props: {},
setup() { setup() {
const userinfo = computed(()=>store.state.userinfo)
const zhou = ref(0); const zhou = ref(0);
const time: any = useRoute().query.time; const time: any = useRoute().query.time;
const week = ref<any>(getweek(time, store.state.userinfo.zoneValue)); let userid = userinfo.value.memberid;
const userid = store.state.userinfo.memberid; const week = ref<any>(getweek(time, userinfo.value.zoneValue));
console.log(week.value);
function getdates(userid: number){ function getdates(userid: number){
getdatelist(week.value.start, week.value.end, userid).then((res: any)=>{ getdatelist(week.value.start, week.value.end, userid).then((res: any)=>{
console.log(res) console.log(res)
@ -287,6 +288,13 @@ export default defineComponent({
console.log(week.value) console.log(week.value)
}) })
} }
watch(userinfo,()=>{
userid = userinfo.value.memberid;
getdates(userid);
week.value = getweek(time, userinfo.value.zoneValue);
})
console.log(week.value);
getdates(userid); getdates(userid);
@ -301,7 +309,7 @@ export default defineComponent({
dayjs.extend(utc) dayjs.extend(utc)
dayjs.extend(timezone) dayjs.extend(timezone)
const days: any = dayjs; const days: any = dayjs;
const now = days().tz(store.state.userinfo.zoneValue) const now = days().tz(userinfo.value.zoneValue)
const xiaoshi = now.hour() const xiaoshi = now.hour()
const fenzhong = now.minute() const fenzhong = now.minute()
top.value = (xiaoshi + (fenzhong / 60)) * 0.63; top.value = (xiaoshi + (fenzhong / 60)) * 0.63;
@ -310,7 +318,7 @@ export default defineComponent({
}, 2000) }, 2000)
watch(zhou, (value) => { watch(zhou, (value) => {
week.value = getweek(time, store.state.userinfo.zoneValue, value); week.value = getweek(time, userinfo.value.zoneValue, value);
console.log(week.value); console.log(week.value);
getdates(userid) getdates(userid)
}); });
@ -341,6 +349,7 @@ export default defineComponent({
console.log(url) console.log(url)
router.push(url) router.push(url)
} }
return { return {
zhou, zhou,
week, week,