<template>
	<view>
		<uni-nav-bar @clickLeft="clickLeft" left-icon="back" left-text="返回" title="发帖"></uni-nav-bar>
		<view class="post">
			<view class="post_title">
				<input type="text" placeholder="请输入标题" v-model="title" />
			</view>
			<view class="post_contert">
				<textarea v-model="mainbody" placeholder="请输入正文" />
				</view>
			<button class="post_btn" @click="post">发布</button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				title:'',  
				mainbody:''
			}
		},
		methods: {
			async getPostmessage(data) { //发帖
				const res = await this.$myRequest({
					url: '/api/api_gateway?method=pest.pests.pests_new_idea',
					data:{
						title:data.title,
						content:data.content
					}
				})
				console.log(res)
			},
			post(){
				if(this.title!=''&&this.mainbody!=''){
					let obj ={}
					obj.title=this.title
					obj.content=this.mainbody
					this.getPostmessage(obj)
				}
			},
			clickLeft(){
				uni.navigateTo({
					url: './exchangeShare'
				})
			},
		}
	}
</script>

<style lang="scss">
	.post {
		background-color: #F5F5F5;
		width: 100%;
		height: 93vh;
		padding-top: 16rpx;

		.post_title {
			padding: 40rpx 20rpx;
			background-color: white;
			width: 100%;
			input {
				width: 90%;
				margin: 0 auto;
			}
		}

		.post_contert {
			margin-top: 16rpx;
			padding: 40rpx 20rpx;
			background-color: white;
			width: 100%;
			height: 660rpx;
			textarea{
				width: 90%;
				margin: 0 auto;
			}
		}
		.post_btn{
			width: 90%;
			margin: 40rpx auto;
			background-color: #57C878;
			color: white;
			font-size: 32rpx;
		}
	}
</style>
