<template>
	<view>
		<customNav :shownav="true" :title="$t('zhanghu.zhanghumingxi')" tinColor="#40AE36" jiantou="0" titledetl=''></customNav>
		<view style="width: 94%;margin-left: 3%;background-color: white;margin-top: 30rpx;">
			<view v-for="(item,index) in balanceList">
				<view class="contentInRowL" style="padding-top: 20rpx;">
					<view class="contentColumn" style="width: 97%;padding-left: 1%;">
						<view class="contentInRowS">
							<text class="timeText">{{rtType(item.type)}}</text>
							<text class="yujidzText" style="margin-left: auto;margin-right: 10rpx;">No.{{item.ddId}}</text>
						</view>
						<view class="contentInRowS">
							<text class="timeText">{{$formPr(item.amount)}}{{$t('api.huobidanwei')}}</text>
							<!-- <text class="yujidzText" style="margin-left: auto;margin-right: 10rpx;">{{$formPr(item.divvy)}}{{$t('api.huobidanwei')}}</text> -->
						</view>
						<view class="contentInRowS">
							<text class="timeText">{{item.cretim}}</text>
							<text class="yujidzText" style="margin-left: auto;margin-right: 10rpx;">{{$t('zhanghu.zhuangtai')}}: {{rtState(item.state)}}</text>
						</view>
					</view>
				</view>
				<view style="width: 94%;margin-left: 3%;height: 4rpx;background-color: lavender;margin-top: 10rpx;"></view>
			</view>
			<view style="height: 60rpx;"></view>
		</view>
	</view>
</template>

<script>
	import api from "@/pages/api/api.js"
	import {
		getUsbalance
	} from '@/pages/api/basic.js';
	export default {
		data() {
			return {
				balanceList:[],
				page:1,
				size:20,
				riqi:'',
				type:0
			}
		},
		onLoad(option) {
			this.riqi=option.riqi;
			this.type = option.type;
		},
		onShow() {
			this.RefreshData(1)
		},
		methods: {
			RefreshData(page){
				if(this.type==0){
					this.itemselctday(page)
				}
				if(this.type==1){
					this.itemselctweek(page)
				}
				if(this.type==2){
					this.itemselctmonth(page)
				}
			},
			rtType(type){
				if(type==0){
					return this.$t('zhanghu.peisongsr')
				}
				if(type==1){
					return this.$t('tixian.chongzhi')
				}
				if(type==2){
					return this.$t('tixian.tixian')
				}
			},
			rtState(state){
				if(state==0){
					return this.$t('order.wancheng')
				}
				if(state==1){
					return this.$t('index.quxiao')
				}
				if(state==2){
					return this.$t('index.quxiao')
				}
				if(state==3){
					return this.$t('order.weizhifu')
				}
			},
			
			itemselctday(page){
				
				api('getzddaylist',{
					page:page,
					size:this.size,
					riqi:this.riqi
				},res=>{
					console.log('getzddaylist',res)
					if(res.data.code==200){
						if(page>1){
							if(res.data.data.list&&res.data.data.list.length>0){
								this.balanceList=this.balanceList.concat(res.data.data.list)
							}
						}
						else{
							this.balanceList=res.data.data.list;
						}
					}
					else{
						
					}
				},failc=>{
					//console.log('getadvertis----',failc)
				})
				
			},
			itemselctweek(page){
				
				api('getzdmeeklist',{
					page:page,
					size:this.size,
					riqi:this.riqi
				},res=>{
					console.log('getzdmeeklist',res)
					if(res.data.code==200){
						if(page>1){
							if(res.data.data.list&&res.data.data.list.length>0){
								this.balanceList=this.balanceList.concat(res.data.data.list)
							}
						}
						else{
							this.balanceList=res.data.data.list;
						}
					}
					else{
						
					}
				},failc=>{
					//console.log('getadvertis----',failc)
				})
			},
			itemselctmonth(page){
				api('getzdmatlist',{
					page:page,
					size:this.size,
					riqi:this.riqi
				},res=>{
					console.log('getzdmatlist',res)
					if(res.data.code==200){
						if(page>1){
							if(res.data.data.list&&res.data.data.list.length>0){
								this.balanceList=this.balanceList.concat(res.data.data.list)
							}
						}
						else{
							this.balanceList=res.data.data.list;
						}
					}
					else{
						
					}
				},failc=>{
					//console.log('getadvertis----',failc)
				})
			},
			
			/**
			 * 下拉刷新回调函数
			 */
			onPullDownRefresh() {
				console.log('onPullDownRefresh')
				this.page = 1;
				this.RefreshData(this.page)
			},
			/**
			 * 上拉加载回调函数
			 */
			onReachBottom() {
				console.log('onReachBottom')
				this.page = this.page+1;
				this.RefreshData(this.page)
			},
		}
	}
</script>

<style>
.timeText{
	color: #1A1A1A;
	font-size: 26rpx;
	padding-left: 20rpx;
}

.yujidzText{
	color: sandybrown;
	font-size: 26rpx;
	padding-left: 20rpx;
}
</style>
