<template>
	<view class="container">
		<view class="top">
			<text class="title"><text class="title-brown">健康生活方式</text>大讲堂</text>
			<image class="top-bg" src="https://zkzh-2025.oss-cn-beijing.aliyuncs.com/orangeShop/famous1.png"></image>
			<view class="txt">
				<view>让医学回归生活化,</view>
				<view>以健康的生活方式,</view>
				<view>改善健康困扰，重拾晚年幸福!</view>
			</view>
		</view>
		<view class="container-body">
			<image class="bg" src="https://zkzh-2025.oss-cn-beijing.aliyuncs.com/orangeShop/bg-class.png"></image>
			<text class="title">{{type==1?'健康大讲堂':'生活大讲堂'}}</text>
			<view class="card-box" v-for="(item,index) in cardList" :key="index" @click="goLearn(item.courseId)">
				<view class="bar">
					<image src="https://zkzh-2025.oss-cn-beijing.aliyuncs.com/orangeShop/bar.png" mode="widthFix"></image>
					<view class="tit">{{item.courseName}}</view>
				</view>
				<view class="img-box">
					<view class="img">
						<image :src="item.imgUrl || 'https://zkzh-2025.oss-cn-beijing.aliyuncs.com/orangeShop/no-img.png'" mode="widthFix"></image>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		courseList,
		courseListB
	} from '@/api/class.js'
	export default {
		data() {
			return {
				type:null,
				cardList: [],
				classListb:[]
			}
		},
		computed: {

		},
		mounted() {
			
		},
		onLoad(option) {
			this.type=option.type
			if(this.type==1){
				this.getCourseList()
			}else{
				this.getCourseListb()
			}
		},
		methods: {
			getCourseListb() {
				//私域看课
				courseListB().then(res => {
					if (res.code == 200) {
						this.cardList = res.data
					} else {
						uni.hideLoading();
						uni.showToast({
							title: res.msg,
							icon: 'none'
						});
					}
				})
			},
			getCourseList() {
				courseList().then(res => {
					if (res.code == 200) {
						this.cardList = res.data
					} else {
						uni.hideLoading();
						uni.showToast({
							title: res.msg,
							icon: 'none'
						});
					}
				})

			},
			goLearn(id) {
				uni.navigateTo({
					url: '/pages_course/learn?courseId='+id+'&type='+this.type
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.container {
		background-color: #f6e5db;
		min-height: 100vh;

		.top {
			position: relative;
			z-index: 1;
			font-size: 78rpx;
			font-weight: 900;
			text-align: center;
			padding: 34rpx 0;

			.title {
				background: linear-gradient(to right, #333032, #5f3b32);
				-webkit-background-clip: text;
				background-clip: text;
				-webkit-text-fill-color: transparent;
				position: relative;
				z-index: 2;

				.title-brown {
					-webkit-text-stroke: 2rpx #fff;
					text-shadow: 2rpx 2rpx 4rpx rgba(183, 94, 52, 0.5);
					background: linear-gradient(to bottom, #c47243, #b0592a);
					-webkit-background-clip: text;
					background-clip: text;
					-webkit-text-fill-color: transparent;
				}
			}

			.top-bg {
				position: absolute;
				top: 0;
				left: 0;
				width: 100%;
				z-index: 0;
			}

			.txt {
				font-style: italic;
				text-align: left;
				color: #fff;
				font-size: 36rpx;
				font-weight: 500;
				position: absolute;
				left: 8%;
				top: 172rpx;
				text-shadow:
					0 0 1rpx #b0663c,
					1rpx 1rpx 10rpx rgba(183, 0, 3, 0.3);
			}
		}

		.container-body {
			margin-top: 250rpx;
			min-height: calc(100vh - 250rpx);
			padding: 50rpx 24rpx;
			display: flex;
			flex-direction: column;
			align-items: center;
			position: relative;
			z-index: 1;

			.bg {
				position: absolute;
				top: 0;
				left: 0;
				width: 100%;
				height: 100%;
				object-fit: cover;
				z-index: -1;
			}

			.title {
				font-size: 70rpx;
				font-weight: 900;
				background: linear-gradient(to bottom, #c47243, #b0592a);
				-webkit-background-clip: text;
				background-clip: text;
				-webkit-text-fill-color: transparent;

				-webkit-text-stroke: 2rpx #fff;
				text-shadow: 2rpx 2rpx 4rpx rgba(183, 94, 52, 0.5);
			}

			.card-box {
				width: 100%;
				margin-top: 30rpx;

				.bar {
					position: relative;

					image {
						position: absolute;
						width: 100%;
						height: 100%;
						z-index: -1;
					}

					.tit {
						text-align: center;
						line-height: 90rpx;
						color: #fff;
						font-weight: 500;
						font-size: 36rpx;
					}
				}

				.img-box {
					margin-top: -8rpx;
					padding: 24rpx;
					background-color: #fff;
					border-radius: 0 0 20rpx 20rpx;

					.img {

						max-height: 380rpx;
						overflow: hidden;
						border-radius: 20rpx;

						image {
							width: 100%;
							height: 100%;
						}
					}
				}

			}
		}

	}
</style>