<template>
	<view class="contribution_body">
		<view style="display: flex;flex-direction: column;flex-wrap: wrap;" class="contribution_header_car">
			<view class="flex ac jc">
				<view class="flex  jc">
					<uni-icons v-if="dedata.routerIndex" color="#2866ff" custom-prefix="iconfont" type="iconjiayou" size="25"></uni-icons>
					<image v-else style="width: 60rpx; height: 60rpx;" src="../../../static/selegs.png"></image>
					<view style="margin-left: 24rpx;width: 365rpx; overflow: hidden;">
						<view style="overflow: hidden;width:100%;white-space: nowrap;text-overflow: ellipsis;" >
							{{dedata.routerIndex?dedata.siteName:dedata.companyName}}
						</view>
						<view class="samalltext">{{dedata.id}}</view>
					</view>
					<view  v-if="!dedata.routerIndex" :style="{background:dedata.parentMark=='0'?'':'#BC853B'}" class="list_item_tip">
					{{dedata.parentMark=='0'?'总公司':'子公司'}}
					</view>
				</view>
			</view>
			<view style="justify-content: space-around; margin-top: 24rpx;" class="flex">
				<view>{{dedata.liters.toFixed(2)}}
				<text style="color: #BBBBBB;">L</text>
				
				</view>
				<view>
				{{dedata.enterpriseContributionAmount|price}}
				<text style="color: #BBBBBB;">￥</text></view>
			</view>
			<view class="contribution_header_car_tip flex ac jc">{{dedata.startTime.split(' ')[0]}} - {{dedata.endTime.split(' ')[0]}}</view>
		</view>
		<view style="flex: 1; margin-top: 73rpx; overflow: hidden; ">
			<scroll-view class="scroll-view" @scrolltolower='scrolltolower' style="height: 100%;" scroll-y="true">
				<view v-for="(item,index) in list" class="list_item">
					<view>NO.{{item.rankingNum}}</view>
					<view  style="width: 192rpx; text-align: center;">
						<view v-if="dedata.routerIndex" :style="{background:item.parentMark=='0'?'':'#BC853B'}" class="list_item_tip">{{item.parentMark=='0'?'总公司':'子公司'}}</view>
						<view v-else>
							<image v-if="item.siteImages" style="width: 50rpx; height: 50rpx;" :src="item.siteImages"></image>
							<uni-icons v-if="!dedata.routerIndex&&!item.siteImages" color="#2866ff" custom-prefix="iconfont" type="iconjiayou" size="25"></uni-icons>
							<image   v-if="dedata.routerIndex&&!item.siteImages" style="width: 60rpx; height: 60rpx;" src="../../../static/selegs.png"></image>
						</view>
						<view class="samalltext">{{item.siteContacts||'暂无'}}</view>
					</view>
					<view style=" flex: 1;  overflow: hidden; ">
						<view style="width: 100%;white-space:nowrap;overflow:hidden;text-overflow: ellipsis;" >{{item.name}}</view>
						<view style="display: flex;justify-content: space-between;">
							<view> <text>{{item.volume.toFixed(2)}}</text>L </view>
							<view> <text>{{item.realPrice|price}}</text>￥</view>
						</view>
					</view>
				</view>
			</scroll-view>
		</view>
	</view>
</template>

<script>
	import sy from '@/api/sy'
	import convertW from '../../components/convertW.js'
	export default {
		data() {
			return {
				list:[],
				dedata:null,
				getData: {
					pageSize: 10,
					currentPage: 1,
					params: {
						siteId: '',
						endTime: '',
						startTime: ''
					}
				},
			}
		},
		onLoad(e) {
			console.log(e)
			if (e.jsData) {
				this.dedata = JSON.parse(e.jsData)
				this.getData.params.siteId = this.dedata.id
				this.getData.params.endTime = this.dedata.endTime.split(' ')[0]
				this.getData.params.startTime = this.dedata.startTime.split(' ')[0]
				this.getlist()
			}
		},
		filters:{
			price(e){
				return convertW.convertW(e)
			}
		},
		methods: {
			getlist(){
				sy[(this.dedata.routerIndex ? 'inquireAboutCorporateContributions':'queryTheRevenueContributionOfGasStations')]({
					pageSize: this.getData.pageSize,
					currentPage: this.getData.currentPage,
					params: {
						[(this.dedata.routerIndex?'siteId':'companyId')]:this.getData.params.siteId,
						endTime: this.getData.params.endTime,
						startTime:this.getData.params.startTime
					}
				}).then(res=>{
					if (res.code !== 20000) return
					if (res.data.list.length == 0) {
						uni.showToast({
							title: '没有数据了哦',
							icon: 'none'
						})
					}
					if (this.getData.currentPage !== 1) {
						this.list = this.list.concat(res.data.list);
						return
					}
					this.list = res.data.list
				})
			},
			scrolltolower() {
				this.getData.currentPage+=1
				this.getlist()
			}
		}
	}
</script>

<style scoped>
	@import url("./contribution.css");
	::-webkit-scrollbar {
		width: 0;
		color: transparent;
	}
	.list_item_tip{
		padding: 11rpx 14rpx;
		background-color:#9F43CC;
		color: #FFFFFF;
		font-size: 16rpx;
		width: fit-content;
		margin: 0 auto;
		height: fit-content;
	}
</style>
