| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175 |
- "use strict";
- const common_vendor = require("../../common/vendor.js");
- if (!Array) {
- const _component_up_button = common_vendor.resolveComponent("up-button");
- const _component_up_popup = common_vendor.resolveComponent("up-popup");
- (_component_up_button + _component_up_popup)();
- }
- const _sfc_main = {
- __name: "index",
- props: {
- attr: {
- type: Object,
- default: () => ({})
- },
- showPopup: {
- type: Boolean,
- default: false
- },
- limitNum: {
- type: Number,
- default: 0
- },
- isShow: {
- type: Number,
- default: 0
- },
- iSbnt: {
- type: Number,
- default: 0
- },
- iSplus: {
- type: Number,
- default: 0
- },
- iScart: {
- type: Number,
- default: 0
- }
- },
- emits: [
- "goCat",
- "iptCartNum",
- "myevent",
- "ChangeCartNum",
- "attrVal",
- "ChangeAttr",
- "submit",
- "closePopup"
- ],
- setup(__props, { emit: __emit }) {
- const props = __props;
- const emit = __emit;
- const calcNumPrice = common_vendor.computed(() => {
- var _a;
- if (!((_a = props.attr) == null ? void 0 : _a.productSelect)) {
- return "0.00";
- }
- const { storePrice, cart_num } = props.attr.productSelect;
- if (!storePrice || !cart_num) {
- return "0.00";
- }
- const price = Number(storePrice);
- const quantity = Number(cart_num);
- if (isNaN(price) || isNaN(quantity)) {
- return "0.00";
- }
- if (price < 0 || quantity < 0) {
- return "0.00";
- }
- const total = price * quantity;
- return total.toFixed(2);
- });
- function bindCode() {
- emit("iptCartNum", props.attr.productSelect.cart_num);
- }
- function close() {
- emit("closePopup");
- }
- function submit() {
- emit("submit");
- }
- function CartNumDes() {
- emit("ChangeCartNum", false);
- }
- function CartNumAdd() {
- emit("ChangeCartNum", true);
- }
- function tapAttr(indexw, indexn) {
- emit("attrVal", { indexw, indexn });
- if (props.attr.productAttr && props.attr.productAttr[indexw]) {
- props.attr.productAttr[indexw].index = props.attr.productAttr[indexw].attrValues[indexn];
- }
- const value = getCheckedValue().join(",");
- emit("ChangeAttr", value);
- }
- function getCheckedValue() {
- const productAttr = props.attr.productAttr || [];
- const value = [];
- for (let i = 0; i < productAttr.length; i++) {
- for (let j = 0; j < productAttr[i].attrValues.length; j++) {
- if (productAttr[i].index === productAttr[i].attrValues[j]) {
- value.push(productAttr[i].attrValues[j]);
- }
- }
- }
- return value;
- }
- return (_ctx, _cache) => {
- return common_vendor.e({
- a: __props.attr.productSelect.image,
- b: common_vendor.t(__props.attr.productSelect.storeName),
- c: common_vendor.t(calcNumPrice.value),
- d: __props.isShow
- }, __props.isShow ? {
- e: common_vendor.t(__props.attr.productSelect.stock)
- } : {}, {
- f: __props.limitNum
- }, __props.limitNum ? {
- g: common_vendor.t(__props.attr.productSelect.quota)
- } : {}, {
- h: common_vendor.o(close),
- i: common_vendor.f(__props.attr.productAttr, (item, indexw, i0) => {
- return {
- a: common_vendor.t(item.attrName),
- b: common_vendor.f(item.attrValues, (itemn, indexn, i1) => {
- return {
- a: common_vendor.t(itemn),
- b: common_vendor.n(item.index === itemn ? "on" : ""),
- c: common_vendor.o(($event) => tapAttr(indexw, indexn), indexn),
- d: indexn
- };
- }),
- c: indexw
- };
- }),
- j: common_vendor.n(__props.attr.productSelect.cart_num <= 1 ? "on" : ""),
- k: common_vendor.o(CartNumDes),
- l: common_vendor.o([($event) => __props.attr.productSelect.cart_num = $event.detail.value, ($event) => bindCode(__props.attr.productSelect.cart_num)]),
- m: __props.attr.productSelect.cart_num,
- n: __props.iSplus
- }, __props.iSplus ? {
- o: common_vendor.n(__props.attr.productSelect.cart_num >= __props.attr.productSelect.stock ? "on" : ""),
- p: common_vendor.o(CartNumAdd)
- } : {
- q: common_vendor.n(__props.attr.productSelect.cart_num >= __props.attr.productSelect.quota || __props.attr.productSelect.cart_num >= __props.attr.productSelect.stock || __props.attr.productSelect.cart_num >= __props.attr.productSelect.num ? "on" : ""),
- r: common_vendor.o(CartNumAdd)
- }, {
- s: __props.attr.productSelect.stock > 0
- }, __props.attr.productSelect.stock > 0 ? {
- t: common_vendor.o(submit),
- v: common_vendor.p({
- type: "primary",
- text: "确定"
- })
- } : {
- w: common_vendor.o(submit),
- x: common_vendor.p({
- type: "primary",
- text: "已售罄"
- })
- }, {
- y: common_vendor.n((__props.iSbnt ? "join" : "") + " " + (__props.iScart ? "joinCart" : "")),
- z: common_vendor.o(close),
- A: common_vendor.p({
- show: __props.showPopup,
- closeOnClickOverlay: true
- })
- });
- };
- }
- };
- const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-2914200c"]]);
- wx.createComponent(Component);
- //# sourceMappingURL=../../../.sourcemap/mp-weixin/components/productWindow/index.js.map
|