<template>
	<view>
		<u-navbar title="提现记录"></u-navbar>
		<view class="detailed">
		
			<view class="detailed-list"  
			:key="index" 
			v-for="(item ,index) in list" >
				<view class="detailed-time"  v-if="item.show">
					<p>{{item.showtime}}</p>
					<p>共提现 {{showMap.get(item.showtime)}}</p>
				</view>
				<view class="detailed-item">
					<view class="detailed-item-name">
						<view class="u-flex">
							<h4>提现</h4>
							 <span v-if="item.status==1" class="success">(提现成功)</span>
							 <span v-if="item.status==0" class="error">(待转账)</span>
						</view>
						<p>{{item.createTime}}</p>
					</view>
					<view class="detailed-item-num">
						<h2>{{item.applicationAmount}}</h2>
					</view>
				</view>
			
			</view>
			
		 
		</view>
	</view>
</template>

<script>
	import * as API from '@/apis/finance.js'
	
	export default {
		data() {
			return {
				pageIndex: 1,
				recordsTotal: 0,
				list: [],
				form: {
					name: '',
					intro: '',
				},
				showMap:null,
			 
			}
		},
		onReady() {
			this.getList()
		},
		
		onReachBottom() {
			if (this.list.length < this.recordsTotal) {
				this.myLoadmore();
			}
		},
		methods: {
			getList() {
			
				uni.showLoading({
					title: "加载中",
					mask: true,
				})
				
				
				API.withdrawRecord({
					pageIndex:this.pageIndex
				}).then((res) => {
					
					this.list = [
						...this.list,
						...res.data.data
					];
					
					var showMap=new Map()
					this.list.forEach(item=>{
						var ktime=item.createTime.split(" ")[0]
						if(showMap.has(ktime)){
							item.show=false;
							var m=showMap.get(ktime)+item.applicationAmount;
							showMap.set(ktime,m)
						}else{
							showMap.set(ktime,item.applicationAmount)
							
							item.show=true;
							item.showtime=ktime;
						}
					})
					this.showMap=showMap;
					this.recordsTotal = res.data.recordsTotal
					uni.hideLoading()
					
				}).catch(error => {
					uni.showToast({
					
						title: error
					})
				})
			},
		}
	}
</script>
<style>
	page{
		background-color: #F7F7F7;
	}
</style>
<style lang="scss" scoped>
	
	.detailed-time{
		display: flex;
		justify-content: space-between;
		align-items: center;
		padding: 10px 20px;
		p{
			color:#666;
		}
	}
	.detailed-item{
		background-color: #fff;
		display: flex;
		justify-content: space-between;
		padding: 10px 20px;
		border-bottom: 1px solid #ededed;
		.detailed-item-name{
			h4{
				font-weight: normal;
			}
			p{
				font-size: 12px;
				margin-top: 4px;
				color:#A2A9B5;
			}
			span{
				margin-left: 10px;
			}
			.success{color:#27b148}
			.error{color:#FF6200;}
		}
		.detailed-item-num{
			display: flex;
			align-items: center;
			h2{
				margin-right: 4px;
			}
		}
	}
</style>
