<template>
	<view class="index">
		<view class="inde-top">
			<view class="item1">
				<view class="num">
					{{total_order_money}}
				</view>
				<view class="">
					已发金额
				</view>
			</view>
			<view class="item">
				<view class="num">
					{{total_order_nums}}/{{total_nums}}
				</view>
				<view class="">
					已发红包
				</view>
			</view>
		</view>
		<view class="list">
			<view class="list-item" v-for="(item,index) in list" :key='index'>
				<view class="left">
					￥{{item.total_money}}
				</view>
				<view class="right">
					{{item.pay_time}}
				</view>
				<view class="right1">
					{{item.pay_status==0 ? '待支付' : item.pay_status==1 ? '成功' : '失败'}}
				</view>
			</view>

		</view>
		<view class="buttom">
			<view class="open" @click="getOpen">
				开
			</view>
			<view class="close" @click="getClose">
				关
			</view>
			<view class="ref" @click="getStatistical">
				新
			</view>
		</view>
	</view>
</template>

<script>
	var app = getApp()
	let countTime
	export default {
		data() {
			return {
				list: [],
				total_nums: '',
				total_order_money: '',
				total_order_nums: ''
			}
		},

		onLoad(options) {
			this.getStatistical()
		},
		methods: {
			getStatistical() {
				uni.showLoading({
					title: '加载中...',
					icon: 'none'
				})
				app.request('/statistical').then(res => {
					console.log(res.data.orders, '2222')
					this.list = res.data.orders
					this.total_nums = res.data.total_nums
					this.total_order_money = res.data.total_order_money
					this.total_order_nums = res.data.total_order_nums
					uni.hideLoading()
				})
			},
			getOpen() {
				uni.showLoading({
					title: '加载中...',
					icon: 'none'
				})
				app.request('/open').then(res => {
					uni.hideLoading()
					console.log(res, 'getOpen')
				})
			},
			getClose() {
				uni.showLoading({
					title: '加载中...',
					icon: 'none'
				})
				app.request('/close').then(res => {
					console.log(res, 'getClose')
					uni.hideLoading()
				})
			}

		}
	}
</script>

<style lang="scss" scoped>
	.index {
		.inde-top {
			position: fixed;
			top: 0;
			display: flex;
			width: 100%;
			padding: 20px 0;
			color: #FFFFFF;
			background-color: #aca1ff;

			.item1,
			.item {
				flex: 1;
				text-align: center;
				padding: 20px 10px;

				border-radius: 12px;
				font-size: 14px;

			}

			.item1 {
				margin-left: 10px;
				background-color: #ffb12a;
				margin-right: 20px;
			}

			.item {
				margin-right: 10px;
				background-color: #ff5f4a;

			}

			.num {
				font-size: 18px;
				margin-bottom: 10px;
			}
		}

		.buttom {
			position: fixed;
			right: 20px;
			bottom: 50px;

			// background-color: #4CD964;
			view {
				height: 40px;
				text-align: center;
				margin-top: 10px;
				border-radius: 50%;
				width: 40px;
				line-height: 40px;
				color: #FFFFFF;
			}

			.open {
				background-color: #1ecf1e;
			}

			.close {
				background-color: #fe6357;
			}

			.ref {
				background-color: #069cff;
			}
		}

		.list {
			padding: 0 10px;
			padding-top: 135px;


			// background-color: #9fd9ae;
			.list-item {
				display: flex;
				border-bottom: solid 1px #d5d5d5;
				// border-top: solid 1px #d5d5d5;
				height: 45px;
				line-height: 45px;
				font-size: 13px;

				.left {
					flex: 1;
				}

				.right {
					flex:0 0 50%;
				}
				.right1 {
					flex:1;
				}
			}
		}
	}
</style>
