<template name="alert">
	<view class="alert spec" :class="specClass">
		<!-- 运费弹窗说明 -->
		<view class="freight-alert"  @click.stop="hideConfirm">
			<view class="content clearfix">
				<view class="text-content">
					<view class="text-t">分享码</view>
					<view class="text-c">{{shareCode}} <text class="clipboard" @click.stop="clipboard(shareCode)">复制</text></view>
					<view class="text-h1">有效期为72小时。如果对方还没有绑定采美账号，需要输入该分享码才能查看本订单</view>
				</view>
				<view class="text-btn">
					<!-- #ifdef MP-WEIXIN -->
					<button class="btn" open-type="share" @click="btnConfirm(shareCode)">去分享</button>
					<!-- #endif -->
					<view class="btn-none" @click.stop="hideConfirm(shareCode)">取消</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	const thorui = require("@/components/clipboard/clipboard.thorui.js")
	export default{
		name:'alert',
		props:{
			shopOrderId:{
				type:Number
			}
		},
		data() {
			return{
				shareCode:'',
			}
		},
		created() {
			this.getShareCode(this.shopOrderId)
		},
		onLoad(){
			
		},
		methods:{
			getShareCode(data){
				this.ShopService.ShopOrderShareCode({shopOrderId:data}).then(response =>{
					this.shareCode = response.data
					this.$parent.shareCode = this.shareCode;
				}).catch(error =>{
					this.$parent.isShareModal = false;
					this.$util.modal('提示',error.msg,'确定','',false,() =>{})
				})
			},
			clipboard(data) {
				thorui.getClipboardData(data, (res) => {
					if (res) {
						this.$util.msg("复制成功",2000,true,'success');
					} else {
						this.$util.msg("复制失败",2000,true,'none');
					}
				})
			},
			hideConfirm(){
				this.$parent.isShareModal = false
			},
			btnConfirm(code){//点击事件
				this.$emit('btnConfirm')
			}
		},
		onShow(){
	
		}
	}
</script>

<style lang="scss">
	/*弹窗*/
	.model-warp.none{
		display: none;
	}
	.model-warp.show{
		display: block;
	}
	.freight-alert{
		width: 100%;
		height: 100%;
		background: rgba(0,0,0,.5);
		position: fixed;
		top: 0;
		left: 0;
		z-index: 8888;
		transition: all 0.4s;
		&.none{
			display: none;			
		}
		&.show{
			display: block;
		}
		.content{
			width: 492rpx;
			height: 666rpx;
			position: absolute;
			background: url(https://img.caimei365.com/group1/M00/03/95/Cmis2F76nVaAPs9JAAHGoKa8KvY492.png) no-repeat;
			background-size: cover;
			left: 0;
			right: 0;
			bottom: 0;
			top: 0;
			margin: auto;
			padding:0 24rpx 20rpx 24rpx;
			border-radius: 12rpx;
			.text-content{
				width: 100%;
				height: auto;
				margin-top: 210rpx;
				.text-t{
					font-size: $font-size-28;
					color: $text-color;
					text-align: center;
					line-height: 44rpx;
				}
				.text-c{
					font-size: $font-size-44;
					color: #16E17C;
					text-align: center;
					line-height: 80rpx;
					position: relative;
					.clipboard{
						width: 84rpx;
						height: 36rpx;
						background: #EFEFEF;
						text-align: center;
						font-size: $font-size-24;
						color: #999999;
						border-radius: 4rpx;
						line-height: 36rpx;
						display: inline-block;
						position: absolute;
						top: 29%;
						right: 18%;
					}
				}
				.text-h1{
					line-height: 40rpx;
					font-size: $font-size-28;
					color: $text-color;
					text-align: justify;
				}
			}
			.text-btn{
				width: 100%;
				height: auto;
				margin-top: 40rpx;
				.btn{
					width: 80%;
					height: 70rpx;
					margin: 0 auto;
					background: $btn-confirm;
					line-height: 70rpx;
					font-size: $font-size-28;
					text-align: center;
					color: #FFFFFF;
					border-radius: 35rpx;
					padding: 0;
				}
				.btn-none{
					width: 100%;
					height: 70rpx;
					float: left;
					line-height: 70rpx;
					font-size: $font-size-28;
					text-align: center;
					color: #666666;
					padding: 0;
				}
			}
		}
	}
	
</style>
