<template>
	<view class="home-page">
		<!-- <view class="status_bar">
		</view> -->
		<view class="banner">
			<!-- <view class="search-block">
				<image class="icon-search" src="../../static/image/search@3x.png" mode=""></image>
				<text>搜索</text>
			</view> -->
			<uni-swiper-dot :info="info" :current="current" field="content" :dotsStyles="dotsStyles" :mode="mode">
				<swiper class="swiper-box" @change="change" autoplay='true' interval='7000'>
					<swiper-item v-for="(item ,index) in info" :key="index">
						<view class="swiper-item">
							<image class="swiper-item-img" src="../../static/image/banner@3x.png" mode="widthFix">
							</image>
						</view>
					</swiper-item>
				</swiper>
			</uni-swiper-dot>
		</view>
		<view class="content">
			<view class="todo-box block">
				<text class="title">市场秩序</text>
				<view class="amount-block">
					<view class="order-amount" @click="entryHandle('breakwords-clue')">
						<view class="order-amount--wrapper">
							<image class="entry-icon" src="@/static/image/home_report@3x.png" mode="aspectFit">
							</image>
							<text class="order-amount--num">提报线索</text>
						</view>
					</view>
					<view class="order-amount" @click="entryHandle('breakwords-market')">
						<view class="order-amount--wrapper">
							<image class="entry-icon" src="@/static/image/home_marketclue@3x.png" mode="aspectFit">
							</image>
							<text class="order-amount--num">市场线索</text>
						</view>
					</view>
					<view class="order-amount" @click="entryHandle('breakwords-mission')">
						<view class="order-amount--wrapper">
							<image class="entry-icon" src="@/static/image/home_breakmission@3x.png" mode="aspectFit">
							</image>
							<text class="order-amount--num">违约任务</text>
						</view>
					</view>
					<view class="order-amount" @click="entryHandle('breakwords-handle')">
						<view class="order-amount--wrapper">
							<image class="entry-icon" src="@/static/image/home_breakrule@3x.png" mode="aspectFit">
							</image>
							<text class="order-amount--num">违约处理</text>
						</view>
					</view>
				</view>
			</view>
			<!-- 	<view class="notice-block block">
				<image class="icon-notic" src="../../static/image/notice@3x.png" mode=""></image>
				<uni-notice-bar single="true" showGetMore="false" backgroundColor='#feebe6' color="#333"
					:text="noticeContent">
				</uni-notice-bar>
			</view> -->
			<!-- <view class="todo-box block">
			<text class="title">待办</text>
			<view class="cell-list">
				<view class="cell-list-block" @click="goFundsConfirm">
					<image class="icon-address" src="@/static/image/funds@3x.png" mode="aspectFit"></image>
					<view class="cell-list-block__content">
						<text class="cell-list-block__title">打款500,000.00 ，请确认用途</text>
						<text class="cell-list-block__desc">3月27日 14:00</text>
					</view>
					<image class="icon-arrow" src="@/static/image/arrow_r@3x.png" mode="aspectFit"></image>
				</view>
				<view class="cell-list-block">
					<image class="icon-address" src="@/static/image/funds@3x.png" mode="aspectFit"></image>
					<view class="cell-list-block__content">
						<text class="cell-list-block__title">打款500,000.00 ，请确认用途</text>
						<text class="cell-list-block__desc">3月27日 14:00</text>
					</view>
					<image class="icon-arrow" src="@/static/image/arrow_r@3x.png" mode="aspectFit"></image>
				</view>
			</view>
		</view> -->
			<view class="charts-box block">
				<view class="title">
					<text class="title-text">订单执行情况</text>
					<view class="summary">
						<text class="num">{{orderAmount}}</text>万
					</view>
				</view>
				<qiun-data-charts type="column" :chartData="chartData" :opts="uchartOpts" :ontouch="true"
					background="none" />
			</view>
		</view>
	</view>
</template>

<script>
	import {
		mapState
	} from 'vuex'
	import {
		apiGetHomeStatistics
	} from '@/servers/common.js'

	export default {
		data() {
			return {
				info: [{
					content: '内容 A'
				}, {
					content: '内容 B'
				}, {
					content: '内容 C'
				}],
				current: 0,
				mode: 'round',
				noticeContent: '9.10日，21:00-24:00系统升级，系统停止服务',
				uchartOpts: {
					padding: [0, 0, 0, 0],
					color: ['#FDB95A', '#528FF4', '#FF7282', '#C38AFF', '#FFD600'],
					enableScroll: true,
					xAxis: {
						disableGrid: true,
						itemCount: 3,
						fontSize: 12
					},
					yAxis: {
						"dashLength": 20,
						disabled: true
					},
					legend: {
						"position": "bottom",
						"float": "left",
						margin: 20
					},
					extra: {
						column: {
							categoryGap: 7
						}
					},
					series: {
						show: false
					},
					padding: [50, 0, 20, 0]
				},
				chartData: {
					"categories": [
						"1618",
						"七代",
					],
					"series": [{
						"name": "制票总金额",
						"data": []
					}, {
						"name": "订单总金额",
						"data": []
					}, {
						"name": "订单总件数",
						"data": []
					}]
					// "series": [{
					// 		"name": "购买数量(件)",
					// 		"data": [
					// 			35,
					// 			36,
					// 			31,
					// 			33,
					// 			13,
					// 			34
					// 		]
					// 	},
					// ]
				},
				statisticsData: []
			}
		},
		computed: {
			dotsStyles() {
				return {
					width: 9,
					bottom: 8,
					color: '#FF1D32',
					backgroundColor: '#E6E6E6',
					border: 'none',
					selectedBackgroundColor: '#FF1D32',
					selectedBorder: 'none'
				}
			},
			orderAmount() {
				let num = 0
				this.statisticsData.forEach(item => num += item.INFO.PRICE_OD)
				return num / 10000
			},
			...mapState(['sysinfo', 'userInfo'])
		},
		created() {
			this.getHomeStatistics()
		},
		methods: {
			async getHomeStatistics() {
				const res = await apiGetHomeStatistics({
					PARTNER: this.userInfo.code
				})
				let {
					DATA
				} = res
				this.statisticsData = DATA
				if (DATA.length > 0) {
					this.chartData.categories = DATA.map((item) => {
						return item.BRAND_BQ_NAME
					})
					let series = [{
						"name": "制票总金额",
						"data": []
					}, {
						"name": "订单总金额",
						"data": []
					}, {
						"name": "订单总件数",
						"data": []
					}]
					DATA.forEach((item, index) => {
						series[0].data[index] = item.INFO.PRICE_ZP
						series[1].data[index] = item.INFO.PRICE_OD
						series[2].data[index] = item.INFO.NUMBER_OD
					})
					this.chartData.series = series
				}
			},
			goFundsConfirm() {
				uni.navigateTo({
					url: `/pages/funds-confirm/funds-confirm`
				});
			},
			change(e) {
				this.current = e.detail.current;
			},
			entryHandle(path) {
				// uni.showToast({
				// 	title: '开发中...',
				// 	icon: 'none',
				// 	duration: 1500
				// });

				// return

				uni.navigateTo({
					url: `/pages/${path}/${path}`
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.home-page {
		display: flex;
		flex-direction: column;
		box-sizing: border-box;
		background-color: #fff;
		padding-bottom: 100rpx;
	}

	.status_bar {
		height: var(--status-bar-height);
	}

	.banner {
		position: relative;
		width: 100%;
		height: 480rpx;
		overflow: hidden;
	}

	.search-block {
		display: flex;
		align-items: center;
		position: absolute;
		width: calc(100% - 32px);
		height: 30px;
		left: 16px;
		top: var(--status-bar-height);
		z-index: 10;
		background-color: rgba(255, 255, 255, 0.25);
		border-radius: 16px;
		padding-left: 33px;
		font-size: 13px;
		color: rgba(255, 255, 255, 0.8);

		.icon-search {
			position: absolute;
			left: 13px;
			width: 14px;
			height: 14px;
		}
	}

	.swiper-item {
		height: 480rpx;
	}

	/deep/ .uni-swiper__warp {
		height: 100%;

		.swiper-box {
			height: 100%;
		}

		.uni-swiper__dots-item {
			border-radius: 2px;
			width: 9px !important;
			height: 3px !important;
		}

		.uni-swiper__dots-item:first-child {
			border-radius: 2px;
			width: 3px !important;
			height: 3px !important;
		}

		.uni-swiper__dots-item:last-child {
			border-radius: 2px;
			width: 3px !important;
			height: 3px !important;
		}

		.uni-swiper__dots-long {
			width: 9px !important;
		}
	}

	.swiper-item-img {
		width: 100%;
		height: 100%;
	}

	.content {
		flex: 1;
		width: 100%;
		padding: 32rpx 36rpx 24px;
		box-sizing: border-box;
		background: #ffffff;
		border-radius: 32rpx 32rpx 0px 0px;
		margin-top: -110rpx;
		z-index: 10;
	}

	.block {
		background: #ffffff;
		overflow: hidden;

		.title {
			display: inline-block;
			font-size: 14px;
			color: #333;
			font-weight: 600;
			margin-bottom: 24rpx;
		}
	}

	.amount-block {
		display: flex;
		flex-direction: row;
		margin-top: 8px;
		margin-bottom: 8px;
	}

	.order-amount {
		flex: 1;
		height: 70px;
	}

	.order-amount--wrapper {
		display: flex;
		flex-direction: column;
		align-items: center;
	}

	.entry-icon {
		width: 58px;
		height: 58px;
	}

	.order-amount--num {
		font-size: 12px;
		color: #333;
	}

	.bill-amount {
		background: url('~@/static/image/home_bill_bg@3x.png') no-repeat;
		background-size: 100% 100%;
		margin-right: 0;

	}

	.notice-block {
		position: relative;
		height: 39px;
		margin-bottom: 16px;
		background: #feebe6;
		border-radius: 40rpx;
	}

	.icon-notic {
		position: absolute;
		left: 8px;
		top: 50%;
		margin-top: -10px;
		z-index: 10;
		width: 20px;
		height: 20px;
	}

	.uni-noticebar {
		margin-bottom: 0;
		height: 39px;
		padding-left: 36px;
	}

	.todo-box {
		margin-bottom: 64rpx;
	}

	.cell-list {
		flex-direction: column;

		.cell-list-block {
			display: flex;
			height: 77px;
			margin-bottom: 24rpx;
			background: #f8f9fa;
			border-radius: 8px;
			padding: 0 32rpx 0 24rpx;
			align-items: center;
		}

		.icon-address {
			width: 88rpx;
			height: 88rpx;
			margin-right: 24rpx;
		}

		.cell-list-block__content {
			display: flex;
			flex: 1;
			flex-direction: column;
		}

		.cell-list-block__title {
			color: #333;
			font-size: 28rpx;
			font-weight: 500;
			flex: 1;
			align-items: center;
		}

		.cell-list-block__desc {
			color: #acacac;
			font-size: 12px;
		}

		.icon-arrow {
			width: 12rpx;
			height: 20rpx;
		}
	}

	.charts-box {
		height: 380px;
		padding-bottom: 40px;

		.title {
			margin-bottom: 32rpx;
			display: flex;
			justify-content: space-between;

			.summary {
				color: #B2B2B2;
				font-size: 36rpx;

				.num {
					color: #333333;
					margin-right: 8rpx;
				}
			}
		}
	}
</style>
