<template>
	<home-frame @toPath="toPath">
		<view class="main">
			<view class="one">
				<view class="one_1">
					<input type="text" placeholder="搜索视频" @tap="toCommon('pagesVideo/search/index','')">
				</view>
				<view class="one_2">
					<button size="mini" @tap="toCommon('pagesVideo/search/index','')">筛选</button>
				</view>
			</view>
			<view class="two">
				<scroll-view scroll-y="true" class="scroll-view">
					<view class="list-scroll-view">
						<view class="two_0 two_1">
							<swiper class="swiper" :autoplay="true" :interval="3000" :duration="1000">
								<swiper-item class="list" v-for="(item,index) in bannerList" :key="index"
									@tap="toWeb(item)">
									<image class="image"
										:src="item.img_url&&item.img_url.length>0?item.img_url[0].url:''" mode="">
									</image>
								</swiper-item>
							</swiper>
						</view>
						<view class="two_0 two_2">
							<view class="list textOver" v-for="(item,index) in linkList" :key="index"
								@tap="toWeb(item)">
								<image class="image" :src="item.img_url&&item.img_url.length>0?item.img_url[0].url:''"
									mode="">
								</image>
								<view class="name">
									{{item.title}}
								</view>
							</view>
						</view>
						<view class="two_0 two_4">
							<view class="top">
								<view class="top_1 textOver">
									<span>{{one_title}}</span>
								</view>
								<view class="top_2">
									<span
										@tap="toCommon('pagesVideo/more/index','head_actor=63f7175721efa85eb49b8ccd')">
										更多
										<uni-icons color="var(--rgbfff)" size="12" type="forward"></uni-icons>
									</span>
								</view>
							</view>
							<view class="info">
								<view class="list" v-for="(item,index) in oneList" :key="index">
									<image class="image"
										:src="item.img_url&&item.img_url.length>0?item.img_url[0].url:''" mode="">
									</image>
									<view class="name textOver">
										{{item.title}}
									</view>
									<view class="other">
										<view class="other_1">
											<uni-icons type="eye" color="var(--rgbfff)" size="12"></uni-icons>
											{{item.view_num}}
										</view>
										<view class="other_2">
											{{item.time_num}}
										</view>
									</view>
								</view>
							</view>
							<view class="btn">
								<button
									@tap="toCommon('pagesVideo/more/index','head_actor=63f7175721efa85eb49b8ccd')">查看更多</button>
							</view>
						</view>
						<view class="two_0 two_5">
							<view class="top">
								<view class="top_1 textOver">
									<span>{{two_title}}</span>
								</view>
								<view class="top_2">
									<span
										@tap="toCommon('pagesVideo/more/index','head_actor=63f7177221efa85eb49b8cdd')">
										更多
										<uni-icons color="var(--rgbfff)" size="12" type="forward"></uni-icons>
									</span>
								</view>
							</view>
							<view class="info">
								<view class="list" v-for="(item,index) in twoList" :key="index">
									<image class="image"
										:src="item.img_url&&item.img_url.length>0?item.img_url[0].url:''" mode="">
									</image>
									<view class="name textOver">
										{{item.title}}
									</view>
									<view class="other">
										<view class="other_1">
											<uni-icons type="eye" color="var(--rgbfff)" size="12"></uni-icons>
											{{item.view_num}}
										</view>
										<view class="other_2">
											{{item.time_num}}
										</view>
									</view>
								</view>
							</view>
							<view class="btn">
								<button
									@tap="toCommon('pagesVideo/more/index','head_actor=63f7177221efa85eb49b8cdd')">查看更多</button>
							</view>
						</view>
						<view class="two_0 two_5">
							<view class="top">
								<view class="top_1 textOver">
									<span>{{thr_title}}</span>
								</view>
								<view class="top_2">
									<span @tap="toCommon('pagesVideo/more/index','head_actor=63f7177f21efa85eb49b8ced')">更多<uni-icons color="var(--rgbfff)" size="12" type="forward"></uni-icons>
									</span>
								</view>
							</view>
							<view class="info">
								<view class="list" v-for="(item,index) in thrList" :key="index">
									<image class="image"
										:src="item.img_url&&item.img_url.length>0?item.img_url[0].url:''" mode="">
									</image>
									<view class="name textOver">
										{{item.title}}
									</view>
									<view class="other">
										<view class="other_1">
											<uni-icons type="eye" color="var(--rgbfff)" size="12"></uni-icons>
											{{item.view_num}}
										</view>
										<view class="other_2">
											{{item.time_num}}
										</view>
									</view>
								</view>
							</view>
							<view class="btn">
								<button @tap="toCommon('pagesVideo/more/index','head_actor=63f7177f21efa85eb49b8ced')">查看更多</button>
							</view>
						</view>
						<view class="two_0 two_6">
							<view class="top">
								<view class="top_1 textOver">
									<span>{{four_title}}</span>
								</view>
								<view class="top_2">
									<span @tap="toCommon('pagesVideo/more/index','head_actor=63f729ff3271105df0a88859')">更多<uni-icons color="var(--rgbfff)" size="12" type="forward"></uni-icons>
									</span>
								</view>
							</view>
							<view class="info">
								<view class="list" v-for="(item,index) in fourList" :key="index">
									<image class="image"
										:src="item.img_url&&item.img_url.length>0?item.img_url[0].url:''" mode="">
									</image>
									<view class="name textOver">
										{{item.title}}
									</view>
									<view class="other">
										<view class="other_1">
											<uni-icons type="eye" color="var(--rgbfff)" size="12"></uni-icons>
											{{item.view_num}}
										</view>
										<view class="other_2">
											{{item.time_num}}
										</view>
									</view>
								</view>
							</view>
							<view class="btn">
								<button @tap="toCommon('pagesVideo/more/index','head_actor=63f729ff3271105df0a88859')">查看更多</button>
							</view>
						</view>
					</view>
				</scroll-view>
			</view>
		</view>
	</home-frame>
</template>

<script>
	import homeFrame from "../components/home-frame.vue";
	export default {
		components: {
			homeFrame
		},
		data() {
			return {
				bannerList: [],
				linkList: [],
				one_title: '',
				oneList: [],
				two_title: '',
				twoList: [],
				thr_title: '',
				thrList: [],
				four_title: '',
				fourList: [],
			};
		},
		onLoad() {
			const that = this;
			that.search()
		},
		onShow() {},
		methods: {
			async search() {
				const that = this;
				// 轮播图
				let res;
				res = await that.$api('appbanner', 'GET', {
					place: '1',
					is_use: '0'
				});
				if (res.errcode == '0') {
					that.$set(that, `bannerList`, res.data)
				}
				// 热门链接
				res = await that.$api('hotlink', 'GET', {
					place: '1',
					is_use: '0'
				});
				if (res.errcode == '0') {
					that.$set(that, `linkList`, res.data)
				}
				// 顾红伟
				res = await that.$api('scenedata/63f7175721efa85eb49b8ccd', 'GET', {});
				if (res.errcode == '0') {
					that.$set(that, `one_title`, res.data.title);
					res = await that.$api('videos', 'GET', {
						skip: 0,
						limit: 6,
						is_use: '0',
						head_actor: res.data._id
					})
					if (res.errcode == '0') that.$set(that, `oneList`, res.data)
				}
				// 成龙
				res = await that.$api('scenedata/63f7177221efa85eb49b8cdd', 'GET', {});
				if (res.errcode == '0') {
					that.$set(that, `two_title`, res.data.title);
					res = await that.$api('videos', 'GET', {
						skip: 0,
						limit: 4,
						is_use: '0',
						head_actor: res.data._id
					})
					if (res.errcode == '0') that.$set(that, `twoList`, res.data)
				}
				// 李连杰
				res = await that.$api('scenedata/63f7177f21efa85eb49b8ced', 'GET', {});
				if (res.errcode == '0') {
					that.$set(that, `thr_title`, res.data.title);
					res = await that.$api('videos', 'GET', {
						skip: 0,
						limit: 6,
						is_use: '0',
						head_actor: res.data._id
					})
					if (res.errcode == '0') that.$set(that, `thrList`, res.data)
				}
				// 李小龙
				res = await that.$api('scenedata/63f729ff3271105df0a88859', 'GET', {});
				if (res.errcode == '0') {
					that.$set(that, `four_title`, res.data.title);
					res = await that.$api('videos', 'GET', {
						skip: 0,
						limit: 4,
						is_use: '0',
						head_actor: res.data._id
					})
					if (res.errcode == '0') that.$set(that, `fourList`, res.data)
				}
			},
			toWeb(e) {
				const that = this;
				let system = that.$config.system
				if (system.uniPlatform == 'app') {
					plus.runtime.openURL(e.web_url)
				} else if (system.uniPlatform == 'mp-weixin') {
					uni.showToast({
						title: '小程序无法打开链接，请打开app进行跳转',
						icon: "none"
					})
				}
			},
			toCommon(route, query) {
				uni.navigateTo({
					url: `/${route}?${query}`
				})
			},
			// 跳转页面
			toPath(e) {
				let url = `/${e.route}`;
				if (e.type == '0') uni.navigateTo({
					url
				})
				else if (e.type == '1') uni.redirectTo({
					url
				})
				else if (e.type == '2') uni.reLaunch({
					url
				})
				else if (e.type == '3') uni.switchTab({
					url
				})
			}
		},
	};
</script>

<style lang="scss">
	.main {
		background-color: var(--rgb000);
		display: flex;
		flex-direction: column;
		width: 100vw;
		height: 92vh;

		.one {
			background-color: var(--rgb111);
			display: flex;
			padding: 8px;

			.one_1 {
				flex-grow: 1;

				input {
					border: 1px solid var(--rgbf1f);
					height: 30px;
					border-radius: 2px;
					padding: 0 5px;
					font-size: 12px;
				}
			}

			.one_2 {
				button {
					height: 100%;
					background-color: var(--rgbfa4);
					color: var(--rgbfff);
				}
			}
		}

		.two {
			position: relative;
			flex-grow: 1;


			.two_0 {
				margin: 0 0 10px 0;
				padding: 0 8px;

				.top {
					margin: 0 0 10px 0;
					display: flex;
					padding: 5px 0;

					.top_1 {
						flex-grow: 1;

						span {
							color: var(--rgbfff);
							font-size: 20px;
							font-family: monospace;
							font-weight: bold;
						}
					}

					.top_2 {
						span {
							color: var(--rgbfff);
							font-size: 14px;
						}

					}
				}

				.info {
					margin: 0 0 10px 0;
					display: flex;
					justify-content: space-between;
					flex-wrap: wrap;

					.list {
						width: 48%;
						margin: 0 0 10px 0;

						.image {
							width: 100%;
							height: 100px;
							overflow: hidden;
							border-radius: 5px;
						}

						.name {
							font-size: 14px;
							color: var(--rgbfff);
						}

						.other {
							display: flex;
							color: var(--rgbfff);
							font-size: 12px;
							justify-content: space-between;
						}


					}
				}

				.btn {
					button {
						border-radius: 25px;
						background-color: var(--rgbfa4);
						color: var(--rgbfff);
						font-size: 14px;
					}
				}
			}

			.two_1 {
				.swiper {
					height: 200px;
					overflow: hidden;
				}

				.list {
					.image {
						width: 100%;
						height: 100%;
					}
				}
			}

			.two_2 {
				display: flex;
				flex-direction: row;
				flex-wrap: wrap;
				justify-content: space-between;

				.list {
					text-align: center;
					width: 18%;
					margin: 0 0 10px 0;

					.image {
						width: 100%;
						height: 64px;
						border-radius: 90%;
						margin: 0 0 5px 0;
					}

					.name {
						font-size: 12px;
						color: #ffffff;
					}

				}
			}
		}
	}

	.scroll-view {
		position: absolute;
		top: 0;
		left: 0;
		right: 0;
		bottom: 0;

		.list-scroll-view {
			display: flex;
			flex-direction: column;
		}
	}
</style>
