<!-- 确认装车 -->
<template>
	<view class="content">
		<view class="level1-title">
			任务信息
		</view>
		<view class="content1">
			<view class='row-between'>
				<view class="">订单编号</view>
				<view>CY20220210666666</view>
			</view>
			<view class='row-between'>
				<view class="">货主</view>
				<view>张三</view>
			</view>
			<view class='row-between'>
				<view class="">货主单位</view>
				<view>黑龙江中天昊元贸易有限公司</view>
			</view>
			<view class='row-between'>
				<view class="">发货地</view>
				<view>鲅鱼圈</view>
			</view>
			<view class='row-between'>
				<view class="">卸货地</view>
				<view>黑龙江省齐齐哈尔市梅里斯达斡尔族区杜尔门沁达斡尔乡53农场</view>
			</view>
			<view class='row-between'>
				<view class="">货名</view>
				<view>玉米</view>
			</view>
			<view class='row-between'>
				<view class="">运费</view>
				<view>100元/吨</view>
			</view>
		</view>
		<view class="level1-title">
			卸车信息
		</view>
		<view class="content2">
			<view class='row-between'>
				<view class="">车牌号</view>
				<view>辽H12345</view>
			</view>
			<view class='row-between'>
				<view class="">卸车时间</view>
				<view>2022-02-10 16:13:15</view>
			</view>
			<view class='row-between'>
				<view class="">卸车净重</view>
			</view>
			<view class='s-flex'>
				<view class="">上传卸车照片</view>
				<upload class="upload" ref="upload" :action="action" :max-size="maxSize" :max-count="3"
					:size-type="['compressed']" @on-success="getImgUrl" @on-error="onError" @on-remove="onRemove"
					@on-uploaded="isAdd = true" :before-upload="filterFileType" @on-progress="onProgress"></upload>
			</view>
			<view class='s-flex'>
				<view class="">上传卸车磅单</view>
				<upload class="upload" ref="upload" :action="action" :max-size="maxSize" :max-count="1"
					:size-type="['compressed']" @on-success="getImgUrl" @on-error="onError" @on-remove="onRemove"
					@on-uploaded="isAdd = true" :before-upload="filterFileType" @on-progress="onProgress"></upload>
			</view>
		</view>
		<view class="content3 flex">
			<u-button text="暂存" type="primary" @click="submit(0)"></u-button>
			<u-button text="提交" type="primary" @click="submit(1)"></u-button>
		</view>
		<u-toast ref="uToast"></u-toast>
		<u-modal :show="isShowAlert" :title="alertTitle" :content='alertContent' :closeOnClickOverlay='true' :showCancelButton='true' confirmColor='#22C572'  @confirm="confirmClick" @close="cancelClick" @cancel="cancelClick"></u-modal>
	</view>
</template>

<script>
	import upload from '@/components/upload.vue';
	export default {
		components: {
			upload
		},
		data() {
			return {
				detailData: {
					addressUrl: ''
				},
				action: this.$helper.ossUploadUrl,
				maxSize: 50 * 1024 * 1024, //限制文件大小 50M
				isAdd: true,
				isShowAlert: false,
				alertContent: '',
				alertTitle: '',
			}
		},
		onLoad(options) {
			console.log(options)
		},
		methods: {
			alertBtn() {
				// uni.navigateTo({
				// 	url: '/pages/public/login'
				// })
			},
			cancelClick() {
				this.isShowAlert = false
			},
			getImgUrl(res) {
				this.detailData.addressUrl = res
				console.log(res)
				console.log('------------res-----------')
			},
			onError(error) {
				alert(error)
				console.log('------------error-----------')
				console.log(error)
			},
			onRemove(index) {},
			filterFileType(index, lists) {
				if (lists[index].fileType != 'jpg' && lists[index].fileType != 'png' && lists[index].fileType != 'gif') {
					lists.splice(index, 1);
					// 当前文件不支持
					uni.showModal({
						title: '暂不支持当前图片类型',
						showCancel: false
					});
				} else {
					this.isAdd = false;
				}
			},
			onProgress(e) {
				console.log(e)
			},
			submit(type) {
				console.log(type)
				let params = {
						type: 'success',
						title: '成功主题(带图标)',
						message: "庄生晓梦迷蝴蝶",
						iconUrl: 'https://cdn.uviewui.com/uview/demo/toast/success.png'
					}
					if(type==0){
						
					}else{
						this.alertContent='确定提交装车信息？'
						this.alertTitle='提示'
						this.isShowAlert = true
					}
				// this.$refs.uToast.show({
				// 	...params,
				// 	complete() {
				// 		params.url && uni.navigateTo({
				// 			url: params.url
				// 		})
				// 	}
				// })
			},
			confirmClick(){
				console.log('提交')
			}
		},
	}
</script>

<style>

</style>
