<template>
	<view class="box">
		<view class="mainBox">

			<view @click="goSonGroup(item)" class="workBox2" v-for="(item,index) in itemList" :key="index">
				<view class="leftBox">
					<view class="oneBox">
						<view class="comtent2">
							<view class="left2">名称：</view>
							<view class="right2">{{item.caption}}</view>
						</view>
						<view class="comtent2">
							<view class="left2">车型：</view>
							<view class="right2">{{item.vin_11}}</view>
						</view>
					</view>

					<view class="oneBox">
						<view class="comtent2">
							<view class="left2">年份：</view>
							<view class="right2">{{item.year}}</view>
						</view>
						<view class="comtent2">
							<view class="left2" style="width: 28%;">发动机：</view>
							<view class="right2">{{item.engine_prefix}}</view>
						</view>
					</view>

					<view class="oneBox">
						<view class="comtent2">
							<view class="left2" style="width: 28%;">变速箱：</view>
							<view class="right2">{{item.trans}}</view>
						</view>
						<view class="comtent2">
							<view class="left2">地区：</view>
							<view class="right2">{{item.area}}</view>
						</view>
					</view>

					<view class="oneBox">
						<view class="comtent2">
							<view class="left2">配置：</view>
							<view class="right2">{{item.equips}}</view>
						</view>
						<view class="comtent2">
							<view class="left2">级别：</view>
							<view class="right2">{{item.grade}}</view>
						</view>
					</view>

					<view class="oneBox">
						<view class="comtent2">
							<view class="left2" style="width: 35%;">模型代码：</view>
							<view class="right2">{{item.model_code}}</view>
						</view>

					</view>

				</view>
				<image src="../../static/img/rightArrow.png" mode="" style="width: 12rpx; height: 20rpx"></image>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				epc_id: '',
				partnum: '',
				itemData: {},
				itemList: [],
				page: 1,
				total_page: 1

			}
		},
		onLoad(opt) {
			this.epc_id = opt.epc_id;
			this.partnum = opt.partnum;
			this.getItemData();
		},
		methods: {
			// 配件车型
			getItemData() {
				uni.showLoading({
					title: '加载中'
				});
				this.$http('advancedEpc/findApplicableModels', {
					epc_id: this.epc_id,
					partnum: this.partnum,
					page: this.page
				}, 'GET').then(res => {
					uni.hideLoading();

					this.itemData = res.data.result;
					var list = res.data.result.list;

					this.total_page = res.data.result.total_page;
					if (list.length != 0) {
						this.itemList = this.itemList.concat(list)
					}

				});
			},
			goSonGroup(item) {
				uni.navigateTo({

					url: 'SonGroup?epc_id=' + this.epc_id + '&token=' + item.token + '&param=' + item.param +
						'&access_time=' + this.itemData.access_time
				})
			},
		},
		// 下拉刷新 上拉加载更多
		onPullDownRefresh() {
			// this.page = 1
			// this.getItemData()
			setTimeout(function() {
				uni.stopPullDownRefresh();
			}, 1000);
		},
		onReachBottom() {
			console.log('page--total_page', this.page, this.total_page);
			if (this.page <= this.total_page) {
				this.page++;

				this.getItemData()
			}
		}
	}
</script>

<style>
	.box {
		min-height: 100vh;
		background: #F4F5F7;
		padding-top: 20rpx;
		padding-bottom: constant(safe-area-inset-bottom);
		padding-bottom: env(safe-area-inset-bottom);
	}

	.mainBox {
		background: #FFFFFF;

	}

	.oneBox {
		display: flex;
		justify-content: space-between;
		align-items: baseline;
		font-size: 26rpx;
		padding-bottom: 20rpx;
	}

	.comtent2 {
		display: flex;
		align-items: baseline;
		font-size: 26rpx;
		width: 50%;
	}

	.workBox2 {

		background: #FFFFFF;
		border-bottom: 1rpx solid #EEEEEE;
		padding: 20rpx 24rpx 0rpx;

		display: flex;
		align-items: center;
	}

	.leftBox {
		width: calc(100vw - 20rpx);
	}

	.rightBox {
		width: 20rpx;
	}

	.left2 {
		width: 20%;
		color: #999999;
		white-space: nowrap;
	}

	.right2 {
		width: 80%;
		color: #333333;
		margin-right: 20rpx;
	}
</style>
