<template>
	<view class="expertTeamPage">
		<image :class="['bg', 'bg_1']" v-show="curTabIndex==1" :src="$baseUrl + 'homepage/et_bg_sj1.jpg'"
			mode="aspectFit">
		</image>
		<image :class="['bg', 'bg_2']" v-show="curTabIndex==2" :src="$baseUrl + 'homepage/et_bg_zj1.jpg'"
			mode="aspectFit">
		</image>
		<image :class="['bg', 'bg_3']" v-show="curTabIndex==3" :src="$baseUrl + 'homepage/et_bg_jg1.jpg'"
			mode="aspectFit">
		</image>
		<view class="tab_box">
			<view class="tab tab_1" @tap="onSelTab(1)"></view>
			<view class="tab tab_2" @tap="onSelTab(2)"></view>
			<view class="tab tab_3" @tap="onSelTab(3)"></view>
		</view>
		<view class="bottom_btn_box">
			<image class="et_bottom_btn" :src="$baseUrl + 'homepage/et_bottom_btn.png'" mode="aspectFit" @tap="onLink">
			</image>
		</view>
	</view>
</template>

<script setup>
	import {
		ref
	} from 'vue';
	import {
		onLoad
	} from '@dcloudio/uni-app'
	import {
		jump,
		JumpType
	} from '@/utils';

	import {
		getHealthField
	} from "@/api/common";

	import md from '@/md';

	const curTabIndex = ref(1);

	onLoad((options) => {
		curTabIndex.value = options.tab
		console.log('接收到的参数:', curTabIndex.value)
	});
	const onSelTab = (index) => {
		let str = index === 1 ? '名医专家' : (index === 2 ? '科研专家' : '权威机构')
		md.sensorLogTake({
			xcxClick: "专家团二级页面点击",
			pageName: "专家团-二级页面",
			buttonName: str + "tab按钮点击",
		});
		curTabIndex.value = index;
	}
	//跳转到医生问诊页面
	const onLink = async () => {
		md.sensorLogTake({
			xcxClick: "专家团二级页面点击",
			pageName: "专家团-二级页面",
			buttonName: "专家在线咨询按钮点击",
		});
		const res = await getHealthField();

		if (!res.success) {
			uni.showToast({
				title: "获取健康字段失败",
				icon: "none",
			});
			return;
		}

		const {
			sign,
			timestamp,
			appId,
			partnerUserId,
			env
		} = res.data;

		jump({
			type: JumpType.MINI,
			url: "/pages/partner/redirect",
			extra: {
				appId: "wx81ecfb5aa3fb512f",
				envVersion: env,
				extraData: {
					sign, // 参考 4.请求参数
					timestamp, // 参考 4.请求参数
					appId, // 参考 4.请求参数
					partnerUserId, // 参考 4.请求参数
					targetApp: "/h5/partner/shining-like-a-start/landing-free-consult?sysType=CRF",
				},
			},
		});
	}
</script>

<style lang="less" scoped>
	.expertTeamPage {
		position: absolute;
		width: 100vw;
		height: 100vh;
		overflow-y: scroll;

		.bg {
			position: absolute;
			width: 100vw;
			height: auto;
			background-size: 100% 100%;
		}

		.bg_1 {
			height: 13142rpx;
		}

		.bg_2 {
			height: 6108rpx;
		}

		.bg_3 {
			height: 2503rpx;
		}

		.tab_box {
			position: absolute;
			top: 505rpx;
			z-index: 100;
			width: 100%;
			height: 100rpx;
			display: flex;
			justify-content: center;
			gap: 0rpx;
			opacity: 0;

			.tab {
				// position: absolute;
				width: 230rpx;
				height: 60rpx;
			}

			.tab_1 {
				// left: 45rpx;
				background-color: red;
			}

			.tab_2 {
				// left: 290rpx;
				background-color: #00ff00;
			}

			.tab_3 {
				// left: 510rpx;
				background-color: #0f0f0f;
			}
		}

		.bottom_btn_box {
			position: fixed;
			width: 750rpx;
			height: 118rpx;
			bottom: 0rpx;

			.et_bottom_btn {
				position: absolute;
				width: 681rpx;
				height: 98rpx;
				top: 10rpx;
				left: 35rpx;
			}
		}
	}
</style>