<template>
	<view class="publishPost">
		<navbar 
		leftClick
		@leftClick="$utils.navigateBack"
		title="发布帖子"/>
		
		<view class="images box">
			<uv-upload 
			:fileList="fileList" 
			:maxCount="5" 
			multiple 
			width="150rpx" 
			height="150rpx"
			@delete="deleteImage"
			@afterRead="afterRead"
			:previewFullImage="true"></uv-upload>
		</view>
		
		<view class="title-input box">
			<input type="text" placeholder="添加标题"/>
		</view>
		
		<view class="content-input">
			<uv-textarea 
			v-model="form.content" 
			:maxlength="200" 
			autoHeight
			count
			placeholder="添加正文"></uv-textarea>
		</view>
		
		<view class="upTop">
			<view class="title">
				<uv-icon name="pushpin-fill"></uv-icon>
				是否置顶
			</view>
			<uv-radio-group v-model="form.upTop">
				<view class="list">
					<view class="item"
					v-for="(item, index) in upTopList"
					:key="index">
						<view class="left">
							{{ item.info }}
						</view>
						<view class="right">
							<uv-radio
							size="35rpx"
							icon-size="35rpx"
							:name="item.id">
							</uv-radio>
						</view>
					</view>
				</view>
			</uv-radio-group>
		</view>
		
		<view class="configBtn"
		@click="$refs.configPopup.open()">
			《发布须知》
		</view>
		
		<submit
		@submit="submit"
		@preview="preview"
		@draft="draft"
		submitTitle="发布帖子"
		/>
		
		<confirmationPopup
		ref="confirmationPopup"
		title="提示"
		confirmText="确认支付">
			<view class="confirmationPopup">
				<image src="/static/image/publish/pay.png" 
				style="width: 150rpx;height: 150rpx;"
				mode=""></image>
				<view class="info">
					确认支付3元，可置顶1天
				</view>
			</view>
		</confirmationPopup>
		
		<confirmationPopup
		ref="confirmationPopupUpload"
		title="提示"
		confirmText="确认">
			<view class="confirmationPopup">
				<image src="/static/image/publish/upload.png" 
				style="width: 150rpx;height: 150rpx;"
				mode=""></image>
				<view class="info">
					已由平台进行审核，时间周期为24小时
				</view>
			</view>
		</confirmationPopup>
		
		<configPopup
		ref="configPopup"
		/>
		
	</view>
</template>

<script>
	import submit from '@/components/content/submit.vue'
	import confirmationPopup from '@/components/toast/confirmationPopup.vue'
	export default {
		components : {
			submit,
			confirmationPopup
		},
		data() {
			return {
				upTopList : [
					{
						info : '置顶1天3元',
						id : 1,
					},
					{
						info : '置顶2天3元',
						id : 4,
					},
					{
						info : '置顶3天3元',
						id : 3,
					},
					{
						info : '置顶4天3元',
						id : 2,
					},
				],
				form : {
					image : [],
					content : '',
					upTop : '',
				},
				fileList: [
					{
						url: 'https://cdn.uviewui.com/uview/swiper/2.jpg'
					},
				],
			};
		},
		methods : {
			deleteImage(e){
				this.fileList.splice(e.index, 1)
			},
			afterRead(e){
				let self = this
				e.file.forEach(file => {
					self.$Oss.ossUpload(file.url).then(url => {
						self.fileList.push({
							url
						})
					})
				})
			},
			submit(){
				console.log(1);
				this.$refs.confirmationPopup.open()
			},
			preview(){},
			draft(){},
		}
	}
</script>

<style lang="scss" scoped>
.publishPost{
	background-color: #fff;
	min-height: 100vh;
	font-size: 28rpx;
	padding-bottom: 150rpx;
	/deep/ .uv-textarea{
		background-color: transparent;
		border: none;
	}
	/deep/ .uv-textarea__count{
		background-color: transparent !important;
	}
	.box{
		padding: 0 20rpx;
	}
	.images{
		display: flex;
		flex-wrap: wrap;
		padding: 20rpx;
	}
	.title-input{
		border-bottom: 1px solid #00000015;
		padding-bottom: 25rpx;
		margin-bottom: 15rpx;
	}
	.content-input{
		min-height: 400rpx;
	}
	.upTop{
		.title{
			padding-top: 20rpx;
			padding-left: 30rpx;
			border-top: 1px solid #00000015;
			display: flex;
			align-items: center;
		}
		.list{
			padding-top: 30rpx;
			width: 100%;
			.item{
				display: flex;
				padding: 20rpx;
				padding-left: 80rpx;
				justify-content: space-between;
				width: 600rpx;
				border-bottom: 1px solid #00000015;
				align-items: center;
			}
		}
	}
	
	.configBtn{
		padding: 20rpx;
		color: #777;
		padding-top: 40rpx;
		font-size: 28rpx;
	}
	
	.confirmationPopup{
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
		width: 100%;
		height: 300rpx;
		image{
			margin-top: 40rpx;
		}
		.info{
			margin-top: 40rpx;
			font-size: 26rpx;
		}
	}
}
</style>
