<!-- 数据组件页面 -->
<template>
	<view class="container">
		<view class="topdata">
			<view class="topdata-box">
				<view>数据汇总</view>
				<view class="x-bc">
					<view class="topdata-item">
						<view class="topdata-item-num"><text>0</text>人</view>
						<view>会员总数</view>
					</view>
					<view class="topdata-item">
						<view class="topdata-item-num"><text>0</text>人</view>
						<view>今日新增会员</view>
					</view>
				</view>
			</view>
			<view class="searchbox">
				<view class="searchbox-bar x-ac">
					<view :class="queryParam.type == index ? 'searchbox-item searchbox-active':'searchbox-item'"
						v-for="(item,index) in typeOption" :key="index" @click="handleType(index)">{{item.label}}</view>
				</view>
			</view>
		</view>
		<view class="statistics" :style="{height: contentH}">
			<u-collapse :border='false' :value='collapseValue' @change="changeCollapse">
				<u-collapse-item name="course">
					<text slot="title" class="statistics-title">课程统计</text>
					<text slot="value" class="statistics-slot-title">{{collapseValue.includes('course')?'收回':'展开'}}</text>
					<text slot="right-icon">
						<u-icon name="arrow-right" color="#1677ff" size="12"></u-icon>
					</text>
					<view class="collapse-content x-ac">
						<view class="collapse-content-item">
							<view class="collapse-content-title">观看人数</view>
							<view class="collapse-content-num"><text>0</text>人</view>
							<view style="color: #1677ff;" v-show="queryParam.type == 0">较昨天持平0</view>
							<view v-show="queryParam.type == 0">昨天0</view>
						</view>
						<view class="collapse-content-item">
							<view class="collapse-content-title">完播人数</view>
							<view class="collapse-content-num"><text>0</text>人</view>
							<view style="color: #1677ff;" v-show="queryParam.type == 0">较昨天持平0</view>
							<view v-show="queryParam.type == 0">昨天0</view>
						</view>
						<view class="collapse-content-item">
							<view class="collapse-content-title">完播率</view>
							<view class="collapse-content-num"><text>0</text>%</view>
							<view style="color: #1677ff;" v-show="queryParam.type == 0">较昨天持平0</view>
							<view v-show="queryParam.type == 0">昨天0</view>
						</view>
					</view>
				</u-collapse-item>
				<u-collapse-item name="questions">
					<text slot="title" class="statistics-title">答题统计</text>
					<text slot="value" class="statistics-slot-title">{{collapseValue.includes('questions')?'收回':'展开'}}</text>
					<text slot="right-icon">
						<u-icon name="arrow-right" color="#1677ff" size="12"></u-icon>
					</text>
					<view class="collapse-content x-ac">
						<view class="collapse-content-item">
							<view class="collapse-content-title">答题人数</view>
							<view class="collapse-content-num"><text>0</text>人</view>
							<view style="color: #1677ff;" v-show="queryParam.type == 0">较昨天持平0</view>
							<view v-show="queryParam.type == 0">昨天0</view>
						</view>
						<view class="collapse-content-item">
							<view class="collapse-content-title">正确人数</view>
							<view class="collapse-content-num"><text>0</text>人</view>
							<view style="color: #1677ff;" v-show="queryParam.type == 0">较昨天持平0</view>
							<view v-show="queryParam.type == 0">昨天0</view>
						</view>
						<view class="collapse-content-item">
							<view class="collapse-content-title">正确率</view>
							<view class="collapse-content-num"><text>0</text>%</view>
							<view style="color: #1677ff;" v-show="queryParam.type == 0">较昨天持平0</view>
							<view v-show="queryParam.type == 0">昨天0</view>
						</view>
					</view>
				</u-collapse-item>
				<u-collapse-item name="redenvelope">
					<text slot="title" class="statistics-title">红包统计</text>
					<text slot="value" class="statistics-slot-title">{{collapseValue.includes('redenvelope')?'收回':'展开'}}</text>
					<text slot="right-icon">
						<u-icon name="arrow-right" color="#1677ff" size="12"></u-icon>
					</text>
					<view>
						<view class="collapse-content x-ac">
							<view class="collapse-content-item">
								<view class="collapse-content-title">答题红包数</view>
								<view class="collapse-content-num"><text>0</text>个</view>
								<view style="color: #1677ff;" v-show="queryParam.type == 0">较昨天持平0</view>
								<view v-show="queryParam.type == 0">昨天0</view>
							</view>
							<view class="collapse-content-item">
								<view class="collapse-content-title">答题红包金额</view>
								<view class="collapse-content-num"><text>0.00</text>元</view>
								<view style="color: #1677ff;" v-show="queryParam.type == 0">较昨天持平0.00</view>
								<view v-show="queryParam.type == 0">昨天0.00</view>
							</view>
						</view>
						<view class="collapse-content x-ac" style="padding: 8px 0;">
							<view class="collapse-content-item">
								<view class="collapse-content-title">新会员奖励数</view>
								<view class="collapse-content-num"><text>0</text>个</view>
								<view style="color: #1677ff;" v-show="queryParam.type == 0">较昨天持平0</view>
								<view v-show="queryParam.type == 0">昨天0</view>
							</view>
							<view class="collapse-content-item">
								<view class="collapse-content-title">新会员奖励金额</view>
								<view class="collapse-content-num"><text>0.00</text>元</view>
								<view style="color: #1677ff;" v-show="queryParam.type == 0">较昨天持平0.00</view>
								<view v-show="queryParam.type == 0">昨天0.00</view>
							</view>
						</view>
					</view>
				</u-collapse-item>
			</u-collapse>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				typeOption: [{
					label: '今日',
					value: 0
				}, {
					label: '昨日',
					value: 1
				}, {
					label: '本月',
					value: 2
				}, {
					label: '自定义',
					value: 3
				}],
				queryParam: {
					type: 0
				},
				contentH: 0,
				collapseValue:['course','questions','redenvelope']
			}
		},
		mounted() {
			const windowHeight = uni.getSystemInfoSync().windowHeight
			this.contentH = `calc(${windowHeight}px - 180px - 56px)`
		},
		methods: {
			handleType(type) {
				this.queryParam.type = type
			},
			changeCollapse(e) {
				this.collapseValue = e.filter(item=>item.status == 'open').map(it=>it.name)
			}
		}
	}
</script>

<style scoped lang="scss">
	.container {
		font-family: PingFang SC, PingFang SC;
		font-weight: 400;
		font-size: 14px;
		color: #222222;
	}
	.topdata {
		padding-top: 25px;
		background-color: rgb(216, 232, 255);

		&-box {
			padding: 12px;
			margin: 0 12px 0 12px;
			background-color: rgba(255, 255, 255, 0.5);
			border-radius: 8px 8px 0 0;
			font-family: PingFang SC, PingFang SC;
			font-weight: 400;
			font-size: 14px;
			color: #222222;
		}

		&-item {
			width: 50%;
			text-align: center;
			padding: 8px;
			box-sizing: border-box;

			&-num {
				color: #1677ff;
				text {
					font-family: DIN, DIN;
					font-weight: bold;
					font-size: 25px;
				}
			}
		}

		.searchbox {
			background-color: #fff;
			border-radius: 8rpx 8rpx 0 0;
			padding: 15px;

			&-item {
				height: 23px;
				line-height: 23px;
				width: 65px;
				background: #f5f5f5;
				text-align: center;
				border-radius: 5px;
				font-family: PingFang SC, PingFang SC;
				font-weight: 400;
				font-size: 12px;
				color: #888;
			}

			&-active {
				color: #fff !important;
				background-color: #1677ff !important;
			}
		}
	}
	.statistics {
		background-color: #fff;
		overflow-y: auto;
		box-sizing: border-box;
		&-title {
			font-family: PingFang SC, PingFang SC;
			font-weight: bold;
			font-size: 16px;
			color: #222222;
		}
		&-slot-title {
			font-size: 12px;
			color: #1677ff;
		}
		.collapse-content {
			margin: 0 -8px -8rpx 0;
			&-item {
				flex: 1;
				padding: 12px;
				box-sizing: border-box;
				border-radius: 10px;
				background: #f5f5f5;
				font-family: PingFang SC, PingFang SC;
				font-weight: 400;
				font-size: 10px;
				color: #222222;
				margin: 0 8px 8rpx 0;
			}
			&-title {
				font-size: 14px;
				margin-bottom: 10px;
			}
			&-num {
				color: #1677ff;
				font-size: 10px;
				text {
					font-family: DIN, DIN;
					font-weight: bold;
					font-size: 25px;
				}
			}
		}
	}
</style>