<template>
	<view class="container" style="padding-bottom: 150rpx;">
		<view class="main">
			<view class="order-des">
				<view class="title">订单手机号：</view>
				<view class="textarea-wrap">
					<input type="number" v-model="phone" class="input" maxlength="11" placeholder="请输入订单手机号"
						placeholder-style="font-size: 12px;" />
				</view>
			</view>
			
			<view class="order-des">
				<view class="title">支付金额：</view>
				<view class="textarea-wrap">
					<input type="digit" v-model="money" class="input" readonly="readonly" placeholder="请输入支付金额"
						placeholder-style="font-size: 12px;" />
				</view>
			</view>
			
			<view class="order-des">
				<view class="textarea-wrap" style="display: flex;">
					<view class="uni-title uni-common-pl">订单平台：</view>
					<view>{{className}}</view>
				</view>
			</view>
			<view class="order-des">
				<view class="title">上传订单凭证(最少两张)：</view>
				<shmily-drag-image :list.sync="imageList" number="3"></shmily-drag-image>
			</view>
				<view class="order-des">
				<view class="title">上传订单凭证示例图</view>
				<shmily-drag-image :select="false" :list.sync="imageList1" number="2"></shmily-drag-image>
			</view>
		</view>
		<view class="btns">
			<button class="tui-button-primar qr" @tap="addSave">提交凭证</button>
			<button class="tui-button-primar qx" @tap="fangqi">放弃任务</button>
		</view>
	</view>
</template>

<script>
	import shmilyDragImage from '@/components/shmily-drag-image/shmily-drag-image.vue'
	export default {
		components: {
			shmilyDragImage
		},
		data() {
			return {
				phone: '',
				money: "",
				imageList: [],
				imageList1: ['https://download.cyjyyjy.com/e3975ab59055a9e453563ff9f3c6356.jpg',
					'https://download.cyjyyjy.com/f0ca8f2c95df8a516da37d83d90314d.jpg'
				],
				orderId: '', //修改是用到的ID
				value1: 0,
				options1: [{
						label: '默认排序',
						value: 1,
					},
					{
						label: '距离优先',
						value: 2,
					},
					{
						label: '价格优先',
						value: 3,
					}
				],
				message: '',
				changeSelectStyle: '',
				title: 'picker',
				array: ['美团', '饿了么'],
				className: '',
				index: 0,
			}
		},
		onLoad(e) {
			this.orderId = e.orderId;
			this.className = e.classify == 1 ? '饿了么' : '美团';
		},
		methods: {
			// 放弃任务
			fangqi() {
				uni.showModal({
					title: '温馨提示',
					content: '您是否要放弃当前任务？',
					showCancel: true,
					cancelText: '取消',
					confirmText: '确认',
					success: d => {
						var that = this;
						if (d.confirm) {
							console.log('用户点击确定');
							that.$queue.showLoading('提交中...');
							that.$Request.postT('/wm/abandonOrders?orderId=' + this.orderId).then(res => {
								if (res.code === 0) {
									that.$queue.showToast('已放弃当前任务！');
									setTimeout(d => {
										uni.navigateBack();
										uni.hideLoading();
									}, 1000);
								} else {
									that.$queue.showToast(res.msg);
									uni.hideLoading();
								}
							})
						}
					}
				});
			},
			changeStyle(index) {
				this.changeSelectStyle = index;
			},
			bindPickerChange: function(e) {
				console.log('picker发送选择改变，携带值为', e.target.value)
				this.index = e.target.value
			},
			// 发布
			addSave() {
				let that = this;
				this.$queue.showLoading('提交中...');
				var images = '';
				if (this.phone.length != 11) {
					uni.hideLoading();
					this.$queue.showToast('请输入正确手机号!');
					return;
				}
				if (this.money === '') {
					uni.hideLoading();
					this.$queue.showToast('请输入正确金额');
					return;
				}

				if (this.imageList.length > 1) {
					for (var i = 0; i < this.imageList.length; i++) {
						if (i === 0) {
							images = this.imageList[i];
						} else {
							images = images + ',' + this.imageList[i];
						}
					}
				} else {
					uni.hideLoading();
					this.$queue.showToast('请最少上传两张订单凭证!');
					return;
				}

				this.$Request.postT('/wm/submitOrders?orderId=' + this.orderId + '&phone=' + this.phone + '&money=' +
					this.money + '&img=' + images).then(res => {
					if (res.code === 0) {
						this.$queue.showToast("提交成功！");
						setTimeout(d => {
							uni.navigateBack();
							uni.hideLoading();
						}, 1000);
					} else {
						uni.hideLoading();
						this.$queue.showToast(res.msg);
					}
				});
			},
		}
	}
</script>

<style lang="scss">
	page {
		width: 100%;
		background-color: #FFFFFF;
	}

	.container {
		width: 100%;
		padding-bottom: calc(98upx + env(safe-area-inset-bottom));
		padding-bottom: calc(98upx + constant(safe-area-inset-bottom));

		.main {
			padding: 20upx 20upx 20upx;

			.order-des {
				padding: 30upx;
				// border-radius: 20upx;
				background-color: #fff;
				// margin-bottom: 20upx;

				.title {
					font-size: 14px;
					font-weight: 400;
					color: #333333;
					line-height: 32upx;
					padding-bottom: 20upx;

				}


				.textarea-wrap {
					padding-top: 20upx;
					width: 100%;
					border-bottom: 1upx solid #E6E6E6;

					.changeStyle {
						background: #F8E3DF;
						border: 1px solid #FF6A6A;
						opacity: 1;
						border-radius: 2px;
						color: #FF7171;
					}

					.a {
						background: #F5F5F5;
						border: 1px solid #999999;
						opacity: 1;
						border-radius: 2px;
						color: #999999;
					}

					.textarea {
						width: 100%;
						font-size: 28upx;
						line-height: 35upx;
						color: #333;
					}
				}

				.textarea-counter {
					text-align: right;
					font-size: 28upx;
					font-weight: 500;
					color: #999999;
					margin-top: 10upx;
				}
			}

			.order-list {
				margin-top: 20upx;
				padding: 0 30upx;
				border-radius: 20upx;
				background-color: #fff;

				.order-list-item {
					width: 100%;
					height: 110upx;
					border-bottom: 1upx solid #E6E6E6;
					display: flex;
					align-items: center;
					justify-content: space-between;

					.tit {
						font-size: 34upx;
						font-weight: 500;
						color: #333333;
					}

					.right {
						font-size: 34upx;
						font-weight: 500;
						color: #666;
						display: flex;
						align-items: center;

						.input {
							flex: 1;
							display: flex;
							align-items: center;
							text-align: right;
							padding-right: 10upx;
						}
					}
				}

				.order-list-item:last-child {
					border-bottom: 0;
				}
			}

		}

		.btns {
			button {
				// width: 80%;
				margin: 0 auto;
				color: #fff;
				border: none;
				width: 152px;
				height: 32px;
				opacity: 1;
				border-radius: 16px;
				line-height: 32px;

			}

			.qr {
				background: linear-gradient(141deg, #FF4848 0%, #FF2929 100%);
			}

			.qx {
				background: #CCCCCC;
				margin-top: 16px;
			}
		}

		.footer {
			width: 100%;
			height: calc(98upx + env(safe-area-inset-bottom));
			height: calc(98upx + constant(safe-area-inset-bottom));
			padding-bottom: env(safe-area-inset-bottom);
			/*兼容IOS>11.2*/
			padding-bottom: constant(safe-area-inset-bottom);
			/*兼容IOS<11.2*/
			background: #FFFFFF;
			position: fixed;
			bottom: 0;
			padding: 0 30upx;
			z-index: 10;
			display: flex;
			align-items: center;
			justify-content: space-between;

			.payinfo {
				font-size: 32upx;
				font-weight: bold;
				color: #333333;

				text {
					color: #FF3737;
				}
			}

			.tui-button-primar {
				width: 152px;
				height: 32px;
				opacity: 1;
				border-radius: 16px;
			}
		}



	}
</style>
