<template>
	<view class="warpper">
		<scroll-list ref="list" :option="option" @load="upCallback" @refresh="downCallback" style="background-color: #FFFFFF;">
			<view class="sum-box">
				<view class="">
					<view class="title">交易金额</view>
					<view class="value">458 682.00</view>
				</view>
				<view class="">
					<view class="title">总交易量(吨)</view>
					<view class="value">125.7752</view>
				</view>
			</view>
			<uGap></uGap>
			<view class="card-box"  v-for="(item, index) in list" :key="index">
				<view class="header">
					<view class="left-title">{{item.customerEnterpriseName}}</view>
					<view class="right-title">¥ {{item.totalOfferPrice}}</view>
				</view>
				<view class="content" v-for="(subItem, subIndex) in item.supplierOrderList" :key="subIndex">
					<image class="image" src="https://qncloud.oss-cn-shenzhen.aliyuncs.com/ztb_pic/testPic.jfif" mode=""></image>
					<view class="">
						<view class="title">金蝶蓝白卡</view>
						<view class="desc">白卡纸/金蝶蓝/350g/787*1092/2200张</view>
					</view>
				</view>
				<!-- <view class="content">
					<image class="image" src="https://qncloud.oss-cn-shenzhen.aliyuncs.com/ztb_pic/testPic.jfif" mode=""></image>
					<view class="">
						<view class="title">丽盈白卡</view>
						<view class="desc">白卡纸/丽盈/350g/787*1092/2200张</view>
					</view>
				</view> -->
				<view class="other">
					<view class="time">2021-12-23 12:30:45</view>
					<view class="btn">
						更多详情
						<image class="icon" src="/static/imgs/client-detail/arrow-right-icon.png"></image>
					</view>
				</view>
				<uGap></uGap>
			</view>
		</scroll-list>
	</view>
</template>

<script>
import uGap from '@/components/u-gap/u-gap.vue'
import { getBasePaperDeals } from '@/apis/clientDetailApi.js'

export default {
	components: { uGap },
	data() {
		return {
			option: {
				size: 10,
				auto: true,
				emptyText: '暂无数据~',
				background: '#F7F8FA',
				disabled: false
			},
			params: {
				asc: '',
				desc: '',
				// customerEnterpriseId: this.$store.state.supplierInfo.id || null, // 客户企业ID默认为空，传值时网关获取当前用户关联企业id失效
				// mallSupplierId: this.$store.state.supplierInfo.supplierId || null, // 供应商id
				customerEnterpriseId: '651107734133018624',
				mallSupplierId: '670334117090562048', // 供应商id
				status: '0', // 状态 0 全部 待发货/30106,待收货/30107,待借款/30207,已完成/30104
				enterpriseIds: [] //企业ID集合网关获取
			},
			pagination: {
				pageNum: 0, // 初始会执行一次下拉加载
				pageSize: 10
			},
			list: []
		}
	},
	methods: {
		getList() {
			return new Promise((resolve, reject) => {
				getBasePaperDeals({ ...this.params, ...this.pagination })
					.then(res => {
						console.log('原纸交易', res)
						if (res) {
							if (this.pagination.pageNum == 1) {
								this.list = res.records
							} else {
								this.list = this.list.concat(res.records)
							}
							// this.list = []
							// this.list = [...this.list, ...[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]]
							resolve({ list: this.list, total: res.total })
						}
					})
					.catch(err => {
						reject(err)
					})
			})
		},
		downCallback() {
			this.pagination.pageNum = 1
			this.getList()
				.then(({ list, total }) => {
					this.$refs.list.refreshSuccess({ list, total })
				})
				.catch(() => {
					this.$refs.list.refreshFail()
				})
		},
		upCallback() {
			this.pagination.pageNum++
			this.getList()
				.then(({ list, total }) => {
					this.$refs.list.loadSuccess({ list, total })
				})
				.catch(() => {
					this.$refs.list.loadFail()
				})
		}
	}
}
</script>

<style lang="scss">
.warpper {
	width: 750rpx;
	.sum-box {
		display: flex;
		flex-direction: row;
		justify-content: space-around;
		align-items: center;
		// text-align: center;
		height: 184rpx;
		background: url('/static/imgs/client-detail/yzjy-icon.png') no-repeat;
		background-size: 100%;
		.title {
			font-size: 26rpx;
			color: #ffffff;
			letter-spacing: 0;
			font-weight: 500;
		}
		.value {
			font-size: 56rpx;
			color: #ffffff;
			letter-spacing: 0;
			text-align: left;
			font-weight: 500;
			margin-top: 16rpx;
		}
	}
	.card-box {
		.header {
			display: flex;
			flex-direction: row;
			justify-content: space-between;
			align-items: center;
			height: 88rpx;
			background: #ffffff;
			border-bottom: 2rpx solid #dddddd;
			padding: 0rpx 32rpx;
			.left-title {
				font-size: 30rpx;
				color: #000000;
				letter-spacing: 0;
				font-weight: 600;
			}
			.right-title {
				font-size: 30rpx;
				color: #ff5368;
				letter-spacing: 0;
				text-align: right;
				font-weight: 500;
			}
		}
		.content {
			display: flex;
			flex-direction: row;
			align-items: center;
			height: 148rpx;
			background: #ffffff;
			border-bottom: 2rpx solid #dddddd;
			padding: 0rpx 32rpx;
			.image {
				width: 100rpx;
				height: 100rpx;
				flex: 0 0 100rpx;
				margin-right: 20rpx;
			}
			.title {
				font-size: 30rpx;
				color: #333333;
				letter-spacing: 0;
				text-align: left;
				font-weight: 400;
			}
			.desc {
				padding-top: 26rpx;
				font-size: 26rpx;
				color: #888888;
				letter-spacing: 0;
				text-align: left;
				font-weight: 400;
			}
		}
		.other {
			display: flex;
			flex-direction: row;
			justify-content: space-between;
			align-items: center;
			height: 80rpx;
			background: #ffffff;
			padding: 0rpx 32rpx;
			.time {
				font-size: 26rpx;
				color: #888888;
				letter-spacing: 0;
				text-align: left;
				font-weight: 400;
			}
			.btn {
				font-size: 28rpx;
				color: #007aff;
				letter-spacing: 0;
				text-align: center;
				font-weight: 500;
				display: flex;
				align-items: center;
			}
			.icon {
				width: 24rpx;
				height: 24rpx;
				margin-left: 6rpx;
			}
		}
	}
}
</style>
