<template>
	<view class="page flex-col" style="height: auto;">
		<view class="group_1 flex-row" style="height: auto;">
			<view class="box_1 flex-col justify-end" style="height: auto;margin-top: 0;">

				<view class="text-wrapper flex-row justify-between"
					style="margin-top:50rpx;width: 80%;padding: 0 50rpx;background-color: rgba(248, 246, 237, 1);margin-left: 10%;">
					<text class="x1" :class="{ active: activeTab === '平台课程' }" @click="changeTab('平台课程')">平台课程</text>
					<text class="x1" :class="{ active: activeTab === '大咖课程' }" @click="changeTab('大咖课程')">大咖课程</text>
	
				</view>



				<view class="input_1 flex-row" style="">
					<image class="icon_1" referrerpolicy="no-referrer" @click="getData()"
						src="/static/lanhu_kecheng/81c7c1c64717dc63b3f22bf8626afcc4.png" />
					<input pclass="text_4" placeholder="请输入课程的关键字搜索" @confirm="getData" v-model="search"
						style="height:80rpx;margin-left: 20rpx;"></text>
				</view>

				<view v-for="(item, index) in list" :key="index" @tap="go(item.id)">
					<view class="image-text_1 flex-row justify-between">
						<image class="section_1 flex-col" :src="item.cover" />

						<view class="text-group_1 flex-col justify-between">
							<text class="text_5">{{item.title}}</text>
							<text class="text_6">￥{{item.price}}</text>
						</view>
					</view>
					<image class="image_1" referrerpolicy="no-referrer"
						src="/static/lanhu_kecheng/46abcc18492bf4d15394ff15f9fca598.png" />
				</view>

			</view>


		</view>
	</view>
</template>
<script>
	import {
		mapState
	} from 'vuex';
	export default {
		data() {
			return {
				activeTab: "平台课程",
				cate_id: 1,
				list: [],
				search: '',
				constants: {}
			};
		},
		computed: {
			...mapState(['user', 'statistics', 'common'])
		},
		onLoad() {
			this.getData()
			uni.setNavigationBarColor({
				backgroundColor: '#802931', // 背景颜色
				frontColor: '#ffffff' // 前景颜色（包括标题、返回图标等）
			})
		},
		methods: {
			changeTab(tab) {

				console.log(tab)
				if (tab == '平台课程') {
					this.cate_id = 1
				}
				if (tab == '大咖课程') {
					this.cate_id = 2
				}
				if (tab == '餐饮动态') {
					this.cate_id = 3
				}
				this.activeTab = tab;
				this.getData()
			},

			getData() {
				this.$api.get({
					url: '/wanlshop/data/getKeChengList',
					data: {
						'cate_id': this.cate_id,
						'search': this.search
					},
					success: res => {
						this.list = res
					}
				})
			},
			go(id) {
				if (!this.user.id) {
					this.$wanlshop.msg('请先登录');
					return false
				}
				uni.navigateTo({
					url: '/pages/lanhu_kechengxiangqingmulu/index?id='+id
				});
			}
		}
	}
</script>


<style lang="scss">
	.justify-between {
		display: flex;
		justify-content: space-between;
	}

	.flex-row {
		display: flex;
		flex-direction: row;
	}

	.container {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
		height: 100vh;
	}

	.text-wrapper {
		width: 100%;
		padding: 20px 0;
		background-color: #f5f5f5;
	}

	.box_3 {
		width: 710rpx;
		height: 68rpx;
		margin: 31rpx 0 0 15rpx;
	}

	.image_5 {
		width: 77rpx;
		height: 68rpx;
	}



	.x1 {
		width: 40%;
		height: 50rpx;
		// margin: 0 3%;
		padding: 0;
		font-size: 30rpx;
		color: rgba(102, 102, 102, 1);
		text-align: center;

		text-decoration: none;
	}

	.active {
		color: black;
		font-size: 15px;
		font-weight: 900;
		border-bottom: 3px solid #802931;
	}
</style>


<style lang='css'>
	@import '../common/common.css';
	@import './assets/style/index.rpx.css';
</style>