<template>
	<view class="center">
		<view class="row">
			<!-- <view class="left-text">发布公告</view> -->
			<!-- <u--textarea v-model="fleetInfo.notice" placeholder="输入公告文字,0-500字" maxlength="500"  count></u--textarea> -->
			<u--textarea v-model="fleetInfo.notice" placeholder="输入公告文字,0-500字" maxlength="500" height="100"
				border="none" class="textInfo"></u--textarea>
		</view>
		<view class="number_css">
			{{fleetInfo.notice?fleetInfo.notice.length:"0"}}/500
		</view>
		<!-- <u-button type="primary" @click="submit"></u-button>-->
		<u-toast ref="uToast"></u-toast>
	</view>
</template>

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

		},
		onLoad(option) {
			this.id = option.id
			this.getList()
		},
		onNavigationBarButtonTap(e) {
			this.submit()
		},
		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) {
					uni.navigateBack({
						delta: 1
					});
					return
				}
				this.fleetInfo.flag = 1
				var data={
					flag : 1,
					notice:this.fleetInfo.notice,
					id:this.fleetInfo.id
				}
				this.$request.baseRequest('post', '/fleetInfo/api/editFleetInfo', data).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;
	}

	.textInfo {
		background: #F9F9FB;
	}

	.number_css {
		width: 100%;
		text-align: right;
		margin-top: 26rpx;
		color: #BABABA;
	}
</style>
