<template>
	<!-- 商家发货 -->
	<view class="delivery fahuo yocode">
		<view class="fahuobox">
			<!-- <picker @change="bindPickerChange" :value="index" :range="logsitslist"> -->
				<view class="selectcell flex ali-c jus-b" @tap='pickerone'>
					<view class="flex ali-c">
						<image class="icons1" src="/static/news/fahuo.png" mode=""></image>
						<view class="names">{{chindtext==''?'选择快递公司':chindtext}}</view>
					</view>
					<image class="icons2" src="/static/news/xiala.png" mode=""></image>
				</view>
				<lb-picker ref="picker" :list="logsitslist" :value='chindtext' range-key="label" :props="myProps" @confirm='confirm'></lb-picker>
			<!-- </picker> -->
			
			<view class="selectcell flex ali-c jus-b">
				<view class="flex ali-c">					
					<image class="icons3" src="/static/news/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/news/saoma.png" mode=""></image>
				</view>
			</view>
			
			<view class="btnsbox flex ali-c jus-a">
				<view class="btns">取消</view>
				<view class="btns btns1" @tap="oneKeyShipmentsfun">确定发货</view>
			</view>
		</view>
	</view>
</template>

<script>
	import { logisticsList,setDeliverGoods  } from '@/utils/api/api.js';
	export default{
		data(){
			return{
				myProps: {
				      label: 'value',
				      value: 'cate_id',
				},
				logsitslist:[
					"圆通速递",
					"百世快递",
					"中通快递",
					"申通快递",
					"顺丰速运",
					"韵达速递",
					"邮政快递包裹",
					"EMS",
					"天天快递",
					"京东快递",
					"优速快递",
					"德邦快递",
					"宅急送",
					"TNT快递",
					"UPS",
					"DHL",
					"FEDEX联邦(国内件）",
					"FEDEX联邦(国际件）"
				],
				index:0,
				chindtext:"",
				logscode:"",
				refund_id: '',//订单id
			}
		},
		onLoad(options) {
			this.refund_id = options.refund_id;
			this.logisticsListfun();
		},
		methods:{
			confirm(e){
				this.chindtext=e.value;
			},
			pickerone(){
				this.$refs.picker.show() // 显示
			},
			async logisticsListfun(){
				let res = await logisticsList({
					
				});
				
				if(res.code==0){
					this.logsitslist  =res.data;
				}else{
					this.$api.msg(res.msg);
				}
			},
			//快速发货 确认发货
			async oneKeyShipmentsfun(){
				if(this.chindtext==""){
					this.$api.msg("请选中快速公司");
					return false;
				}
				if(this.logscode==""){
					this.$api.msg("物流单号不能为空");
					return false;
				}
				let res = await setDeliverGoods({
					logisticCode:this.logscode,//物流号 快递单号 订单号
					shipperCode:this.chindtext,//名称 快递公司编号 名称
					refund_id:this.refund_id,//订单id 订单id
					shop_id:'',
				});
				if(res.code==0){
					uni.showModal({
					  title: '提示',
					  content: res.msg,
					  showCancel: false,
					  success(res) {
						uni.$emit("isDelorder",{action: 'setDeliverGoods'});
						uni.navigateBack({}); //返回上一页
					  }
					})
				}else{
					this.$api.msg(res.msg);
				}
			},
			//请求end
			bindPickerChange(e){
				this.chindtext = this.logsitslist[e.detail.value];
			},
			//扫码方法
			tosaoyisao(){
				uni.scanCode({
				    success:  (res)=> {
						// let qrcodecon = 
						this.logscode = res.result;
				    }
				});
			}
		}
	}
</script>

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