<template>

	<view class="">
		<you-scroll ref="scroll" @onPullDown="onPullDown">

			<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="3" 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.shop_name}}</view>
								<view class="content-one-con">
									<view>店主姓名：{{item.shop_user}}</view>
									<view>联系电话：{{item.shop_phone}}</view>
									<view>商家地址：{{item.shop_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>

							<view class="btn" @click="openCamera(item)">
								<view class="btn1">


									<image src="@/static/images/er.png" mode=""></image>
								</view>
								<view class="btn2">扫码取货</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>


			</view>


		</you-scroll>
		<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,
		takeGoods
	} from '@/api/oa.js'
	import {
		Toast
	} from '../../libs/uniApi'

	import youScroll from '@/components/you-scroll'
	export default {
		components: {
			youScroll
		},

		data() {
			return {
				popupVisible: false, // 控制弹窗显示与隐藏的变量
				list: [],
				page_no: 1,
				page_size: 10,
				keyword: '',
				erweima: '',
				result: '', // 扫码结果信息
				error: '', // 错误信息
				// show: false,
				// qrcode: false,
				qrcode: true,
				torchActive: false,
				camera: 'auto'
			}
		},

		mounted() {


			this.initlist()
		},


		methods: {
			onPullDown(done) { // 下拉刷新
				setTimeout(() => {
					this.initlist()
					done(); // 完成刷新
				}, 1000 * 1)
			},
			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(val) {
				let data = {
					page_no: this.page_no,
					page_size: this.page_size,
					keywords: this.keyword,
					status: 0
				}

				lists(
					data
				).then(res => {
					if (res.code == 1) {
						uni.hideLoading();
						this.list = [...this.list, ...res.data]
						this.page_no = this.page_no + 1

					}
				})
			},
			kk(item) {

				// this.$nextTick(() => {
				// 	uni.navigateTo({
				// 		url: '/pages/index/detail?id=' + item.id
				// 	})
				// })

				this.$emit('onfunction', item.id, 1)

			},
			loadMoreData() {

				this.getlist()
			},
			//提取商品
			getDocumentListApi(item, oredr) {
				let data = {
					id: item.id,
					order_id: item.order_id,
					order_sn: oredr
				}

				takeGoods(data).then(res => {

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

					}
				})
			},
			// 打开相机
			openCamera(item) {
				console.log(item);
				uni.scanCode({
					success: (res) => {
						this.getDocumentListApi(item, res.result)
						console.log(item, res.result); // 打印扫码结果
					}
				});


			}



		}

	}
</script>

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

		.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;
		}
	}

	.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;
		}
	}

	.container-content {

		margin-top: 10rpx;
	}

	.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;
		position: relative;
		display: inline-block;
	}

	.content-one-title {
		height: 39rpx;
		line-height: 39rpx;
		padding-left: 15rpx;
		background: #0022c7;
		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 #0022c7;
		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: #0022c7;
		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>