<template>
	<view class="updatePrice" style="padding-bottom: 120upx;">
		<view class="head-info">
			<!-- 搜索 -->
			<view class="searchContent">
				<u-input v-model="searchText" 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 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.goods.goods_image" mode="aspectFill"></image>
				<view class="right">
					<view class="title">
						{{item1.goods.goods_name}}
					</view>
					<view style="display: flex;align-items: center;justify-content: space-between;">
						<view class="num">
							x{{item1.goods.total_num}}
						</view>
						<view class="price">
							<text style="font-size: 26upx;">¥</text>
							<text>{{item1.goods.goods_price}}</text>
						</view>
					</view>

				</view>
			</view>
			<view class="totalNum">
				<text>含运费¥{{item.orderData.express_price}}</text>
				<text>共计：</text>
				<text>¥{{item.orderData.total_price}}</text>
			</view>
			<view class="footerBtn">
				<view class="wuliuBtn" @click="onCondiments">
					调货记录
				</view>
			</view>
		</view>
	</view>
	<view class="footerBtns" @click="manualEntry">
		手动录入
	</view>
</template>

<script>
	import * as newFunApi from '@/api/newFun'
	export default {
		data() {
			return {
				searchText: '',
				goodsList: [],
				total: 1,
				pageNum: 1,
			}
		},
		onLoad(o) {
			this.getOrderList(1)
		},
		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() {
				uni.navigateTo({
					url: "/pages/news3/seasoningCondimentsRecord"
				})
			},
			/**
			 * 获取商品列表
			 */
			async getOrderList(type) {
				uni.showLoading({
					title: "加载中"
				})
				if (type == 1) {
					this.pageNum = 1;
					this.goodsList = []
				}
				let {
					status,
					message,
					data
				} = await newFunApi.deliveryList({
					page: this.pageNum,
					searchValue: this.searchText,
					searchType: 10
				});
				if (status == 200) {
					this.goodsList = this.goodsList.concat(data.list.data)
					this.total = data.list.total
				}
			},
			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;

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

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


		}
	}

	.bg {
		position: relative;

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

		.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: 10upx 30upx;

	}

	.dispatchContent {
		margin: 20upx 0;
		background: #FFF;
		border-radius: 6px;
		padding: 20upx 30upx 10upx 30upx;
	}

	.dispatchItem {
		display: flex;
		align-items: center;

		image {
			width: 194upx;
			height: 194upx;
		}

		.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: #3B3B3B;

			}

			.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: #F21A1C;


			}
		}
	}

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

		text:first-child {
			font-size: 24upx;
			font-family: PingFang SC, PingFang SC;
			font-weight: 500;
			color: #B7B7B7;

		}

		text:nth-child(2) {
			font-size: 32upx;
			font-family: PingFang SC, PingFang SC;
			font-weight: 500;
			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;
	}

	.footerBtns {
		width: 86%;
		height: 88upx;
		background: #F55349;
		border-radius: 36px 36px 36px 36px;
		opacity: 1;
		font-size: 28upx;
		font-family: PingFang SC, PingFang SC;
		font-weight: 500;
		color: #FFFFFF;
		line-height: 88upx;
		text-align: center;
		position: fixed;
		bottom: 20rpx;
		left: 7%;
	}
</style>
