myOrder.js 8.6 KB
"use strict";
var common_vendor = require("../../common/vendor.js");
var api_index = require("../../api/index.js");
require("../../utils/request.js");
if (!Array) {
  const _easycom_u_navbar2 = common_vendor.resolveComponent("u-navbar");
  const _easycom_u_tabs2 = common_vendor.resolveComponent("u-tabs");
  const _easycom_u_count_down2 = common_vendor.resolveComponent("u-count-down");
  (_easycom_u_navbar2 + _easycom_u_tabs2 + _easycom_u_count_down2)();
}
const _easycom_u_navbar = () => "../../uni_modules/uview-plus/components/u-navbar/u-navbar.js";
const _easycom_u_tabs = () => "../../uni_modules/uview-plus/components/u-tabs/u-tabs.js";
const _easycom_u_count_down = () => "../../uni_modules/uview-plus/components/u-count-down/u-count-down.js";
if (!Math) {
  (_easycom_u_navbar + _easycom_u_tabs + _easycom_u_count_down + orderShop + PayMode + tipPops)();
}
const orderShop = () => "../../componets/orderShop.js";
const PayMode = () => "../../componets/checkPayMode.js";
const tipPops = () => "../../componets/tipPop.js";
const _sfc_main = {
  setup(__props) {
    common_vendor.onLoad((e) => {
      tabStatus.value = e.status * 1;
      getOrderLists(tabStatus.value == 5 ? 21 : tabStatus.value == 4 ? 5 : tabStatus.value * 1);
    });
    common_vendor.onShow(() => {
      console.log("\u8BA2\u5355\u72B6\u6001", tabStatus.value);
    });
    let tabStatus = common_vendor.ref(0);
    let orderList = common_vendor.ref([]);
    const list1 = common_vendor.reactive([{ name: "\u5168\u90E8" }, { name: "\u5F85\u4ED8\u6B3E" }, { name: "\u5F85\u53D1\u8D27" }, { name: "\u5F85\u6536\u8D27" }, { name: "\u5F85\u8BC4\u4EF7" }, { name: "\u552E\u540E" }]);
    const operateOrder = (item, type) => {
      orderId.value = item.id;
      if (type == 0 || type == 2) {
        tipType.value = type == 0 ? 1 : 2;
        tipShow.value = true;
      } else if (type == 1) {
        modeShow.value = true;
      } else if (type == 3) {
        getReceipts();
      } else if (type == 4) {
        common_vendor.index.navigateTo({
          url: `/pages/mine/evaluate?id=${item.id}`
        });
      } else if (type == 5) {
        toDetaile(item.id);
      }
    };
    const pointsBtns = (type) => {
      console.log(type);
      tipShow.value = false;
      if (type == 1) {
        tipType.value == 1 ? getCancleOrders() : getRefunds();
      }
    };
    let orderId = common_vendor.ref("");
    let integral = common_vendor.ref(0);
    let tipType = common_vendor.ref(1);
    let modeShow = common_vendor.ref(false);
    let tipShow = common_vendor.ref(false);
    const toDetaile = (id) => {
      console.log("\u8BA2\u5355");
      common_vendor.index.navigateTo({
        url: `/pages/mine/orderDetail?id=${id}`
      });
    };
    const copy = (text) => {
      common_vendor.index.setClipboardData({
        data: text,
        success: () => {
          common_vendor.index.showToast({ title: "\u590D\u5236\u6210\u529F", icon: "none" });
        }
      });
    };
    const click = (e) => {
      console.log(e);
      getOrderLists(e.index == 5 ? 21 : e.index == 4 ? 5 : e.index);
    };
    const getOrderLists = async (status) => {
      try {
        const res = await api_index.getOrderList(status);
        orderList.value = res;
        console.log("getOrderList", res);
      } catch (err) {
        common_vendor.index.showToast({
          title: err,
          icon: "none"
        });
        console.log("getOrderList", err);
      }
    };
    const getCancleOrders = async () => {
      try {
        const res = await api_index.getCancleOrder(orderId.value);
        common_vendor.index.showToast({ title: "\u8BA2\u5355\u5DF2\u53D6\u6D88~", icon: "none" });
        tipShow.value = false;
        tabStatus.value = 0;
        getOrderLists(0);
        console.log("getCancleOrder", res);
      } catch (err) {
        common_vendor.index.showToast({ title: err, icon: "none" });
        console.log("getCancleOrder", err);
      }
    };
    const getRefunds = async () => {
      try {
        const res = await api_index.getRefund(orderId.value);
        common_vendor.index.showToast({ title: "\u5DF2\u7533\u8BF7,\u7B49\u5F85\u5BA2\u670D\u5BA1\u6838", icon: "none" });
        getOrderLists(2);
        console.log("getRefund", res);
      } catch (err) {
        common_vendor.index.showToast({ title: err, icon: "none" });
        console.log("getRefund", err);
      }
    };
    const getReceipts = async () => {
      try {
        const res = await api_index.getReceipt(orderId.value);
        common_vendor.index.showToast({ title: "\u5DF2\u6536\u8D27,\u671F\u5F85\u4E0B\u6B21\u4E0B\u5355~", icon: "none" });
        getOrderLists(3);
        console.log("getReceipt", res);
      } catch (err) {
        common_vendor.index.showToast({ title: err, icon: "none" });
        console.log("getReceipt", err);
      }
    };
    return (_ctx, _cache) => {
      return common_vendor.e({
        a: common_vendor.p({
          placeholder: true,
          title: "\u8BA2\u5355",
          bgColor: "#F8FAFB",
          autoBack: true
        }),
        b: common_vendor.o(click),
        c: common_vendor.p({
          activeStyle: {
            color: "#000000",
            fontWeight: "bold",
            transform: "scale(1.05)"
          },
          inactiveStyle: {
            color: "#00000099",
            transform: "scale(1)"
          },
          itemStyle: "padding-left: 5px;padding-bottom:12rpx; padding-right: 5px; height: 34px;",
          list: common_vendor.unref(list1),
          current: common_vendor.unref(tabStatus),
          lineWidth: "15",
          lineColor: "#FB753C",
          scrollable: false
        }),
        d: common_vendor.f(common_vendor.unref(orderList), (item, index, i0) => {
          return common_vendor.e({
            a: item.order_status == 1
          }, item.order_status == 1 ? {
            b: "67be9ace-2-" + i0,
            c: common_vendor.p({
              time: item.time * 1e3,
              format: "mm:ss"
            })
          } : {}, {
            d: [3, 4, 21].includes(item.order_status)
          }, [3, 4, 21].includes(item.order_status) ? {
            e: common_vendor.t(item.express_no),
            f: common_vendor.o(($event) => copy(item.express_no))
          } : {}, {
            g: "67be9ace-3-" + i0,
            h: common_vendor.p({
              shop: item
            }),
            i: item.order_status == 1
          }, item.order_status == 1 ? common_vendor.e({
            j: common_vendor.t(item.goodstatus_text == "" ? "\u53D6\u6D88\u4ED8\u6B3E" : "\u53D6\u6D88\u5151\u6362"),
            k: common_vendor.o(($event) => operateOrder(item, 0)),
            l: item.order_status == 1
          }, item.order_status == 1 ? {
            m: common_vendor.t(item.goodstatus_text == "" ? "\u7ACB\u5373\u652F\u4ED8" : "\u7ACB\u5373\u5151\u6362"),
            n: common_vendor.o(($event) => operateOrder(item, 1))
          } : {}) : {}, {
            o: item.order_status == 2
          }, item.order_status == 2 ? {
            p: common_vendor.o(($event) => operateOrder(item, 2))
          } : {}, {
            q: item.order_status == 3
          }, item.order_status == 3 ? common_vendor.e({
            r: item.order_status == 3
          }, item.order_status == 3 ? {
            s: common_vendor.o(($event) => true)
          } : {}, {
            t: common_vendor.o(($event) => operateOrder(item, 3))
          }) : {}, {
            v: item.order_status == 5
          }, item.order_status == 5 ? {
            w: common_vendor.o(($event) => operateOrder(item, 4))
          } : {}, {
            x: item.order_status == 21
          }, item.order_status == 21 ? {
            y: common_vendor.o(($event) => operateOrder(item, 5))
          } : {}, {
            z: item.id,
            A: common_vendor.o(($event) => toDetaile(item.id), item.id)
          });
        }),
        e: !common_vendor.unref(orderList).length
      }, !common_vendor.unref(orderList).length ? {} : {}, {
        f: common_vendor.o(($event) => common_vendor.isRef(modeShow) ? modeShow.value = false : modeShow = false),
        g: common_vendor.p({
          orderId: common_vendor.unref(orderId),
          isOrderPay: true,
          totalPrice: common_vendor.unref(orderList).total_price,
          modeShow: common_vendor.unref(modeShow)
        }),
        h: common_vendor.o(pointsBtns),
        i: common_vendor.p({
          integral: common_vendor.unref(integral),
          tipType: common_vendor.unref(tipType),
          tipShow: common_vendor.unref(tipShow)
        })
      });
    };
  }
};
var MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__file", "D:/vue/\u5927\u5065\u5EB7\u5546\u57CE/healthMall/pages/mine/myOrder.vue"]]);
wx.createPage(MiniProgramPage);