<template>
	<view class="list">
		<!-- 验收列表 -->
		<view class="sub-list goods" :class="subState">
			<!-- 空白页 -->
			<empty v-if="goodsList.length === 0" tip='无验收数据'></empty>
			<view v-else class="content">
				<view class="titleview">
					<view style="display: flex; width: 100%;height: auto;">
						<view style="flex: 1; text-align: left;">{{orderinfo.dh}}</view>
						<view style="flex: 1; text-align:right; display: block;">{{orderinfo.dhrq}}</view>
					</view>
					<view style="display: flex; width: 100%;height: auto;">
						<view style="flex: 1; text-align: left;">{{orderinfo.shortname}}</view>
						<view style="flex: 1; text-align:right; display: block; font-size: 35rpx; color: #f06c7a;">￥{{sumshisje}}</view>
					</view>
				</view>
				<view class="row" v-for="(row,index) in goodsList" :key="index" >
					<!-- content -->
					<view class="carrier" :class="[typeClass=='goods'?theIndex==index?'open':oldIndex==index?'close':'':'']">
						<view class="goods-info">
							<view class="img">
								<image :src="row.img"></image>
							</view>
							<view class="info">
								<view class="title">{{row.mc}}</view>
								<view class="price-number">
									<view class="keep-num">规格：{{row.gg}}</view>
									<view class="price">￥{{row.price}}</view>
								</view>
								<view class="price-number">
									<view class="keep-num">订货量：{{row.dinghl}}{{row.dw}}</view>
									<view class="price" style="color: #6C9850;">送货量：{{row.songhl}}{{row.dw}}</view>
								</view>
								<view class="shisl-number">
									<view class="keep-num" style="color: #f06c7a;">验收金额：{{row.je}}</view>
									<view class="price">
										验收量
										<view class="input">
											<input type="digit" v-model="row.shisl==0?'':row.shisl" @input="inputchange($event,row.id,index,row.shisl,row.price)" />
										</view>
									</view>
								</view>
							</view>
						</view>
					</view>
				</view>
				<view style="width: 100%;color: grey; font-size: 22rpx; text-align: center;display: block;">没有更多了~~</view>
				<view class="pay" v-if="orderinfo.zt<3">
					<view class="btn" @tap="doDeposit">保存验收</view>
				</view>
			</view>
		</view>
	</view>

</template>
<script>
import empty from "@/components/empty";
	export default {
		components: {
			empty
		},
		data() {
			return {
				goodsList:[],
				headerTop:0,
				//控制滑动效果
				typeClass:'goods',
				subState:'',
				theIndex:null,
				oldIndex:null,
				isStop:false,
				uid:0,
				orderinfo:[],
				sumshisje:0,
				dhid:0,
			}
		},
		onPageScroll(e){
			
		},
		//下拉刷新，需要自己在page.json文件中配置开启页面下拉刷新 "enablePullDownRefresh": true
		onPullDownRefresh() {
		    setTimeout(function () {
		        uni.stopPullDownRefresh();
		    }, 1000);
		},
		onLoad(e) {
			//兼容H5下排序栏位置
			// #ifdef H5
				//定时器方式循环获取高度为止，这么写的原因是onLoad中head未必已经渲染出来。
				let Timer = setInterval(()=>{
					let uniHead = document.getElementsByTagName('uni-page-head');
					if(uniHead.length>0){
						this.headerTop = uniHead[0].offsetHeight+'px';
						clearInterval(Timer);//清除定时器
					}
				},1);
			// #endif
			//获取当前用户信息
			let getuserinfo=uni.getStorageSync('userinfo');
			this.uid=getuserinfo.uid;
			uni.showLoading({title:'加载中'})
			this.dhid=e.dhid;
			this.getorderinfo(e.dhid)
			this.getfoodlist(e.dhid)
		},
		onShow(){
			// this.collectionlist()
		},
		methods: {
			//修改验收量
			inputchange(even,id,index,shisl,dj)
			{
				let inputnum=parseFloat(even.detail.value);
				if(inputnum>0 && dj>0)
				{
					let shisje=inputnum * dj;
					this.goodsList[index].je=parseFloat(shisje.toFixed(2))
					this.goodsList[index].shisl=parseFloat(inputnum)
				}else{
					this.goodsList[index].je=0;
					this.goodsList[index].shisl=parseFloat(inputnum)
				}
				this.getshisje();
			},
			//获取验收数据
			async getfoodlist(id) {
				// let userinfo=uni.getStorageSync('userinfo');
				let redata=await this.$api.orderdetail({action:'orderdetail',dhid:id});
				if(redata.code==1){
					this.goodsList = redata.data;
				}else{
					uni.showToast({
						title:'暂无数据',icon:'none'
					})
				}
				this.getshisje();
				uni.hideLoading()
			},//获取订单信息
			async getorderinfo(id) {
				// let userinfo=uni.getStorageSync('userinfo');
				let redata=await this.$api.orderinfo({action:'orderinfo',dhid:id});
				this.orderinfo = redata.data;
			},
			//汇总金额
			getshisje(){
				this.sumshisje=0;
				this.goodsList.map((item, index) => {
					this.sumshisje=this.sumshisje+item.je;
				});
				this.sumshisje=this.sumshisje.toFixed(2);
			},
			async doDeposit(){
				let userinfo=uni.getStorageSync('userinfo');
				//本地模拟订单提交UI效果
				uni.showLoading({
					title:'正在提交订单...'
				})
				let strsjid='';
				let strshisl='';
				this.goodsList.map((item, index) => {
					strsjid=strsjid+','+item.id;
					strshisl=strshisl+','+item.shisl;
				});
				let getsjid=strsjid.substr(1);
				let getshisl=strshisl.substr(1);
				
				let reinfo=await this.$api.postyans({action:'postyans',dhid:this.dhid,
				uid:userinfo.uid,aid:userinfo.aid,name:userinfo.name,strsjid:getsjid,strshisl:getshisl});
				if(reinfo.code==1)
				{
					uni.showToast({title:'保存成功',icon:'none'});
					setTimeout(function(){
						uni.hideToast();
						uni.redirectTo({
							url: '/pages/orderlist/orderlist?state=0'
						})
					},1500)
				}else
				{
					uni.showToast({title:reinfo.msg,icon:'none'});
				}
				uni.hideLoading();
			},
			discard() {
				//丢弃
			}
		}
	}
</script>
<style lang="scss">
	view{
		display: flex;
		flex-wrap: wrap;
		
	}
	page{position: relative;background-color: #f5f5f5;}
	@font-face {font-family:"HMfont-home";src:url('data:application/x-font-woff2;charset=utf-8;base64,d09GMgABAAAAAAYcAAsAAAAAC7AAAAXPAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHEIGVgCDMgqKTIgRATYCJAMUCwwABCAFhG0HShufCciemjxtEyiE0MJUUYjN7gIePI911ftJqrY61RxhAeHWc1taR0BXaRAvS0cGxd7FXycwvQF4WLxnP3czaSZwFdHkmjTO77s3Gq8T2hKtbaWhlUQDcsL+/+Ne1UzbGprPvsVxjwUYCnAsmHRvDnUssKU9L4hXRPoIr6uBbOALl0MAS25cYBo2vnuELAZbIlAwchg7gGxBi+mgCp7CbTjUIPNx8NQMdRvAvOj75TNe4oHC0di7th18Poajd/VebNbx/+gZoODNZwbEo0ADJQEYkPGN1pEkEnHJSGqbliepC2DxUKi5FjV4MezF5v+HTHgiuXWsoGb5wzMgLrY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xrRp1L3JHT8o6/XIBCneoIDkQRII9yLpLvBKenqYu3JHobtpKAm5KaAX9q76sXoK+D99XnsCINpCVsB/+oHu/rvYjG+TOQ/62Nb86vnfh5kHD1Lmofs/A00KH24ZZN6vgEccMYbA1jlGa/e4Wq4j5YGAzxX/A9/y2Xcm8GAeeTKZ9yOTJ2egyEU2aDwKog2+JDj4VAQXjzpgKUH80T6JdCGBmABQnOEMhCgbQRHmHGiinEcb/H1wSOE9uERFg6WzJJ7Sp7AMsw3G08CiMZb3xroKVWFcg5WPC++JtaWBkRdE9GcyTD6Anm4e5cQlKWTMsUfXHuxmt24MVndRZYxjVyNJUrFTF1WgkbVa283Sdtzdq5vWtFrRIkOeBhgQAyyIMUg5PkgdI1QUmGC6Rb7y9fcQLDYSA4yOjjrnM4SBCT8/4okbHgT0pVQhddxLeVccWDbphmEGpFrMV5FB4tBMSE5UBenUvJEAMcJildoRYY0d3HFSNVW6ur5cfox5f8Gu9qkdUaLFiCMugWnDTI73+IGaGO6Lk55LyUwYCpERZwMAAA==') format('woff2');}
	.icon {
		font-family:"HMfont-home" !important;
		font-size:60upx;
		font-style:normal;
		color:#000000;
		&.jia {
			&:before{content:"\e641";}
		}
		&.jian {
			&:before{content:"\e643";}
		}
		&.shanchu {
			&:before{content:"\e6a4";}
		}
		&.shixiao {
			&:before{content:"\e669";}
		}
		
	}
	.hidden{
		display: none !important;
	}
	.list{
		width: 100%;
		display: block;
		position: relative;
	}
	@keyframes showGoods {
		0% {transform: translateX(-100%);}100% {transform: translateX(0);}
	}
	.sub-list{
	
		&.showgoods{
			display: flex;
			// animation: showGoods 0.20s linear both;
		}
		
		width: 100%;
		padding: 20upx 0 120upx 0;
		.tis{
			width: 100%;
			height: 60upx;
			justify-content: center;
			align-items: center;
			font-size: 32upx;
		}
		
		.row{
			width: 100%;
			height: 30vw; 
			align-items: center;
			position: relative;
			overflow: hidden;
			.menu{
				.icon{
					color: #fff;
					font-size:50upx;
				}
				position: absolute;
				width: 28%;
				height: 100%;
				right: 0;
				justify-content: center;
				align-items: center;
				background-color: red;
				color: #fff;
				z-index: 2;
			}
			
			.carrier{
				@keyframes showMenu {
					0% {transform: translateX(0);}100% {transform: translateX(-28%);}
				}
				@keyframes closeMenu {
					0% {transform: translateX(-28%);}100% {transform: translateX(0);}
				}
				&.open{
					animation: showMenu 0.25s linear both;
				}
				&.close{
					animation: closeMenu 0.15s linear both;
				}
				background-color: #fff;

				position: absolute;
				width: 100%;
				padding: 0 0;
				height: 100%;
				z-index: 3;
				flex-wrap: nowrap;
				.goods-info{
					width: calc(100% - 40upx);
					padding: 10upx;
					flex-wrap: nowrap;
					.img{
						width: calc(30vw - 50upx);
						height: calc(30vw - 50upx);
						border-radius: 10upx;
						overflow: hidden;
						flex-shrink: 0;
						margin-right: 20upx;
						image{
							width: calc(30vw - 50upx);
							height: calc(30vw - 50upx);
						}
					}
					.info{
						width: 100%;
						height: calc(30vw - 40upx);
						overflow: hidden;
						flex-wrap: wrap;
						align-content: space-between;
						position: relative;
						.title{
							width: 100%;
							font-size: 28upx;
							display: -webkit-box;
							-webkit-box-orient: vertical;
							-webkit-line-clamp: 2;
							overflow: hidden;
						}
						.gg{
							width: 100%;
							font-size: 25upx;
							display: -webkit-box;
							-webkit-box-orient: vertical;
							-webkit-line-clamp: 2;
							overflow: hidden;
							color: #999;
						}
						
						.price-number{
							width: 100%;
							justify-content: space-between;
							align-items: baseline;
							
							.keep-num{
								font-size: 25upx;
								color: #999;
							}
							.price{
								font-size: 25upx;
								color: #f06c7a;
							}
						}
						.shisl-number{
							width: 100%;
							justify-content: space-between;
							align-items: baseline;
							.keep-num{
								font-size: 25upx;
								color: #999;
							}
							.price{
								font-size: 25upx;
								color: #f06c7a;
							}
						}
						.input {
							width: 100upx;
							height: 45upx;
							margin: 0 10upx;
							// background-color: #f3f3f3;
							border-bottom: 1upx #ADADAD solid;
						
							input {
								width: 80upx;
								height: 40upx;
								display: flex;
								justify-content: center;
								align-items: center;
								text-align: center;
								font-size: 26upx;
							}
						}
					}
				}
			}

		}
	}
	.titleview{
		position: fixed;
		top: 0;
		left: 0;
		z-index: 5;
		width: 100%;
		height: 120upx;
		background-color: #f5f5f5;
		border-bottom: 1upx solid #f0f0f0;
		padding: 20upx 40upx;
		font-size: 28rpx;
		// color: #999;
		background-color: white;
	}
	.content{
		width: 100%;
		height: auto;
		padding-top: 100upx;
	}
	.pay{
		position: fixed;
		bottom: 0;
		left: 0;
		z-index: 5;
		margin-top: 20upx;
		width: 100%;
		display: flex;
		justify-content: center;
		flex-wrap: wrap;
		background-color: white;
		padding: 20rpx;
		.btn{
			width: 70%;
			height: 70upx;
			border-radius: 80upx;
			display: flex;
			justify-content: center;
			align-items: center;
			color: #fff;
			background-color: #f06c7a;
			box-shadow: 0upx 5upx 10upx rgba(0,0,0,0.2);
		}
	}
</style>
