<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.$api.get('/order/share',{orderID:res},
					response => {
						if(response.code === '1'){
							// console.log( response.data)
							this.shareCode = response.data
							this.$parent.shareCode = this.shareCode;
						}else{
							this.$parent.isShareModal = false;
							this.$util.modal('提示',response.msg,'确定','',false,() =>{
								 this.$api.switchTabTo('/pages/tabBar/home/home')
							})
						}
					}
				)
			},
			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;
			.text-content{
				width: 448rpx;
				height: 264rpx;
				padding: 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: 100%;
				height: 88rpx;
				display: flex;
				.btn{
					flex: 1;
					line-height: 88rpx;
					font-size: $font-size-28;
					text-align: center;
					color: #FFFFFF;
					border-radius: 0;
					padding: 0;
					&.btn-cancel{
						background: $btn-cancel;
					}
					&.btn-confirm{
						background: $btn-confirm;
					}
				}
			}
		}	
	}
</style>
