<template>
	<view class="content">
		<view class="content_top">
			<view class="content_top-one">
				<image src="@/static/images/dong.gif" mode="aspectFill"></image>
			</view>
			<view class="content_top-two">
				<view class="top-two-one">

					{{objinfo.mer_status==0?"待处理":""||objinfo.mer_status==2?"已拒绝":""||objinfo.mer_status==1?"已接受":""}}
				</view>
				<view class="top-two-two">
					<!-- 2020-07-07 14:14:14
					 -->
					{{objinfo.entrust_start_date}}
				</view>
			</view>
		</view>
		<view class="content_center">
			<view class="content_center-one" v-for="(item,index) in objinfo.product_list">
				<view class="center-one">
					<view class="center-one-img">
						<image :src="item.image[0]" mode="aspectFit"></image>
					</view>
					<view class="center-one-txt">
						<view class="one-txta">
							{{item.store_name}}
						</view>
						<view class="one-txtb">
							<view class="">
								委托价:¥<span>{{item.price}}</span>
							</view>
							<view class="">
								数量:{{item.number}}个
							</view>
						</view>
					</view>
				</view>

			</view>

			<view class="content_center-two" v-if="objinfo">
				<view class="center-two">
					<view class="center-twoa">
						委托方:
					</view>
					<view v-if="objinfo.mer_info" class="center-twob">
						{{objinfo.mer_info.mer_name}}
					</view>
				</view>
				<view class="center-two">
					<view class="center-twoa">
						被委托方:
					</view>
					<view v-if="objinfo.entrust_mer_info" class="center-twob">
						{{objinfo.entrust_mer_info.mer_name}}
					</view>
				</view>
				<view class="center-two">
					<view class="center-twoa">
						委托周期:
					</view>
					<view class="center-twob">
						{{objinfo.entrust_day}}天
					</view>
				</view>
				<view v-if="credit_buy==1" class="center-two">
					<view class="center-twoa">
						结算周期:
					</view>
					<view v-if="objinfo.mer_info" class="center-twob">
						{{objinfo.mer_info.settle_cycle}}天
					</view>
				</view>
				<view v-if="credit_buy==1" class="center-two">
					<view class="center-twoa">
						结算利息:
					</view>
					<view v-if="objinfo.mer_info" class="center-twob">
						{{objinfo.mer_info.interest_rate}}%
					</view>
				</view>
				<view class="center-two">
					<view class="center-twoa">
						状态:
					</view>
					<view class="center-twob">

						{{objinfo.mer_status==0?"待处理":""||objinfo.mer_status==2?"已拒绝":""||objinfo.mer_status==1?"已接受":""}}
					</view>
				</view>
				<view class="center-two">
					<view class="center-twoa">
						是否结束委托:
					</view>
					<view class="center-twob">
						{{objinfo.entrust_finish==0?'未结束':""||objinfo.entrust_finish==1?'已结束':""||objinfo.entrust_finish==2?'商家拒绝':""||objinfo.entrust_finish==3?'申请':""}}
					</view>
				</view>
				<view class="center-two" v-if="objinfo.entrust_finish_refusal">
					<view class="center-twoa">
						拒绝原因:
					</view>
					<view class="center-twob" :style="{'text-align':objinfo.entrust_finish_refusal.length<15?'right':'left'}">
						{{objinfo.entrust_finish_refusal}}
					</view>
				</view>
			</view>

		</view>
		<view class="content_bootm">
			<view class="content_bootm_txt">
				查看TA提到的宝贝
        <text v-if="objinfo.product_list">({{objinfo.product_list.length||0}})</text>
			</view>


			<view class="content_bootm_one" v-for="(item,i) in objinfo.product_list" @click="Merchbaby(item)">
				<view class="bootm_oneimg">
					<image :src="item.image[0]" mode="aspectFit"></image>
				</view>
				<view class="">
					{{item.store_name}}
				</view>
			</view>

		</view>
		<button class="release_btn button" v-if="objinfo.mer_status==1&&type==1" @click="submit(objinfo)">发布</button>
	</view>
</template>

<script>
	import {
		addEntrustCart,
		entrustdetail
	} from '@/api/sale.js'
	export default {
		data() {
			return {
				objinfo: {},
				goodsData: [{
						name: '我发起的',
						name1: '委托销售商品',
						type: 1,
						src: require('@/static/images/wtbg1.png'),
						img: require('@/static/images/wtt1.png')
					},
					{
						name: '我收到的',
						name1: '帮助销售商品',
						type: 2,
						src: require('@/static/images/wtbg2.png'),
						img: require('@/static/images/wtt2.png')
					}
				],
				type: 0,
        credit_buy: 0,
			}
		},
		onLoad(e) {
			this.list(e.id)
			this.type = e.type
      this.credit_buy = e.credit_buy || 0;
		},
		onShow() {

		},
		methods: {
			//商品详情
			list(id) {
				entrustdetail(id).then((res) => {

					this.objinfo = res.data
				})
			},
			//商品宝贝详情
			Merchbaby(item) {
				uni.navigateTo({
					url: `/pages/goods_details/index?id=${item.product_id}`
				})

			},

			//提交购物车
			submit(item) {
				addEntrustCart({
					community_id: item.community_id
				}).then(res => {

					if (res.status == 200) {
						this.$util.Tips({
							title: res.message,
							icon: 'success'
						})
						uni.navigateTo({
							url: '/pages/users/order_confirm/index?cartId=' + res.data.cart_id.toString()
						})
					}

				})
			}
		}

	}
</script>



<style lang="scss">
	.content {
		position: relative;
	}

	.content_top {
		height: 151rpx;
		background: linear-gradient(84deg, #2352FA 0%, #6497FF 100%);
		display: flex;
		padding-top: 21rpx;

		.content_top-one {
			width: 107rpx;
			height: 107rpx;
			margin-left: 28rpx;

			image {
				width: 100%;
				height: 100%;
			}
		}

		.content_top-two {
			margin-left: 25rpx;

			.top-two-one {
				font-size: 35rpx;
				font-family: PingFang SC-Medium, PingFang SC;
				font-weight: 500;
				color: #FFFFFF;
				margin-top: 10rpx;

			}

			.top-two-two {
				font-size: 28rpx;
				font-family: SF Pro Display-Light, SF Pro Display;
				font-weight: 300;
				color: #FFFFFF;
				margin-top: 10rpx;
			}
		}

	}

	.content_center {

		background: #FFFFFF;
		border-radius: 14px 14px 14px 14px;
		margin: 28rpx 28rpx;

		.content_center-one {
			display: flex;
			padding: 0 28rpx;

			.center-one {
				margin-top: 32rpx;
				margin-bottom: 32rpx;
				display: flex;

				.center-one-img {
					width: 154rpx;
					height: 154rpx;
					margin-right: 21rpx;

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

				.center-one-txt {
					.one-txta {
						font-size: 32rpx;
						font-family: PingFang SC;
						font-weight: 500;
						color: #333333;
					}

					.one-txtb {
						display: flex;
						margin-top: 28rpx;
						font-size: 32rpx;
						font-family: PingFang SC;
						font-weight: 400;
						color: #999999;

						span {
							color: #F84221;
							margin-right: 30rpx;

						}
					}
				}
			}

		}

		.content_center-two {
			padding: 0 28rpx;
			padding-bottom: 2rpx;

			.center-two {
				display: flex;
				justify-content: space-between;
				margin-top: 32rpx;
				margin-bottom: 32rpx;

				.center-twoa {
					font-size: 32rpx;
					font-family: PingFang SC;
					font-weight: 400;
					color: #333333;
				}

				.center-twob {
					width: 360rpx;
					text-align: right;

					word-wrap: break-word;
					font-size: 32rpx;
					font-family: PingFang SC;
					font-weight: 400;
					color: #999999;
				}
			}
		}


	}

	.content_bootm {

		margin-bottom: 150rpx;

		.content_bootm_txt {
			margin-top: 42rpx;
			padding-left: 28rpx;
		}

		.content_bootm_one {
			height: 112rpx;
			line-height: 112rpx;
			background: #FFFFFF;
			display: flex;
			margin-top: 21rpx;

			.bootm_oneimg {
				width: 80rpx;
				height: 80rpx;
				margin: auto 0;
				margin-left: 28rpx;
				margin-right: 21rpx;

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

		}
	}

	.button {
		width: 694rpx;
		height: 84rpx;
		line-height: 84rpx;
		text-align: center;
		background: linear-gradient(84deg, #F98649 0%, #F34E45 100%);
		border-radius: 42px 42px 42px 42px;
		font-size: 32rpx;
		font-family: PingFang SC;
		font-weight: 500;
		color: #FFFFFF;
		position: absolute;
		left: 50%;
		margin-left: -347rpx;
		position: fixed;
		bottom: 100rpx;
	}
</style>