<template>
	<view>
		<uni-nav-bar title="经销商工作平台" backgroundColor='#03803B' color="#fff" fixed statusBar>
		</uni-nav-bar>
		<view style="padding: 20rpx 20rpx 0 20rpx;">
			<view style="border-radius: 10rpx;overflow: hidden;">
				<uni-swiper-dot :info="swiperList" :current="dotCurrent" mode="round" :dots-styles="dotsStyles">
					<swiper circular :autoplay="true" :interval="2000" :duration="500" @change="swiperChange">
						<!-- 	<swiper-item v-for="(item,index) in swiperList" :key="index">
							<image mode="scaleToFill" :src="item" style="width: 100%;height: 100%;">
							</image>
						</swiper-item> -->
						<swiper-item>
							<image mode="scaleToFill" src="@/static/images/home/sw1.jpg"
								style="width: 100%;height: 100%;">
							</image>
						</swiper-item>
						<swiper-item>
							<image mode="scaleToFill" src="@/static/images/home/sw2.jpg"
								style="width: 100%;height: 100%;">
							</image>
						</swiper-item>
						<swiper-item>
							<image mode="scaleToFill" src="@/static/images/home/sw3.png"
								style="width: 100%;height: 100%;">
							</image>
						</swiper-item>
						<swiper-item>
							<image mode="scaleToFill" src="@/static/images/home/sw4.jpg"
								style="width: 100%;height: 100%;">
							</image>
						</swiper-item>
					</swiper>
				</uni-swiper-dot>
			</view>
		</view>
		<view style="display: flex;justify-content: space-around;margin-top: 30rpx;">
			<view class="home-btn">
				<image style="width: 36rpx;height: 36rpx;" src="@/static/images/home/out.png" />扫码出库
			</view>
			<view class="home-btn">
				<image style="width: 36rpx;height: 36rpx;" src="@/static/images/home/work.png" />工作审批
			</view>
		</view>
		<view class="home-card">
			<view class="home-card-title">
				工厂
			</view>
			<uni-grid :column="4" :showBorder="false">
				<uni-grid-item style="display: flex;justify-content: center;">
					<view class="grid-item-box" @click="allClick('工厂订单')">
						<view class="grid-item-box-img">
							<image style="width: 45rpx;height: 45rpx;" src="@/static/images/home/home (1).png" />
						</view>
						<view class="grid-item-box-text">
							工厂订单
						</view>
					</view>
				</uni-grid-item>
				<uni-grid-item>
					<view class="grid-item-box" @click="allClick('工厂库存')">
						<view class="grid-item-box-img">
							<image style="width: 45rpx;height: 45rpx;" src="@/static/images/home/home (2).png" />
						</view>
						<view class="grid-item-box-text">
							工厂库存
						</view>
					</view>
				</uni-grid-item>
				<uni-grid-item>
					<view class="grid-item-box" @click="allClick('销售预测')">
						<view class="grid-item-box-img">
							<image style="width: 45rpx;height: 45rpx;" src="@/static/images/home/home (3).png" />
						</view>
						<view class="grid-item-box-text">
							销售预测
						</view>
					</view>
				</uni-grid-item>
				<uni-grid-item>
					<view class="grid-item-box" @click="allClick('商务政策 ')">
						<view class="grid-item-box-img">
							<image style="width: 45rpx;height: 45rpx;" src="@/static/images/home/home (4).png" />
						</view>
						<view class="grid-item-box-text">
							商务政策
						</view>
					</view>
				</uni-grid-item>
			</uni-grid>
		</view>
		<view class="home-card">
			<view class="home-card-title">
				门店
			</view>
			<uni-grid :column="4" :showBorder="false">
				<uni-grid-item style="display: flex;justify-content: center;">
					<view class="grid-item-box" @click="allClick('门店信息')">
						<view class="grid-item-box-img">
							<image style="width: 45rpx;height: 45rpx;" src="@/static/images/home/home (5).png" />
						</view>
						<view class="grid-item-box-text">
							门店信息
						</view>
					</view>
				</uni-grid-item>
				<uni-grid-item>
					<view class="grid-item-box" @click="allClick('门店审核')">
						<view class="grid-item-box-img">
							<image style="width: 45rpx;height: 45rpx;" src="@/static/images/home/home (6).png" />
						</view>
						<view class="grid-item-box-text">
							门店审核
						</view>
					</view>
				</uni-grid-item>
				<uni-grid-item>
					<view class="grid-item-box" @click="allClick('门店公海')">
						<view class="grid-item-box-img">
							<image style="width: 45rpx;height: 45rpx;" src="@/static/images/home/home (7).png" />
						</view>
						<view class="grid-item-box-text">
							门店公海
						</view>
					</view>
				</uni-grid-item>
				<uni-grid-item>
					<view class="grid-item-box" @click="allClick('装修申请')">
						<view class="grid-item-box-img">
							<image style="width: 45rpx;height: 45rpx;" src="@/static/images/home/home (8).png" />
						</view>
						<view class="grid-item-box-text">
							装修申请
						</view>
					</view>
				</uni-grid-item>
				<uni-grid-item>
					<view class="grid-item-box" @click="allClick('销售开单')">
						<view class="grid-item-box-img">
							<image style="width: 45rpx;height: 45rpx;" src="@/static/images/home/home (9).png" />
						</view>
						<view class="grid-item-box-text">
							销售开单
						</view>
					</view>
				</uni-grid-item>
				<uni-grid-item>
					<view class="grid-item-box" @click="allClick('收款')">
						<view class="grid-item-box-img">
							<image style="width: 45rpx;height: 45rpx;" src="@/static/images/home/home (10).png" />
						</view>
						<view class="grid-item-box-text">
							收款
						</view>
					</view>
				</uni-grid-item>
				<uni-grid-item>
					<view class="grid-item-box" @click="allClick('扫码')">
						<view class="grid-item-box-img">
							<image style="width:74rpx;height: 45rpx;" src="@/static/images/home/home (11).png" />
						</view>
						<view class="grid-item-box-text">
							扫码
						</view>
					</view>
				</uni-grid-item>
				<uni-grid-item>
					<view class="grid-item-box" @click="allClick('返利兑现')">
						<view class="grid-item-box-img">
							<image style="width: 45rpx;height: 45rpx;" src="@/static/images/home/home (12).png" />
						</view>
						<view class="grid-item-box-text">
							返利兑现
						</view>
					</view>
				</uni-grid-item>
			</uni-grid>
		</view>
		<view class="home-card" style="margin-bottom: 30rpx;">
			<view class="home-card-title">
				外勤
			</view>
			<uni-grid :column="4" :showBorder="false">
				<uni-grid-item style="display: flex;justify-content: center;">
					<view class="grid-item-box" @click="allClick('出入库')">
						<view class="grid-item-box-img">
							<image style="width: 45rpx;height: 45rpx;" src="@/static/images/home/home (13).png" />
						</view>
						<view class="grid-item-box-text">
							出入库
						</view>
					</view>
				</uni-grid-item>
				<uni-grid-item>
					<view class="grid-item-box" @click="allClick('投诉')">
						<view class="grid-item-box-img">
							<image style="width: 45rpx;height: 45rpx;" src="@/static/images/home/home (14).png" />
						</view>
						<view class="grid-item-box-text">
							投诉
						</view>
					</view>
				</uni-grid-item>
				<uni-grid-item>
					<view class="grid-item-box" @click="allClick('理赔')">
						<view class="grid-item-box-img">
							<image style="width: 45rpx;height: 45rpx;" src="@/static/images/home/home (15).png" />
						</view>
						<view class="grid-item-box-text">
							理赔
						</view>
					</view>
				</uni-grid-item>
				<uni-grid-item>
					<view class="grid-item-box" @click="allClick('活动')">
						<view class="grid-item-box-img">
							<image style="width: 45rpx;height: 45rpx;" src="@/static/images/home/home (16).png" />
						</view>
						<view class="grid-item-box-text">
							活动
						</view>
					</view>
				</uni-grid-item>
			</uni-grid>
		</view>
	</view>
</template>

<script>
	import {
		getAddress
	} from '@/api/home/index.js'
	export default {
		data() {
			return {
				dotsStyles: {
					backgroundColor: 'rgba(0, 0, 0, .1)',
					border: '1px #03803B solid',
					color: '#03803B',
					selectedBackgroundColor: '#03803B',
					selectedBorder: '1px #03803B solid'
				},
				dotCurrent: 0,
				swiperList: [
					'@/static/images/home/sw1.jpg',
					'@/static/images/home/sw2.jpg',
					'@/static/images/home/sw3.jpg',
					'@/static/images/home/sw4.jpg'
				],
			}
		},
		onLoad() {
			if (uni.getStorageSync('accessToken')) {
				this.getAddressdata()
			}
		},
		methods: {
			swiperChange(e) {
				this.dotCurrent = e.detail.current;
			},
			getAddressdata() {
				if (!uni.getStorageSync("addressData")) {
					getAddress().then(res => {
						uni.setStorageSync('addressData', JSON.stringify(res.data));
					})
				}
			},
			allClick(name) {
				if (name == '门店信息') {
					uni.navigateTo({
						url: '/pages/home/store/index'
					});
				}
				if (name == '理赔') {
					uni.navigateTo({
						url: '/pages/home/claim/index'
					});
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
	.nav-right {
		width: 32rpx;
		height: 30rpx;
	}
	.home-btn{
		width: 288rpx;
		height: 100rpx;
		background: #03803B;
		border-radius: 10rpx;
		display: flex;
		justify-content: center;
		align-items: center;
		font-size: 34rpx;
		color: #FFFFFF;
	}
	.home-card {
		margin-top: 30rpx;
		background: #FFFFFF;
		padding: 40rpx 40rpx 10rpx 40rpx;

		.home-card-title {
			font-weight: 500;
			font-size: 34rpx;
			color: #0F0D0D;
			margin-left: 20rpx;
			margin-bottom: 10rpx;
		}

		.grid-item-box {
			display: flex;
			flex-direction: column;
			align-items: center;

			.uni-grid-item__box {
				justify-content: center;
			}

			.grid-item-box-img {
				display: flex;
				justify-content: center;
				align-items: center;
				width: 100rpx;
				height: 100rpx;
			}

			.grid-item-box-text {
				// width: 120rpx;
				text-align: center;
				font-weight: 500;
				font-size: 26rpx;
				color: #6A6A6A;
			}
		}

	}
</style>