xbx #60

Merged
theluyuan merged 9 commits from xbx into master 2020-10-20 17:09:35 +08:00
3 changed files with 74 additions and 17 deletions
Showing only changes of commit d6a2569255 - Show all commits

View File

@ -4,14 +4,22 @@ import { AxiosRequestConfig, CustomSuccessData } from 'axios';
import { getValue } from '@/utils/common'; import { getValue } from '@/utils/common';
import { message } from 'ant-design-vue'; import { message } from 'ant-design-vue';
import router from '@/router'; import router from '@/router';
import { MessageType } from 'ant-design-vue/types/message';
// 泛型接口 // 泛型接口
export interface Get { export interface Get {
<T>(url: string, params?: unknown, config?: AxiosRequestConfig): Promise<CustomSuccessData<T>>; <T>(url: string, params?: unknown, config?: AxiosRequestConfig): Promise<CustomSuccessData<T>>;
} }
const login:MessageType[] = []
axios.interceptors.request.use((config)=>{
login.push(message.loading('加载中..', 0))
return config;
})
axios.interceptors.response.use((response)=>{ axios.interceptors.response.use((response)=>{
// console.log(response) // console.log(response)
login[0]();
login.splice(0,1);
if(response.data.code == 1001){ if(response.data.code == 1001){
router.push("/") router.push("/")
} }

View File

@ -89,7 +89,9 @@ export function getweek(zhou?: number){
for(let j = 0;j < 24; j++){ for(let j = 0;j < 24; j++){
date[i].list?.push({ date[i].list?.push({
start:"", start:"",
num:"" num:"",
title: "",
time:""
}) })
} }
} }
@ -104,3 +106,23 @@ export function getDay(date: string){
console.log(now.date()) console.log(now.date())
return now.date(); return now.date();
} }
export function gethour(date: string){
const now = dayjs(date)
console.log(now.hour(), now.date(), now.minute())
return now.hour();
}
export function getminute(date: string){
const now = dayjs(date)
// console.log(now.hour(), now.date(), now.minute())
return now.minute();
}
export function gettime(date: string, num: number){
let now = dayjs(date)
const start = `${now.hour() > 9 ? now.hour() : '0' + now.hour()}:${now.minute() > 9 ? now.minute() : '0' + now.minute()}`
now = now.minute(now.minute() + num);
const end = `${now.hour() > 9 ? now.hour() : '0' + now.hour()}:${now.minute() > 9 ? now.minute() : '0' + now.minute()}`
return start + "-" + end;
}

View File

@ -39,21 +39,21 @@
</div> </div>
<div class="body"> <div class="body">
<div class="row" v-for="item in 24" :key="item"> <div class="row" v-for="item in 24" :key="item">
<div class="day date"> <div class="day date">
{{ item > 10 ? item - 1 : "0" + (item - 1) }}:00-{{ {{ item > 10 ? item - 1 : "0" + (item - 1) }}:00-{{
item > 9 ? item : "0" + item item > 9 ? item : "0" + item
}}:00 }}:00
</div> </div>
<div v-for="i in 7" :key="i"> <div v-for="i in 7" :key="i">
<div class="day"> <div class="day">
<div class=""> <div class="next" v-if="week.date[i -1].list[item - 1].title != ''">
<div class="one-line-hide"> <div class="one-line-hide" style="max-width: 1.5rem">
one-line-hideon {{week.date[i -1].list[item - 1].title}}
</div>
<div>{{week.date[i -1].list[item - 1].time}}</div>
</div>
</div> </div>
<div>11:00-11:00</div>
</div> </div>
</div>
</div>
</div> </div>
</div> </div>
</div> </div>
@ -176,7 +176,8 @@
align-items: center; align-items: center;
justify-content: center; justify-content: center;
font-size: 11px; font-size: 11px;
border-radius: 6px;
overflow: hidden;
> div:last-child { > div:last-child {
font-size: 11px; font-size: 11px;
margin-top: 8px; margin-top: 8px;
@ -185,6 +186,7 @@
.old { .old {
background-color: #f7f7f7; background-color: #f7f7f7;
color: #111; color: #111;
} }
.ing { .ing {
background-color: #0dbba4; background-color: #0dbba4;
@ -206,17 +208,42 @@
</style> </style>
<script lang="ts"> <script lang="ts">
import { defineComponent, ref, watch } from "vue"; import { defineComponent, ref, watch } from "vue";
import { getweek } from "@/utils/date"; import { getDay, gethour, getminute, gettime, getweek } from "@/utils/date";
import store from '@/store';
import { getdatelist, userinfo } from '@/api';
export default defineComponent({ export default defineComponent({
props: {}, props: {},
setup() { setup() {
const zhou = ref(0); const zhou = ref(0);
const week = ref(getweek()); const week = ref<any>(getweek());
const userid = store.state.userinfo.memberid;
console.log(week.value); console.log(week.value);
getdates(userid);
function getdates(userid: number){
getdatelist(week.value.start, week.value.end, userid).then((res: any)=>{
console.log(res)
for(let i in res){
const day = getDay(res[i].dateline)
console.log(day)
for(let j in week.value.date){
console.log(getDay(week.value.date[j].day))
if(day == getDay(week.value.date[j].day)){
console.log("fuzhi")
week.value.date[j].list[gethour(res[i].dateline)].start = getminute(res[i].dateline);
week.value.date[j].list[gethour(res[i].dateline)].num = res[i].livetime
week.value.date[j].list[gethour(res[i].dateline)].title = res[i].title
week.value.date[j].list[gethour(res[i].dateline)].time = gettime(res[i].dateline, res[i].livetime)
}
}
}
console.log(week.value)
})
}
watch(zhou, (value) => { watch(zhou, (value) => {
week.value = getweek(value); week.value = getweek(value);
console.log(week.value); console.log(week.value);
getdates(userid)
}); });
return { return {
zhou, zhou,