<template>
	<!-- 快速发货 -->
	<!-- 发货 -->
	<view class="delivery fahuo yocode">
		<view class="fahuobox">
			<picker @change="bindPickerChange" :value="index" :range="logsitslist">
				<view class="selectcell flex ali-c jus-b">
					<view class="flex ali-c">

						<image class="icons1" src="../../static/store/fahuo.png" mode=""></image>
						<view class="names">{{chindtext==''?'选择快递公司':chindtext}}</view>
					</view>
					<image class="icons2" src="../../static/store/xiala.png" mode=""></image>

				</view>
			</picker>
			<view class="selectcell flex ali-c jus-b">
				<view class="flex ali-c">					

					<image class="icons3" src="../../static/store/dindhao.png" mode=""></image>
					<input  class="names" type="text" value="" v-model="logscode"  placeholder="输入快递单号" />
				</view>
				<view @tap="tosaoyisao"  class="tosaomaboxs">
					<image class="icons4" src="../../static/store/saoma.png" mode=""></image>

				</view>
			</view>
			
			<view class="btnsbox flex ali-c jus-a">
				<view class="btns">取消</view>
				<view class="btns btns1" @tap="showsend">确定发货</view>
			</view>
		</view>
	</view>
</template>

<script>
	import { logisticsList, oneKeyShipments  } from '@/utils/api/hotel.js';
	import { showsend  } from '@/utils/api/merchant.js';
	export default{
		data(){
			return{
				logsitslist:[],
				index:0,
				chindtext:"",
				logscode:"",
				shop_id:'',//厂家id
			}
		},
		onLoad(opdata) {
			console.log(opdata)
			this.order_id = opdata.order_id;
			this.shop_id = opdata.shop_id;
			this.logisticsList();
		},
		methods:{
			async logisticsList(){
				let res = await logisticsList({
					
				});
				
				if(res.code==0){
					this.logsitslist  =res.data;
				}else{
					this.$api.msg(res.msg);
				}
			},
			//快速发货 确认发货
			async showsend(){
				
				// if(this.order_id.replace(/\s*/g,"")==""){
				// 	this.$api.msg("没有获取到您的订单信息");
				// 	return false;
				// }
				if(this.chindtext==""){
					this.$api.msg("请选中快速公司");
					return false;
				}
				if(this.logscode==""){
					this.$api.msg("物流单号不能为空");
					return false;
				}
				let res = await showsend({
					logisticCode:this.logscode,//物流好
					shipperName:this.chindtext,//名称
					order_id:this.order_id,
					shop_id:this.shop_id,
				});
				
				if(res.code==0){
					uni.showModal({
					  title: '提示',
					  content: res.msg,
					  showCancel: false,
					  success(res) {
						uni.navigateBack({
						});
					  }
					})
				}else{
					this.$api.msg(res.msg);
				}
			},
			//请求end
			bindPickerChange(e){
				console.log(e.detail.value);
				this.chindtext = this.logsitslist[e.detail.value];
			},
			//扫码方法
			tosaoyisao(){
				uni.scanCode({
				    success:  (res)=> {
				        console.log('条码类型：' + res.scanType);
				        console.log('条码内容：' + res.result);
						
						// let qrcodecon = 
						
						this.logscode = res.result;
				    }
				});
			}
		}
	}
</script>

<style lang="scss">
	@import  "./delivery.scss"
</style>
 