<template>
	<view class="content">
		<view class="sheet">
			<rich-text :nodes="articleContent"></rich-text>
			<!-- 立即咨询 -->
			<view class="lawyerBtn">
				<view class="lawyerBtn-name">您的心事，我们“抖”懂</view>
				 <!-- @click="$Router.push({name: 'indexSortpay', params:{id: lawyersData.lawyer_business_id, type:'business'}})" -->
				<image class="lawyerBtn-img lawyerBtn-go" @click="sheetClick" src="https://douhuo-storage.oss-cn-beijing.aliyuncs.com/images/2023/06/06/e1323131217b0ca7e1ed2e89a55a0740.png" mode="widthFix"></image>
				<image class="lawyerBtn-img lawyerBtn-see" src="https://douhuo-storage.oss-cn-beijing.aliyuncs.com/images/2023/06/06/e4f37a76780df657cda85c242bfd792c.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="https://douhuo-storage.oss-cn-beijing.aliyuncs.com/images/2023/06/06/6b1485847b45273618f8d922ceee889c.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 { businessDet, authFollow } from '@/apis/interfaces/index'
	import { judgeReal } from '@/apis/interfaces/user'
	
	export default {
		data() {
			return {
				lawyersData		: '',
				articleContent	: '',
				generalShow		: false // 公众号
			}
		},
		onShow() {
			// 律师业务详情
			this.lawyersInfo()
		},
		methods: {
			// 业务详情
			lawyersInfo() {
				businessDet(this.$Route.query.id).then(res => {
					this.lawyersData = res
					this.articleContent= res.content.replace(/\<img/gi, '<img style="max-width:100%;height:auto;display:block;"')
				}).catch(err => {
					uni.showToast({
						title: err.message,
						icon: "none"
					})
				})
			},
			
			// 判断是否认证
			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.douhuotest.douhuofalv.com/webview/webCode'
					// url: 'https://web.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;
	}
	
	.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>