hookehuyr

✨ feat(教师视频,家长视频): API联调

This diff is collapsed. Click to expand it.
......@@ -27,6 +27,7 @@ export const useUnwatchList = () => {
.then(res => {
if (res.data.code === 1) {
prod_list.value = _.concat(prod_list.value, res.data.data.prod);
prod_list.value = _.uniqBy(prod_list.value, 'id');
offset.value = prod_list.value.length;
loading.value = false;
// 数据全部加载完成
......
......@@ -102,6 +102,7 @@ export const useVideoList = ($route) => {
if (res.data.code === 1) {
bookInfo.value = res.data.data;
prod_list.value = _.concat(prod_list.value, res.data.data.prod_list);
prod_list.value = _.uniqBy(prod_list.value, 'id');
offset.value = prod_list.value.length;
loading.value = false;
// 数据全部加载完成
......
<template>
<div class="">
<van-tabs v-model:active="active" sticky @click-tab="onClickTab" color="#F9D95C" background="#F7F7F7"
title-active-color="#222222" title-inactive-color="#777777">
<van-tab title="待审核" badge="24" :title-style="titleStyle">
title-active-color="#222222" title-inactive-color="#777777">
<van-tab title="待审核" :badge="prod_num" :title-style="titleStyle">
<template v-if="!active">
<van-list v-model:loading="loading" :finished="finished" finished-text="没有更多了" @load="onLoad">
<template v-for="item in dataList" :key="item" style="height: 3rem;">
<template v-for="item in prod_list" :key="item" style="height: 3rem;">
<b-video-card :item="item" status="PENDING"></b-video-card>
</template>
</van-list>
......@@ -14,7 +14,7 @@
<van-tab title="已审核" :title-style="titleStyle">
<template v-if="active">
<van-list v-model:loading="loading" :finished="finished" finished-text="没有更多了" @load="onLoad">
<template v-for="item in dataList1" :key="item" style="height: 3rem;">
<template v-for="item in prod_list" :key="item" style="height: 3rem;">
<b-video-card :item="item" status="PROCESS"></b-video-card>
</template>
</van-list>
......@@ -25,54 +25,98 @@
</template>
<script setup>
import dataList from '@/mock/video_list'
import dataList1 from '@/mock/video_list1'
import BVideoCard from '@/components/BVideoCard/index.vue'
import { ref, reactive, onMounted } from 'vue'
import { useRoute, useRouter } from 'vue-router'
import axios from '@/utils/axios';
import $ from 'jquery'
import _ from 'lodash'
import { Toast } from 'vant';
const $route = useRoute();
const $router = useRouter();
const titleStyle = {
fontSize: '1rem'
}
/**
* 重载刷新程序
*/
const onReload = (v) => {
status.value = v
offset.value = 0
prod_list.value = []
loading.value = true;
finished.value = false;
onLoad()
}
const active = ref(0)
let tabStatus = ref('PENDING')
const onClickTab = () => {
console.warn(0);
const onClickTab = (v) => {
if (!v.name) {
onReload('apply')
} else {
onReload('checked')
}
}
// 绑定页面数据
const status = ref('apply');
const prod_num = ref('');
const prod_list = ref([]);
const limit = ref(10)
const offset = ref(0)
// 处理书籍下作品列表
const list = ref([]);
const loading = ref(false);
const finished = ref(false);
/**
* 向下滚动查询数据
*/
const onLoad = () => {
// 异步更新数据
// setTimeout 仅做示例,真实场景中一般为 ajax 请求
setTimeout(() => {
for (let i = 0; i < 20; i++) {
list.value.push(list.value.length + 1);
axios.get('/srv/?a=check_prod_list', {
params: {
status: status.value,
limit: limit.value,
offset: offset.value
}
// 加载状态结束
loading.value = false;
// 数据全部加载完成
if (list.value.length >= 100) {
finished.value = true;
}
}, 1000);
})
.then(res => {
if (res.data.code === 1) {
prod_num.value = res.data.data.prod_num;
_.each(res.data.data.prod, item => {
item.status = item.status.toUpperCase()
})
prod_list.value = _.concat(prod_list.value, res.data.data.prod);
prod_list.value = _.uniqBy(prod_list.value, 'id');
offset.value = prod_list.value.length;
loading.value = false;
// 数据全部加载完成
if (!res.data.data.prod.length) {
// 加载状态结束
finished.value = true;
}
} else {
console.warn(res);
Toast({
icon: 'close',
message: res.data.msg
});
}
})
.catch(err => {
console.error(err);
})
};
onMounted(() => {
})
</script>
<script>
......@@ -80,12 +124,12 @@ import mixin from 'common/mixin';
export default {
mixins: [mixin.init],
data () {
data() {
return {
}
},
mounted () {
mounted() {
},
methods: {
......@@ -98,7 +142,8 @@ export default {
:global(.van-badge--top-right) {
right: -10px;
}
:global(.van-sticky--fixed) {
z-index: 1000;
}
</style>
\ No newline at end of file
</style>
......
<template>
<div class="">
<van-list v-model:loading="loading" :finished="finished" finished-text="没有更多了" @load="onLoad">
<template v-for="item in dataList" :key="item" style="height: 3rem;">
<b-video-card :item="item"></b-video-card>
</template>
</van-list>
<template v-for="item in kgProdList" :key="item" style="height: 3rem;">
<b-video-card :item="item"></b-video-card>
</template>
<div style="height: 2rem;"></div>
</div>
</template>
<script setup>
import dataList from '@/mock/video_list'
import BVideoCard from '@/components/BVideoCard/index.vue'
import { ref, reactive, onMounted } from 'vue'
import { useRoute, useRouter } from 'vue-router'
import axios from '@/utils/axios';
import $ from 'jquery'
import _ from 'lodash'
import { Toast } from 'vant';
const $route = useRoute();
const $router = useRouter();
// 处理书籍下作品列表
const list = ref([]);
const loading = ref(false);
const finished = ref(false);
const onLoad = () => {
// 异步更新数据
// setTimeout 仅做示例,真实场景中一般为 ajax 请求
setTimeout(() => {
for (let i = 0; i < 20; i++) {
list.value.push(list.value.length + 1);
}
// 加载状态结束
loading.value = false;
// 数据全部加载完成
if (list.value.length >= 100) {
finished.value = true;
}
}, 1000);
};
onMounted(() => {
})
const kgProdList = ref([])
axios.get('/srv/?a=kg_prod_list')
.then(res => {
if (res.data.code === 1) {
_.each(res.data.data.prod, item => {
item.status = item.status.toUpperCase()
})
kgProdList.value = res.data.data.prod;
} else {
console.warn(res);
Toast({
icon: 'close',
message: res.data.msg
});
}
})
.catch(err => {
console.error(err);
})
</script>
<script>
......@@ -69,4 +61,4 @@ export default {
<style lang="less" scoped>
</style>
\ No newline at end of file
</style>
......