<template>
	<view class="">
		<!-- <view class="out-wrapper">
			卖出
		</view> -->
		<view class="jg" style="height: 20rpx;"></view>
		<empty v-if="loaded === true && list.length === 0"></empty>
		<view class="out-wrapper" v-for="item in list" :class="{'outt': item.status == 2}">
			<view class="out-top flex">
				<view class="buy-info flex">
					<view class="fsz">卖家：</view>
					<image :src="item.user.avatar" mode="" class="user-logo fsz"></image>
					<view class="user-name fsz clamp">{{item.user.real_name}}</view>
					<view class="user-phone fsz">
						{{item.user.phone}}
					</view>
				</view>
				<view class="buy-status">{{item.status | status}}</view>
			</view>
			<view class="item-info">
				<view class="info-data">
					<view class="info-tit">编号：</view>
					<view class="info-val">{{item.order_id}}</view>
				</view>
				<view class="info-data">
					<view class="info-tit">价值：</view>
					<view class="info-val">300</view>
				</view>
			</view>
			<view class="upimg">
				<view class="up-tit">
					打款凭证：
				</view>
				<view class="img-wrap" v-if="item.pay_evaluation" @click="lookimg(item.pay_evaluation)">
					<image :src="item.pay_evaluation" mode=""></image>
				</view>
				<view class="" style="color: #0F253A;font-weight: bold;font-size: 26rpx;" v-else>
					买家未上传支付凭证
				</view>
			</view>
			<template v-if="item.status == 2">
				<view class="mc-btn pass" @click="passPackage(item)">
					通过
				</view>
				<view class="mc-btn fail" @click="openrefuse">
					拒绝
				</view>
			</template>
			
		</view>
		<uni-load-more :status="loadingType"></uni-load-more>
		<uni-popup ref="refuse" type="center">
			<view class="refuse-box">
				<view class="box-tit">
					请输入拒绝原因
				</view>
				<textarea :value="resone" placeholder="请输入拒绝原因" class="resone-wrapper" focus />
				<view class="btn-wrap">
					<view class="btn" @click="refusFali">
						取消
					</view>
					<view class="btn" style="color: #000000;" @click="refusOk">
						确定
					</view>
				</view>
			</view>
		</uni-popup>
		<uni-popup ref="lookimg" type="center">
			<view class="pop-wrap" style="position: relative;" >
				<movable-area class="popup-box">
					<movable-view class="popup-item" :scale="true" direction="all">
						<image :src="chooseImg" mode=""></image>
					</movable-view>
				</movable-area>
				<image src="../../static/icon/close.png" mode="" class="close" style="width: 80rpx;height: 80rpx;" @click="closePup"></image>
			</view>
		</uni-popup>
	</view>
</template>

<script>
	import uniPopup from '@/components/uni-popup/uni-popup.vue';
	import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
	import empty from '@/components/empty';
	import { packageOrder, packageAudit } from '@/api/package.js'
	import {
		tabbar,
		tabbar1
	} from "@/utils/tabbar.js";
	export default {
		components: {
			uniLoadMore,
			empty,
			uniPopup
		},
		filters: {
			status(val) {
				let str = ''
				// 状态:0-预约,1-待支付,2-待审核,3-释放中,4-释放完成,5-重新发放,6-完成,-1-没抢到,-2-审核无效
				switch (val) {
					case 0:
						str = '预约'
						break;
					case 1:
						str = '待支付'
						break;
					case 2:
						str = '待审核'
						break;
					case 3:
						str = '释放中'
						break;
					case 4:
						str = '释放完成'
						break;
					case 5:
						str = '重新发放'
						break;
					case 6:
						str = '完成'
						break;
					case -1:
						str = '没抢到'
						break;
					case -2:
						str = '审核无效'
						break;
					default:
						str = ''
				}


				return str
			}
		},
		data() {
			return {
				resone: '', //拒绝理由
				tabbar: tabbar,
				tabbar1: tabbar1,
				current: 2,
				list: [],
				loadingType: 'more',
				page: 1,
				limit: 10,
				loaded: false,
				chooseImg: '',//选择要查看的图片
				choose_order: ''
			}
		},
		onLoad() {
			console.log('卖出')
			this.loadData()
		},
		//上拉加载更多
		onReachBottom() {
			this.loadData()
		},
		methods: {
			lookimg(src) {
				console.log(src,'chooseImg++++++')
				this.chooseImg = src
				this.$refs.lookimg.open()
			},
			loadData() {
				let obj = this
				if (obj.loadingType == 'noMore' || obj.loadingType == 'loading') {
					return
				}
				obj.loadingType = 'loading'
				packageOrder({
					page: obj.page,
					limit: obj.limit,
					status: 1
				}).then(({
					data
				}) => {
					console.log(data)
					obj.list = data.data
					obj.page++
					if (obj.limit == data.data.length) {
						obj.loadingType = 'more'
					} else {
						obj.loadingType = 'noMore'
					}
					obj.loaded = true
				})

			},
			openrefuse() {
				this.$refs.refuse.open()
			},
			//取消拒绝
			refusFali() {
				this.resone = ''
				this.$refs.refuse.close()
			},
			//确定拒绝
			refusOk() {
				let obj = this
				if(obj.resone == '') {
					obj.$api.msg('请输入拒绝理由')
					return
				}
				
				packageAudit({
					re: obj.resone,
					id: obj.choose_order,
					status: -2
				}).then(res => {
					obj.resone = ''
					obj.$refs.refuse.close()
					obj.page = 0
					obj.list = []
					obj.loaded = false
					obj.loadingType = 'more'
					obj.loadData()
				})
				
			},
			closePup() {
				this.chooseImg = ''
				this.$refs.lookimg.close()
			},
			passPackage() {
				packageAudit({
					re: '',
					id: obj.choose_order,
					status: 3
				}).then(res => {
					console.log(res)
					obj.$refs.refuse.close()
					obj.page = 0
					obj.list = []
					obj.loaded = false
					obj.loadingType = 'more'
					obj.loadData()
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.outt {
		height: 392rpx;
	}
	.out-wrapper {
		width: 690rpx;
		// height: 392rpx;
		background: #FFFFFF;
		box-shadow: 0px 0px 17rpx 0px rgba(0, 0, 0, 0.05);
		border-radius: 20rpx;
		margin: 0 auto 20rpx;
		padding: 30rpx;
		position: relative;
		.outt {
			height: 392rpx;
		}
		.out-top {
			line-height: 46rpx;
			justify-content: space-between;

			.buy-info {
				width: 450rpx;
				font-size: 32rpx;
				font-family: PingFang SC;
				font-weight: bold;
				color: #0F253A;
				justify-content: flex-start;

				.fsz {
					flex-shrink: 0;
				}

				.user-name {
					max-width: 180rpx;
				}

				.user-phone {
					padding-left: 10rpx;
					font-size: 24rpx;
					font-family: PingFang SC;
					font-weight: 500;
					color: #999999;
				}

				.user-logo {
					display: block;
					width: 46rpx;
					height: 46rpx;
					border-radius: 50%;
					// background-color: red;
					// padding-right: 10rpx;
					margin-right: 10rpx;
				}
			}

			.buy-status {
				font-size: 26rpx;
				font-family: PingFang SC;
				font-weight: 500;
				color: #6D7C88;
			}
		}

		.item-info {
			width: 100%;
			margin-top: 28rpx;
			line-height: 50rpx;
			font-size: 26rpx;
			font-family: PingFang SC;
			display: flex;
			flex-wrap: wrap;

			.info-data {
				width: 100%;
				display: flex;

				.info-tit {

					font-weight: 500;
					color: #6D7C88;
				}

				.info-val {
					color: #0F253A;
					font-weight: bold;
				}
			}
		}

		.upimg {
			padding-top: 10rpx;
			display: flex;

			.up-tit {
				display: inline-block;
				font-size: 26rpx;
				font-family: PingFang SC;
				font-weight: 500;
				color: #6D7C88;
			}

			.img-wrap {
				width: 153rpx;
				height: 152rpx;

				border-radius: 20rpx;

				image {
					border-radius: 20rpx;
					width: 153rpx;
					height: 152rpx;
					background-color: red;
				}
			}
		}

		.mc-btn {
			width: 144rpx;
			line-height: 50rpx;
			border-radius: 25px;
			background: #FFFFFF;
			font-size: 26rpx;
			font-family: PingFang SC;
			font-weight: 500;
			text-align: center;
			position: absolute;
			bottom: 47rpx;
		}

		.pass {
			color: #FF4C4C;
			border: 2px solid #FF4C4C;
			right: 190rpx;
		}

		.fail {
			color: #999999;
			border: 2px solid #EBEBEB;

			right: 36rpx;
		}
	}

	.refuse-box {
		width: 549rpx;
		height: 437rpx;
		background: #FFFFFF;
		border-radius: 14rpx;

		.box-tit {
			line-height: 120rpx;
			text-align: center;
			font-size: 37rpx;
			font-family: PingFang SC;
			font-weight: bold;
			color: #333333;
		}

		.resone-wrapper {
			width: 494rpx;
			height: 181rpx;
			margin: auto;
			background: rgba(224, 224, 224, 0.35);
			border-radius: 10px;
			padding: 10rpx;
			font-size: 28rpx;
		}

		.btn-wrap {
			margin-top: 60rpx;
			display: flex;

			.btn {
				width: 50%;
				font-size: 37rpx;
				font-family: PingFang SC;
				font-weight: 500;
				color: #999999;
				text-align: center;
			}
		}
	}
	.pop-wrap {
		width: 522rpx;
		height: 800rpx;
		// background-color: red;
	}
	.popup-box {
		width: 522rpx;
		height: 800rpx;
		border-radius: 20rpx;
		position: relative;
		overflow: hidden;
		background-color: #fff;
		.popup-item {
			width: 100%;
			height: 100%;
			
			
			image {
				width: 100%;
				// height: 100%;
			}
		}
		
	}
	.close {
		display: block;
		width: 40rpx;
		height: 40rpx;
		border: 50%;
		position: absolute;
		// background-color: red;
		bottom: -100rpx;
		left: 0;
		right: 0;
		margin: 0 auto;
	}
</style>
