<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="width: 365rpx; overflow: hidden;margin-left: 24rpx;" >
						<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'}" style="height: fit-content;" class="list_item_tip">
					{{dedata.parentMark=='0'?'总公司':'子公司'}}
					</view>
				</view>
			</view>
			<view style=" margin-top: 24rpx;justify-content: space-around;" class="flex">
				<view>
				{{dedata.orderNumber|price}}
				<text style="color: #BBBBBB;">笔</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 style="width: 160rpx;font-size: 25rpx;">{{item.createTime}}</view>
					<view  style="text-align: center;margin: 0 20rpx;">
						<view v-if="dedata.routerIndex"  :style="{background:item.parentMark=='0'?'':'#BC853B'}" class="list_item_tip">{{item.parentMark=='0'?'总公司':'子公司'}}</view>
						<view v-else>
							<image @error='imgError(item.siteImages)' v-if="item.siteImages" style="width: 50rpx; height: 50rpx;" :src="item.siteImages"></image>
							<uni-icons v-else color="#2866ff" custom-prefix="iconfont" type="iconjiayou" size="25"></uni-icons>
							<!-- <image @error='imgError' style="width: 50rpx; height: 50rpx;" :src="item.siteImages?item.siteImages:'../../../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.payRealAmount|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 {
				routerIndex:true,
				list:[],
				dedata:null,
				getData: {
					pageSize: 10,
					currentPage: 1,
					params: {
						siteId: '',
						endTime: '',
						startTime: ''
					}
				},
			}
		},
		onLoad(e) {
			let routes = getCurrentPages();
			let routerIndex = routes[(routes.length - 2)].$page.fullPath.indexOf('?') != -1 ?
				routes[(routes.length - 2)].$page.fullPath.split('?')[0].split('/')[routes[(routes.length - 2)]
					.$page.fullPath.split('?')[0].split('/').length - 1] :
				routes[(routes.length - 2)].$page.fullPath.split('/')[routes[(routes.length - 2)].$page
					.fullPath.split('/').length - 1];
					// this.routerIndex= routerIndex =='enterpriseIndex'?false:true;
					// console.log(routerIndex)
					// console.log(this.routerIndex)
			if (e.jsData) {
				this.dedata = JSON.parse(e.jsData);
				console.log(this.dedata,'***')
				this.getData.params.siteId = this.dedata.id
				this.getData.params.endTime = this.dedata.endTime.split(' ')[0]?this.dedata.endTime.split(' ')[0]:this.dedata.endTime
				this.getData.params.startTime = this.dedata.startTime.split(' ')[0]?this.dedata.startTime.split(' ')[0]:this.dedata.startTime
				this.getlist()
			}
		},
		filters:{
			price(e){
				return convertW.convertW(e)
			}
		},
		methods: {
			imgError(e){
				e.siteImages=null
			},
			getlist(){
				sy[(this.dedata.routerIndex ? 'queryGasStationBusinessOrders':'queryTheOrderOfTheEnterpriseGasStation')]({
					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;
	}
</style>