<template>
<view>
<!--mine/express/express.wxml-->
<!-- <view class="list">
		<view class="li">
			<text>快递公司</text>
		</view>
		<view class="li">
			<text>快递单号：</text>
			<input value="" placeholder="填写订单号"></input>
		</view>
	</view> -->
<!-- <view class="list">
		<view class="li">
    <text>联系方式：</text>
    <input value="" placeholder="填写手机号"></input>
    </view>
	</view> -->

<view class="list">
	<view class="li" @tap="getRefund" data-isrefund="4">
		<text>快递公司</text>
		<view class="dflex express">
			<text>{{express?express:'请选择'}}</text>
			<image src="/static/pages/images/more.png" class="right"></image>
		</view>
	</view>
	<view class="li">
		<text>快递单号：</text>
		<input placeholder="输入您的快递单号" @input="getexpressId"></input>
	</view>
</view>
<!-- <view class="list">
		<view class="li">
    <text>联系方式：</text>
    <input placeholder="12342235321"></input>
    </view>
	</view> -->
<view class="btn bgline" @tap="sub">确定</view>
<block v-if="isShow">
	<refund-popup :refund-type="type" @hidePopup="hidePopup" @getValue="getValue" @getIndex="getIndex"></refund-popup>
</block>
</view>
</template>

<script>
// mine/express/express.js
const req = require("../../../utils/request.js");
import refundPopup from "../../../components/refund-popup/index";

export default {
  data() {
    return {
      isShow: true,
      id: "",
      isrefund: "",
      type: "",
      expressIndex: "",
      express: "",
      expressId: ""
    };
  },

  components: {
    refundPopup
  },
  props: {},

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    // console.log(options);
    this.setData({
      isShow: false,
      id: options.id,
      isrefund: options.isrefund
    });
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {},
  methods: {
    getRefund(event) {
      // console.log(event.currentTarget.dataset.isrefund)
      this.setData({
        isShow: true,
        type: event.currentTarget.dataset.isrefund
      });
    },

    hidePopup() {
      this.setData({
        isShow: false
      });
    },

    getIndex: function (e) {
      if (this.type == 4) {
        this.setData({
          expressIndex: e.detail
        });
      }
    },
    getValue: function (e) {
      if (this.type == 4) {
        this.setData({
          express: e.detail
        });
      }
    },

    getexpressId(event) {
      let expressId = "";
      expressId = event.detail.value;
      this.setData({
        expressId: expressId
      });
      // console.log(this.expressId);
    },

    sub() {
      let parameter = {
        express: this.express,
        expressCode: this.expressIndex,
        expressNo: this.expressId,
        // dto[0].orderId:this.data.orderId
        id: this.id
      };
      // console.log(parameter);
      if (parameter.express == undefined) return req.msg("请您选择快递公司");
      if (parameter.expressNo == undefined || parameter.expressNo == '') return req.msg("请您填写快递单号");
      req.putRequest('/api/orderRefund/update', parameter, data => {
        uni.navigateBack({
          url: '/mine/refund/refundDetails/refundDetails?id=' + this.id + '&isrefund=' + this.isrefund
        });
      });
    }

  }
};
</script>
<style>
@import "./express.css";
</style>