"use strict";
const common_vendor = require("../../common/vendor.js");
if (!Array) {
  const _easycom_u_album2 = common_vendor.resolveComponent("u-album");
  const _easycom_u_icon2 = common_vendor.resolveComponent("u-icon");
  (_easycom_u_album2 + _easycom_u_icon2)();
}
const _easycom_u_album = () => "../../node-modules/uview-plus/components/u-album/u-album.js";
const _easycom_u_icon = () => "../../node-modules/uview-plus/components/u-icon/u-icon.js";
if (!Math) {
  (_easycom_u_album + _easycom_u_icon)();
}
const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({
  __name: "index",
  setup(__props) {
    var _a;
    const $api = (_a = common_vendor.getCurrentInstance()) == null ? void 0 : _a.appContext.config.globalProperties.$api;
    common_vendor.computed(() => {
      return common_vendor.index.getStorageSync("openid");
    });
    const config = common_vendor.ref({});
    const id = common_vendor.ref("");
    const current = common_vendor.ref(0);
    const itemId = common_vendor.ref("");
    const imageList = common_vendor.ref([{ name: "外观", url: [] }, { name: "内饰", url: [] }, { name: "空间", url: [] }]);
    const shop = common_vendor.ref({});
    common_vendor.onLoad(async (options) => {
      id.value = options && options.id;
      const shopId = options && options.shop;
      await searchConfig();
      await searchOther(shopId);
      await search();
    });
    const searchOther = async (id2) => {
      let res;
      res = await $api(`shop/${id2}`, "GET", {});
      if (res.errcode === 0) {
        shop.value = res.data;
      } else {
        common_vendor.index.showToast({
          title: res.errmsg || "",
          icon: "error"
        });
      }
    };
    const searchConfig = async () => {
      config.value = common_vendor.index.getStorageSync("config");
    };
    const search = async () => {
      var _a2, _b;
      if (id.value) {
        const res = await $api(`car/${id.value}`, "GET", {});
        if (res.errcode === 0) {
          if (((_b = (_a2 = res.data) == null ? void 0 : _a2.file) == null ? void 0 : _b.length) > 0) {
            res.data.file = res.data.file.map((item, index) => {
              return item.url;
            });
            var one = res.data.file.slice(0, 9);
            var two = res.data.file.slice(9, 18);
            var thr = res.data.file.slice(18, 21);
            imageList.value = imageList.value.map((item, index) => {
              if (index == 0)
                item.url = one;
              else if (index == 1)
                item.url = two;
              else if (index == 2)
                item.url = thr;
              return item;
            });
          }
        } else {
          common_vendor.index.showToast({
            title: res.errmsg || "",
            icon: "error"
          });
        }
      }
    };
    const toChat = () => {
      var _a2;
      common_vendor.index.makePhoneCall({
        phoneNumber: (_a2 = shop.value) == null ? void 0 : _a2.tel,
        success: function() {
          console.log("拨打电话成功");
        },
        fail: function() {
          common_vendor.index.showToast({
            title: "拨打电话失败",
            icon: "error"
          });
        }
      });
    };
    const swichMenu = (index) => {
      if (index == current.value)
        return;
      current.value = index;
      itemId.value = `item${index}`;
    };
    return (_ctx, _cache) => {
      return {
        a: common_vendor.f(imageList.value, (item, index, i0) => {
          var _a2;
          return {
            a: common_vendor.t(item.name),
            b: common_vendor.t(((_a2 = item == null ? void 0 : item.url) == null ? void 0 : _a2.length) || 0),
            c: common_vendor.n(current.value == index ? "border" : ""),
            d: index,
            e: common_vendor.o(($event) => swichMenu(index), index)
          };
        }),
        b: common_vendor.f(imageList.value, (item, index, i0) => {
          var _a2;
          return {
            a: common_vendor.t(item.name),
            b: common_vendor.t(((_a2 = item == null ? void 0 : item.url) == null ? void 0 : _a2.length) || 0),
            c: "item" + index,
            d: common_vendor.o((width) => _ctx.albumWidth = width, index),
            e: "0d1a9630-0-" + i0,
            f: common_vendor.p({
              urls: item.url,
              multipleSize: "110"
            }),
            g: index
          };
        }),
        c: common_vendor.o(
          //@ts-ignore
          (...args) => _ctx.toPage && _ctx.toPage(...args)
        ),
        d: itemId.value,
        e: common_vendor.p({
          color: "#ffffff",
          name: "red-packet",
          size: "20"
        }),
        f: common_vendor.o(toChat),
        g: common_vendor.o(toChat),
        h: common_vendor.o(toChat)
      };
    };
  }
});
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-0d1a9630"], ["__file", "D:/project/赋强公证/notarization_applet/pagesHome/picture/index.vue"]]);
wx.createPage(MiniProgramPage);
