<template>
	<view class="content">
		<view class="sheet">
			<image class="sheet-img" v-if="type == 1" src="https://cdn.douhuofalv.com/images/2022/11/30/cb0654de804d11905d2bb539e2fb5f24.jpg" mode="widthFix"></image>
			<image class="sheet-img" v-else-if="type == 2" src="https://cdn.douhuofalv.com/images/2022/11/30/365f75baeaa1b4c5d041dce7f5ad6867.jpg" mode="widthFix"></image>
			<image class="sheet-img" v-else src="https://cdn.douhuofalv.com/images/2022/11/30/007cf45b7138a2552f6a80ffa390c3ad.jpg" mode="widthFix"></image>
			<!-- 立即咨询 -->
			<view class="lawyerBtn">
				<view class="lawyerBtn-name">您的心事，我们“抖”懂</view>
				<image class="lawyerBtn-img lawyerBtn-go" @click="sheetClick" src="../../static/imgs/consult_btn.png" mode="widthFix"></image>
				<image class="lawyerBtn-img lawyerBtn-see" src="../../static/imgs/consult_text.png" mode="widthFix"></image>
			</view>
		</view>
		
		<!-- 关注 -->
		<view class="tipsBack" v-if="generalShow"></view>
		<view class="tipsCont" v-if="generalShow">
			<view class="tipsWhite">
				<image class="tipsCont-img" src="@/static/imgs/general_back.png" mode="widthFix"></image>
				<view class="tipsWhite-top">
					<view class="tipsWhite-name">
						请您先关注抖火法律咨询公众号
					</view>
					<view class="tipsWhite-text">
						关注后，可立即下单
					</view>
				</view>
				<view class="tipsWhite-btn">
					<view class="tipsWhite-btn-go" @click="generalShow = false">
						稍后关注
					</view>
					<view class="tipsWhite-btn-go" @click="judgeGeneral">
						马上关注
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import { judgeReal } from '@/apis/interfaces/user'
	import { authFollow } from '@/apis/interfaces/index'
	
	export default {
		data() {
			return {
				type	   : '',
				generalShow: false // 公众号
			}
		},
		onShow() {
			this.type = this.$Route.query.type
		},
		
		methods: {
			// 判断是否认证
			sheetClick() {
				judgeReal().then(res => {
					if(res.has_sign) {
						if(!res.has_subscribe) {
							// 弹出公众号
							this.generalShow = true
						} else {
							// 跳到咨询单
							this.$Router.replace({name: 'sheetCreate'})
						}
						return
					}
					// 跳到认证页面
					this.$Router.replace({name: 'sheetIdcard'})
				}).catch( err => {
					uni.showToast({
						title: err.message,
						icon: "none"
					})
				})
			},
			
			// 状态
			judgeGeneral(){
				// 获取微信授权信息
				authFollow({
				    // url: 'https://web.douhuofalv.com/webview/webCode',
					url: 'https://web.douhuotest.douhuofalv.com/webview/webCode'
				}).then(res => {
				    window.location.href = res
				}).catch(err => {
				    uni.showToast({
				        title: err.message,
				        icon: "none"
				    })
				})
				
				// 关闭公众号
				this.generalShow = false
			}
		}
	}
</script>

<style lang="scss" scoped>
	.sheet {
		width: 100%;
		height: 100%;
		position: relative;
		left: 0;
		top: 0;
		.sheet-img {
			width: 100%;
		}
	}
	
	.lawyerBtn {
		position: absolute;
		z-index: 99;
		left: 0;
		bottom: $padding;
		width: 100%;
		padding: $padding - 10 $padding;
		box-sizing: border-box;
		text-align: center;
		.lawyerBtn-name {
			font-size: $title-size-sm - 2;
			line-height: 60rpx;
			opacity: .9;
			color: #fff;
		}
		.lawyerBtn-img {
			display: block;
			margin: 0 auto;
		}
		.lawyerBtn-go {
			width: 42%;
			margin: 15rpx auto;
		}
		.lawyerBtn-see {
			width: 60%;
		}
	}
	
	// 关注
	.tipsBack {
		position: fixed;
		width: 100vw;
		height: 100vh;
		left: 0;
		top: 0;
		z-index: 9;
		background-color: rgba(0, 0, 0, .8);
	}
	.tipsCont {
		display: -webkit-box;
		-webkit-box-orient: vertical;
		-webkit-box-pack: center;
		position: fixed;
		left: 0;
		right: 0;
		top: 0;
		bottom: 0;
		z-index: 10;
		padding: 0 10%;
		box-sizing: border-box;
	}
	
	.tipsWhite {
		background-color: #ffffff;
		border-radius: 20rpx;
		overflow: hidden;
	}
	
	.tipsWhite-top {
		padding: $padding;
		box-sizing: border-box;
		text-align: center;
	}
	
	.tipsCont-img {
		width: 100%;
	}
	
	.tipsWhite-name {
		text-align: center;
		color: #111111;
		font-size: 34rpx;
		font-weight: 600;
		margin-bottom: 15rpx;
	}
	
	.tipsWhite-text {
		font-size: 30rpx;
		color: #666666;
		line-height: 48rpx;
	}
	
	.tipsWhite-btn {
		display: flex;
		padding: $padding 10rpx;
		box-sizing: border-box;
		.tipsWhite-btn-go {
			flex: 2;
			color: #fff;
			margin: 0 15rpx;
			height: 80rpx;
			line-height: 80rpx;
			text-align: center;
			border: 2rpx solid #F6F6F6;
			background-color: #007df5;
			border-radius: $radius-m;
			&:first-child {
				color: #333333;
				background-color: #ffffff;
				border: 2rpx solid #cccccc;
			}
		}
	}
</style>