<template>
	<page-meta :page-font-size="fontValue+'px'" :root-font-size="fontValue+'px'"></page-meta>
  <view class="content">
    <view class="top-wrapper">
		<view style="margin-left: 20px;">补贴总额</view>
		<view style="margin-left: 20px;margin-top: 10px;font-size: 48rpx;font-weight: bold;">￥{{subsidyBal}}</view>
    </view>
	<!-- 明细 -->
	<view style="margin: 10px;font-size: 40rpx;font-weight: bold;">明细</view>
    <scroll-view style="width: 100%;height: 72vh;" @scrolltolower="onScrollTolower" scroll-y="true">
       <view v-for="(item,index) in tableList" :key="index" style="width: 96%;height: auto;background: #FFF;border-radius: 10rpx;margin: 10rpx auto;"> 
		<view style="width: 94%;margin: 10rpx auto;display: flex;align-items: center;justify-content: space-between;margin-bottom: 10rpx;padding-top: 10rpx;">
			<text>{{item.tradeStateName}}</text>
			<text style="color: #ff9410;font-weight: bold;font-size: 28rpx;">¥{{ (item.amount/100).toFixed(2) }}</text>
		</view>
       	<view style="width: 100%;padding: 10rpx;padding-left: 20rpx;color: #999;">
       		{{item.tradeTime}}
       	</view> 
       </view> 
    </scroll-view> 
	
  </view>
</template>

<script> 
import Tabs from '@/pages/components/Tabs.vue' 
import { getDate } from '../../uni_modules/uni-datetime-picker/components/uni-datetime-picker/util'
import { getSubsidyTradeListApi } from '../../api/index/index.js'

export default {
	components: { Tabs },
	props: {
		show: {
		  type: Boolean,
		  default: false
		}
	},
	data() {
		return {
			fontValue:uni.getStorageSync('fontSize') || 8,
			subsidyBal:0,  
			//待评价
			pageNum: 1,
			pageSize: 10,
			total: 0, 
			tableList: [], 
			status: 'loadmore', 
			sourceTypeList:[],
			 
		}
	}, 
	onLoad(options) {
		this.subsidyBal = Number(options.subsidyBal/100).toFixed(2)
		this.getList() 
	},
	methods: {  
		async getList() {
			let param = {
				"tradeType":20,
				"pageNum": 1,
				"pageSize": 10,
				"userId": uni.getStorageSync('userId')
			}
		    const res = await getSubsidyTradeListApi(param)
			this.total = Number(res.total);
			console.log(res) 
			if(this.pageNum==1){
				this.tableList = res.rows
			}else{
				this.tableList.push(...res.rows)
			}
			
		},
		// 翻页
		onScrollTolower(){
			if(this.total>this.tableList.length){
				this.pageNum++
				this.getList()
			}
		}, 
		//翻页
		onReachBottom() {
			console.log('?? ~ onReachBottom ~ ') 
		},  
		formatDate(date) {
			const year = date.getFullYear()
			const month = String(date.getMonth() + 1).padStart(2, '0')
			const day = String(date.getDate()).padStart(2, '0')
			return `${year}-${month}-${day}`
		},
		// 跳转订单详情
		goDetail(item) {
			// console.log('跳转订单详情', item)
			// uni.navigateTo({
			// 	url: `/pages/work/details?params=${JSON.stringify(item)}`
			// })
		},
		//评价按钮
		goEvaluate(item) {
			// console.log('跳转订单详情', item)
			// uni.navigateTo({
			// 	url: `/pages/work/evaluate?params=${JSON.stringify(item)}`
			// })
		},
	}
}
</script>

<style lang="scss" scoped>
.content {
  // background: #f9fbff;
  // height: 100%;
  height: 94vh;
	.top-wrapper {
		width: 96%;
		height: 90px;
		background: #ffaa00;
		color: #FFF;
		margin: 10px auto;
		border-radius: 10rpx;
		padding-top: 10px;
		// z-index: 999;
	}

	.top-cont {
		padding: 0 16px;
		display: flex;
		justify-content: space-between;
		align-items: center;
		margin-bottom: 20px;
		.top-title {
			font-weight: 500;
			font-size: 40rpx;
			color: #0f274b;
		}
		.top-ipt {
			height: 31px;
			background: #fff;
			margin-left: 26px;
			margin-right: 12px;
		}
		.top-filter {
			display: flex;
			align-items: center;
		}
	}

	.order-list {
		padding: 8px;
		background: #fff;
		border-radius: 8px;
		font-size: 24rpx;
		font-weight: 400;
		// margin-bottom: 12px;
		margin-top: 10px;

		.order-source {
			margin-bottom: 12px;
			font-weight: 500;
			color: #0f274b;
		}

		.intervalName {
			margin-left: 10px;
			color: #ff6816;
			border-radius: 1px 1px 1px 1px;
			border: 1px solid #ff6816;
			padding: 0 4px;
		}

		.img-cont {
			margin: 10px;
			display: flex;
			justify-content: space-between;

			.img {
			display: flex;
			flex-direction: column;
			align-items: center;
				view {
					margin-top: 8px;
					color: #0f274b;
				}
			}
		}
			
		.price {
			display: flex;
			flex-direction: column;
			justify-content: center;
			align-items: center;
			color: #0f274b;
			font-weight: 400;
			font-size: 24rpx;
		}

		.btn-cont {
			display: flex;
			justify-content: flex-end;
			margin-top: 10px;
		}
	}
}
.evaluateCenter{
	height: 30px;width: 100%;display: flex;justify-content: space-between;align-items: center;
	.evaluateCenterLeft{
		width: 25%;display: flex;justify-content: space-between;align-items: center;margin-left: 20px;
	}
	.evaluateCenterRight{
		width: 60px;height: 24px;line-height:24px;border: 1px solid #ff6816;color: #ff6816;margin-right: 20px;font-size: 24rpx;text-align: center;border-radius: 8px;
	}
}
.filter-popup {
  padding: 30rpx;
  min-height: 60vh;
  max-height: 90vh;
	.section {
		margin-bottom: 40rpx;

		.section-title {
		  font-size: 32rpx;
		  color: #333333;
		  font-weight: 500;
		  margin-bottom: 20rpx;
		}
	}

	.date-quick-select {
		display: flex;
		gap: 20rpx;
		margin-bottom: 20rpx;

		.date-option {
		  flex: 1;
		  height: 80rpx;
		  display: flex;
		  align-items: center;
		  justify-content: center;
		  background-color: #f8f8f8;
		  border-radius: 100rpx;
		  font-size: 28rpx;
		  color: #666666;

		  &.active {
			background-color: #fff2ef;
			color: #ff6633;
		  }
		}
	}

	.date-range {
		display: flex;
		align-items: center;
		gap: 20rpx;

		.date-input {
		flex: 1;
		height: 80rpx;
		background-color: #f8f8f8;
		border-radius: 100rpx;
		padding: 0 20rpx;
		display: flex;
		align-items: center;
		font-size: 28rpx;

		.date-placeholder {
		color: #999999;
		}

		.selected-date {
		color: #333333;
		}
		}

		.date-separator {
		color: #999999;
		font-size: 28rpx;
		}
	}

	.order-type-item {
		width: 200rpx;
		height: 80rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		background-color: #f8f8f8;
		border-radius: 25px;
		font-size: 28rpx;
		color: #666666;
		margin: 10rpx auto;

		&.active {
		  background-color: #fff2ef;
		  color: #ff6633;
		}
	}

	.bottom-buttons {
		position: fixed;
		left: 0;
		right: 0;
		bottom: 0;
		padding: 28px 16rpx;
		background-color: #ffffff;
		display: flex;
		justify-content: space-between;
		box-shadow: 0 -2rpx 10rpx rgba(0, 0, 0, 0.05);
	}
}
</style>
