UNPKG

5.51 kBJavaScriptView Raw
1var __defProp = Object.defineProperty;
2var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3var __getOwnPropNames = Object.getOwnPropertyNames;
4var __hasOwnProp = Object.prototype.hasOwnProperty;
5var __export = (target, all) => {
6 for (var name2 in all)
7 __defProp(target, name2, { get: all[name2], enumerable: true });
8};
9var __copyProps = (to, from, except, desc) => {
10 if (from && typeof from === "object" || typeof from === "function") {
11 for (let key of __getOwnPropNames(from))
12 if (!__hasOwnProp.call(to, key) && key !== except)
13 __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14 }
15 return to;
16};
17var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18var stdin_exports = {};
19__export(stdin_exports, {
20 cardProps: () => cardProps,
21 default: () => stdin_default
22});
23module.exports = __toCommonJS(stdin_exports);
24var import_vue = require("vue");
25var import_utils = require("../utils");
26var import_tag = require("../tag");
27var import_image = require("../image");
28const [name, bem] = (0, import_utils.createNamespace)("card");
29const cardProps = {
30 tag: String,
31 num: import_utils.numericProp,
32 desc: String,
33 thumb: String,
34 title: String,
35 price: import_utils.numericProp,
36 centered: Boolean,
37 lazyLoad: Boolean,
38 currency: (0, import_utils.makeStringProp)("\xA5"),
39 thumbLink: String,
40 originPrice: import_utils.numericProp
41};
42var stdin_default = (0, import_vue.defineComponent)({
43 name,
44 props: cardProps,
45 emits: ["clickThumb"],
46 setup(props, {
47 slots,
48 emit
49 }) {
50 const renderTitle = () => {
51 if (slots.title) {
52 return slots.title();
53 }
54 if (props.title) {
55 return (0, import_vue.createVNode)("div", {
56 "class": [bem("title"), "van-multi-ellipsis--l2"]
57 }, [props.title]);
58 }
59 };
60 const renderThumbTag = () => {
61 if (slots.tag || props.tag) {
62 return (0, import_vue.createVNode)("div", {
63 "class": bem("tag")
64 }, [slots.tag ? slots.tag() : (0, import_vue.createVNode)(import_tag.Tag, {
65 "mark": true,
66 "type": "primary"
67 }, {
68 default: () => [props.tag]
69 })]);
70 }
71 };
72 const renderThumbImage = () => {
73 if (slots.thumb) {
74 return slots.thumb();
75 }
76 return (0, import_vue.createVNode)(import_image.Image, {
77 "src": props.thumb,
78 "fit": "cover",
79 "width": "100%",
80 "height": "100%",
81 "lazyLoad": props.lazyLoad
82 }, null);
83 };
84 const renderThumb = () => {
85 if (slots.thumb || props.thumb) {
86 return (0, import_vue.createVNode)("a", {
87 "href": props.thumbLink,
88 "class": bem("thumb"),
89 "onClick": (event) => emit("clickThumb", event)
90 }, [renderThumbImage(), renderThumbTag()]);
91 }
92 };
93 const renderDesc = () => {
94 if (slots.desc) {
95 return slots.desc();
96 }
97 if (props.desc) {
98 return (0, import_vue.createVNode)("div", {
99 "class": [bem("desc"), "van-ellipsis"]
100 }, [props.desc]);
101 }
102 };
103 const renderPriceText = () => {
104 const priceArr = props.price.toString().split(".");
105 return (0, import_vue.createVNode)("div", null, [(0, import_vue.createVNode)("span", {
106 "class": bem("price-currency")
107 }, [props.currency]), (0, import_vue.createVNode)("span", {
108 "class": bem("price-integer")
109 }, [priceArr[0]]), priceArr.length > 1 && (0, import_vue.createVNode)(import_vue.Fragment, null, [(0, import_vue.createTextVNode)("."), (0, import_vue.createVNode)("span", {
110 "class": bem("price-decimal")
111 }, [priceArr[1]])])]);
112 };
113 return () => {
114 var _a, _b, _c;
115 const showNum = slots.num || (0, import_utils.isDef)(props.num);
116 const showPrice = slots.price || (0, import_utils.isDef)(props.price);
117 const showOriginPrice = slots["origin-price"] || (0, import_utils.isDef)(props.originPrice);
118 const showBottom = showNum || showPrice || showOriginPrice || slots.bottom;
119 const Price = showPrice && (0, import_vue.createVNode)("div", {
120 "class": bem("price")
121 }, [slots.price ? slots.price() : renderPriceText()]);
122 const OriginPrice = showOriginPrice && (0, import_vue.createVNode)("div", {
123 "class": bem("origin-price")
124 }, [slots["origin-price"] ? slots["origin-price"]() : `${props.currency} ${props.originPrice}`]);
125 const Num = showNum && (0, import_vue.createVNode)("div", {
126 "class": bem("num")
127 }, [slots.num ? slots.num() : `x${props.num}`]);
128 const Footer = slots.footer && (0, import_vue.createVNode)("div", {
129 "class": bem("footer")
130 }, [slots.footer()]);
131 const Bottom = showBottom && (0, import_vue.createVNode)("div", {
132 "class": bem("bottom")
133 }, [(_a = slots["price-top"]) == null ? void 0 : _a.call(slots), Price, OriginPrice, Num, (_b = slots.bottom) == null ? void 0 : _b.call(slots)]);
134 return (0, import_vue.createVNode)("div", {
135 "class": bem()
136 }, [(0, import_vue.createVNode)("div", {
137 "class": bem("header")
138 }, [renderThumb(), (0, import_vue.createVNode)("div", {
139 "class": bem("content", {
140 centered: props.centered
141 })
142 }, [(0, import_vue.createVNode)("div", null, [renderTitle(), renderDesc(), (_c = slots.tags) == null ? void 0 : _c.call(slots)]), Bottom])]), Footer]);
143 };
144 }
145});