course.vue 3.82 KB
<template>
	<view>
		<view class="search-area">
			<uni-easyinput prefixIcon="search" v-model="query.courseName" placeholder="搜索课程名称" 
			@change="getList" @clear="getList">
			</uni-easyinput>
		</view>
				<view class="imageFlowBox">
					<view class="imageFlow">
						<view v-for="(b,index) in clist" :key="b.courseId" @click="goDetail(b)">
							<image mode="aspectFill" :src="config.baseUrl_api+b.coursePic" class="cover"></image>
<!-- 							<div class="info">
								<h3 class="name esp">{{b.paperName}}</h3>
								<p class="esp_2">{{b.description}}</p>
								<view class="timeblock">预计用时 {{b.evalTime}}分钟
									
								</view>
							</div> -->
						</view>
					</view>
				</view>
				<view class="tbar">
					全部课程
				</view>
		<view class="list">
				<view class="kcitem" v-for="n in list" :key="n.courseId" @click="goDetail(n)">
					<image :src="config.baseUrl_api+n.coursePic" mode="aspectFill"></image>
					<view class="info">
						<view class="tt esp_2">{{n.courseName}}</view>
						<!-- <view class="pp"><uni-icons type="chatboxes" size="12" />209w 学习</view> -->
						<view class="text-warning" v-if="n.isFree==0">免费</view>
						<view class="text-warning" v-else>金币{{n.allGold}}/积分{{n.allScore}}</view>
					</view>
				</view>
		</view>
		<view class="nodata" v-if="list.length==0">
			<image mode="aspectFit" src="/static/nodata.png"></image>
		</view>
	</view>
</template>

<script setup>
	import {
		onLoad,
		onShow
	} from '@dcloudio/uni-app';
	import config from '@/config.js';
	import {
		ref,
		getCurrentInstance
	} from 'vue';
	import * as api from '@/common/api.js';
	const list = ref([])
	const clist = ref([])
	const kindList = ref([])
	const kindId = ref('')
	const query = ref({
		courseName:''
	})
	const system = uni.getStorageSync('systemType');
	onShow(() => {
		init()
	})

	function init() {
		getList()
		getHot()
	}
	function getHot(){
		uni.showLoading({
			title:`加载中`
		})
		api.getHomePageHotCourse().then(res => {
			clist.value = res.data
			uni.hideLoading()
		})
	}
	function getList() {
		uni.showLoading({
			title:`加载中`
		})
		api.getCourseList(query.value).then(res => {
			list.value = res.rows
			uni.hideLoading()
		})
	}

	function goDetail(item) {
		let path = `/course/courseDetail?id=${item.courseId}`;
		uni.navigateTo({
			url: path
		});

	}
</script>

<style lang="scss" scoped>
	.imageFlowBox {
		position: relative;
		height: 300rpx;
		overflow: auto;
	}
	
	.imageFlow {
		display: flex;
		position: absolute;
		left: 0;
		padding: 0 10rpx;
	
		&>view {    border-radius: 10px;
    overflow: hidden;
			width: 630rpx;
			height: 300rpx;
			margin: 0 10rpx;
			position: relative;
		}
	
		image {
			width: 630rpx;
			height: 300rpx;
		}
	
		.info {
			position: absolute;
			color: #fff;
			top: 0;
			width: 100%;
			height: 100%;
			padding: 30rpx 40rpx;
			overflow: hidden;
			box-sizing: border-box;
	
			.name {
				font-size: 34rpx;
				color: #fff;
				padding-bottom: 20rpx;
				margin-bottom: 20rpx;
				border-bottom: 1px solid RGBA(255, 255, 255, 0.7);
			}
		}
	
		.esp_2 {
			font-size: 28rpx;
			margin-bottom: 26rpx;
		}
	
		.timeblock {
			background: rgba(27, 27, 27, 0.1);
			border-radius: 25rpx;
			font-size: 22rpx;
			padding: 12rpx 17rpx;
			display: inline-flex;
			align-items: center;
	
			image {
				width: 28rpx;
				height: 28rpx;
				margin-left: 22rpx;
			}
		}
	
	}
	
	.list {
		padding: 24rpx 0 0 24rpx;
		overflow: hidden;
	}

	.item {
		border-radius: 15rpx;
		background: #fff;
		width: 338rpx;
		float: left;
		margin: 0 24rpx 24rpx 0;

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

		.info {
			padding: 20rpx 26rpx;
			height: 100rpx;
			box-sizing: border-box;

			.tt {
				font-size: 28rpx;
				line-height: 36rpx;
			}
		}
	}
</style>