<template>
	<view class="container record clearfix"> 
		<view class="record-content">
			<view class="record-list clearfix"  v-for="(pros,index) in productsList" :key="index" >
				<view class="record-top clearfix">
					<view class="top-view">
						<view class="top-viewlabel">发货时间:</view>
						<view class="top-viewtext">2019-07-11 13:52:23</view>
					</view>
					<view class="top-view">
						<view class="top-viewlabel">申通快递:</view>
						<view class="top-viewtext">
							<text v-for="(item,idx) in lgisList" :key="idx">{{item}}</text>
						</view>
					</view>
				</view>
				<view class="goods-pros">
					<view class="goods-pros-t">
						<view class="pros-img"><image :src="pros.mainImage ? pros.mainImage:''" alt="" /></view>
						<view class="pros-product">
							<view class="producttitle">{{pros.name}}</view>
							<view class="productspec">规格:{{pros.productUnit ? pros.productUnit : ''}}</view>
							<view class="productspec">商品编码:{{pros.productCode ? pros.productCode : ''}}</view>
							<view class="product-view">
								<view class="view-num">数量：{{pros.num}}</view>
							</view>
							<view class="product-view">
								<view class="view-num">本次发货：{{pros.taxRate}}</view>
								<view class="view-num">已发货：{{pros.discount == null ? '0' : pros.discount}}</view>
							</view>
							<view class="product-view">
								<view class="view-num">未发货：{{pros.discountPrice}}</view>
								<view class="view-num">已退货：{{pros.discountPrice}}</view>
							</view>
						</view>	
					</view>
					<view class="goods-pros-b clearfix">
						<view class="b-label">拍照备注</view>
						<view class="b-photo">
							<view class="b-imageView" v-for="(imgItem,imgIdx) in ramkesList" :key="imgIdx" >
								<image :src="imgItem" mode="widthFix"  @click="previewImg(imgIdx)"></image>
							</view>
						</view>
					</view>
					<view class="goods-pros-b clearfix">
						<view class="b-label">拍照备注</view>
						<view class="b-photo">
							<view class="text">{{pros.note ? pros.note : ''}}</view>
						</view>
					</view>
				</view>
				<!-- 底部button -->
				<order-button ref="orderButton" 
							  :orderID="item.id" 
							  @buttonConfirm="handButtonConfirm">
				</order-button>
			</view>
		</view>
	</view>
</template>
<script>
	import authorize from '@/common/config/authorize.js'
	import { mapState,mapMutations } from 'vuex';
	import orderButton from '@/components/cm-module/orderDetails/supplierRecorgButton.vue'	//底部按钮
	import { queryShoppingCartList,shoppingCartUpdate,shoppingCartDelete } from "@/api/cart.js" 
	var isPreviewImg;
	export default{
		components:{
			orderButton
		},
		data(){
			return{
				CustomBar:this.CustomBar,// 顶部导航栏高度
				isIphoneX:this.$store.state.isIphoneX,
				userID:'',
				alertType:'',
				isStock:'',
				lgisList:['ST465464646','SF656565656','YD12541545454'],
				ramkesList:[
					'https://img14.360buyimg.com/n7/jfs/t1/114670/38/7458/171560/5ec3b80fE5c5f15f9/549ceeeca82f0d02.jpg',
					'https://img14.360buyimg.com/n7/jfs/t1/114670/38/7458/171560/5ec3b80fE5c5f15f9/549ceeeca82f0d02.jpg',
					'https://img14.360buyimg.com/n7/jfs/t1/114670/38/7458/171560/5ec3b80fE5c5f15f9/549ceeeca82f0d02.jpg',
					'https://img14.360buyimg.com/n7/jfs/t1/114670/38/7458/171560/5ec3b80fE5c5f15f9/549ceeeca82f0d02.jpg',
					'https://img14.360buyimg.com/n7/jfs/t1/114670/38/7458/171560/5ec3b80fE5c5f15f9/549ceeeca82f0d02.jpg',
					'https://img14.360buyimg.com/n7/jfs/t1/114670/38/7458/171560/5ec3b80fE5c5f15f9/549ceeeca82f0d02.jpg',
					'https://img14.360buyimg.com/n7/jfs/t1/114670/38/7458/171560/5ec3b80fE5c5f15f9/549ceeeca82f0d02.jpg',
					'https://img14.360buyimg.com/n7/jfs/t1/114670/38/7458/171560/5ec3b80fE5c5f15f9/549ceeeca82f0d02.jpg',
					'https://img14.360buyimg.com/n7/jfs/t1/114670/38/7458/171560/5ec3b80fE5c5f15f9/549ceeeca82f0d02.jpg',
					'https://img14.360buyimg.com/n7/jfs/t1/114670/38/7458/171560/5ec3b80fE5c5f15f9/549ceeeca82f0d02.jpg'
				],
				productsList:[
					{
						mainImage:'https://img14.360buyimg.com/n7/jfs/t1/114670/38/7458/171560/5ec3b80fE5c5f15f9/549ceeeca82f0d02.jpg',
						name:'华西生物奥斯卡等级阿奥术大师大所打撒大啊萨达时代萨德',
						productUnit:'盒',
						productCode:'FXSW2131231231',
						num:20,
						id:233,
						taxRate:5,
						discount:5,
						discountPrice:3,
						productCount:6,
						price:'200.00',
						checked:false,
						note:'华西生物奥斯卡等级阿奥术大师大所打撒大啊萨达时代萨德华西生物奥斯卡等级阿奥术大师大所打撒大啊萨达时代萨德'
					},{
						mainImage:'https://img14.360buyimg.com/n7/jfs/t1/114670/38/7458/171560/5ec3b80fE5c5f15f9/549ceeeca82f0d02.jpg',
						name:'华西生物奥斯卡等级阿奥术大师大所打撒大啊萨达时代萨德',
						productUnit:'盒',
						productCode:'FXSW2131231231',
						num:20,
						id:255,
						taxRate:5,
						discount:5,
						productCount:6,
						discountPrice:3,
						price:'200.00',
						checked:false,
						note:'华西生物奥斯卡等级阿奥术大师大所打撒大啊萨达时代萨德华西生物奥斯卡等级阿奥术大师大所打撒大啊萨达时代萨德'
					}
				],	//购物车的商品
				setGoodData:'', //确认订单的商品
				isCheckAll:false,//是否全选
				isModallayer:false,
				isDisabled: false, // 供应商/店铺全选是否禁用状态
				isNoConfim:false,
			}
		},
		onLoad(option){
			console.log(option)
			// this.initGetCartGoodsList();
		},
		computed: {
			...mapState(['hasLogin','userInfo'])
		},
		methods:{
			initGetCartGoodsList(){//初始化购物车 index:1
				let params = {userID:this.userID}
				queryShoppingCartList(params).then(response =>{
					this.$store.commit('updateAllNum',response.data.cartQuantity)
					const responseData = response.data
					if(responseData.pageDate && responseData.pageDate.length > 0 ){
						this.productsList = responseData.pageDate;
						this.productsList.forEach((item,index) => {
							let productsListLength = item.productsList.length,
								invalidLength = 0;
							item.productsList.forEach(pros => {
								pros.shopID = item.shopID;
								if(pros.validFlag == '3' ) {invalidLength++;}
							})
							item.isDisabled = invalidLength === productsListLength;
						})
					} else {
						this.productsList = [];
					}
				}).catch(error =>{
					this.$util.msg(error.msg,2000);
				})
			},	
			previewImg (index) {//顶部商品图片预览
				isPreviewImg = true
				let previewUrls = this.ramkesList
				uni.previewImage({
					current: index, 	//图片索引
					urls: previewUrls, //必须是http图片，本地图片无效
					longPressActions:''
				})
			},
			handButtonConfirm(data){//监听点击时间的按钮类型并执行...
				this.handShowAlert(data)
			},
			handShowAlert(data){//判断点击的按钮类型并执行...
				switch(data.type){
					case 'cancel':
						this.handCenceConfirm()
						break
					case 'add':
						this.$api.navigateTo('/supplier/pages/deliver/add-logistics?orderID='+this.orderID)
						break
				}
			},
			handCenceConfirm(){//取消订单
				this.$util.modal('提示','确定要撤销本次发货吗？撤销后需重新发货','确定','取消',true,() =>{
					cancelOrder({orderID:this.orderID}).then(response =>{
						this.$util.msg(response.msg,2000,true,'success');
						this.initOrderDetaileData()
					}).catch(error =>{
						this.$util.msg(error.msg,2000)
					})
				})
			},
		},
		onPullDownRefresh() {//下拉刷新
			// this.initGetCartGoodsList()
			// uni.stopPullDownRefresh()
		},
		onShow(){
			
		},
	}
</script>

<style lang="scss">
	page{
		background: #f7f7f7;
		height: auto;
	}
	.record-content{
		position: relative;
		border-top: 1px solid #EBEBEB;
	}
	.record-list{
		width: 100%;
		height: auto;
		background-color: #F7F7F7;
		margin-bottom: 24rpx;
		.record-top{
			width: 702rpx;
			padding: 20rpx 24rpx;
			height: auto;
			border-bottom: 2px solid #FF9100;
			background-color: #FFF;
			.top-view{
				width: 100%;
				height: auto;
				float: left;
				line-height: 50rpx;
				font-size: $font-size-28;
				color: #333333;
				display: flex;
				.top-viewlabel{
					width: 130rpx;
					margin-right: 10rpx;
				}
				.top-viewtext{
					width:562rpx;
					height: auto;
					text{
						display: inline-block;
						margin-right: 30rpx;
					}
				}
			}
		}
		.goods-pros{
			width: 702rpx;
			padding: 0 24rpx;
			background: #FFFFFF;
		}	
		.goods-pros-t{
			display: flex;
			width: 100%;
			height: auto;
			padding:20rpx 0;
			.pros-img{
				width: 210rpx;
				height: 210rpx;
				border-radius: 10rpx;
				margin:0 20rpx;
				border:1px solid #f3f3f3;
				margin-left: 0;
				image{
					width: 100%;
					height: 100%;
					border-radius: 10rpx;
				}
			}
			.pros-product{
				width: 492rpx;
				height: 100%;
				line-height: 36rpx;
				font-size: $font-size-28;	
				position: relative;
				.producttitle{
					width: 100%;
					display: inline-block;
					height: auto;							
					text-overflow:ellipsis;
					display: -webkit-box;
					word-break: break-all;
					-webkit-box-orient: vertical;
					-webkit-line-clamp: 2;
					overflow: hidden;
					margin-bottom: 8rpx;
				}
				.productspec{
					height: 44rpx;
					color: #999999;
					line-height: 44rpx;
					font-size: $font-size-26;
				}
				.product-view{
					width: 100%;
					height: auto;
					display: flex;
					.view-num{
						flex: 1;
						text-align: left;
						font-size: $font-size-26;
						color: #666666;
						line-height: 44rpx;
					}
				}
			}
		}
		.goods-pros-b{
			width:100%;
			height: auto;
			padding: 10rpx 0;
			border-top: 1px solid #F7F7F7;
			border-bottom: 1px solid #F7F7F7;
			position: relative;
			.b-label{
				width: 100%;
				line-height: 70rpx;
				font-size: $font-size-28;
				color: $text-color;
			}
			.b-photo{
				width: 100%;
				height: auto;
				padding: 10rpx 0;
				.b-imageView{
					width: 112rpx;
					height: 112rpx;
					margin: 0 20rpx 20rpx 0;
					float: left;
					image{
						width: 112rpx;
						height: 112rpx;
						display: block;
					}
				}
				.text{
					line-height: 44rpx;
					font-size: $font-size-28;
					color: $text-color;
				}
			}
			.goods-pros-m{
				width: 100%;
				height: auto;
				line-height: 76rpx;
				font-size: $font-size-26;
				color: $text-color;
				float: left;
				padding: 10rpx 0;
				border-top: 1px solid #F7F7F7;
				border-bottom: 1px solid #F7F7F7;
				.m-text{
					width: 62rpx;
					float: left;
					padding-right: 20rpx;
					font-weight:bold;
				}
				.m-input{
					display: -webkit-box;
					display: -webkit-flex;
					display: flex;
					-webkit-box-align: center;
					-webkit-align-items: center;
					align-items: center;
					position: relative;
					width: 620rpx;
					height: auto;
					padding: 20rpx 0 10rpx 0;
					background: #FFFFFF;
					.text{
						width: 100%;
						height: 100%;
						font-size: $font-size-26;
						line-height: 36rpx;
						color: #333333;
					}
				}
			}
		}
		
	}
</style>