<template>
	<view class="content">
		<u-card :title="classInfo.name" :show-foot="false" title-size="32" margin="0px 0px 10px 0px" :head-style="cardStyle">
			<view slot="body">
				<view class="class-info-text">
					<u-icon name="clock"></u-icon>
					{{classInfo.classStartDate}}&nbsp;&nbsp;{{classInfo.classStartHours}}&nbsp;&nbsp;{{classInfo.residue}}课时
				</view>
				<view class="class-info-text">
					<u-icon name="map"></u-icon>
					{{classInfo.address}}
				</view>
			</view>
		</u-card>
		<u-card title="授课教练" :show-foot="false" title-size="32" margin="0px 0px 10px 0px" :head-style="cardStyle">
			<view class="techaer-info-box" slot="body">
				<u-image :src="classInfo.coachUrl" mode="aspectFill" width="80px" height="80px" border-radius="10px" style=""></u-image>
				<view class="techaer-info">
					<view class="class-info-title">{{classInfo.coachName}}</view>
					<view class="class-info-text">{{classInfo.coachName}}</view>
				</view>
			</view>
		</u-card>
		<u-card title="班级简介" title-size="32" margin="0px 0px 10px 0px" :head-style="cardStyle">
			<view slot="body">
				<view class="class-info-text">{{classInfo.desc}}</view>
			</view>
			<view slot="foot" style="text-align: center;">
				<u-icon name="arrow-down" size="34" color="" label="查看更多" label-pos="left"></u-icon>
			</view>
		</u-card>
		<u-card title="班级展示" sub-title="查看更多" :show-foot="false" title-size="32" margin="0px" :head-style="cardStyle">
			<view class="class-show-box" slot="body">
				<view v-for="(item, index) in classInfo.showList" :key="index" class="class-show-card">
					<u-image :src="item.url" mode="aspectFill" height="30vw" border-radius="10px"></u-image>
					<view class="class-show-name">{{item.name}}</view>
				</view>
			</view>
		</u-card>
		<view class="handle-fix-box">
			<u-button type="warning" shape="circle" :ripple="true" :custom-style="customStyle" @click="goToSubscribelForm()">立即预约</u-button>
		</view>
		<u-top-tips ref="uTips"></u-top-tips>
	</view>
</template>

<script>
	import {
		mapGetters
	} from 'vuex'
	const NET = require('@/utils/request')
	const API = require('@/config/api')
	export default {
		computed: {
			...mapGetters([
				'customStyle',
			])
		},
		data() {
			return {
				classId: '',
				classInfo: {
					name: '',
					classStartDate: '',
					classStartHours: '',
					residue: '',
					address: '',
					coachName: '',
					coachDesc: '',
					coachUrl: '',
					desc: '',
					showList: [],
				},
				cardStyle: {
					fontWeight: 'bold'
				}
			}
		},
		onLoad(options) {
			this.classId = options.id
			this.initialize()
		},
		onReady() {},
		onPullDownRefresh() {
			this.initialize()
			setTimeout(() => {
				uni.stopPullDownRefresh();
			}, 500)
		},
		methods: {
			//  获取初始化数据
			initialize() {
				NET.request(API.getClassDetail, {
					id: this.classId
				}, 'POST').then(res => {
					this.classInfo = res.data
				}).catch(error => {
					this.$refs.uTips.show({
						title: '获取班级详情失败',
						type: 'warning',
					})
				})
			},
			//  跳转预定表单
			goToSubscribelForm() {
				uni.navigateTo({
					url: '/pagesMember/subscribelForm?id=' + this.classId
				});
			},
		},
	}
</script>

<style>
	page {
		width: 100%;
		height: 100%;
		background-color: #f7f7f7;
		position: relative;
	}
</style>
<style lang="scss" scoped>
	@import "@/static/css/themes.scss";
	.content {
		width: 100%;
		float: left;
		padding-bottom: 60px;

		.class-info-text {
			color: #999999;
			line-height: 18px;
		}

		.techaer-info-box {
			display: flex;

			.techaer-info {
				flex: 1;
				margin-left: 10px;

				.class-info-title {
					font-size: 14px;
					font-weight: bold;
					margin-bottom: 5px;
				}
			}
		}

		.class-show-box {
			width: calc(100% + 32px);
			margin: 0 -16px;
			float: left;

			.class-show-card {
				width: calc(50% - 16px);
				margin: 0 8px 16px 8px;
				float: left;

				.class-show-name {
					width: 100%;
					text-align: center;
					line-height: 20px;
					font-size: 14px;
					margin-top: 5px;
				}
			}
		}
	}
</style>
