<template>
	<view class="professional">
		<!-- 导航栏 -->
		<u-navbar title="专业介绍" :background="background" title-color="#fff" back-icon-color="#fff" :border-bottom="false"/>
		
		<view class="professional-bg"></view>
		
		<view class="professional-content">
			
			<!-- 专业详情 -->
			<view class="professional-content-info">
				<view class="professional-content-info-left">
					<u-image src="../../../static/img/skill-工业机器人系统运维员.png" width="198" height="220" border-radius="10"/>
				</view>
				<view class="professional-content-info-right">
					<view class="name">
						<view>专业</view>
						<view>{{ details.name }}</view>
						<!-- <view>（630601）</view> -->
					</view>
					<view class="study">
						难度 <u-rate :count="5" v-model="details.difficult" active-color="#EF651F" disabled size="24" :gutter="4"/>
					</view>
					<view class="study">
						学习时间：{{ details.cycle }}年
					</view>
				</view>
			</view>
			
			<!-- 课程预览 -->
			<view class="professional-content-preview">
				<view class="professional-content-preview-video">
					<view class="title">
						<view><text>课程预览</text>精彩教学视频</view>
						<view @click="jumpPage('/pages/upgrade/upgradeCourse/upgradeCourse', { id: learnpackageId })">
							更多<u-icon name="arrow-right"></u-icon>
						</view>
					</view>
					<view class="list" v-if="details.courseList && details.courseList.length">
						<swiper
							class="swiper"
							:indicator-dots="false"
							:autoplay="false"
							height="196rpx"
						>
							<swiper-item class="swiper-item" v-for="(item, index) in details.courseList" :key="index" @click="jumpPage('/pages/upgrade/courseDetail/courseDetail', { id: item.id })">
								<u-image :src="item.img" width="95%" height="196"/>
								<view class="classes-name">{{ item.name }}</view>
								<view class="classes-teacher">讲师：{{ item.teacherName }}</view>
							</swiper-item>
						</swiper>
					</view>
					<u-empty v-else text="暂无课程" mode="list" margin-top="50"></u-empty>
				</view>
				<!-- 专业介绍 -->
				<view class="professional-content-preview-introduction">
					<view class="title">
						<view><text>专业介绍</text>深入了解本课程</view>
					</view>
					<view class="content">
						<u-parse :html="details.description"></u-parse>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				background: {
					backgroundColor: '#3D5D4C'
				},
				learnpackageId: '',
				details: {}
			}
		},
		onLoad(page) {
			if (page.id) {
				this.learnpackageId = page.id
			}
		},
		onShow() {
			if (this.learnpackageId) {
				this.getDetails(this.learnpackageId)
			}
		},
		methods: {
			/**
			 * 获取专业详情
			 * @param {Object} id
			 */
			getDetails(id) {
				this.$u.api.school.getLearnpackageDetails({ id }).then(res => {
					console.log(res)
					if (res.code === 200) {
						this.details = res.data
					}
				})
			},
			/**
			 * 跳转到指定页面
			 * @param {Object} url
			 * @param {Object} params
			 */
			jumpPage(url, params) {
				this.$u.route({
					url,
					params
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
@import './professionalIntroduction.scss';
</style>
