<template>
	<view class="container">
		<u-cell-group :border="false">
			<u-field label="快递单号" placeholder="请输入快递单号" v-model="logisticsNum"></u-field>
		</u-cell-group>
		<view class="form-handle">
			<u-button type="success" shape="circle" :ripple="true" @click="submitData" class="handle-custom" :disabled="!logisticsNum">绑定</u-button>
		</view>
		<u-top-tips ref="uTips"></u-top-tips>
	</view>
</template>

<script>
	const NET = require('@/utils/request')
	const API = require('@/config/api')
	export default {
		data() {
			return {
				orderId: '',
				logisticsNum: '',
			}
		},
		onLoad(options) {
			this.orderId = options.orderId
		},
		methods: {
			//  提交数据
			submitData() {
				NET.request(API.bindOrder, {
					orderId: this.orderId,
					logisticsNum: this.logisticsNum,
				}, 'GET').then(res => {
					this.$refs.uTips.show({
						title: '绑定成功',
						type: 'success',
					})
					setTimeout(() => {
						uni.redirectTo({
							url: '/pagesMain/orderList?type=3'
						});
					}, 1000)
				}).catch(error => {
					this.$refs.uTips.show({
						title: error.data.msg,
						type: 'warning',
					})
				})
			},
		},
	}
</script>

<style lang="less" scoped>
	page {
		width: 100%;
		height: 100%;
	}

	.container {
		width: 100%;
		height: 100%;
		float: left;
		position: absolute;
		box-sizing: border-box;
		padding-bottom: 70px;
		overflow-y: auto;

		.form-handle {
			width: calc(100% - 30px);
			height: 40px;
			position: fixed;
			bottom: 20px;
			left: 15px;

			.handle-custom {
				background-color: #51A539;
			}
		}
	}
</style>
