<template>
	<view class="dashboard-container">

		<view class="container-top">
			<!-- <input v-model="keyword" prefix-icon="el-icon-search" placeholder="请输入内容" @input="inpuval" /> -->
			<u-search placeholder="请输入订单编号,联系方式,名称" v-model="keyword" @input="inpuval" :showAction='false' height="30"
				bgColor='#fff'></u-search>
			<view class="serch" @click="serch">搜索</view>
		</view>
		<view class="container-content" v-if="list.length>0">
			<scroll-view scroll-x="true" style="width: 565rpx;white-space: nowrap;overflow: hidden;"
				@scrolltolower="loadMoreData">
				<view v-for="(item,i) in list" :key="i" class="content-one">
					<view class="" @click="kk(item)">
						<view class="content-one-title">收货人名称：{{item.receiver_name}}</view>
						<view class="content-one-con">
							<view>联系电话：{{item.receiver_phone}}</view>
							<view>商家地址：{{item.receiver_address}}</view>
							<view>订单编号：{{item.order_sn}}</view>
							<!-- <view>订单状态：{{item.status==0?'待取货':item.status==1?'配送中':item.status==2?'已配送':'待取消'}}</view> -->
						</view>


					</view>
					<view class="shop-content">
						<view class="shop-content-a">
							<view class="shop-content-a1">商品信息：</view>
							<view class="shop-content-a2">{{ item.products.length }}件</view>

						</view>
						<view class="shop-list">

							<view class="shop" v-for="(items,j) in item.products" :key="j">
								<view style="display: flex;">
									<view class="shop-img">
										<image :src="items.goods_pic" mode=""></image>
									</view>
									<view class="container-txt">
										<text class=" centered-multi-line shop-txt">
											{{ items.goods_name }}</text>
									</view>
								</view>
								<view style="line-height: 34rpx;">X{{ items.product_num}}</view>
							</view>

						</view>

						<view class="btn" @click="show1(item)">
							<view class="btn1">
								<image src="@/static/images/che.png" mode=""></image>

							</view>
							<view class="btn2">货物送达</view>
						</view>
					</view>
				</view>
			</scroll-view>

		</view>
		<view class="bj" v-else>

			<view class="bj-conter">
				<view class="bja">
					<image src="@/static/images/zanwu.png" mode=""></image>
				</view>
				<view class="bjb">
					暂无订单信息
				</view>
			</view>
		</view>
		<gb-popup :isShow="isShow1" rName="确定" :isBut="false" lName="取消" @lEvent="copyshow" @rEvent="copyData"
			title="请输入取件码">

			<view style="padding: 30rpx;">
				<input type="value" v-model="code" placeholder="请输入"
					placeholder-style="font-size: 12rpx;height: 50rpx;line-height: 50rpx;"
					style="height: 50rpx;font-size: 18rpx;" />
			</view>
		</gb-popup>

		<uni-popup ref="globalPopup"  :custom="true">
			<view class="popup-content" @click="close">
				
				<view class="popup-content-a">
					<view class="popup-item">
						用户完成收货
					</view>

					<view class="popup-item">
						<image src="@/static/images/zzw.png" mode="aspectFit" style="width: 150rpx; height: 150rpx;">
						</image>
					</view>
				</view>
			</view>
		</uni-popup>
	</view>
</template>

<script>
	import {
		lists,
		delivery
	} from '@/api/oa.js'

	export default {

		data() {
			return {
				isShow1: false,
				list: [],
				page_no: 1,
				page_size: 10,
				keyword: '',
				erweima: '',
				result: '', // 扫码结果信息
				error: '', // 错误信息
				// show: false,
				// qrcode: false,
				qrcode: true,
				torchActive: false,
				camera: 'auto',
				code: '',
				typeid: ''
			}
		},
		mounted() {
			this.getlist()

		},

		methods: {
			refresh() {
				this.initlist()

			},
			close() {
				this.$refs.globalPopup.close()
			},
			
			//查询
			serch() {
				this.initlist()
			},
			//监听
			inpuval(e) {
				if (e.length == 0) {
				
					this.initlist()
				}
			},
			initlist() {
				this.list = []
				this.page_no = 1
				this.getlist()
			},
			//列表
			getlist() {
				let data = {
					page_no: this.page_no,
					page_size: this.page_size,
					keywords: this.keyword,

					status: 1
				}
				lists(
					data
				).then(res => {
					if (res.code == 1) {
						this.list = [...this.list, ...res.data]
						this.page_no = this.page_no + 1
					}
				})
			},
			loadMoreData() {

				this.getlist()
			},
			show1(row) {

				this.isShow1 = true
				this.typeid = row.id
			
			},
			copyshow() {
				this.isShow1 = false
				this.code = ''
			},
			//取件弹窗
			copyData() {


				if (this.code.length > 0) {

					delivery({
						id: this.typeid,
						take_code: this.code
					}).then((res) => {

						console.log(res)
						this.code = ''
						if (res.code == 1) {
							// Toast(res.msg)
							this.$refs.globalPopup.open()
							this.initlist()

						}
						this.isShow1 = false

					})

				} else {
					this.isShow1 = false
					uni.showModal({
						content: '请输入取件码',
						confirmText: "确认",
						cancelText: '取消',
						success: (res) => {
							if (res.confirm) {

							} else {
								console.log('取消');
								return false;
							}
						}
					})
				}


			},
			kk(item) {
				// uni.navigateTo({
				// 	url: '/pages/psong/detail?id=' + item.id
				// })
				this.$emit('onfunction1', item.id)

			},
			// 打开相机
			openCamera() {
				// uni.navigateTo({
				// 	url:'/pages/index/index1'
				// })

			}


		}

	}
</script>

<style lang="scss" scoped>
	.container-top {
		display: flex;
		justify-content: space-between;
		margin-top: 10rpx;
		background-color: #fff;
		border-radius: 24rpx 24rpx;

		.serch {
			width: 59rpx;
			height: 31rpx;
			line-height: 31rpx;
			border-radius: 15rpx 15rpx;
			border: 1px solid #0022C7;
			text-align: center;


			font-size: 12rpx;
			font-family: PingFang SC-Medium, PingFang SC;
			font-weight: 400;
			color: #0022C7;
		}
	}


	.container-content {
		margin-top: 10rpx;


	}

	.bj {
		width: 565rpx;
		display: flex;
		justify-content: center;
		/* 水平居中 */
		align-items: center;
		/* 垂直居中 */
		text-align: center;

		.bj-conter {}

		.bja {
			width: 249rpx;
			height: 249rpx;

			margin: 0 auto;
			margin-top: 30rpx;
			margin-bottom: 30rpx;
			margin-right: 30rpx;


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

			}
		}

		.bjb {
			font-size: 15rpx;
			font-family: PingFang SC-Regular, PingFang SC;
			font-weight: 400;
			color: #707070;
			margin-right: 40rpx;
		}
	}

	.popup-content {
		width: 308rpx;
		height: 220rpx;
		/* 根据需要调整弹窗内容的宽度 */
		background-color: #fff;
		/* 设置弹窗内容的背景色 */
		padding-top: 30rpx;
		/* 根据需要设置内边距 */
		border-radius: 9rpx 9rpx;
	}

	.popup-content-a {
		display: flex;
		flex-direction: column;
		align-items: center;
		/* 水平居中 */
	}

	.popup-item {
		font-size: 13rpx;
		font-family: PingFang SC-Regular, PingFang SC;
		font-weight: 400;
		color: #0022C7;
		margin-bottom: 10rpx;
		/* 可根据需要调整项之间的间距 */
	}

	.content-one {
		margin-right: 12rpx;
		width: 270rpx;
		padding-bottom: 50rpx;

		background: #ffffff;
		box-shadow: 0px 3px 6px 1px rgba(51, 51, 51, 0.2);
		border-radius: 12px 12px 12px 12px;
		opacity: 1;
		display: inline-block;
		position: relative;

	}

	.content-one-title {
		height: 39rpx;
		line-height: 39rpx;
		padding-left: 15rpx;
		background: #FF7C32;
		border-radius: 12px 12px 0px 0px;
		font-size: 13rpx;
		font-family: PingFang SC-Regular, PingFang SC;
		font-weight: 400;
		color: #ffffff;
	}

	.content-one-con {
		padding-left: 15rpx;
		padding-right: 40rpx;
		margin-top: 10rpx;
		font-size: 12rpx;

		font-family: PingFang SC-Regular, PingFang SC;
		font-weight: 400;
		color: #000000;
		border-bottom: 1px dashed #FF7C32;
		height: 130rpx;

		view {
			margin-bottom: 5rpx;
			white-space: normal;
			word-wrap: break-word;

		}
	}

	.shop-content {
		padding-left: 20px;
		padding-right: 20px;

	}

	.shop-content-a {
		display: flex;
		justify-content: space-between;
		margin-top: 14px;
		margin-bottom: 10px;
	}

	.shop-content-a1 {
		font-size: 13rpx;
		font-family: PingFang SC-Regular, PingFang SC;
		font-weight: 400;
		color: #000000;
	}

	.shop-content-a2 {
		font-size: 12rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
		color: #0022C7;
	}

	.shop-list {
		height: 80rpx;
		overflow: hidden;
		overflow-y: auto;
		margin-bottom: 10rpx;
	}

	.shop {
		display: flex;
		justify-content: space-between;
		font-size: 10rpx;
		font-family: PingFang SC-Regular, PingFang SC;
		font-weight: 400;
		color: #333333;
		margin-bottom: 10rpx;
	}

	.shop-img {
		width: 34rpx;
		height: 34rpx;

		border-radius: 6px 6px 6px 6px;
	}

	.shop-img image {
		width: 34rpx;
		height: 34rpx;
		border-radius: 6px 6px 6px 6px;
	}



	.container-txt {
		margin-left: 10rpx;
		width: 130rpx;
		/* 设置容器高度 */
		display: flex;
		justify-content: center;
		/* 水平居中 */
		align-items: center;
		/* 垂直居中 */
	}

	.centered-multi-line {
		text-align: left;
		/* 文本水平居中 */
		width: 100%;
		/* 宽度占满父容器 */
	}

	.shop-txt {
		display: inline-block;
		/* 转换为行内块元素 */
		white-space: normal;
		/* 允许自动换行 */
		word-break: break-all;
		/* 单词内断行 */
	}

	.btn {
		width: 198rpx;
		height: 32rpx;
		line-height: 32rpx;
		background: #FF7C32;
		border-radius: 23px 23px 23px 23px;
		display: flex;
		position: absolute;
		left: 50%;
		margin-left: -99rpx;
	}

	.btn1 image {
		width: 23rpx;
		height: 23rpx;
	}

	.btn2 {
		font-size: 12rpx;
		font-family: Microsoft YaHei-Regular, Microsoft YaHei;
		font-weight: 400;
		color: #ffffff;
	}

	.btn1 {
		width: 23rpx;
		height: 23rpx;
		margin-left: 60rpx;
		margin-top: 2rpx;
		margin-right: 10rpx;
	}
</style>