<template>
	<view class="page" :style="{'min-height':(h)+'px','padding-top':mt+'px'}">
		<c-nav-bar title="船只管理"></c-nav-bar>
		<view class="list">
			<view class="item" v-for="(i,index) in data" :key="index" >
				<div>
					<div style="font-size: 32rpx;font-weight: bold;">{{i.boatName}}</div>
					<div style="font-size: 24rpx;font-weight: normal;margin-top: 12rpx;">
						{{i.boatNo}} {{i.capacity}}座
					</div>
				</div>
				<div style="position: absolute;right: 20rpx;top: 20rpx;font-size: 24rpx;">
					<div style="color: #007BFF;" v-if="i.sailFlag==0">在港</div>
					<div style="color: #28A745;" v-if="i.sailFlag==1">已出航</div>
					
				</div>
				<div v-if="i.sailFlag==1" @click="back(i.boatNo)" style="font-size: 32rpx;position: absolute;right: 20rpx;bottom: 20rpx;background-color: #007A69;color: #fff;padding: 6rpx 24rpx;border-radius: 12rpx;">回港</div>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				date: new Date().Format('yyyy-MM-dd'),
				show: false,
				data: [],
			}
		},
		onLoad() {
			this.getList();
		},
		methods: {
			back(no){
				this.$api.get(`/scenic/api/boat/boatSailBack/${uni.getStorageSync('merchantId')}/${no}`).then(res=>{
					if(res.data.code==0){
						if(res.data.msg == 'success'){
							this.$showToast('操作成功')
							this.getList()
						}
					}else{
						this.$showToast(res.data.msg)
					}
				})
			},
			jj(){
				uni.navigateTo({
					url:'/pagesHouse/Verification/success'
				})
			},
			dd(){
				uni.navigateTo({
					url:'/pagesHouse/Verification/record'
				})
			},
			getList(){
				this.$api.get('/scenic/api/boat/page?page=1&limit=999&merchantId='+ uni.getStorageSync('merchantId')).then(res=>{
					if(res.data.code==0){
						console.log(res)
						this.data=res.data.data.list;
					}
				})
			},
			check(item) {
				// #ifdef APP-PLUS
					uni.navigateTo({
						url: '/pagesHouse/Verification/checkApp?=&boatNo='+item.BOAT_NO
					})
				// #endif
				// #ifdef MP-WEIXIN
					uni.navigateTo({
						url: '/pagesHouse/Verification/check?=&boatNo='+item.BOAT_NO
					})
				// #endif
			}
		}
	}
</script>

<style lang="less" scoped>
	.page {
		background: #F5F8FA;
		padding-bottom: 40rpx;
		box-sizing: border-box;
	}

	.list {
		box-sizing: border-box;
		padding: 30rpx 30rpx 0;

		.item {
			height: 160rpx;
			display: flex;
			justify-content: space-between;
			padding: 0 24rpx;
			background-color: #fff;
			align-items: center;
			box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.08);
			margin-bottom: 20rpx;
			border-radius: 16rpx;
			position: relative;
			text {
				&:first-child {
					font-size: 54rpx;
					font-weight: bold;
					color: #111;
				}

				&:last-child {
					display: inline-block;
					width: 168rpx;
					height: 88rpx;
					line-height: 88rpx;
					text-align: center;
					background-color: #007A69;
					color: #fff;
					font-size: 32rpx;
					border-radius: 44rpx;
				}
			}
		}
	}
</style>