<template>
	<view class="center">
		<view class="row">
			<view class="left-text">发布公告</view>
			<u--textarea v-model="fleetInfo.notice" placeholder="输入公告文字,0-500字" maxlength="500" autoHeight count></u--textarea>
		</view>
		<u-button type="primary" @click="submit">提交</u-button>

<u-toast ref="uToast"></u-toast>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				id:"",
				fleetInfo:{}
			}
		},
		onShow() {

		},
		onLoad(option) {
			this.id = option.id
			this.getList()
		},
		methods: {
			getList(){
				this.$request.baseRequest('get', '/fleetInfo/getFleetInfo', {
						id: this.id
					}).then(res => {
						this.fleetInfo = res.data
					})
					.catch(res => {
						uni.$u.toast(res.message);
					});
			},
			submit(){
				if(!this.fleetInfo.notice){
					this.$refs.uToast.show({
						type: 'error',
						message: "请输入公告内容！",
					})
					return 
				}
				this.$request.baseRequest('post', '/fleetInfo/api/editFleetInfo',this.fleetInfo).then(res => {
						if (res.code == 200) {
							this.$refs.uToast.show({
								type: 'success',
								message: "公告发布成功！",
								complete() {
									// uni.$u.route("pages/riders/myTeam")
									uni.navigateBack({
										delta: 1
									});
								}
							})
						}
						// this.fleetInfo = res.data
					})
					.catch(res => {
						uni.$u.toast(res.message);
					});
			}
		}
	}
</script>

<style lang="scss" scoped>
	.center {
		padding: 30rpx;
	}

	.form_css {
		width: 100%;
		display: flex;
		margin: 20rpx 0;
		height: 60rpx;
		border-bottom: 1px solid #eeeeee;

		.left-text {
			width: 50%;
			text-align: left;
		}

		.right-text {
			width: 50%;
			justify-content: flex-end;
			display: flex;
			text-align: right;
		}
	}
</style>
