<template>
	<view class="home">
		<view class="home-navbar" :style="{'height': (statusBarHeight+44)+'px'}">
			<u-navbar :bgColor="bgColor" :fixed="false" title="首页">
				<view class="u-nav-slot" slot="left"></view>
				<view class="u-nav-slot" slot="content">
					<view class="nav"></view>
				</view>
			</u-navbar>
		</view>
		<view class="blank" :style="{'height': (statusBarHeight+44)+'px'}"></view>
		<view class="home-title">
			<text>共享经历 — 鹰眼计划</text>让恶行无处遁形，让善举更有价值！
		</view>
		<view class="home-search" @click="openPage(1)">
			<image src="@/static/icon-search.png"></image>
			支持根据姓名、公司、手机号等维度搜索
		</view>
		<view class="home-swiper">
			<u-swiper :list="bannerList" circular @change="changeSwiper" autoplay>
				<view slot="indicator" class="indicator">
					<view class="indicator__dot" v-for="(item, idx) in bannerList" :key="idx"
						:class="[idx === current && 'indicator__dot--active']"></view>
				</view>
			</u-swiper>
		</view>
		<view class="home-list">
			<view class="title">热门推荐</view>
			<view class="tab">
				 <u-tabs :list="list1" @click="click"
					lineWidth="0"
					:activeStyle="{
						 color: '#00C6A9',
						 border: '1px solid #00C6A9',
						 borderRadius: '5px',
						 width: '150rpx',
						 textAlign: 'center',
						padding: '10rpx 0',
						display: 'block',
					}"
					:inactiveStyle="{
						color: '#999999',
						border: '1px solid #999999',
						width: '150rpx',
						display: 'block',
						padding: '10rpx 0',
						textAlign: 'center',
						borderRadius: '5px'
					 }"
				 ></u-tabs>
			</view>
			<view class="list">
				<view class="item" v-for="i in 20" :key="i" @click="openPage(2)">
					<view class="name">王某某欠钱不还，已起诉</view>
					<view class="desc">欠钱不还/欺诈/拖欠工资</view>
					<view class="do">
						<view class="fl"><image class="img1" src="@/static/icon-view.png"></image>560</view>
						<view class="fl"><image class="img2" src="@/static/dianzan.png"></image>260</view>
					</view>
					<view class="tag">善</view>
				</view>
				<view class="item">
					<view class="name">王某某欠钱不还，已起诉</view>
					<view class="desc">欠钱不还/欺诈/拖欠工资</view>
					<view class="do">
						<view class="fl"><image class="img1" src="@/static/icon-view.png"></image>560</view>
						<view class="fl"><image class="img2" src="@/static/dianzan.png"></image>260</view>
					</view>
					<view class="tag tag-on">恶</view>
				</view>
			</view>
		</view>
		<foo-bar @toIndex="toIndex" :home="0"></foo-bar>
	</view>
</template>

<script>
	import fooBar from '@/components/fooBar/fooBar.vue'
	export default {
		components: {
			fooBar
		},
		data() {
			return {
				current: 0,
				list1: [{
                    name: '热点事件',
                }, {
                    name: '暖心善举',
                }, {
                    name: '恶行曝光'
                }],
				statusBarHeight: 0,
				bannerList: ['https://cdn.uviewui.com/uview/swiper/swiper1.png', 'https://cdn.uviewui.com/uview/swiper/swiper2.png', 'https://cdn.uviewui.com/uview/swiper/swiper3.png'],
				goodsList: [],
				bgColor: "transparent",
				index: 0,
				title: ''
			}
		},
		
		mounted() {
			uni.hideTabBar();
			this.statusBarHeight = uni.getSystemInfoSync().statusBarHeight;
			
		},
		onShow() {
			uni.removeStorageSync("goodsList")
			uni.removeStorageSync("scanInfo")
		},
		methods: {
			
			changeSwiper(e) {
				this.current = e.current;
			},
			openPage(index,id){
				if(index == 1){
					uni.navigateTo({
						url: "/pages/index/search"
					})
				}else if(index == 2){
					uni.navigateTo({
						url: "/pages/release/detail?id="+id
					})
				}
			},
			//系统公告
			async queryArticleList1() {
				const { code, data } = await this.$api.articleList({type: 2})
				if(code == 200){
					if(data && data.length > 0){
						this.articleList1 = data[0]
						this.showPopup = false
					}
				}
			},
			//获取轮播图
			async queryBannerList() {
				const { code, data } = await this.$api.bannerList({})
				let arr = []
				if(data && data.length > 0){
					data.map(a=>{
						arr.push(a.image)
					})
				}
				if(code == 200){
					this.bannerList = arr
				}
			},
			
			async toIndex(index) {
				let that = this
				that.index = index
				if (index == 0) {
					uni.switchTab({
						url: '/pages/index/index'
					})
				}else if (index == 2) {
					uni.switchTab({
						url: '/pages/release/index'
					})
				} else if (index == 3) {
					uni.switchTab({
						url: '/pages/user/index'
					})
				}
			},
		}
	}
</script>

<style lang="scss" scoped>
	.home {
		min-height: 100vh;
		background: url(@/static/bg.png) center top no-repeat;
		background-size: 100% auto;
		padding-bottom: 150rpx;
		overflow: hidden;
		box-sizing: border-box;
		&-navbar{
			position: fixed;
			left: 0;
			right: 0;
			top: 0;
			z-index: 12;
			width: 100%;
			background: url(@/static/bg.png) center top no-repeat;
			background-size: 100% auto;
		}
		&-title{
			text-align: center;
			padding: 38rpx;
			font-weight: 500;
			font-size: 26rpx;
			color: #333333;
			text{
				display: block;
				font-weight: bold;
				font-size: 36rpx;
				color: #333333;
				margin-bottom: 25rpx;
			}
		}
		&-search{
			width: 702rpx;
			height: 100rpx;
			background: #FFFFFF;
			border-radius: 20rpx;
			margin: 0 auto;
			display: flex;
			align-items: center;
			padding: 30rpx;
			box-sizing: border-box;
			margin-top: 20rpx;
			image{
				width: 31rpx;
				height: 35rpx;
				margin-right: 14rpx;
			}
			color: #808080;
				font-weight: 500;
				font-size: 26rpx;
			
		}
		&-swiper {
			padding: 0 30rpx;
			overflow: hidden;
			margin-top: 30rpx;
			.indicator {
				@include flex(row);
				justify-content: center;
				&__dot {
					width: 16rpx;
					height: 8rpx;
					border-radius: 16rpx;
					background-color: rgba(255, 255, 255, 0.35);
					margin: 0 3px;
					transition: background-color 0.3s;

					&--active {
						width: 30rpx;
						height: 8rpx;
						background-color: #ffffff;
					}
				}
			}
		}
		&-list{
			overflow: hidden;
			margin-top: 30rpx;
			.title{
				font-weight: bold;
				font-size: 36rpx;
				color: #333333;
				padding: 0 25rpx;
			}
			.tab{
				margin-top: 10rpx;
			}
			.list{
				padding: 0 25rpx 0;
				overflow: hidden;
				.item{
					width: 100%;
					height: 180rpx;
					background: #FFFFFF;
					box-shadow: 0px 3rpx 10rpx 0px rgba(9,44,39,0.05);
					border-radius: 20rpx;
					padding: 30rpx;
					box-sizing: border-box;
					position: relative;
					margin-top: 25rpx;
					.tag{
						width: 80rpx;
						height: 56rpx;
						text-align: center;
						line-height: 56rpx;
						background: #00C6A9;
						border-radius: 0px 20rpx 0px 20rpx;
						font-size: 32rpx;
						color: #FFFFFF;
						position: absolute;
						right: 0;
						top: 0;
						z-index: 2;
						&-on{
							background: #333333;
						}
					}
					.name{
						font-weight: 500;
						font-size: 30rpx;
						white-space: nowrap;
						text-overflow: ellipsis;
						overflow: hidden;
						color: #333333;
					}
					.desc{
						font-weight: 500;
						font-size: 24rpx;
						color: #999999;
						margin-top: 18rpx;
						white-space: nowrap;
						text-overflow: ellipsis;
						overflow: hidden;
					}
					.do{
						display: flex;
						align-items: center;
						margin-top: 10rpx;
						.fl{
							width: 130rpx;
							display: flex;
							align-items: center;
							font-weight: 500;
							font-size: 24rpx;
							color: #999999;
							.img1{
								width: 30rpx;
								height: 20rpx;
								margin-right: 10rpx;
								margin-top: 5rpx;
							}
							.img2{
								width: 24rpx;
								height: 24rpx;
								margin-right: 10rpx;
							}
						}
					}
				}
			}
		}
	}
</style>
