hookehuyr

✨ feat(我的作品,我的订阅,我的收藏): API联调

1 <template> 1 <template>
2 <div class="video-wrapper" style="position: relative;"> 2 <div class="video-wrapper" style="position: relative;">
3 - <div class="status"> 3 + <div v-if="mp" class="status">
4 <van-image v-if="item.status === 'ENABLE'" round width="6rem" height="6rem" style="vertical-align: bottom;" :src="icon_enable" /> 4 <van-image v-if="item.status === 'ENABLE'" round width="6rem" height="6rem" style="vertical-align: bottom;" :src="icon_enable" />
5 <van-image v-if="item.status === 'REFUSE'" round width="6rem" height="6rem" style="vertical-align: bottom;" :src="icon_refuse" /> 5 <van-image v-if="item.status === 'REFUSE'" round width="6rem" height="6rem" style="vertical-align: bottom;" :src="icon_refuse" />
6 <van-image v-if="item.status === 'APPLY'" round width="6rem" height="6rem" style="vertical-align: bottom;" :src="icon_apply" /> 6 <van-image v-if="item.status === 'APPLY'" round width="6rem" height="6rem" style="vertical-align: bottom;" :src="icon_apply" />
7 </div> 7 </div>
8 <div class="video-div" :id="'mui-player-' + item.id"></div> 8 <div class="video-div" :id="'mui-player-' + item.id"></div>
9 + <div v-if="mp">
9 <div v-if="item.status === 'ENABLE'" class="normal-module"> 10 <div v-if="item.status === 'ENABLE'" class="normal-module">
10 <div class="video-bar"> 11 <div class="video-bar">
11 <van-row> 12 <van-row>
...@@ -40,6 +41,7 @@ ...@@ -40,6 +41,7 @@
40 </div> 41 </div>
41 </div> 42 </div>
42 </div> 43 </div>
44 + </div>
43 </template> 45 </template>
44 46
45 <script setup> 47 <script setup>
...@@ -49,6 +51,7 @@ ...@@ -49,6 +51,7 @@
49 import icon_dianzan1 from '@images/icon-dianzan01@2x.png' 51 import icon_dianzan1 from '@images/icon-dianzan01@2x.png'
50 import icon_dianzan2 from '@images/icon-dianzan02@2x.png' 52 import icon_dianzan2 from '@images/icon-dianzan02@2x.png'
51 import icon_liuyan from '@images/icon-liuyan@2x.png' 53 import icon_liuyan from '@images/icon-liuyan@2x.png'
54 +
52 import icon_refuse from '@images/icon-jujue@2x.png' 55 import icon_refuse from '@images/icon-jujue@2x.png'
53 import icon_apply from '@images/icon-shenhe@2x.png' 56 import icon_apply from '@images/icon-shenhe@2x.png'
54 import icon_enable from '@images/icon-tongguo@2x.png' 57 import icon_enable from '@images/icon-tongguo@2x.png'
...@@ -77,7 +80,8 @@ export default { ...@@ -77,7 +80,8 @@ export default {
77 props: ['item'], 80 props: ['item'],
78 data() { 81 data() {
79 return { 82 return {
80 - detail: {} 83 + detail: {},
84 + mp: ''
81 } 85 }
82 }, 86 },
83 created() { 87 created() {
...@@ -96,6 +100,7 @@ export default { ...@@ -96,6 +100,7 @@ export default {
96 { attrKey: 'x5-video-player-type', attrValue: 'h5-page' }, 100 { attrKey: 'x5-video-player-type', attrValue: 'h5-page' },
97 ] 101 ]
98 }) 102 })
103 + this.mp = mp; // 渲染速度问题,只有视频控件渲染完成后显示
99 this.detail = _.cloneDeep(this.item); 104 this.detail = _.cloneDeep(this.item);
100 }, 500); 105 }, 500);
101 }, 106 },
......
...@@ -26,7 +26,7 @@ const props = defineProps({ ...@@ -26,7 +26,7 @@ const props = defineProps({
26 const emit = defineEmits(['on-click']); 26 const emit = defineEmits(['on-click']);
27 const handle = () => { 27 const handle = () => {
28 if (props.type === 'C') { // 类型是客户端时,才能查看 28 if (props.type === 'C') { // 类型是客户端时,才能查看
29 - emit('on-click', '') 29 + emit('on-click', props.item)
30 } 30 }
31 } 31 }
32 32
......
1 <template> 1 <template>
2 <div class="video-wrapper"> 2 <div class="video-wrapper">
3 <div class="video-div" :id="'mui-player-' + item.id"></div> 3 <div class="video-div" :id="'mui-player-' + item.id"></div>
4 - <div class="normal-module"> 4 + <div v-if="mp" class="normal-module">
5 <div class="video-bar"> 5 <div class="video-bar">
6 <van-row> 6 <van-row>
7 <van-col span="12" @click="goTo"> 7 <van-col span="12" @click="goTo">
...@@ -65,7 +65,8 @@ export default { ...@@ -65,7 +65,8 @@ export default {
65 props: ['item'], 65 props: ['item'],
66 data() { 66 data() {
67 return { 67 return {
68 - detail: {} 68 + detail: {},
69 + mp: ''
69 } 70 }
70 }, 71 },
71 created() { 72 created() {
...@@ -84,6 +85,7 @@ export default { ...@@ -84,6 +85,7 @@ export default {
84 { attrKey: 'x5-video-player-type', attrValue: 'h5-page' }, 85 { attrKey: 'x5-video-player-type', attrValue: 'h5-page' },
85 ] 86 ]
86 }) 87 })
88 + this.mp = mp;
87 this.detail = _.cloneDeep(this.item) 89 this.detail = _.cloneDeep(this.item)
88 }, 500); 90 }, 500);
89 }, 91 },
......
...@@ -26,7 +26,7 @@ axios.interceptors.request.use( ...@@ -26,7 +26,7 @@ axios.interceptors.request.use(
26 // 响应拦截器 26 // 响应拦截器
27 axios.interceptors.response.use( 27 axios.interceptors.response.use(
28 response => { 28 response => {
29 - let userType = router && router.currentRoute.value.href.indexOf('business') > 0 ? 'b' : 'c'; 29 + let userType = router && router.currentRoute.value.href?.indexOf('business') > 0 ? 'b' : 'c';
30 if (response.data.code === 401) { 30 if (response.data.code === 401) {
31 // 未授权跳转登录页 31 // 未授权跳转登录页
32 // 带着上一个页面的信息 32 // 带着上一个页面的信息
......
1 <template> 1 <template>
2 <div class="book-video-list"> 2 <div class="book-video-list">
3 - <van-list v-model:loading="loading" :finished="finished" finished-text="没有更多了" @load="onLoad"> 3 + <template v-for="item in prodList" :key="item" style="height: 3rem;">
4 - <template v-for="item in dataList" :key="item" style="height: 3rem;">
5 <video-card :item="item"></video-card> 4 <video-card :item="item"></video-card>
6 </template> 5 </template>
7 - </van-list> 6 + <div style="height: 2rem;"></div>
8 </div> 7 </div>
9 </template> 8 </template>
10 9
...@@ -21,31 +20,22 @@ const $route = useRoute(); ...@@ -21,31 +20,22 @@ const $route = useRoute();
21 const $router = useRouter(); 20 const $router = useRouter();
22 21
23 // 处理书籍下作品列表 22 // 处理书籍下作品列表
24 -const list = ref([]); 23 +const prodList = ref([])
25 -const loading = ref(false); 24 +axios.get('/srv/?a=my_favor')
26 -const finished = ref(false); 25 +.then(res => {
27 - 26 + if (res.data.code === 1) {
28 -const onLoad = () => { 27 + prodList.value = res.data.data.prod;
29 - // 异步更新数据 28 + } else {
30 - // setTimeout 仅做示例,真实场景中一般为 ajax 请求 29 + console.warn(res);
31 - setTimeout(() => { 30 + Toast({
32 - for (let i = 0; i < 20; i++) { 31 + icon: 'close',
33 - list.value.push(list.value.length + 1); 32 + message: res.data.msg
34 - } 33 + });
35 -
36 - // 加载状态结束
37 - loading.value = false;
38 -
39 - // 数据全部加载完成
40 - if (list.value.length >= 100) {
41 - finished.value = true;
42 } 34 }
43 - }, 1000); 35 +})
44 -}; 36 +.catch(err => {
45 - 37 + console.error(err);
46 - onMounted(() => { 38 +})
47 -
48 - })
49 </script> 39 </script>
50 40
51 <script> 41 <script>
......
...@@ -16,16 +16,31 @@ import { Toast } from 'vant'; ...@@ -16,16 +16,31 @@ import { Toast } from 'vant';
16 const $route = useRoute(); 16 const $route = useRoute();
17 const $router = useRouter(); 17 const $router = useRouter();
18 18
19 -const items = reactive([]) 19 +const items = ref([]);
20 - 20 +axios.get('/srv/?a=my_subscribe')
21 - onMounted(() => { 21 + .then(res => {
22 - for (let index = 0; index < 20; index++) { 22 + if (res.data.code === 1) {
23 - items.push({ 23 + items.value = res.data.data;
24 - id: index, 24 + } else {
25 - avatar: 'https://cdn.jsdelivr.net/npm/@vant/assets/cat.jpeg' 25 + console.warn(res);
26 - }) 26 + Toast({
27 + icon: 'close',
28 + message: res.data.msg
29 + });
27 } 30 }
28 }) 31 })
32 + .catch(err => {
33 + console.error(err);
34 + });
35 +
36 +const onClick = (item) => {
37 + $router.push({
38 + path: '/client/bookDetail',
39 + query: {
40 + id: item.id
41 + }
42 + });
43 +}
29 </script> 44 </script>
30 45
31 <script> 46 <script>
...@@ -33,12 +48,12 @@ import mixin from 'common/mixin'; ...@@ -33,12 +48,12 @@ import mixin from 'common/mixin';
33 48
34 export default { 49 export default {
35 mixins: [mixin.init], 50 mixins: [mixin.init],
36 - data () { 51 + data() {
37 return { 52 return {
38 53
39 } 54 }
40 }, 55 },
41 - mounted () { 56 + mounted() {
42 57
43 }, 58 },
44 methods: { 59 methods: {
...@@ -48,5 +63,4 @@ export default { ...@@ -48,5 +63,4 @@ export default {
48 </script> 63 </script>
49 64
50 <style lang="less" scoped> 65 <style lang="less" scoped>
51 -
52 </style> 66 </style>
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -47,7 +47,6 @@ export default { ...@@ -47,7 +47,6 @@ export default {
47 mixins: [mixin.init], 47 mixins: [mixin.init],
48 data () { 48 data () {
49 return { 49 return {
50 -
51 } 50 }
52 }, 51 },
53 mounted () { 52 mounted () {
......