"use strict";
const common_vendor = require("../../../common/vendor.js");
const common_assets = require("../../../common/assets.js");
const sheep_index = require("../../../sheep/index.js");
const sheep_api_trade_afterSale = require("../../../sheep/api/trade/afterSale.js");
const sheep_api_trade_delivery = require("../../../sheep/api/trade/delivery.js");
require("../../../sheep/api/index.js");
require("../../../sheep/api/distri/score.js");
require("../../../sheep/request/index.js");
require("../../../sheep/config/index.js");
require("../../../sheep/store/index.js");
require("../../../sheep/store/app.js");
require("../../../sheep/api/promotion/diy.js");
require("../../../sheep/platform/index.js");
require("../../../sheep/platform/provider/wechat/index.js");
require("../../../sheep/platform/provider/wechat/miniProgram.js");
require("../../../sheep/api/member/auth.js");
require("../../../sheep/api/member/social.js");
require("../../../sheep/api/member/user.js");
require("../../../sheep/platform/provider/apple/index.js");
require("../../../sheep/platform/share.js");
require("../../../sheep/router/index.js");
require("../../../sheep/hooks/useModal.js");
require("../../../sheep/helper/index.js");
require("../../../sheep/helper/test.js");
require("../../../sheep/helper/digit.js");
require("../../../sheep/api/member/signin.js");
require("../../../sheep/helper/throttle.js");
require("../../../sheep/url/index.js");
require("../../../sheep/platform/pay.js");
require("../../../sheep/api/pay/order.js");
require("../../../sheep/store/user.js");
require("../../../sheep/store/cart.js");
require("../../../sheep/api/trade/cart.js");
require("../../../sheep/api/pay/wallet.js");
require("../../../sheep/api/trade/order.js");
require("../../../sheep/api/promotion/coupon.js");
require("../../../sheep/store/sys.js");
require("../../../sheep/store/modal.js");
require("../../../sheep/api/distri/share.js");
require("../../../sheep/api/distri/team.js");
require("../../../sheep/api/infra/file.js");
require("../../../sheep/api/member/address.js");
require("../../../sheep/api/member/point.js");
require("../../../sheep/api/migration/app.js");
require("../../../sheep/api/migration/chat.js");
require("../../../sheep/api/migration/index.js");
require("../../../sheep/api/migration/third.js");
require("../../../sheep/api/pay/channel.js");
require("../../../sheep/api/product/category.js");
require("../../../sheep/api/product/comment.js");
require("../../../sheep/api/product/favorite.js");
require("../../../sheep/api/product/history.js");
require("../../../sheep/api/product/spu.js");
require("../../../sheep/api/promotion/activity.js");
require("../../../sheep/api/promotion/article.js");
require("../../../sheep/api/promotion/bargain.js");
require("../../../sheep/api/promotion/combination.js");
require("../../../sheep/api/promotion/rewardActivity.js");
require("../../../sheep/api/promotion/seckill.js");
require("../../../sheep/api/system/area.js");
require("../../../sheep/api/system/voice.js");
require("../../../sheep/api/trade/brokerage.js");
require("../../../sheep/api/trade/config.js");
require("../../../sheep/config/zIndex.js");
if (!Array) {
  const _easycom_s_layout2 = common_vendor.resolveComponent("s-layout");
  _easycom_s_layout2();
}
const _easycom_s_layout = () => "../../../sheep/components/s-layout/s-layout.js";
if (!Math) {
  _easycom_s_layout();
}
const _sfc_main = {
  __name: "return-delivery",
  setup(__props) {
    const state = common_vendor.reactive({
      id: 0,
      // 售后编号
      expressIndex: 0,
      // 选中的 expresses 下标
      expresses: []
      // 可选的快递列表
    });
    function bindPickerChange(e) {
      state.expressIndex = e.detail.value;
    }
    async function subRefund(e) {
      if (!state.expresses[state.expressIndex].id) {
        sheep_index.sheep.$helper.toast(`请选择物流公司`);
        return false;
      }
      if (!e.detail.value.logisticsNo) {
        sheep_index.sheep.$helper.toast(`请填写物流单号`);
        return false;
      }
      let data = {
        id: state.id,
        logisticsId: state.expresses[state.expressIndex].id,
        logisticsNo: e.detail.value.logisticsNo
      };
      const {
        code
      } = await sheep_api_trade_afterSale.AfterSaleApi.deliveryAfterSale(data);
      if (code !== 0) {
        return;
      }
      common_vendor.index.showToast({
        title: "填写退货成功"
      });
      sheep_index.sheep.$router.go("/pages/order/aftersale/detail", {
        id: state.id
      });
    }
    async function getExpressList() {
      const {
        code,
        data
      } = await sheep_api_trade_delivery.DeliveryApi.getDeliveryExpressList();
      if (code !== 0) {
        return;
      }
      state.expresses = data;
      state.expresses.unshift({
        "id": 0,
        "name": "请选择"
      });
    }
    common_vendor.onLoad((options) => {
      if (!options.id) {
        sheep_index.sheep.$helper.toast(`缺少订单信息，请检查`);
        return;
      }
      state.id = options.id;
      getExpressList();
    });
    return (_ctx, _cache) => {
      return {
        a: common_vendor.t(state.expresses[state.expressIndex].name),
        b: common_assets._imports_0$1,
        c: common_vendor.o(bindPickerChange),
        d: state.expressIndex,
        e: state.expresses,
        f: common_vendor.o(subRefund),
        g: common_vendor.p({
          title: "退货物流"
        })
      };
    };
  }
};
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-e2252b3c"], ["__file", "D:/zx/mall-front-app/pages/order/aftersale/return-delivery.vue"]]);
wx.createPage(MiniProgramPage);
