wyling007 3 年之前
父節點
當前提交
6b5a5a1e77
共有 2 個文件被更改,包括 11 次插入3 次删除
  1. 1 0
      src/api/modules/carVideo.js
  2. 10 3
      src/pages/carVideo/components/branchOne.vue

+ 1 - 0
src/api/modules/carVideo.js

@@ -84,6 +84,7 @@ class CarVideo {
 		const mapFn = (obj) => {
 			let newObj = {}
 			newObj.chapterName = obj.typeName
+			newObj.id = obj.id
 			newObj.children = obj.children.map(mapFn)
 			newObj.list = obj.videos.map(cleanData)
 			return newObj

+ 10 - 3
src/pages/carVideo/components/branchOne.vue

@@ -6,7 +6,10 @@
 				<van-sidebar-item :title="item.chapterName" v-for="(item,index) in carVideoList" :key='index' />
 			</van-sidebar>
 			<view class="video-box">
-				<m-video-leftright :carVideoItem='item' v-for="(item,index) in carVideoList[activeKey].list" :key='index'>
+				<view v-if="currentList.length===0">
+					暂无视频
+				</view>
+				<m-video-leftright v-else :carVideoItem='item' v-for="(item,index) in currentList" :key='index'>
 				</m-video-leftright>
 			</view>
 		</view>
@@ -23,17 +26,21 @@
 		data: () => ({
 			bannerList: [],
 			loading: true,
-			activeKey: 0
+			activeKey: 0,
+			currentList:[]
 		}),
 		methods: {
-			sidebarOnChange(e) {
+			async sidebarOnChange(e) {
 				this.activeKey = e.detail
+				const {data} = await this.$api.carVideo.getCarVideoList(this.carVideoList[this.activeKey].id)
+				this.currentList=data
 			}
 		},
 		async mounted() {
 			let {
 				data: bannerListData
 			} = await this.$api.home.getHomePageDataList(['carouselChart'])
+			this.sidebarOnChange({detail:this.activeKey})
 			this.bannerList = bannerListData.carouselChart
 			this.$nextTick(() => {
 				this.loading = false