"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) {
  (addProduct + _easycom_uni_popup)();
}
const addProduct = () => "../../Shopping-cart/component/addProduct2.js";
const _sfc_main = {
  __name: "ProductDetails",
  setup(__props) {
    const popup = common_vendor.ref(null);
    const goodObject = common_vendor.ref({});
    const idInfo = common_vendor.ref(0);
    const userInfo = common_vendor.ref({});
    const labelList = common_vendor.ref([]);
    const imgArr = common_vendor.ref([]);
    const coupon = common_vendor.ref(0);
    common_vendor.onLoad((options) => {
      getProduct(JSON.parse(options.gid));
    });
    common_vendor.onShow(() => {
      userInfo.value = common_vendor.wx$1.getStorageSync("userInfo");
    });
    common_vendor.onMounted(() => {
      utils_emitter.emitter.on("close", () => {
        close();
      });
      getFonts();
    });
    const getProduct = async (gid) => {
      const res = await common_vendor.index.request({
        url: api_request.baseUrl + "/goods/getById",
        method: "POST",
        data: { id: gid },
        header: {
          cookie: common_vendor.wx$1.getStorageSync("cookie")
        }
      });
      console.log("请求请求--->", res.data);
      if (res.data.code === 1) {
        goodObject.value = res.data.data;
        imgArr.value = res.data.data.goodImg.split(";");
        labelList.value = goodObject.value.label.split(";");
        labelList.value = labelList.value.filter((s) => {
          return s;
        });
        idInfo.value = goodObject.value.id;
      }
    };
    const loadPop = () => {
      popup.value.open("bottom");
      utils_emitter.emitter.emit("product", goodObject.value);
    };
    const close = () => {
      popup.value.close();
    };
    const jump_buy = () => {
      common_vendor.index.navigateTo({
        url: "../../../pages/order/singleGoodOrder/singleGoodOrder?cartInfo=" + JSON.stringify(idInfo.value)
      });
    };
    const getFonts = () => {
      common_vendor.index.loadFontFace({
        family: "FangZhengFonts",
        source: `url("https://carbon2.obs.cn-north-4.myhuaweicloud.com/fonts/FangZhengFonts.TTF")`,
        success: (res) => {
          console.log("success", res);
        },
        fail: (err) => {
          console.log("err", err);
        }
      });
    };
    const previewImage = (index) => {
      console.log(index);
      common_vendor.index.previewImage({
        current: index,
        urls: imgArr.value
      });
    };
    return (_ctx, _cache) => {
      return common_vendor.e({
        a: common_vendor.f(imgArr.value, (item, index, i0) => {
          return {
            a: item,
            b: common_vendor.o(($event) => previewImage(index), index),
            c: index
          };
        }),
        b: common_vendor.t(goodObject.value.price),
        c: common_vendor.t(coupon.value),
        d: common_vendor.t(goodObject.value.name),
        e: goodObject.value.festivalName != null
      }, goodObject.value.festivalName != null ? {
        f: common_vendor.t(goodObject.value.festivalName)
      } : {}, {
        g: common_vendor.t(goodObject.value.introDetail),
        h: common_vendor.f(labelList.value, (item, index, i0) => {
          return {
            a: common_vendor.t(item),
            b: index
          };
        }),
        i: goodObject.value.detailImg,
        j: common_vendor.o(loadPop),
        k: common_vendor.o(jump_buy),
        l: common_vendor.sr(popup, "3361b524-0", {
          "k": "popup"
        }),
        m: common_vendor.p({
          ["background-color"]: "#fff"
        })
      });
    };
  }
};
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-3361b524"], ["__file", "D:/微信小程序/课设整合/匠承非遗小程序端/jiangchengfeiyi-xiaochengxu/pages/store-home/ProductDetails/ProductDetails.vue"]]);
wx.createPage(MiniProgramPage);
