<template>
	<view>
		<Headers></Headers>
		<view class="content wrap dflex">
			<Left-nav currentTab="index"></Left-nav>
			<view class="right">
				<view class="c-title">概况</view>
				<view class="idx-nav dflex">
					<navigator url="/pages/declareHonor/declareHonor" hover-class="none" class="li"><image src="../../static/images/sy_honor.png"></image></navigator>
					<navigator url="/pages/declareFunds/declareFunds" hover-class="none" class="li"><image src="../../static/images/sy_declare.png"></image></navigator>
				</view>
				<view class="c-box hb-box">
					<view class="sj-tits dflex">
						<view class="flex">文旅红榜</view>
						<navigator url="/pages/boardContent/boardContent" hover-class="none" class="sj-more">查看全部</navigator>
					</view>
					<view class="hb-list dflex">
						<view v-if="index <= 5" v-for="(item, index) in moneyDeclareList" :key="index" @click="jumpUrl('/pages/content/content?id=' + item.id)" class="li dflex">
							<image :src="'../../static/images/bdico' + getRandom() + '.png'"></image>
							<view class="flex">
								<view class="hb-tit tover">{{ item.title }}</view>
								<view class="hb-bri tover">{{ removeHtmlStyle(item.text) }}</view>
							</view>
						</view>
					</view>
				</view>
				<view class="c-box gk-info dflex">
					<view class="li dflex">
						<image src="../../static/images/idxico1.png"></image>
						<view>
							<text>累计营收</text>
							￥{{ indexData.money ? indexData.money : '0.00' }}
						</view>
					</view>
					<view class="li dflex">
						<image src="../../static/images/idxico2.png"></image>
						<view>
							<text>累计客流量</text>
							{{ indexData.person ? indexData.person : 0 }}
						</view>
					</view>
					<view class="li dflex" @click="jumpUrl('/pages/personal/personal')">
						<image src="../../static/images/idxico3.png"></image>
						<view>
							<text>人力资源</text>
							{{ indexData.humanResources ? indexData.humanResources : 0 }}
						</view>
					</view>
					<view class="li dflex" @click="jumpUrl('/pages/materials/materials')">
						<image src="../../static/images/idxico4.png"></image>
						<view>
							<text>物资资源</text>
							{{ indexData.material ? indexData.material : 0 }}
						</view>
					</view>
					<view class="li dflex" @click="jumpUrl('/pages/complaint/complaint')">
						<image src="../../static/images/idxico5.png"></image>
						<view>
							<text>累计投诉</text>
							{{ indexData.complaint ? indexData.complaint : 0 }}
						</view>
					</view>
				</view>
				<view class="c-box sy-box">
					<view class="sj-tit">营收额</view>
					<view class="sye">
						<view class="canvasView">
							<!-- :echartsH5="true" :echartsApp="true" -->
							<qiun-data-charts
								type="line"
								:chartData="Line"
								:opts="{
									legend: {
										show: false
									},
									yAxis: {
										showTitle: true,
										data: [{ title: '单位（元）', titleOffsetY: -8 }]
									}
								}"
							/>
						</view>
					</view>
				</view>
			</view>
		</view>
		<Foot></Foot>
	</view>
</template>
<script>
const app = getApp();
const req = require('../../utils/request.js');
const utils = require('../../utils/util.js');
export default {
	data() {
		return {
			indexData: '',
			Line: {},
			form: {
				page: 1,
				limit: 10
			},
			moneyDeclareList: []
		};
	},
	onLoad() {
		this.getHongBList();
	},

	onShow() {
		let userInfo = req.getStorage('userInfo');
		if (userInfo.type!=1&&userInfo.institutionState != 2) {
			uni.navigateTo({
				url: '/pages/company/company'
			});
		}
		if(userInfo.type==1){
			uni.navigateTo({
				url: '/pages/learn/learn'
			});
			return 
		}
		this.getData();
	},

	methods: {
		jumpUrl(url) {
			uni.navigateTo({
				url: url
			});
		},

		removeHtmlStyle(text) {
			var str = '';
			if (text) {
				str = utils.removeHtml(text);
			}
			return str;
		},

		getRandom() {
			return parseInt(Math.random() * 3 + 1);
		},

		getHongBList() {
			var formP = this.form;
			formP.code = 'wenlvhonbang';
			return new Promise((resolve, reject) => {
				req.getRequest('/api/v3/content/page', formP, data => {
					//资金申报公告
					this.moneyDeclareList = data.list;
					resolve();
				});
			});
		},

		getData() {
			req.getRequest('/api/v3/hy/indexData/get', {}, data => {
				this.indexData = data;
				if (data.monitors && data.monitors.length > 0) {
					this.Line = this.setStyleLine(data.monitors);
				}
			});
		},

		setStyleLine(data) {
			var line = {};
			if (data && data.length > 0) {
				//获取时间轴数据；
				line.categories = data.map(it => {
					return it.name;
				});
				line.series = [];
				var seriesItem = {};
				var list = data.map(itx => {
					return itx.value;
				});
				seriesItem.name = '';
				seriesItem.data = list;
				line.series.push(seriesItem);
			}
			return line;
		}
	}
};
</script>

<style>
.ec-canvas {
	display: flex;
	width: 100%;
	height: 100%;
	flex: 1;
}
.canvasView {
	width: 100%;
	margin-top: 30rpx;
	height: 100%;
}
</style>
