<template>
	<div class="pb_content2" style="background: #fff">
		<div class="pb_head">
			<van-icon
				name="arrow-left"
				color="#fff"
				class="pb_back"
				size="1.2rem"
				@click="goBack"
			/>
			<span>提交作业</span>
		</div>
		<div
			class="pb_content_body"
			style="
				display: flex;
				flex-direction: column;
				justify-content: space-between;
				position: relative;
				min-height: calc(100% - 3rem);
			"
		>
			<div class="myp_parent_textarea">
				<van-field
					v-model="message"
					rows="6"
					autosize
					type="textarea"
					placeholder="输入文字描述..."
					border
				/>
			</div>
			<div class="myp_upload">
				<van-uploader v-model="fileList" multiple />
			</div>
			<div class="upload_work" @click="uploadNow">立即上传</div>
		</div>
		<el-dialog></el-dialog>
	</div>
</template>

<script>
	import Vue from "vue";
	import { Uploader } from "vant";
	import { Dialog } from "vant";

	// 全局注册
	Vue.use(Dialog);

	Vue.use(Uploader);
	export default {
		data() {
			return {
				message: "",
				fileList: [],
			};
		},
		methods: {
			goBack() {
				this.$router.isBack = true;
				if (window.history.length <= 1) {
					this.$router.push({ path: "/" });
					return false;
				} else {
					this.$router.go(-1);
				}
			},
			uploadNow() {
				this.$toast.success("提交成功");
				setTimeout(() => {
					this.goBack();
				}, 1000);
			},
		},
	};
</script>

<style scoped>
	.myp_parent_textarea {
		width: 100%;
		margin: 0 auto;
	}
	.myp_upload {
		margin: 0 0 6rem 1.5rem;
	}
	.upload_work {
		position: absolute;
		bottom: 0;
		width: 100%;
		height: 2.8rem;
		background: #50cf72;
		color: #fff;
		text-align: center;
		line-height: 2.8rem;
	}
</style>
