UNPKG

@icreate/ics-mui

Version:

京东风格的轻量级移动端 Vue2、Vue3 组件库(支持小程序开发)

101 lines (100 loc) 3.77 kB
var __defProp = Object.defineProperty; var __defProps = Object.defineProperties; var __getOwnPropDescs = Object.getOwnPropertyDescriptors; var __getOwnPropSymbols = Object.getOwnPropertySymbols; var __hasOwnProp = Object.prototype.hasOwnProperty; var __propIsEnum = Object.prototype.propertyIsEnumerable; var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; var __spreadValues = (a, b) => { for (var prop in b || (b = {})) if (__hasOwnProp.call(b, prop)) __defNormalProp(a, prop, b[prop]); if (__getOwnPropSymbols) for (var prop of __getOwnPropSymbols(b)) { if (__propIsEnum.call(b, prop)) __defNormalProp(a, prop, b[prop]); } return a; }; var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b)); import { defineComponent, computed, openBlock, createElementBlock, normalizeClass, createCommentVNode, createElementVNode, normalizeStyle, toDisplayString } from "vue"; import { w as withInstall } from "../with-install-DWwOiZS3.js"; const _hoisted_1 = ["innerHTML"]; const _hoisted_2 = ["innerHTML"]; const prefix = "nut-price"; const _sfc_main = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues({}, { name: "IcsPrice" }), { __name: "price", props: { price: { default: 0 }, needSymbol: { type: Boolean, default: true }, symbol: { default: "¥" }, priceSize: { default: "" }, priceColor: {}, symbolSize: { default: "" }, symbolColor: { default: "rgba(0, 0, 0, 0.45)" }, decimalDigits: { default: 2 }, thousands: { type: Boolean, default: false }, position: { default: "before" }, size: { default: "normal" }, strikeThrough: { type: Boolean, default: false } }, setup(__props) { const props = __props; const classes = computed(() => { return { [prefix]: true, [`${prefix}--strike`]: props.strikeThrough }; }); const showSymbol = computed(() => { const symbol = props.needSymbol ? props.symbol : ""; return symbol; }); const checkPoint = (price) => { return String(price).indexOf(".") > 0; }; const formatThousands = (num) => { if (Number(num) == 0) { num = 0; } if (checkPoint(num)) { num = Number(num).toFixed(props.decimalDigits); } else { num = num.toString(); } if (props.thousands) { return (num || 0).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","); } else { return num; } }; return (_ctx, _cache) => { return openBlock(), createElementBlock("view", { class: normalizeClass(classes.value) }, [ _ctx.needSymbol && _ctx.position === "before" ? (openBlock(), createElementBlock("view", { key: 0, class: normalizeClass(["nut-price--symbol", `nut-price--symbol-${_ctx.size}`]), innerHTML: showSymbol.value }, null, 10, _hoisted_1)) : createCommentVNode("", true), createElementVNode("view", { class: normalizeClass(`nut-price--${_ctx.size} ${_ctx.priceSize}`), style: normalizeStyle({ color: _ctx.priceColor }) }, toDisplayString(formatThousands(_ctx.price)), 7), _ctx.needSymbol && _ctx.position === "after" ? (openBlock(), createElementBlock("view", { key: 1, class: normalizeClass(["nut-price--symbol", `nut-price--symbol-${_ctx.size} ${_ctx.symbolSize}`]), style: normalizeStyle({ color: _ctx.symbolColor }), innerHTML: showSymbol.value }, null, 14, _hoisted_2)) : createCommentVNode("", true) ], 2); }; } })); withInstall(_sfc_main); export { _sfc_main as Price, _sfc_main as default };