直播一部分

This commit is contained in:
luyuan 2020-10-16 09:34:55 +08:00
parent ad1c54fdc9
commit bfcf22b479
Signed by: theluyuan
GPG Key ID: A7972FD973317FF3
4 changed files with 30 additions and 10 deletions

View File

@ -1,6 +1,6 @@
import router from '@/router'; import router from '@/router';
import store from '@/store'; import store from '@/store';
import { LiveList, LoginData, UserInfo, VideoInfo } from '@/types'; import { LiveList, LivelistInfo, LoginData, UserInfo, VideoInfo } from '@/types';
import { saveValue } from '@/utils/common'; import { saveValue } from '@/utils/common';
import { message } from 'ant-design-vue'; import { message } from 'ant-design-vue';
import { del, get, post, put, setToken } from './base' import { del, get, post, put, setToken } from './base'
@ -135,10 +135,10 @@ export async function getvideolist(): Promise<VideoList[]> {
export async function getlivelist(data?:any):Promise<LiveList[]> { export async function getlivelist(data?:any):Promise<LivelistInfo> {
const res = await get<Array<LiveList>>('live',data); const res = await get<Array<LiveList>>('live',data);
// console.log(res); console.log(res);
return res.data return res;
} }
/** /**

View File

@ -10,6 +10,7 @@ declare module 'axios' {
code: number; code: number;
msg: string; msg: string;
data: T; data: T;
total: number;
[keys: string]: any; [keys: string]: any;
} }
} }
@ -87,4 +88,11 @@ export interface LiveList {
statusname: string; statusname: string;
starttime: string; starttime: string;
begin: number; begin: number;
}
export interface LivelistInfo {
data: LiveList[];
code: number;
msg: string;
total: number;
} }

View File

@ -41,7 +41,7 @@
:width="80" :width="80"
v-else v-else
/> />
<video style="display: none" :src="videofile"></video> <!-- <video style="display: none" :src="videofile"></video> -->
</div> </div>
<div <div
class="upload-image upload" class="upload-image upload"

View File

@ -14,13 +14,13 @@
</div> </div>
<div class="sel"> <div class="sel">
<img src="@/static/images/sousuo.png" alt="" class="icon" /> <img src="@/static/images/sousuo.png" alt="" class="icon" />
<input type="text" /> <input placeholder="请输入想要搜索的直播标题" type="text" @keyup.enter="sel()" v-model="input" />
</div> </div>
</div> </div>
<div class="list" v-if="tabindex == 1"> <div class="list" v-if="tabindex == 1">
<LiveItem <LiveItem
:type="2" :type="2"
v-for="(i, j) in livelist" v-for="(i, j) in livelist.data"
:key="j" :key="j"
:img="i.img" :img="i.img"
:title="i.title" :title="i.title"
@ -48,7 +48,7 @@
<LiveItem :type="2"></LiveItem> <LiveItem :type="2"></LiveItem>
</div> </div>
<div class="pages"> <div class="pages">
<a-pagination v-model:current="page" :total="500" :showLessItems="true" /> <a-pagination v-model:current="page" :total="livelist.total" :showLessItems="true" />
</div> </div>
</div> </div>
</template> </template>
@ -156,7 +156,7 @@
import { defineComponent, onMounted, ref } from "vue"; import { defineComponent, onMounted, ref } from "vue";
import LiveItem from "@/components/LiveItem.vue"; import LiveItem from "@/components/LiveItem.vue";
import { getlivelist } from "@/api"; import { getlivelist } from "@/api";
import { LiveList } from "@/types"; import { LivelistInfo } from "@/types";
export default defineComponent({ export default defineComponent({
components: { components: {
LiveItem, LiveItem,
@ -164,18 +164,30 @@ export default defineComponent({
setup() { setup() {
const page = ref(1); const page = ref(1);
const tabindex = ref(1); const tabindex = ref(1);
const livelist = ref<LiveList[]>(); const livelist = ref<LivelistInfo>({
code: 0,
total: 0,
msg: "",
data: []
});
const input = ref("")
onMounted(async () => { onMounted(async () => {
livelist.value = await getlivelist(); livelist.value = await getlivelist();
}); });
function tabchange(e: number): void { function tabchange(e: number): void {
tabindex.value = e; tabindex.value = e;
} }
async function sel(){
console.log(input.value)
livelist.value = await getlivelist({title: input.value});
}
return { return {
page, page,
tabindex, tabindex,
tabchange, tabchange,
livelist, livelist,
input,
sel
}; };
}, },
}); });