<template>
	<view :class="[AppTheme]" class="subrecord">
		<!-- 头部切换 -->
		<!-- #ifdef APP-PLUS || MP-WEIXIN -->
		<u-sticky offsetTop="0" style="z-index: 10;">
			<!-- #endif -->
			<!-- #ifdef H5 -->
			<u-sticky offsetTop="-44" style="z-index: 10;">
				<!-- #endif -->
				<view class="head_fixation">
					<u-tabs :scrollable="false" ref="uTabs" :list="navList" lineWidth="60" :lineColor="primary"
						:activeStyle="{
			        color: primary,
			        transform: 'scale(1.05)'
			    }" :inactiveStyle="{
			        color: '#606266', 
			        transform: 'scale(1)'
			    }" :current="current" @click="tabsChange">
					</u-tabs>
				</view>
			</u-sticky>


			<view v-if="index!=3">
				<view class="notes-con">
					<view class="total-share">
						<view class="ts-left">
							<view class="ts-h">

								<view class="detail">
									<view class="ts-bg bg-primary">
										<text class="all-p text-primary">农场认养</text>
									</view>
									<view class="detail_ani">

										<view class="num">{{ detailInfo.lefttime || 0 }}</view>
										<view class="sam zi">期限(天)</view>
									</view>
									<view class="detail_ani">
										<view>
											{{goods.bonusway || '' }}
										</view>
										<view class="sam zi">认养收获</view>
									</view>
								</view>
							</view>
							<view class="ts-f">
								<view>

									<view class="num">
										{{ goods.copies_price || 0 }}
									</view>
									<view class="sam zi">
										元/{{ goods.unit}}
									</view>
								</view>
								<view>
									<view class="num">{{ detailInfo.totalnum || 0 }}</view>
									<view class="sam zi">数量</view>
								</view>
								<view>
									<view class="num">
										{{ detailInfo.payprice || 0 }}
									</view>
									<view class="sam zi">
										金额(元)</view>
								</view>

							</view>
						</view>
						<view class="ts-right">
							<view></view>
							<view class="abso border-primary">
								<image :src="settingFile.root_img+'/static/app/imgs/mine/17.png'" mode="" />
								<view class="now  text-explain" v-if="detailInfo.status == 0">已取消</view>
								<view class="now  text-neutral" v-if="detailInfo.status == 1"
									@click="goPay(detailInfo.id)">
									去付款</view>
								<view class="now  text-primary" v-if="detailInfo.status ==2 ">认养中</view>
								<view class="now  text-explain" v-if="detailInfo.status ==3 ">已完成</view>
								<view class="now text-primary" v-if="detailInfo.status ==4 ">已发货</view>
								<view class="now text-primary" v-if="detailInfo.status ==8 ">退款中</view>
							</view>
						</view>
					</view>
				</view>
			</view>
			<!-- 基本信息 -->
			<view class="detail-c" v-if="index==0">
				<view class="mb20" style="display: flex;">
					<text class="mr10">认养产品 :</text>
					<text v-if="detailInfo.goods&&detailInfo.goods.name"
						style="flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;">
						{{ detailInfo.goods.name }}
					</text>
				</view>
				<view class="mb20">
					<text class="mr10">订单号 :</text>
					<text>{{ detailInfo.oid }}</text>
				</view>
				<view class="mb20">
					<text class="mr10">开始时间 :</text>
					<text>{{ detailInfo.paytime || 0 }}</text>
				</view>
				<view class="mb20">
					<text class="mr10">现在时间 :</text>
					<text>{{ detailInfo.now || 0 }}</text>
				</view>
				<view class="mb20">
					<text class="mr10">认养周期 :</text>
					<text>{{ detailInfo.lefttime }}天</text>
					<text class="ml10">已过天数 :</text>
					<text>{{ detailInfo.past }}天</text>
					<text class="ml10">剩余天数 :</text>
					<text>{{ detailInfo.lefttime - detailInfo.past }}天</text>
				</view>
				<view class="peisong">
					<view class="mb20 flex">
						<text>预期配送:{{ detailInfo.qinum||0}}次</text>
					</view>
					<view class="mb20 flex">
						<text>
							已配送:
							<text style="color: #f26214;">{{ detailInfo.ypsnum||0 }}</text>
							次
						</text>
					</view>
					<view class="mb20" v-for="(item,index) in log" :key="index"><text class="mr10">订单进度:
							{{ $u.timeFormat(item.ctime,fmt = 'yyyy/mm/dd hh:MM:ss')  || 0 }} {{ item.msg }}</text>
					</view>
				</view>
			</view>
			<!-- 认养日志-->
			<view class="detail-s" v-if="index==1">
				<view class="guan_1">
					<image :src="settingFile.root_img+'/static/app/imgs/mine/dis/41.png'"></image>
				</view>
				<view class="guan_2 bg-primary">
					<view>我是农场管理员:{{operatorlist.name}}</view>
					<view>以下认养操作，是在我的监督下进行的</view>
				</view>

			</view>
			<view class="detail-c" v-if="index==1">

				<view class="u-page">
					<view class="u-demo-block" v-for="(item, index) in operator" :key="index">
						<!-- <text class="u-demo-block__title">多图模式</text> -->
						<view class="u-demo-block__content" style="padding: 20rpx;">
							<view class="operator_1">{{item.operator_name}}/{{item.type_name}}</view>
							<view class="album">
								<view class="album__avatar">
									<image :src=" operatorlist.farm_logo" mode="" style="width: 35px;height: 35px;">
									</image>

								</view>
								<view class="album__content">
									<u--text :text="operatorlist.farm_name" type="primary" bold size="15"></u--text>

									<u--text margin="8px 0 8px 0" :text="item.remark"></u--text>
									<u-album :urls="item.imgs"></u-album>
								</view>
							</view>
							<view class="operator_2">
								<view>{{item.create_time}}</view>
								<view>操作员:{{item.name}}</view>
							</view>
						</view>
						<view class="bor_solp"></view>
					</view>
				</view>
			</view>
			<!-- 配送信息-->
			<view class="order_list" v-if="index==2">
				<view class="detail-c" v-for="(item, index) in delivery" :key="index">
					<view class="model_one">
						<view class="model_two">
							<view class="model_two_1"></view>
							<view class="model_two_2">{{item.titles}}</view>
						</view>
						<view class="model_three">
							<view class="model_three_2">
								<view class="model_three_3" v-if="item.fahuokdnum"> 快递订单号 </view>
								<view class="model_three_3" v-if="item.fahuokd">快递公司 </view>
								<view class="model_three_3">配送模式 </view>
								<view class="model_three_3">配送状态 </view>
								<view class="model_three_3">预计配送时间</view>
								<view class="model_three_3">创建时间</view>
							</view>
							<view class="model_three_2">
								<view class="model_three_4" v-if="item.fahuokdnum">{{item.fahuokdnum}}</view>
								<view class="model_three_4" v-if="item.fahuokd">{{item.fahuokd}}</view>
								<view class="model_three_4">{{item.msg}}</view>
								<view class="model_three_4">{{item.status}}</view>
								<view class="model_three_4">{{item.getdate}}</view>
								<view class="model_three_4">{{item.ctime}}</view>
							</view>
						</view>
					</view>
				</view>
			</view>
			<!-- 认养榜单 -->
			<view class="order_list" v-if="index==3">
				<view class="detail-c" v-for="(item, index) in ranking" :key="index" @click="orderBy(item.id)">
					<view style="padding: 20rpx 20rpx 0 20rpx;">
						<view class="ranking_one">
							<view class="ranking_three">
								<image :src="item.farm_logo"></image>
								<view>{{item.farm_name}}</view>
							</view>
							<view class="ranking_two">
								{{item.titles}}
							</view>
						</view>
						<view class="bor_solp"></view>
						<view class="detail_title_1">
							<view class="detail_title_p1">
								<image class="image" :src="item.pic" mode=""></image>
							</view>
							<view class="detail_title_p2">
								<view class="detail_title_p3">{{item.name}}</view>
								<view class="detail_title_p4">
									{{item.renyantime}}
								</view>
								<view>
									<u-line-progress :percentage="item.munber" activeColor="#ff0000"></u-line-progress>
								</view>
								<view class="fram_oper_1">
									<view class="fram_oper_2">
										<view class="views1">品种</view>
										<view class="views1">周期</view>
										<view class="views1">价格</view>
									</view>
									<view class="fram_oper_2">
										<view class="views2">{{item.vname}}</view>
										<view class="views2">{{item.cycle}}天</view>
										<view class="views2">{{item.copies_price}}</view>
									</view>
								</view>
							</view>
						</view>

					</view>
					<view class="shop ">{{item.shoptitle}}</view>
				</view>
			</view>
			<!-- 	完 -->

			<view style="height: 40rpx;"></view>
	</view>
</template>

<script>
	import mineApi from '@/api/mine/index.js';
	export default {
		data() {
			return {

				primary: this.$theme.primary,
				settingFile: getApp().globalData.siteinfo,
				// 当前排序方式视图
				nowsetyindex: 1,
				// 订单列表
				orderlist: [],
				//顶部距离
				scrollTop: 0,
				modalshow: false,


				customstyle: {
					background: '#F4F6F8'
				},
				navList: [{
						name: '基本信息'
					},
					{
						name: '认养日志'
					},
					{
						name: '配送信息'
					},
					{
						name: '认养榜单'
					}
				],
				current: 0,
				swiperCurrent: 0,
				nomorelist: false,
				id: '',
				log: [],
				detailInfo: {},
				index: '',
				goods: {},
				operatorlist: {},
				operator: '',
				delivery: '',
				ranking: ''

			};
		},
		onLoad(options) {
			this.id = options.id;
			this.getJiLu()
		},
		methods: {

			// tabs通知swiper切换
			tabsChange(e) {
				console.log(e.index)
				this.index = e.index
				if (e.index == 0) {
					this.getJiLu()
				} else if (e.index == 1) {
					this.operatorlog()
				} else if (e.index == 2) {
					this.financedelivery()
				} else if (e.index == 3) {
					this.financeranking()
				}

			},

			getJiLu() {
				mineApi
					.orderDetail({
						orderid: this.id
					})
					.then(res => {
						this.detailInfo = res.data.cache;
						this.goods = res.data.cache.goods;
						console.log(this.goods, "this.detailInfo")
						this.log = res.data.log;
					});
			},
			operatorlog() {
				mineApi
					.operatorlog({
						orderid: this.id
					})
					.then(res => {
						this.operatorlist = res.data.data;
						this.operator = res.data.data1;
						console.log(this.operator.remark, "this.detailInfo")

					});
			},

			financedelivery() {
				mineApi
					.financedelivery({
						orderid: this.id
					})
					.then(res => {
						this.delivery = res.data;


					});
			},
			financeranking() {
				mineApi
					.financeranking()
					.then(res => {
						this.ranking = res.data;
					});
			},

			orderBy(id) {
				uni.navigateTo({
					url: `/pagesA/pages/adopt/adopt?id=` + id
				});
			},

		}
	};
</script>

<style lang="scss">
	page {
		width: 100%;
		height: 100%;
	}

	.head_fixation {
		width: 100%;
		z-index: 11;
		background-color: #ffffff;
	}

	.subrecord {
		width: 100%;
		min-height: 100vh;
		padding-top: 0.1rpx;
		background: #f1f1f1;
		position: relative;

		.notes-con {
			height: 240rpx;
			width: calc(100% - 40rpx);
			margin: 0 auto;
			border-radius: 20rpx;
			background-color: #ffffff;

			.total-share {
				height: 240rpx;
				width: 100%;
				display: flex;
				justify-content: flex-start;
				margin: 20rpx auto;
			}

			.ts-left {
				margin-top: 16rpx;
				margin-left: 20rpx;
				/*float: left;*/
			}

			.total-share .ts-h,
			.ts-f {
				width: 472rpx;
			}

			.ts-f {
				margin-top: -14rpx;
			}

			.total-share .ts-h {
				height: 70rpx;
				display: flex;
				justify-content: flex-start;
				align-items: center;
				margin-bottom: 50rpx;
				margin-top: 10rpx;
				align-items: center;
			}

			.total-share .ts-h .ts-bg {
				width: 74rpx;
				height: 70rpx;
				display: flex;
				align-items: center;
				justify-content: center;
				font-size: 16rpx;
				background-size: 100%;
				margin-right: 16rpx;
				text-align: center;
			}

			.total-share .ts-h .all-p {
				font-size: 20rpx;
				font-family: PingFang SC;
				font-weight: 800;
				color: rgba(255, 255, 255, 1);
				letter-spacing: 6rpx;
				margin-left: 5rpx;
				margin-top: -8rpx;
				margin-left: 5rpx;
			}

			.total-share .ts-h .expect {
				display: inline-block;
				width: 360rpx;
				overflow: hidden;
				text-overflow: ellipsis;
				-o-text-overflow: ellipsis;
				white-space: nowrap;
				font-size: 31rpx;
				font-family: PingFang SC;
				font-weight: bold;
				color: rgba(0, 0, 0, 1);
			}

			.detail {
				display: flex;
				flex: 1;
				justify-content: space-between;

				.detail_ani {
					text-align: center;

					.sam {
						text-align: center;
						font-size: 22rpx;
						color: #bababa;
					}

					.zi {
						margin-top: 15rpx;
					}
				}

				.detail_ani.overflowl {
					width: 65%;
					overflow: hidden;
					text-overflow: ellipsis;

					.ellipsis {
						white-space: nowrap;
						/*强制在一行显示*/
						text-overflow: ellipsis;
						/*设置超出内容显示...*/
						overflow: hidden;
					}
				}
			}

			.ts-f {
				display: flex;
				justify-content: space-between;
				align-items: center;
			}

			.ts-f .red-pre {
				text-align: center;
				top: 14rpx;
				font-weight: 800;
				font-size: 30rpx;
			}

			.ts-f .num {
				position: relative;
				top: 14rpx;
				font-size: 30rpx;
				font-weight: 800;
				text-align: center;
			}

			.ts-f .sam {
				text-align: center;
				font-size: 22rpx;
				color: #bababa;
			}

			.ts-f .sam.zi {
				margin-top: 24rpx;
			}

			.ts-right {
				margin-left: 10rpx;
				position: relative;
				margin-top: 40rpx;
			}

			.ts-right .abso {
				width: 140rpx;
				height: 140rpx;
				position: absolute;
				font-size: 24rpx;
				left: 46rpx;
				border-width: 4rpx;
				border-style: solid;
				border-radius: 50%;
				text-align: center;
				padding-top: 26rpx;
				box-sizing: border-box;

				image {
					width: 45rpx;
					height: 51rpx;
				}
			}

			.abso .yet {
				margin-left: 16rpx;
				width: 46rpx;
				height: 52rpx;
			}

			.abso .now {
				font-size: 26rpx;
				font-family: PingFang SC;
				font-weight: 800;
			}
		}

		.peisong {
			border-top: 1px solid #eeeeee;
		}


		.detail-c {
			width: calc(100% - 40rpx);
			margin: 20rpx auto;
			background-color: #ffffff;
			border-radius: 20rpx;
			font-size: 28rpx;
			color: #999;


			.mb20 {
				padding: 27rpx;
				// margin-bottom: 50rpx;
				// border-bottom: 1px solid #E4E7ED;

				.ml10 {
					margin-left: 20rpx;
				}
			}

			.flex {
				display: flex;
				justify-content: space-between;
			}
		}

		.detail-d {
			width: calc(100% - 40rpx);
			margin: 20rpx auto;
			background-color: #ffffff;
			border-radius: 20rpx;
			font-size: 28rpx;
			color: #999;
			// padding: 20rpx;

			.mb20 {
				padding: 27rpx;
				// margin-bottom: 50rpx;
				// border-bottom: 1px solid #E4E7ED;

				.ml10 {
					margin-left: 20rpx;
				}
			}

			.flex {
				display: flex;
				justify-content: space-between;
			}
		}
	}

	.album {
		@include flex;
		align-items: flex-start;

		&__avatar {
			background-color: $u-bg-color;
			padding: 5px;
			border-radius: 3px;
		}

		&__content {
			margin-left: 10px;
			flex: 1;
		}
	}

	.bor_solp {
		background-color: #999;
		height: 1rpx;
		width: 100%;
		transform: scaleY(0.3);
		margin: 10rpx 0;
	}

	.operator_1 {
		padding: 10rpx 0 20rpx 0;
		font-size: 32rpx;
		color: black;
	}

	.operator_2 {
		display: flex;
		justify-content: space-between;
		padding: 30rpx 10rpx 0 10rpx;
		font-size: 28rpx;
	}

	.detail-s {
		display: flex;
		padding: 30rpx 20rpx 0 20rpx;
		align-items: center;

		.guan_1 {
			image {
				width: 100rpx;
				height: 100rpx;
			}
		}

		.guan_2 {
			width: 80%;

			line-height: 40rpx;
			position: relative;
			border-radius: 10px;
			margin-left: 3.5vh;
			color: #fff;
			padding: 20rpx;
		}

		.guan_2:before {
			content: "";
			position: absolute;
			right: 100%;
			top: 20px;
			border-top: 13px solid transparent;
			border-right: 26px solid red;
			border-bottom: 0px solid transparent;
		}

	}

	.u-page {}

	.model_one {
		display: flex;
		flex-direction: column;
		padding: 20rpx;

		.model_two {
			display: flex;
			justify-content: flex-start;
			float: right;
			padding: 0 20rpx;

			.model_two_1 {
				background-color: green;
				width: 10rpx;
				border-radius: 40rpx;

			}

			.model_two_2 {
				margin-left: 1vh;
				font-size: 30rpx;
			}

		}

		.model_three {
			display: flex;
			justify-content: space-between;
			align-items: center;
			padding: 0 20rpx;

			.model_three_2 {


				padding: 20rpx;

				.model_three_3 {
					color: #999;
					padding: 20rpx 0;
					font-size: 28rpx;
				}

				.model_three_4 {
					display: flex;
					justify-content: flex-end;
					padding: 20rpx 0;
					font-size: 30rpx;
				}
			}

		}

		.model_four {
			display: flex;
			flex-direction: column;

			.model_four_1 {
				display: flex;
				justify-content: space-between;
				padding: 20rpx 50rpx;

				.model_four_2 {
					color: #999;
					font-size: 28rpx;
				}
			}

			.model_four_3 {
				display: flex;
				justify-content: space-between;
				padding: 20rpx 50rpx;


				.model_four_4 {
					font-size: 28rpx;
					text-align: center;
					height: 45rpx;
					line-height: 45rpx;
					min-width: 15%;

				}
			}
		}
	}





	.ranking_one {
		display: flex;
		justify-content: space-between;
		align-items: center;

		.ranking_three {
			display: flex;
			align-items: center;

			image {
				width: 80rpx;
				height: 80rpx;
			}

			view {
				margin-left: 1vh;
			}
		}

		.ranking_two {
			color: red;

		}
	}

	.detail_title_1 {
		display: flex;
		justify-content: flex-start;
		align-items: center;

		.detail_title_p1 {
			width: 35%;

			.image {
				border-radius: 10rpx;
				width: 200rpx;
				height: 200rpx;
			}
		}

		.detail_title_p2 {
			padding-left: 15rpx;
			width: 100%;

			.detail_title_p3 {
				line-height: 45rpx;
				font-size: 30rpx;
				-webkit-line-clamp: 1;
				display: -webkit-box;
				-webkit-box-orient: vertical;
				overflow: hidden;
				color: #000;
				text-overflow: ellipsis;
			}

			.detail_title_p4 {
				padding: 15rpx 0rpx;
				font-size: 26rpx;
			}

			.detail_title_p4 {
				-webkit-line-clamp: 2;
				display: -webkit-box;
				-webkit-box-orient: vertical;
				overflow: hidden;
				text-overflow: ellipsis;
			}

			.fram_oper_1 {
				display: flex;
				flex-direction: column;

				.fram_oper_2 {
					display: flex;
					justify-content: space-between;
					align-items: center;
					padding: 15rpx 0;

					.views1 {
						font-size: 24rpx;
						width: 30%;
						text-align: center;
						-webkit-line-clamp: 1;
						display: -webkit-box;
						-webkit-box-orient: vertical;
						overflow: hidden;
						text-overflow: ellipsis;
					}

					.views2 {
						font-size: 28rpx;
						width: 30%;
						color: #313131;
						text-align: center;
						-webkit-line-clamp: 1;
						display: -webkit-box;
						-webkit-box-orient: vertical;
						overflow: hidden;
						text-overflow: ellipsis;
					}
				}
			}
		}
	}

	.shop {
		// display: flex;
		// justify-content: flex-end;
		text-align: center;
		background-color: red;
		color: #fff;
		width: 60rpx;
		line-height: 35rpx;
		font-size: 24rpx;
		border-bottom-left-radius: 12rpx;
		border-top-right-radius: 12rpx;

	}
</style>
