<template>
	<view class="wrap">
		<image class="bg" :src="require('@/static/qus-bg.jpg')" mode=""></image>
		<view class="book">
			<!-- <swiper class="swiper" @change="changeBook" :current="bookIndex" circular previous-margin="80rpx"
				next-margin="110rpx">
				<swiper-item  class="book-item" v-for="(item,index) in bookList">
					<view class="book-img">
						<image
							:src="item.url?item.url:''" alt="" mode="heightFix">
					</view>
					<view class="book-title">
						{{item.title}}
					</view>
				</swiper-item>
			</swiper> -->
			<u-swiper @change="changeSwiper" :class="{'opacity0':addOpcity}" :list="bookList" :effect3d="true"
				:circular="true" :indicator="true" img-mode="widthFix" effect3d-previous-margin="140"
				:autoplay="false"></u-swiper>

		</view>



		<tabbar :currentPage="2"></tabbar>
	</view>
</template>

<script>
	import tabbar from '@/components/tabbar/tabbar.vue'
	import {
		shareInfo
	} from "@/common/util.js"
	export default {
		components: {
			tabbar
		},
		data() {
			return {
				navBarTop: 0,
				bookList: [],
				bookIndex: 0,
				swiperHeight: 0,
				addOpcity: true

			}
		},
		onShareAppMessage() {
			return shareInfo
		},
		onShareTimeline() {
			return shareInfo
		},
		onLoad() {
			// #ifndef H5
			const MenuButton = uni.getMenuButtonBoundingClientRect()
			this.navBarTop = MenuButton.top //左侧文字与右侧胶囊对齐
			// #endif
			// #ifdef H5
			this.navBarTop = 44 // H5端固定导航栏高度
			// #endif

			this.getBooks()
		},
		onShow() {
			let that = this
			uni.getSystemInfo({
				success: function(info) {
					console.log('屏幕的高度：' + info.windowHeight);
					that.swiperHeight = info.windowHeight * .7 * 2
					console.log(that.swiperHeight)
					console.log('屏幕的宽度：' + info.windowWidth);
				}
			});
		},
		methods: {
			changeSwiper(e) {
				console.log(e)
				this.addOpcity = false
			},
			changeBook(e) {
				console.log(e)
				this.bookIndex = e.detail.current
			},
			getBooks() {
				console.log("123")
				var that = this;
				var host = "https://gbyuyue.szgmbwg.org.cn"
				uni.request({
					url: host + '/api/mobile/book/index',
					data: {
						page: 1,
						page_size: 99,
						sort_name: 'datetime',
						sort_type: "ASC",
					},
					success: function(res) {
						console.log("res", res)
						let arr = []
						res.data.data.map(item => {
							arr.push({
								image: item.image.url,
								id: item.id,
								title: item.name
							})
						})
						that.bookList = arr
						that.addOpcity = true
						console.log(that.bookList)
					},
					fail: function(res) {

					}
				})
			},
		}
	}
</script>

<style lang="scss">
	.wrap {
		width: 100vw;
		height: 100vh;

		// overflow: scroll;
		.bg {
			height: 100vh;
			width: 100vw;
			position: absolute;
			top: 0;
			left: 0;
		}

		.book {
			padding: 175rpx 0;
			height: 100vh;

			swiper {
				height: calc(100vh - 550rpx) !important;
				background-color: transparent !important;

				image {
					height: 85%;

				}
			}

			::v-deep .u-swiper-wrap {
				height: 100%;
			}

			::v-deep .u-swiper-indicator {
				bottom: 150rpx !important;
			}

			::v-deep .u-list-image-wrap {
				// background-color: #fff;
			}

			.opacity0 swiper swiper-item:last-child {
				opacity: 0;
			}

			::v-deep .u-swiper-image {
				position: absolute;
				top: 50%;
				left: 50%;
				transform: translate(-50%, -50%) scale(1.7);
			}

			::v-deep .u-swiper-title {
				height: 15%;
				display: flex;
				align-items: center;
				justify-content: space-around;
				color: #333;
				font-size: 38rpx;
				background-color: #fff;
				overflow: auto;
				white-space: break-spaces;
				text-overflow: clip;
				text-align: center;

			}

			::v-deep .u-indicator-item-round-active {
				background-color: #9f4946;
			}

			&-item {
				padding: 0 30rpx;
				// transform: scale(.7);

				// margin:0 80rpx;
			}

			&-img {
				background-color: #fff;
				height: 70%;

				image {
					width: calc(100vw - 160rpx);
					height: 70%;
				}
			}

			&-title {
				text-align: center;
				padding: 75rpx 30rpx;
				background-color: #ffffff;
				display: flex;
				align-items: center;
				justify-content: space-around;
				font-size: 42rpx;
				color: #000;
			}
		}
	}
</style>