<template>
	<view class="page">
		<u-navbar title="旅行社详情" :border-bottom="false" :background="bgc" back-icon-color="#262B37" title-color='#262B37'
			title-size='36' height='36' id="navbar">
		</u-navbar>
		<!-- 旅行社详情内容 -->
		<view class="agency-detail-container">
			<!-- 头部信息区域 -->
			<view class="header-section">
				<image class="agency-avatar" :src="agencyInfo.picture" mode="aspectFill"></image>
				<view class="agency-name">{{ agencyInfo.name }}</view>
			</view>
			<!-- 红色框区域：评分、简介、联系信息 -->
			<view class="info-card">
				<!-- 评分 -->
				<view class="rating-section">
					<u-rate :count="5" active-color="#FFB400" size="32" inactive-color="#E5E5E5" v-model="agencyInfo.rating" readonly></u-rate>
				</view>
				<!-- 简介部分 -->
				<view class="intro-section">
					<view class="intro-label">简介:</view>
					<view class="intro-content">{{ agencyInfo.description == null ? '暂无简介' : agencyInfo.description }}</view>
				</view>
				<!-- 分割线 -->
				<view class="card-divider"></view>
				<!-- 联系信息部分 -->
				<view class="contact-section">
					<view class="contact-item">
						<view class="contact-label">经营场所</view>
						<text>{{ agencyInfo.address }}</text>
						<view class="contact-value">
							<u-icon name="map-fill" size="28" color="#606060"></u-icon>
						</view>
					</view>
					<view class="divider"></view>
					<view class="contact-item" @click="btntel">
						<view class="contact-label">联系电话</view>
						<text>{{ agencyInfo.legalPersonPhone }}</text>
						<view class="contact-value">
							<u-icon name="phone-fill" size="28" color="#606060"></u-icon>
						</view>
					</view>
				</view>
			</view>
			<!-- 详情介绍部分 -->
			<view class="detail-section">
				<view class="detail-title">详情介绍</view>
				<view class="detail-content" v-html="agencyInfo.details"></view>
			</view>
		</view>

	</view>
</template>

<script>
	export default {
		data() {
			return {
                bgc: {
                	backgroundColor: "#fff",
                },
				agencyInfo: {},
				id:''
			}
		},
		onLoad(option) {
            this.id = option.id
			this.getxq()
		},
		methods: {
			// 请求旅行社详情
			getxq(){
				this.$u.get(`/app/travelAgency/detail/${this.id}`).then((res) => {
					if(res.code == 200){
						this.agencyInfo = res.data
					}
				})
			},
			// 点击拨打电话
			btntel(){
				if(this.agencyInfo.legalPersonPhone){
					uni.makePhoneCall({
						phoneNumber: this.agencyInfo.legalPersonPhone,
						success: function(res) {
							console.log('拨打电话成功', res)
						},
						fail: function(err) {
							console.error('拨打电话失败', err)
						}
					})
				}else{
					uni.showToast({
						title: '暂无联系电话',
						icon: 'none',
						duration: 2000
					})
				}
			}
		}
	}
</script>

<style lang="scss">
	page {
		background: #fff;
	}

	.page {
		background: #fff;
		min-height: 100vh;
	}

	// 旅行社详情容器
	.agency-detail-container {
		padding: 40rpx 30rpx;
		background: #fff;
	}

	// 头部信息区域
	.header-section {
		display: flex;
		flex-direction: column;
		align-items: center;
	}

	.agency-avatar {
		width: 200rpx;
		height: 200rpx;
		border-radius: 20rpx;
		margin-bottom: 30rpx;
	}

	.agency-name {
		font-size: 40rpx;
		font-weight: 600;
		color: #262B37;
		margin-bottom: 20rpx;
		text-align: center;
	}

	// 红色框区域 - 信息卡片
	.info-card {
		background: #fff;
		border-radius: 15rpx;
	}

	// 评分区域
	.rating-section {
		display: flex;
		justify-content: center;
		margin-bottom: 30rpx;
	}

	// 简介部分
	.intro-section {
		margin-bottom: 30rpx;
        font-size: 26rpx;
        color: #999999;		
	}

	.intro-label {
		font-size: 28rpx;
		color: #999;
		margin-bottom: 15rpx;
		font-weight: 600;
	}

	.intro-content {
		font-size: 28rpx;
		color: #999;
		line-height: 1.6;
		text-align: left;
	}

	// 卡片内分割线
	.card-divider {
		height: 1rpx;
		background: #F0F0F0;
	}

	// 联系信息部分
	.contact-section {
		background: transparent;
	}

	.contact-item {
		display: flex;
		justify-content: space-between;
		align-items: center;
		padding: 30rpx 0;
	}

	.contact-label {
		font-size: 28rpx;
		color: #262B37;
		font-weight: 500;
		width: 140rpx;
	}

	.contact-value {
		// display: flex;
		// align-items: center;
		// flex: 1;
		// justify-content: flex-end;
		
		text {
			font-size: 28rpx;
			color: #666;
			margin-right: 15rpx;
		}
	}

	.divider {
		height: 1rpx;
		background: #F0F0F0;
		margin: 0 20rpx;
	}

	// 详情介绍部分
	.detail-section {
		background: #fff;
	}

	.detail-title {
		font-size: 32rpx;
		color: #262B37;
		font-weight: 600;
		text-align: center;
		margin-bottom: 30rpx;
		border-top: 2rpx solid #F0F0F0;
		padding-top: 30rpx;
	}

	.detail-content {
		font-size: 28rpx;
		color: #666;
		line-height: 1.6;
		text-align: justify;
	}

</style>