//添加绑定
<template>
	<view class="center">
		<view class="form_data">
			<view class="flex row">
				<view class="left-text">车队长名字</view>
				<u--input placeholder="请输入车队长姓名" inputAlign='right' border="none" v-model="fleet.carCaptainName"
					maxlength="6">
				</u--input>
			</view>
			<view class="flex row">
				<view class="left-text">车队长账号</view>
				<u--input placeholder="请输入车队长账号" inputAlign='right' border="none"
					v-model="fleet.carCaptainAccountNumber" maxlength="11">
				</u--input>
			</view>
		</view>
		<view class="btn_css">
			<u-button type="primary" text="绑定" @click="submit"></u-button>
		</view>
		<u-toast ref="uToast"></u-toast>
		<u-modal :show="tipsShow" :title="alertTitle" :closeOnClickOverlay='true' :showCancelButton='true'
			confirmColor='#F5BA3C' @confirm="$u.throttle(confirmClick, 1000)" @close="cancelClick"
			@cancel="cancelClick"></u-modal>
	</view>
</template>
<script>
	import {
		mapState
	} from 'vuex';
	export default {
		data() {
			return {
				fleet: {},
				tipsShow: false,
				alertTitle: "确定绑定后请及时联系车队长接受绑定，避免造成您的财产损失"
			}
		},
		onLoad() {

		},
		onShow() {

		},
		computed: {
			...mapState(['hasLogin', 'userInfo', 'firstAuthentication']),
		},
		methods: {
			submit() {
				this.tipsShow = true
			},
			confirmClick() {
				this.tipsShow = false
				uni.showLoading({
					mask: true,
					title: '加载中'
				})
				this.fleet.commonId = this.userInfo.id
				this.fleet.driverName = this.firstAuthentication.driverName
				this.fleet.accountNumber = this.userInfo.phone
				this.$request.baseRequest('post', '/hyBindCarCaptainInfo/api/binding;', this.fleet).then(res => {
						if (res.code == 200) {
							uni.hideLoading()
							this.$refs.uToast.show({
								type: 'success',
								message: "绑定成功,等待队长接受！",
								complete() {
									uni.navigateBack({
										delta: 1
									});
								}
							})
						} else {
							uni.hideLoading()
							uni.$u.toast(res.message);
						}
					})
					.catch(res => {
						uni.hideLoading()
						uni.$u.toast(res.message);
					});
			}
		},
		cancelClick() {
			this.tipsShow = false
		}
	}
</script>

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

	.form_data {
		.row {
			border-bottom: 1px solid #EEEEEE;
			padding-bottom: 28rpx;
			margin-top: 26rpx;

			.ch-style {}
		}

	}

	.btn_css {
		margin-top: 30rpx;
	}
</style>
