<!-- 学历提升课程 -->
<template>
	<view class="course">
		<z-paging ref="paging" v-model="courseList" @query="queryList">
			<view class="course-list">
				<view class="course-list-item" v-for="(item, index) in courseList" :key="index" @click="jumpPage('pages/upgrade/courseDetail/courseDetail', { id: item.id })">
					<view class="left">
						<u-image :src="item.img" mode="aspectFill" width="204" height="132" border-radius="10">
						</u-image>
					</view>
					<view class="right">
						<view>{{ item.name }}</view>
						<view>主讲老师：{{ item.teacherName }}</view>
					</view>
				</view>
			</view>
		</z-paging>
		<u-toast ref="uToast"/>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				courseList: [],
				packageId: ''
			}
		},
		onLoad(page) {
			if (page.id) {
				this.packageId = page.id
			}
		},
		methods: {
			/**
			 * @param {Object} pageNum
			 * @param {Object} pageSize
			 */
			queryList(pageNum, pageSize) {
				this.getList(pageNum, pageSize)
			},
			/**
			 * 获取列表
			 * @param {Object} pageNum
			 * @param {Object} pageSize
			 */
			getList(pageNum, pageSize) {
				this.$u.api.getMoreCourseListApi({ pageNum, pageSize, id: this.packageId }).then(res => {
					if (res.code === 200) {
						this.$refs.paging.complete(res.rows);
					} else {
						this.$refs.paging.complete([]);
						this.$refs.uToast.show({
							title: res.msg,
							type: 'error'
						})
					}
				})
			},
			jumpPage(url, params) {
				this.$u.route({ url, params })
			}
		}
	}
</script>

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

