<!-- 报班通知 -->
<template>
	<view class="registration">
		<u-navbar back-text="" title="" back-icon-color="#FFFFFF" :background="{ background: '#3D5D4C' }"
			:border-bottom="false"></u-navbar>
		<z-paging ref="paging" v-model="noticeList" @query="queryList">
			<view class="registration-list">
				<view class="registration-list-item" v-for="(item, index) in noticeList" :key="index">
					<view class="left">
						<u-image :src="item.img" mode="aspectFill" width="200" height="216" border-radius="10" />
					</view>
					<view class="right">
						<view class="name">{{ item.name }}</view>
						<view class="school">{{ item.schoolName }}</view>
						<view class="content">
							<u-parse :html="item.description"></u-parse>
						</view>
						<view class="button" @click="signUp(item)">报名</view>
					</view>
				</view>
			</view>
		</z-paging>
		<u-toast ref="uToast" />
		<judge-auth ref="judgeAuth" @adoptAuth="adoptAuth"/>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				noticeList: []
			}
		},
		methods: {
			/**
			 * 下拉分页组件触发
			 * @param {Number} pageNum
			 * @param {Number} pageSize
			 */
			queryList(pageNum, pageSize) {
				this.getList(pageNum, pageSize)
			},
			/**
			 * 获取列表
			 * @param {Object} pageNum
			 * @param {Object} pageSize
			 */
			getList(pageNum, pageSize) {
				this.$u.api.skillTraining.getClassNoticeApi({
					pageNum,
					pageSize
				}).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'
						})
					}
				})
			},
			/**
			 * 报名
			 * @param {Object} item
			 */
			signUp(item) {
				this.$refs['judgeAuth'].modalShow(item)
			},
			adoptAuth(item) {
				this.$u.api.skillTraining.signUpClassApi({
						packageId: item.id
					}).then(res => {
						if (res.code === 200) {
							this.jumpPage('/pages/skillsTraining/submitSuccess/submitSuccess');
						} else {
							this.$refs.uToast.show({
								title: res.msg,
								type: 'error'
							})
						}
					})
			}
		}
	}
</script>

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