<template>
	<view class="wrap">
		<view class="top">
			<view class="name">{{ form.classificationName }}</view>
			
			<view class="slogan" v-html="form.slogan"></view>
		</view>
		
		<view class="block">
			<ul class="tabs">
				<li :class="{active: curTab === 0}" @click="tabChange(0)">主页</li>
				<li :class="{active: curTab === 1}" @click="tabChange(1)">商品</li>
			</ul>
			
			<view v-if="!curTab" class="detail">
				<view class="title">公司简介</view>
				<uni-swiper-dot class="pics" :info="desPics" :current="curPic" mode="round" :dots-styles="dotsStyles">
					<swiper class="swiper-box" @change="picChange">
						<swiper-item v-for="(item ,i) in desPics" :key="i">
							<image class="pic" :src="item"></image>
						</swiper-item>
					</swiper>
				</uni-swiper-dot>
				<view class="des" v-html="form.briefIntroduction"></view>
			</view>
			
			<view v-else class="list">
				<!-- <view class="item">
					<image class="pic" src="@/static/image/info-bg.jpg"></image>
					<view class="texts">
						<view class="name">测试标题</view>
						<view class="price">￥12.8</view>
					</view>
				</view>
				<view class="item">
					<image class="pic" src="@/static/image/info-bg.jpg"></image>
					<view class="texts">
						<view class="name">测试标题</view>
						<view class="price">￥12.8</view>
					</view>
				</view>
				<view class="item">
					<image class="pic" src="@/static/image/info-bg.jpg"></image>
					<view class="texts">
						<view class="name">测试标题</view>
						<view class="price">￥12.8</view>
					</view>
				</view>
				<view class="item">
					<image class="pic" src="@/static/image/info-bg.jpg"></image>
					<view class="texts">
						<view class="name">测试标题</view>
						<view class="price">￥12.8</view>
					</view>
				</view> -->
			</view>
		</view>
		
		<view class="block">
			<view class="title">联系我们</view>
			<view class="info address">
				<image class="icon" src="https://occupationlab.com/images/preschoolEdu/address.png" mode="widthFix" />
				地址：{{ form.address || '' }}
			</view>
			<view class="info">
				<image class="icon" src="https://occupationlab.com/images/preschoolEdu/tel.png" mode="widthFix" />
				联系电话：{{ form.phone || '' }}
			</view>
			
			<view class="qrcodes">
				<view v-if="form.qrCodeOneUrl" class="qrcode">
					<image class="pic" :src="form.qrCodeOneUrl" />
					<view class="text">{{ form.qrCodeOneName }}</view>
				</view>
				<view v-if="form.qrCodeTwoUrl" class="qrcode">
					<image class="pic" :src="form.qrCodeTwoUrl" />
					<view class="text">{{ form.qrCodeTwoName }}</view>
				</view>
				<view v-if="form.qrCodeThreeUrl" class="qrcode">
					<image class="pic" :src="form.qrCodeThreeUrl" />
					<view class="text">{{ form.qrCodeThreeName }}</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import { queryTeamInfo } from '@/apis/modules/user.js'
	export default {
		data() {
			return {
				teamId: '',
				curTab: 0,
				form: {
					classificationName: '',
					slogan: '',
					briefIntroduction: '',
					address: '',
					phone: ''
				},
				desPics: [],
				curPic: 0,
				dotsStyles: {
					backgroundColor: 'rgba(83, 200, 249,0.3)',
					border: '1px rgba(83, 200, 249,0.3) solid',
					color: '#fff',
					selectedBackgroundColor: 'rgba(255, 255, 249,0.9)',
					selectedBorder: '1px rgba(251, 251, 251,0.9) solid'
				},
				mpStyle: {
					p: 'font-size: 25rpx !important;font-family: Microsoft Yahei !important;font-weight: 400 !important;color: #333 !important;',
					span: 'font-size: 25rpx !important;font-family: Microsoft Yahei !important;font-weight: 400 !important;color: #333 !important;'
				}
			}
		},
		onShow() {
			const pages = getCurrentPages()
			const { options } = pages[pages.length - 1]
			this.teamId = options.teamId
			this.getInfo()
		},
		methods: {
			// 获取详情
			async getInfo() {
				uni.showLoading({
					title: '加载中'
				})
				const res = await queryTeamInfo({
					teamId: this.teamId
				})
				const data = res.teamInfo
				if (data) {
					// 处理描述图片
					if (data.pictureUrl) {
						this.desPics = data.pictureUrl.split(',')
					}
				}
				this.form = data
				uni.hideLoading()
			},
			// 描述图片切换
			picChange(e) {
				this.curPic = e.detail.current;
			},
			// tab切换
			tabChange(id) {
				this.curTab = id
			},
		}
	}
</script>

<style scoped lang="scss">
.wrap {
	padding-bottom: 140rpx;
}
.top {
	padding: 20rpx;
	.name {
		font-size: 30rpx;
		font-weight: 600;
	}
	.slogan {
		margin: 20rpx 0;
		font-size: 28rpx;
	}
}
.tabs {
	display: flex;
	justify-content: center;
	margin-bottom: 32rpx;
	li {
		width: 33.33%;
		text-align: center;
		font-size: 28rpx;
		color: #333;
		white-space: nowrap;
	}
	.active {
		color: #007EFF;
		&:after {
			content: '';
			display: block;
			width: 40rpx;
			height: 8rpx;
			margin: 18rpx auto 0;
			border-radius: 4px;
			background-color: #007EFF;
		}
	}
}
.block {
	padding: 24rpx;
}
.detail {
	.title {
		margin-bottom: 20rpx;
		font-size: 28rpx;
		font-weight: 600;
	}
	.pics {
		margin: 20rpx 0;
		.pic {
			width: 100%;
			height: 300rpx;
		}
	}
	.des {
		margin-top: 20rpx;
		font-size: 26rpx;
		line-height: 1.6;
	}
}
.info {
	display: flex;
	align-items: center;
	font-size: 28rpx;
	color: #333;
	&.address {
		margin: 30rpx 0 20rpx;
	}
	.icon {
		width: 40rpx;
		margin-right: 10rpx;
	}
}
.qrcodes {
	display: flex;
	justify-content: space-between;
	align-items: center;
	margin-top: 50rpx;
	text-align: center;
	.pic {
		width: 200rpx;
		height: 200rpx;
	}
	.text {
		margin-top: 20rpx;
		font-size: 24rpx;
		color: #333;
	}
}
.list {
	display: flex;
	flex-wrap: wrap;
	padding: 0 10rpx;
	.item {
		width: calc((100% - 40rpx) / 2);
		margin: 20rpx 10rpx;
		background-color: #fff;
		border-radius: 8px;
		overflow: hidden;
	}
	.pic {
		width: 100%;
		height: 200rpx;
	}
	.texts {
		padding: 20rpx;
	}
	.name {
		margin-bottom: 10rpx;
		font-size: 30rpx;
		font-weight: 600;
	}
	.price {
		font-size: 26rpx;
		color: #ff0047;
	}
}
</style>
