"use strict";
const common_vendor = require("../../../common/vendor.js");
const api_request = require("../../../api/request.js");
const utils_emitter = require("../../../utils/emitter.js");
if (!Array) {
  const _easycom_uni_popup2 = common_vendor.resolveComponent("uni-popup");
  _easycom_uni_popup2();
}
const _easycom_uni_popup = () => "../../../uni_modules/uni-popup/components/uni-popup/uni-popup.js";
if (!Math) {
  (timeSelectVue + _easycom_uni_popup)();
}
const timeSelectVue = () => "../component/timeSelect.js";
const _sfc_main = {
  __name: "productmain",
  setup(__props) {
    const pid = common_vendor.ref(0);
    const cookie = common_vendor.wx$1.getStorageSync("cookie");
    const productObject = common_vendor.ref({});
    const popup = common_vendor.ref(null);
    common_vendor.onMounted(() => {
      utils_emitter.emitter.on("closeTimeDialog", () => {
        close();
      });
    });
    common_vendor.onLoad((options) => {
      pid.value = JSON.parse(options.info);
      getProduct();
      getBookingNumberMap();
    });
    const getProduct = async () => {
      const res = await common_vendor.index.request({
        url: api_request.baseUrl + "/goods/service/list/id",
        method: "POST",
        data: {
          id: pid.value
        },
        header: {
          cookie
        }
      });
      if (res.data.code === 1) {
        productObject.value = res.data.data;
      } else {
        common_vendor.index.showToast({
          icon: "error",
          title: "请求错误"
        });
        return;
      }
    };
    let countMap = /* @__PURE__ */ new Map();
    const getBookingNumberMap = async () => {
      const res = await common_vendor.index.request({
        url: api_request.baseUrl + "/pending/list/advance/count",
        method: "POST",
        data: {
          id: pid.value
        },
        header: {
          cookie
        }
      });
      countMap = res.data.data;
      console.log(countMap);
    };
    const close = () => {
      popup.value.close();
    };
    const loadPop = () => {
      utils_emitter.emitter.emit("getGoodData", productObject.value);
      utils_emitter.emitter.emit("getBookingNumberMap", countMap);
      popup.value.open("bottom");
    };
    return (_ctx, _cache) => {
      return {
        a: productObject.value.goodImg,
        b: common_vendor.t(productObject.value.price),
        c: common_vendor.t(productObject.value.name),
        d: common_vendor.t(productObject.value.introDetail),
        e: common_vendor.t(_ctx.specificDate),
        f: common_vendor.t(_ctx.specificTime),
        g: common_vendor.o(loadPop),
        h: productObject.value.detailImg,
        i: common_vendor.sr(popup, "521289db-0", {
          "k": "popup"
        }),
        j: common_vendor.p({
          ["background-color"]: "#fff"
        })
      };
    };
  }
};
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-521289db"], ["__file", "D:/微信小程序/课设整合/匠承非遗小程序端/jiangchengfeiyi-xiaochengxu/pages/workshop/productmain/productmain.vue"]]);
wx.createPage(MiniProgramPage);
