JewelryMall/miniprogram/unpackage/dist/dev/mp-weixin/components/SpecPanel.js
2026-02-21 14:20:00 +08:00

114 lines
3.8 KiB
JavaScript

"use strict";
const common_vendor = require("../common/vendor.js");
const api_product = require("../api/product.js");
const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({
__name: "SpecPanel",
props: {
productId: {}
},
emits: ["close"],
setup(__props) {
const props = __props;
const config = common_vendor.ref(null);
const loadingConfig = common_vendor.ref(false);
const loadingData = common_vendor.ref(false);
const specDataList = common_vendor.ref([]);
const selected = common_vendor.reactive({
fineness: "",
mainStone: "",
ringSize: ""
});
const canQuery = common_vendor.computed(
() => selected.fineness && selected.mainStone && selected.ringSize
);
common_vendor.onMounted(async () => {
loadingConfig.value = true;
try {
config.value = await api_product.getProductSpecs(props.productId);
} catch {
} finally {
loadingConfig.value = false;
}
});
async function querySpecData() {
if (!canQuery.value)
return;
loadingData.value = true;
try {
specDataList.value = await api_product.getSpecDataList(props.productId, {
fineness: selected.fineness,
mainStone: selected.mainStone,
ringSize: selected.ringSize
});
} catch {
} finally {
loadingData.value = false;
}
}
return (_ctx, _cache) => {
return common_vendor.e({
a: common_vendor.o(($event) => _ctx.$emit("close")),
b: loadingConfig.value
}, loadingConfig.value ? {} : config.value ? common_vendor.e({
d: config.value.fineness.length
}, config.value.fineness.length ? {
e: common_vendor.f(config.value.fineness, (item, k0, i0) => {
return {
a: common_vendor.t(item),
b: item,
c: selected.fineness === item ? 1 : "",
d: common_vendor.o(($event) => selected.fineness = item, item)
};
})
} : {}, {
f: config.value.mainStone.length
}, config.value.mainStone.length ? {
g: common_vendor.f(config.value.mainStone, (item, k0, i0) => {
return {
a: common_vendor.t(item),
b: item,
c: selected.mainStone === item ? 1 : "",
d: common_vendor.o(($event) => selected.mainStone = item, item)
};
})
} : {}, {
h: config.value.ringSize.length
}, config.value.ringSize.length ? {
i: common_vendor.f(config.value.ringSize, (item, k0, i0) => {
return {
a: common_vendor.t(item),
b: item,
c: selected.ringSize === item ? 1 : "",
d: common_vendor.o(($event) => selected.ringSize = item, item)
};
})
} : {}, {
j: !canQuery.value ? 1 : "",
k: common_vendor.o(querySpecData),
l: loadingData.value
}, loadingData.value ? {} : specDataList.value.length ? {
n: common_vendor.f(specDataList.value, (spec, k0, i0) => {
return {
a: common_vendor.t(spec.modelName),
b: common_vendor.t(spec.goldTotalWeight),
c: common_vendor.t(spec.goldValue),
d: common_vendor.t(spec.mainStoneAmount),
e: common_vendor.t(spec.sideStoneAmount),
f: common_vendor.t(spec.totalLaborCost),
g: common_vendor.t(spec.totalPrice),
h: spec.id
};
})
} : {}, {
m: specDataList.value.length
}) : {}, {
c: config.value,
o: common_vendor.o(($event) => _ctx.$emit("close"))
});
};
}
});
const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-c30573e9"]]);
wx.createComponent(Component);
//# sourceMappingURL=../../.sourcemap/mp-weixin/components/SpecPanel.js.map