<template>
	<view class="container">
		<view class="top">
			<uni-swiper-dot class="uni-swiper-dot-box" @clickItem=clickItem :info="info" :current="current" :mode="mode"
				field="content">
				<swiper class="swiper-box" @change="changeSwiper" :current="swiperDotIndex" :autoplay="autoplay"
					:interval="interval" :duration="duration">
					<swiper-item v-for="(item, index) in 3" :key="index">
						<view class="swiper-item" :class="'swiper-item' + index">
							<text style="color: #fff; font-size: 32px;">{{index+1}}</text>
						</view>
					</swiper-item>
				</swiper>
			</uni-swiper-dot>
		</view>
		
		<view class="middle">
			<uni-group mode="card">
				<uni-grid :column="2" :square="true" :highlight="false" @change="change" :showBorder="true">
					<uni-grid-item v-for="(val, i) in funcList" :index="i" :key="i">
						<view class="grid-item-box">
							<uni-icons type="image" :size="30" color="#777" />
							<text class="text">{{ val.title }}</text>
						</view>
					</uni-grid-item>
				</uni-grid>
			</uni-group>
		</view>
		
		<view class="foot">
				<uni-group mode="card" title="素材数据" style="text-align:center;">
					<uni-grid :column="3" :square="true" :highlight="false">
						<uni-grid-item v-for="(params, v) in list" :index="v" :key="v">
							<view class="grid-item-box">
								<uni-icons type="image" :size="30" color="#777" />
								<text class="text">{{ params.text }}</text>
								<text class="text">{{ params.num }}</text>
							</view>
						</uni-grid-item>
					</uni-grid>
				</uni-group>
		</view>
		
	</view>
</template>

<script>
	
	export default {
		data() {
			return {
				info: [{
					content: '内容 A'
				}, {
					content: '内容 B'
				}, {
					content: '内容 C'
				}],
				current: 0,
				mode: 'nav',
				swiperDotIndex: 0,
				autoplay: true,
				interval: 5000,
				duration: 500,
				pageUrl:'',
				funcList: [{
					title: '素材管理',
					url: '/pages/index/material/material'
				}, {
					title: '上传素材',
					url: '/pages/index/upload/upload'
				}],
				list: [{
						url: '/static/c1.png',
						text: '头像',
						num: '16'
					},
					{
						url: '/static/c2.png',
						text: '背景图',
						num: '1'
					},
					{
						url: '/static/c3.png',
						text: '手机壁纸',
						num: '99'
					},
					{
						url: '/static/c4.png',
						text: '动态壁纸',
						num: '23',
					},
					{
						url: '/static/c5.png',
						text: 'apple watch',
						num: '15'
					},
					{
						url: '/static/c6.png',
						text: '表情包',
						num: '31'
					}
				]
			};
		},
		created(){
			const userInfo = uni.getStorageSync('userInfo')
			if (!userInfo) {
				console.log('havent userInfo')
				//this.getUserInfo()
			} else {
				console.log('have userInfo')
			}
		},
		methods: {
			changeSwiper(e){
				this.current = e.detail.current;
			},
			change(e) {
				this.pageUrl = this.funcList[e.detail.index].url
				console.log('this.pageUrl',this.pageUrl)
				/** 跳转指定页面*/
				 uni.navigateTo({
				 	url: this.pageUrl
				 });
			},
			clickItem(e) {
				this.swiperDotIndex = e
				console.log('this.swiperDotIndex', this.swiperDotIndex) 
			},
		}
	}
</script>

<style lang="scss">
	.container{
		font-family:‘Franklin Gothic Medium’, ‘Arial Narrow’, Arial, sans-serif;
	}
	.grid-item-box {
		flex: 1;
		// position: relative;
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex-direction: column;
		align-items: center;
		justify-content: center;
		padding: 10px 0;
	}

	.grid-item-box-row {
		flex: 1;
		// position: relative;
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex-direction: row;
		align-items: center;
		justify-content: center;
		padding: 10px 0;
	}

	.swiper-box {
		height: 150px;
	}

	.swiper-item {
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex-direction: column;
		justify-content: center;
		align-items: center;
		height: 200px;
		color: #fff;
	}

	.swiper-item0 {
		background-color: #cee1fd;
	}

	.swiper-item1 {
		background-color: #b2cef7;
	}

	.swiper-item2 {
		background-color: #cee1fd;
	}

	.image {
		width: 750rpx;
	}

	/* #ifndef APP-NVUE */
	::v-deep .image img {
		-webkit-user-drag: none;
		-khtml-user-drag: none;
		-moz-user-drag: none;
		-o-user-drag: none;
		user-drag: none;
	}

	/* #endif */

	@media screen and (min-width: 500px) {
		.uni-swiper-dot-box {
			width: 400px;
			margin: 0 auto;
			margin-top: 8px;
		}

		.image {
			width: 100%;
		}
	}

	.uni-bg-blue {
		background-color: #007aff;
	}

</style>
