<template name="sharealert">
	<view class="alert spec" :class="specClass">
		<view class="model-warp">
			<view class="content">
				<view class="text-content">
					<view class="title">分享订单</view>
					<view class="share">您的分享码：<text class="txt">{{shareCode}}</text></view>
					<view class="text">
						<text>有效期为24小时。订单分享后若对方无法直接登录小程序查看订单，请提供该分享码给对方，通过输入分享码查看</text>
					</view>
				</view>				
				<view class="alert-btn">
					<view class="btn btn-cancel" @click="hideConfirm">取消</view>
					<!-- #ifdef MP-WEIXIN -->
					<button class="btn btn-confirm" open-type="share" @click="btnConfirm(shareCode)">去分享</button>
					<!-- #endif -->
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default{
		name:'sharealert',
		props:{
			orderId:{
				type:Number
			}
		},
		data() {
			return{
				shareCode:'',
			}
		},
		created() {
			this.getShareCode(this.orderId)
		},
		methods:{
			getShareCode(res){
				this.OrderService.QueryOrderShareCode({orderId:res}).then(response =>{
					this.shareCode = response.data
					this.$parent.shareCode = this.shareCode;
				}).catch(error =>{
					this.$parent.isShareModal = false;
					this.$util.modal('提示',error.msg,'确定','',false,() =>{})
				})
			},
			hideConfirm(){
				this.$parent.isShareModal = false
			},
			btnConfirm(code){//点击事件
				this.$emit('btnConfirm')
			}
		}
	}
</script>

<style lang="scss">
	/*弹窗*/
	 .model-warp.none{
		 display: none;
	 }
	 .model-warp.show{
		 display: block;
	 }
	 .model-warp{
		width: 100%;
		height: 100%;
		background: rgba(0,0,0,0.3);
		position: fixed;
		top: 0;
		left: 0;
		z-index: 10000;
		transition: all 0.4s;
		&.none{
			display: none;			
		}
		&.show{
			display: block;
		}
		.content{
			width: 518rpx;
			height: 418rpx;
			position: absolute;
			background: $bg-color;
			left: 0;
			right: 0;
			bottom: 0;
			top: 0;
			margin: auto;
			border-radius: 14rpx;
			.text-content{
				width: 448rpx;
				height: 264rpx;
				padding: 20rpx 35rpx;
				float: left;
				.title{
					line-height: 40rpx;
					font-size: $font-size-28;
					color: $text-color;
					text-align: center;
					font-weight: bold;
					margin-bottom: 36rpx;
				}
				.share{
					line-height: 36rpx;
					font-size: $font-size-26;
					color: $text-color;
					text-align: justify;
					margin-top: 22rpx;
					font-weight: normal;
					.txt{
						margin-left: 10rpx;
						color: #FF2A2A;
					}
				}
				.text{
					line-height: 36rpx;
					font-size: $font-size-26;
					color: $text-color;
					text-align: justify;
					margin-top: 22rpx;
				}
			}
			.alert-btn{
				width: 80%;
				height: 70rpx;
				display: flex;
				margin: 0 auto;
				.btn{
					flex: 1;
					line-height: 70rpx;
					font-size: $font-size-28;
					text-align: center;
					color: #FFFFFF;
					border-radius: 35rpx;
					padding: 0;
					margin: 0 15rpx;
					&.btn-cancel{
						background: $btn-cancel;
					}
					&.btn-confirm{
						background: $btn-confirm;
					}
				}
			}
		}	
	}
</style>
