<template>
	<view class="updatePrice" style="padding-bottom: 120rpx;">
		<view class="head-info">
			<!-- 搜索 -->
			<view class="searchContent">
				<u-input v-model="searchText" style="width:400upx" confirm-type="search" @confirm="getOrderList(1)"
					placeholder="收件人名字/订单号/发货公司" />
				<u-icon name="search" class="search" @click="getOrderList(1)"></u-icon>
			</view>
		</view>
		<view class="bg">
			<image :src="$picUrl+'/static/news3/bg.png'" mode="widthFix"></image>
			<view class="text">
				只属于非商城订单
			</view>
		</view>
		<view style="padding-bottom: 120upx;" v-if="goodsList.length>0">
			<view class="dispatchContent" v-for="(item, index) in goodsList" :key="index">
				<view class="orderNum">
					订单号：{{item.express_no}}
				</view>
				<view class="dispatchItem" v-for="(item1, index) in item.goods">
					<image :src="item1.image" mode="aspectFill"></image>
					<view class="right">
						<view class="title">
							{{item1.name}}
						</view>
						<view style="display: flex;align-items: center;justify-content: space-between;">
							<view class="num">
								x{{item1.num}}
							</view>
							<view class="price">
								<text style="font-size: 26upx;">¥</text>
								<text>{{item1.price}}</text>
							</view>
						</view>

					</view>
				</view>
				<view class="totalNum">
					<text>共计:</text>
					<text style="color: #F21A1C;">¥{{item.total_price}}</text>
				</view>
				<view class="footerBtn">
					<view class="wuliuBtn" @click="onCondiments(item)">
						调货记录
					</view>
				</view>
			</view>
		</view>
		<view v-else style="margin-top: 250rpx;">
			<u-empty text="暂无发货记录～" mode="list"></u-empty>
			</view>
		<view class="goods-fd">
			<view class="btn" @click="manualEntry">手动录入</view>
		</view>
	</view>
</template>

<script>
	import * as newFunApi from '@/api/newFun'
	export default {
		data() {
			return {
				searchText: '',
				goodsList: [],
				total: 1,
				pageNum: 1,
			}
		},
		onLoad(o) {
			this.getOrderList(1)
			uni.$on('refreshData', () => {
				// 调用列表接口
				this.getOrderList(1)
			})
		},
		//页面卸载
		onUnload() {
			//关闭监听选择收货地址事件
			uni.$off('refreshData')
		},
		onShow() {},
		onPullDownRefresh() {
			this.pageNum = 1;
			this.goodsList = [];
			setTimeout(() => {
				uni.stopPullDownRefresh();
			}, 1000)
		},
		onReachBottom() {
			if (this.goodsList.length <= this.total) {
				this.pageNum++;
			}
		},
		methods: {
			// 手动录入
			manualEntry() {
				uni.navigateTo({
					url: "/pages/news3/ManualEntry"
				})
			},
			// 调货记录
			onCondiments(e) {
				uni.navigateTo({
					url: "/pages/news3/seasoningCondimentsRecord?item=" + JSON.stringify(e)
				})
			},
			/**
			 * 获取商品列表
			 */
			async getOrderList(type) {
				uni.showLoading({
					title: "加载中"
				})
				if (type == 1) {
					this.pageNum = 1;
					this.goodsList = []
				}
				let {
					status,
					message,
					data
				} = await newFunApi.deliveryList({
					page: this.pageNum,
					search: this.searchText
				});
				if (status == 200) {
					this.goodsList = this.goodsList.concat(data.data)
					this.total = data.total
					console.log(this.goodsList)
				}
			},
			onClassify(index) {
				this.pageNum = 1;
				this.goodsList = []
				this.getOrderList();
			},
		}
	};
</script>

<style lang="scss" scoped>
	page {
		min-height: 100%;
		background-color: #F7F8FA;
		padding: 0 20upx;
	}

	.head-info {
		margin: 22upx 20upx;

		.searchContent {
			display: flex;
			align-items: center;
			justify-content: space-between;
			position: relative;
			background-color: #fff;
			border-radius: 60upx;
			width: 680upx;
			margin-left: 15upx;

			::v-deep .u-input {
				background: #FFFFFF;
				border-radius: 30px 30px 30px 30px;
				opacity: 1;
				padding-left: 90upx !important;
			}

			.search {
				position: absolute;
				top: 20upx;
				left: 26upx;
				z-index: 9;
			}


		}
	}

	.bg {
		position: relative;
		width: 100%;
		display: flex;
		align-items: center;
		justify-content: center;

		image {

			height: auto;
			width: 690upx;
		}

		.text {
			height: 100%;
			width: 100%;
			display: flex;
			align-items: center;
			justify-content: center;

			font-size: 42upx;
			font-family: YouSheBiaoTiHei, YouSheBiaoTiHei;
			font-weight: 400;
			color: #FFFFFF;
			position: absolute;
			left: 0;
			top: 0;

		}
	}

	.orderNum {

		font-size: 28upx;
		font-family: PingFang SC, PingFang SC;
		font-weight: 400;
		color: #707070;
		margin: 16upx 0;

	}

	.dispatchContent {
		padding: 20upx 40upx;
		background: #FFF;
		border-radius: 6px;
		margin: 20upx 14upx;
	}

	.dispatchItem {
		display: flex;
		align-items: center;
		margin-bottom: 18upx;

		image {
			width: 158upx;
			height: 170upx;
		}

		.right {
			flex: 1;
			margin-left: 40upx;
			position: relative;
			display: flex;
			flex-direction: column;
			justify-content: space-around;

			.title {

				font-size: 28upx;
				font-family: PingFang SC, PingFang SC;
				font-weight: 500;
				color: #000000;
				margin-bottom: 18upx;

			}

			.subTitle {

				font-size: 28upx;
				font-family: PingFang SC, PingFang SC;
				font-weight: 400;
				color: #7C7C7C;
				margin: 14upx 0;

			}

			.num {

				font-size: 28upx;
				font-family: PingFang SC, PingFang SC;
				font-weight: 500;
				color: #1E1E1E;
			}

			.price {
				display: flex;
				align-items: center;
				justify-content: flex-end;
				font-size: 32upx;
				font-family: PingFang SC, PingFang SC;
				font-weight: 500;
				color: #FF584D;

			}
		}
	}

	.totalNum {
		text-align: right;
		margin-top: 26upx;

		text:first-child {
			font-size: 32upx;
			font-family: PingFang SC, PingFang SC;
			font-weight: 700;
			color: #3B3B3B;
		}

		text:nth-child(2) {
			font-size: 32upx;
			font-family: PingFang SC, PingFang SC;
			font-weight: 700;
			color: #3B3B3B;
			margin: 0 10upx;

		}

		text:nth-child(3) {
			font-size: 32upx;
			font-family: PingFang SC, PingFang SC;
			font-weight: 600;
			color: #F21A1C;

		}
	}

	.footerBtn {
		padding: 20upx 0 15upx 30upx;
		display: flex;
		align-items: center;
		border-top: 1px solid #F0F0F0;
		justify-content: flex-end;
		margin-top: 30upx;
	}

	.wuliuBtn {
		// padding:8upx 46upx;
		text-align: center;
		height: 66upx;
		line-height: 66upx;
		border: 1px solid #F63116;
		font-size: 28upx;
		font-family: PingFang SC, PingFang SC;
		font-weight: 500;
		color: #F83F11;
		border-radius: 20px;
		width: 180upx;
	}

	.goods-fd {
		width: 100%;
		position: fixed;
		left: 0;
		bottom: 0;
		padding: 0.9375rem;
		z-index: 99;
		background-color: #fafafa;
		box-sizing: border-box;

		.btn {
			width: 630rpx;
			line-height: 88rpx;
			background: #F34A40;
			border-radius: 88rpx;
			text-align: center;
			font-size: 28rpx;
			font-weight: 500;
			color: #FFFFFF;
			margin: auto;
		}
	}

	.empty {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
		width: 100%;

		image {
			width: 114rpx;
			height: auto;
			margin-top: 200rpx;
		}
	}
</style>
