<template>
  <view class="content">
  	<view class="inner">
  		<view class="form-box">
  			<view class="form-item">
  				<text class="label">快递公司</text>
  				<input type="text" v-model="form.deliveryName" placeholder="请输入物流公司" placeholder-class="form-input" />
  			</view>
  			<view class="form-item">
  			 	<text class="label">快递单号</text>
  			 	<input type="text" v-model="form.deliverySn"   placeholder="请输入物流单号" placeholder-class="form-input" />
  			</view>
  		</view>
  	</view>
  	<view class="btn-box">
  		<view class="sub-btn" @click="submit()">提交</view>
  	</view>
  </view>
</template>

<script>
import {addDelivery} from '@/api/storeAfterSales.js'
	
export default {
  data() {
    return {
		form:{
			salesId:null,
			deliverySn:null,
			deliveryName:null,
		}
    }
  },
  onLoad(option) {
	  this.form.salesId=option.salesId
  },
  methods: {
	submit(){
		if(this.form.deliveryName==null){
			uni.showToast({
				icon:'none',
				title: '请输入快递公司'
			});
			return;
		}
		if(this.form.deliverySn==null){
			uni.showToast({
				icon:'none',
				title: '请输入快递单号'
			});
			return;
		}
	 	addDelivery(this.form).then(
	 		res => {
	 			if(res.code==200){
	 				 uni.showToast({
	 				 	icon:'success',
	 				 	title: "提交成功",
	 				 });
					 uni.navigateBack({
					 	delta: 1
					 })
	 			}else{
	 				uni.showToast({
	 					icon:'none',
	 					title: res.msg,
	 				});
	 			}
	 		},
	 		rej => {}
	 	);
	 },
  },
  
}
</script>

<style lang="scss">
	page{
		height: 100%;
	}
	.content{
		display: flex;
		flex-direction: column;
		justify-content: space-between;
		
		.inner{
			padding: 20upx;
			.form-box{
				padding: 0 30upx;
				background: #FFFFFF;
				border-radius: 16upx;
				.form-item{
					padding: 30upx 0;
					display: flex;
					align-items: flex-start;
					border-bottom: 1px solid #F1F1F1;
					&:last-child{
						border-bottom: none;
					}
					.label{
						width: 150upx;
						text-align: left;
						font-size: 30upx;
						line-height: 44upx;
						font-family: PingFang SC;
						font-weight: 500;
						color: #222222;
						flex-shrink: 0;
					}
					input{
						text-align: left;
					}
					.form-input{
						font-size: 30upx;
						font-family: PingFang SC;
						font-weight: 500;
						color: #999999;
						text-align: left;
					}
					 
				}
			}
			 
		}
		.btn-box{
			height: 120upx;
			padding: 0 30upx;
			display: flex;
			align-items: center;
			justify-content: center;
			.sub-btn{
				width: 100%;
				height: 88upx;
				line-height: 88upx;
				text-align: center;
				font-size: 30upx;
				font-family: PingFang SC;
				font-weight: bold;
				color: #FFFFFF;
				background: #4C49E9;
				border-radius: 44upx;
			}
		}
	}
</style>