<template>
	<view class="main" :style="{ background: `url(${imgUrl}) #f6f6f6 no-repeat`, backgroundSize: backgroundSize }">
	
		<!-- <operateCoach  v-if="identity=='实操教练'"/>
		<principal  v-if="identity=='校长'||identity=='驾校财务'"/> -->
		<view class="content">
			<view class="status_bar"></view>
			<view class="" style="height: 30rpx;"></view>
			<view class="userInfo">
				<view class="tit">Hi,{{ vuex_userInfo.name }}教练</view>
				<view class="flex userRow">
					<view class="schoolIcon">
						<image src="@/static/images/index/ic_jiaxiao.png" mode=""></image>
					</view>
					<view class="schoolName oneRowText">{{ vuex_userInfo.schoolName }}</view>
					<!-- <view class="tag">合作教练</view> -->
				</view>
			</view>
			<view class="card priceBox">
				<view class="blueLab">今日已结算金额</view>
				<view class="price">￥{{statistics.amount}}</view>
				<view class="flex-b">
					<view class="data">截止：{{statistics.refreshDate}}</view>
					<view class="refresh" @click="getSettlementStatisticsFn">
						<view class="text">刷新</view>
						<view class="icon">
							<image src="@/static/images/index/ic_shuaxin.png" mode=""></image>
						</view>
					</view>
				</view>
			</view>
		
			<view class="h1"> 结算统计</view>
			<view class="tab_box">
				<tabDate />
			</view>
			<view class="card">
				<view class="chart">
					<columnChart />
				</view>
			</view>
			<view class="flex-b">
				<view class="h1">结算明细</view>
				<moreRight text="更多" @click.native="$goPage('/pages/indexEntry/settlement/settlement')"/>
			</view>
			<view class="record">
				<view class="card" v-for="(item,index) in list" :key="index">
					<stage :item="item"/>
				</view>
			</view>
			<view class="moreBtn" @click="$goPage('/pages/indexEntry/settlement/settlement')">查看更多</view>
		</view>
		
		<UserTab name ='统计'></UserTab>
		
		<u-popup :show="show" mode="center" round="20rpx">
			<view class="box">
				<view class="tit">您还未上传签名请尽快上传!</view>
				<view class="btnBg" @click="goPage">去签名</view>
			</view>
		</u-popup>
	</view>
</template>


<script>
	import stage from './comp/stage'
	import columnChart from './comp/columnChart'
	import tabDate from './comp/tabDate'
	import { imgUrl } from '@/config/site.config'
	import { needSign } from '@/config/api.js'
	import {
		getSettlementStatistics,
		settle_list
	} from '@/config/api.js'
	export default {
		components: {
			stage,
			columnChart,
			tabDate
		},
		data() {
			return {
				value1: '',
				currentTab: 1,
				statistics: {},
				list: [],
				imgUrl: imgUrl+'indexTopBanner.png',
				backgroundSize: '100% 492rpx',
				show: false,
			}
		},
		onShow() {
			uni.hideTabBar();
			this.getSettlementStatisticsFn()
			this.settle_listFn()
		},
		onLoad() {
			this.needSignFn()
		},
		mounted() {
			
		},
		methods: {
			// 是不是需要签
			async needSignFn() {
				const {data: res} = await needSign()
				if(res) {
					this.show = true
				}
			},
			goPage() {
				this.show = false
				this.$goPage('/pages/userCenter/signature/signature')
			},
			
			tabClick(num) {
				this.currentTab = num
			},
			async getSettlementStatisticsFn() {
				let obj = {
					searchDateType: uni.$u.timeFormat(Date.now(), 'yyyymm'),
					// coachId: this.vuex_coachId || ''
				}
				const {
					data: res
				} = await getSettlementStatistics(obj)
				this.statistics = res
				console.log(res)
			},
			async settle_listFn() {
				let obj = {
					"pageNo": 1,
					"pageSize": 10,
				}
				const {
					data: res
				} = await settle_list(obj)
				this.list = res.list || []
			}
		}
	}
</script>


<style lang="scss" scoped>
	@import './comp/comp.scss';
	.box {
		padding: 40rpx 50rpx;
		text-align: center;
		font-size: 28rpx;
		color: #333;
		.tit {
			padding: 30rpx 0 60rpx 0;
			color: $themC;
			font-weight: 700;
		}
		.btnBg {
			width: 370rpx;
			margin: auto;
		}
	}
</style>

