<template name="information">
	<view class="information-template">
		 <!-- 订单信息 -->
		 <view class="information-content">
			<view class="information-view">
				<view class="view-num ord">订单编号：{{orderData.orderNo =='undefined' ? '' : orderData.orderNo}}</view>
				<view class="view-type bold">{{typeText}}</view>
			</view>
			<view class="information-view">
				<view class="view-num bold">
					订单标识：{{orderData.orderMark =='undefined' ? '' : orderData.orderMark}}
					<text class="clipboard" @click="clipboard(orderData.orderMark)">复制</text>
				</view>
			</view>
			<view class="information-view">
				<view class="view-num">订单总额：￥{{productTotalFee =='undefined' ? '' : productTotalFee}}</view>
			</view>
			<view class="information-view">
				<view class="view-num">余额抵扣：￥{{balancePayFee =='undefined' ? '' : balancePayFee}}</view>
				<view class="view-man" v-if="discountFee!=0">经理折扣：￥{{discountFee =='undefined' ? '' : discountFee}}</view>
			</view>
			<view class="information-view">
				<view class="view-num bold">应付总额：￥{{payableAmount =='undefined' ? '' : payableAmount}}</view>
			</view>
			<view class="information-view">
				<view class="view-num time">下单时间：{{orderData.orderTime =='undefined' ? '' : orderData.orderTime}}</view>
			</view>
		 </view>
	</view>
</template>

<script>
	const thorui = require("@/components/clipboard/clipboard.thorui.js")
	export default{
		name:"information",
		props:{
			information:{
				type:Object
			}
		},
		data() {
			return{
				orderData:'',
				productTotalFee:'',
				balancePayFee:'',
				discountFee:'',
				payableAmount:'',
				typeText:'',
				typeTextObject:{
					4:'交易完成',
					5:'订单完成',
					6:'已关闭',
					7:'交易全退',
					77:'交易全退',
					11:'待付款待发货',
					12:'待付款部分发货',
					13:'待付款已发货',
					21:'部分付款待发货',
					22:'部分付款部分发货',
					23:'部分付款已发货',
					31:'已付款待发货',
					32:'已付款部分发货',
					33:'已付款已发货',
					111:'待付款待发货',
				}
			}
		},
		created(){
			this.initData(this.information)
		},
		computed: {

		},
		watch:{
			information:{
				handler:function(val){
					// console.log(val.status)
					this.initData(val)
				},
				deep:true//对象内部的属性监听，也叫深度监听
			}
		},
		methods:{
			initData(res) {
				this.orderData = res;
				this.productTotalFee = res.productTotalFee.toFixed(2);
				this.balancePayFee = res.balancePayFee.toFixed(2);
				this.discountFee = res.discountFee.toFixed(2);
				this.payableAmount = res.payableAmount.toFixed(2);
				Object.keys(this.typeTextObject).forEach(key => {
					if(key == res.status){
						this.typeText = this.typeTextObject[key]
					}
				})
			},
			clipboard(data) {
				thorui.getClipboardData(data, (res) => {
					// #ifdef H5
					if (res) {
						this.$util.msg("复制成功",3000);
					} else {
						this.$util.msg("复制失败",3000);
					}
					// #endif
				})
			}
		}
	}
</script>

<style lang="scss">
	.information-template{
		width: 100%;
		height: auto;
		background: #FFFFFF;
		float: left;
		margin-top: 24rpx;
		.information-content{
			width: 702rpx;
			padding: 20rpx 24rpx;
			.information-view{
				height: 44rpx;
				line-height: 44rpx;
				font-size: $font-size-base;
				color: $text-color;
				margin: 4rpx 0;
				.view-num{
					float: left;
					color: $text-color;
					text-align: left;
				}
				.view-man{
					float: left;
					margin-left: 40rpx;
				}
				.view-num.ord{
					color: #E15616;
					text-align: left;
					font-weight: bold;
					float: left;
				}
				.view-num.time{
					color: #999999;
				}
				.bold{
					font-weight: bold;
				}
				.view-type{
					float: right;
					text-align: right;
					color: #FF2A2A;
				}
				.clipboard{
					width: 84rpx;
					height: 36rpx;
					background: linear-gradient(34deg,rgba(255,41,41,1) 0%,rgba(255,109,27,1) 100%);
					text-align: center;
					font-size: $font-size-sm;
					color: #FFFFFF;
					border-radius: 6rpx;
					line-height: 36rpx;
					display: inline-block;
					margin-left: 42rpx;
				}
			}
		}
	}
</style>
