<template>
	<view class="orderDetail-digitalShel flex flex_column">
		<view class="contHead" :style="{background:state!= 'CLOSE' ? '#066cff':'#ff5500',color:'#fff'}">
			<view class="statusH">
				<view class="flex flex_column align_center">
					<view class="status-row">
						<u-icon :name="statusIcon" size="42" color="#fff"> 
						</u-icon>
						<text>{{statusText}}</text>
					</view>
					<view class="messageText">{{statusMessage}}</view>
				</view>
			</view>
		</view>
		<view class="order-body">
			<view class="info partList" v-if="partList.length">
				<view class="infoList">
					<view class="title">
						<u-icon name="info-circle" color="#ffaa00" size="28"></u-icon><text>请耐心等待汽配经销商进行配送</text>
					</view>
					<view>
						{{partList.length}}款，共<text class="redText">{{totalNums}}</text>件
					</view>
				</view>
				<view v-for="item in partList" :key="item.productSn" class="flex align-center item-list">
					<view style="height: 150rpx;">
						<u-image :src="item.images" border-radius="16" width="200" height="150" bg-color="#EBEBEB" ></u-image>
						<view class="back-price">返<text>￥15</text></view>
					</view>
					<view>
						<view class="item-name">
						  <text>{{item.productName}}</text>
						</view>
						<view class="item-nums">
							<text>{{item.productCode}}</text>
						</view>
						<view class="item-head">
							<view>
								数量：<text class="redText">{{item.qty}}</text>{{item.unit}}
							</view>
						</view>
					</view>
				</view>
			</view>
			<view class="info" v-if="info">
				<view class="infoList">
					<view class="title">单据信息</view>
					<view class="statu"></view>
				</view>
				<view class="infoList dju">
					<text>订单号</text>
					<text>{{info.shelfOrderNo||'--'}}</text>
				</view>
				<view class="infoList">
					<text>下单时间</text>
					<text>{{info.shelfOrderDate||'--'}}</text>
				</view>
				<view class="infoList">
					<text>下单人员</text>
					<text>{{info.orderPersonName || '--'}}</text>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import carNo from '@/components/carNo.vue'
	import uniIcons from "@/components/uni-icons/uni-icons.vue"
	import moment from 'moment'
	import { findBySnShelfOrder, cancelShelfOrder, takeGoods } from '@/api/shelf.js'
	export default {
	   name: 'orderDetail-digitalShel',
	   components: {
		uniIcons,
		carNo
	   },
	   data() {
		   return {
			   loading: false,
			   info: null,
			   statusText: '',
			   statusIcon: '', // 结算状态icon
			   statusMessage: '',
			   partList: [], // 配件列表
			   shelfOrderSn: null,
			   state: ''
		   }
	   },
	   onReady() {
	   },
	   onLoad(option) { 
		  this.shelfOrderSn = option.shelfOrderSn
		  this.state = option.state
		  uni.setNavigationBarTitle({
		  	title: ''
		  })
		  // 更改标题栏背景色
		  uni.setNavigationBarColor({
		  	frontColor: '#ffffff',
		  	backgroundColor: option.state!= 'error' ? '#066cff':'#ff5500',
		  })
	   },
	   onShow() {
	   	 // this.getDetail()
		 this.info = {
			 orderPersonName: '张三',
			 shelfOrderDate: moment().format('YYYY-MM-DD HH:mm:ss'),
			 shelfOrderNo: '12345678901234567890',
			 billState: 'success'
		 }
		 this.statusText = '提交成功'
		 this.statusIcon = 'checkmark-circle'
		 this.partList = [
			 {
			 	id: new Date().getTime(),
			 	productName: '长安回望绣成堆，山顶千门次第开，一骑红尘妃子笑，无人知是荔枝来',
			 	images: 'https://cdn.uviewui.com/uview/common/logo.png',
				productCode:'432-ddsaf-jjj',
				qty: 5,
			 	unit: '个'
			 }
		 ]
	   },
	   computed: {
		   totalNums(){
			   let ret = 0
			   this.partList.map(item => {
				   ret += item.qty
			   })
			   return ret
		   }
	   },
	   methods: {
		 message(title){
		 	uni.showToast({
		 		icon:'none',
		 		title: title
		 	})
		 },
		  // 获取详情
		  getDetail(){
			  findBySnShelfOrder({sn: this.shelfOrderSn}).then(res => {
				  if(res.status == 200){
					  this.info = res.data
					  this.partList = res.data.shelfOrderDetailList || []
					  if(this.info.billState == 'success'){
						  this.statusText = '提交成功'
						  this.statusIcon = 'checkmark-circle'
						  this.statusMessage = ''
					  }
					  if(this.info.billState == 'error'){
						  this.statusText = '提交失败'
						  this.statusIcon = 'close-circle'
						  this.statusMessage = ''
					  }
				  }
			  })
		  },
	   }
	}
</script>

<style lang="less">
	page{
		height: 100%;
	}
	.orderDetail-digitalShel{
		height: 100%;
		.redText{
			color: #FB1E1E;
		}
		.order-body{
			flex-grow: 1;
			overflow: auto;
			.partList{
				margin-top: 20rpx;
			}
		}
		.contHead {
			.statusH{
				> view{
					padding: 10upx 12%;
					font-size: 34upx;
				}
				.status-row{
					font-size: 42upx;
					text{
						margin-left: 10rpx;
					}
				}
				.messageText{
					font-size: 30upx;
					text-align: center;
					text{
						color: #ffaa00;
					}
					padding: 10rpx 0;
				}
			}
			.orderTj{
				padding: 0 20rpx 20rpx;
				background-color: #fff;
				> view{
					text-align: center;
					border-right: 2rpx solid #eee;
					width: 50%;
					color: #666E75;
					.redText{
						color: #FB1E1E;
					}
					&:last-child{
						border: 0;
					}
					> view{
						color: #666E75;
						&:first-child{
							font-size: 56rpx;
						}
					}
				}
				border-radius: 20rpx 20rpx 0 0;
			}
		}
		.info{
			background-color: #FFFFFF;
			padding: 10rpx 30upx;
			font-size: 32rpx;
			margin-bottom: 20rpx;
			.infoList{
				display: flex;
				justify-content: space-between;
				align-items: center;
				padding: 20rpx 0;
				border-bottom: 2rpx solid #f2f2f2;
				&:last-child{
					border: none;
				}
				.title{
					font-weight: bold;
					> text{
						color: #ff9808;
						font-size: 24upx;
					}
				}
				> text{
					&:first-child{
						color: #666E75;
					}
				}
			}
			.item-list{
				border-bottom: 2rpx solid #f2f2f2;
				padding: 20rpx 0;
				&:last-child{
					border: none;
				}
				> view{
					&:first-child{
						margin-right: 20rpx;
						margin-top: 18rpx;
						position: relative;
						overflow: hidden;
						width: 200rpx;
					}
					.back-price{
						zoom: calc(0.8);
						padding: 6rpx 55rpx;
						background: rgb(255 87 34 / 0.6);
						position: absolute;
						top: 16rpx;
						left: -50rpx;
						color: #fff;
						z-index: 2;
						font-size: 20rpx;
						text-align: center;
						transform: rotate(-40deg);
						display: flex;
						align-items: center;
						text{
							font-size: 28rpx;
						}
					}
					&:last-child{
						flex-grow: 1;
						width: 60%;
					}
				}
				.item-name{
					word-wrap: break-word;
					font-size: 32rpx;
					color: #333;
					font-weight: bold;
					margin-top: 10rpx;
				}
				.item-nums{
					padding: 10rpx 0;
					text{
						font-size: 32rpx;
						color: #222222;
					}
				}
				.item-head{
					display: flex;
					align-items: center;
					justify-content: space-between;
					color: #666;
					> view{
						&:first-child{
							font-size: 28rpx;
							text{
								margin-right: 30rpx;
							}
						}
					}
					.item-no{
						font-size: 28rpx;
						background: rgba(3, 54, 146, 0.15);
						color: #033692;
						border-radius: 100rpx;
						padding: 2rpx 30rpx;
						margin-right: 20rpx;
						display: block;
					}
				}
			}
		}
		.footer{
			padding: 20upx 60upx;
			background: #FFFFFF;
			button{
				&:after{
					border: 0;
				}
				color: #585858;
				font-size: 32rpx;
				margin: 0 20rpx;
			}
		}
	}
	
</style>
