init
This commit is contained in:
131
unpackage/dist/dev/mp-weixin/uni_modules/nutui-uni/components/price/price.js
vendored
Normal file
131
unpackage/dist/dev/mp-weixin/uni_modules/nutui-uni/components/price/price.js
vendored
Normal file
@@ -0,0 +1,131 @@
|
||||
"use strict";
|
||||
const common_vendor = require("../../../../common/vendor.js");
|
||||
const uni_modules_nutuiUni_components__constants_prefix = require("../_constants/prefix.js");
|
||||
require("../_utils/env.js");
|
||||
const uni_modules_nutuiUni_components__utils_style = require("../_utils/style.js");
|
||||
const uni_modules_nutuiUni_components__utils_props = require("../_utils/props.js");
|
||||
const priceProps = {
|
||||
...uni_modules_nutuiUni_components__utils_props.commonProps,
|
||||
/**
|
||||
* @description 价格数量
|
||||
*/
|
||||
price: uni_modules_nutuiUni_components__utils_props.makeNumericProp(0),
|
||||
/**
|
||||
* @description 是否需要加上 symbol 符号
|
||||
*/
|
||||
needSymbol: uni_modules_nutuiUni_components__utils_props.truthProp,
|
||||
/**
|
||||
* @description 符号类型
|
||||
*/
|
||||
symbol: uni_modules_nutuiUni_components__utils_props.makeStringProp("¥"),
|
||||
/**
|
||||
* @description 小数位位数
|
||||
*/
|
||||
decimalDigits: uni_modules_nutuiUni_components__utils_props.makeNumberProp(2),
|
||||
/**
|
||||
* @description 是否按照千分号形式显示
|
||||
*/
|
||||
thousands: Boolean,
|
||||
/**
|
||||
* @description 符号显示在价格前或者后,`before`、`after`
|
||||
*/
|
||||
position: uni_modules_nutuiUni_components__utils_props.makeStringProp("before"),
|
||||
/**
|
||||
* @description 价格尺寸,`small`、`normal`、`large`
|
||||
*/
|
||||
size: uni_modules_nutuiUni_components__utils_props.makeStringProp("normal"),
|
||||
/**
|
||||
* @description 是否展示划线价
|
||||
*/
|
||||
strikeThrough: Boolean
|
||||
};
|
||||
const componentName = `${uni_modules_nutuiUni_components__constants_prefix.PREFIX}-price`;
|
||||
const __default__ = common_vendor.defineComponent({
|
||||
name: componentName,
|
||||
options: {
|
||||
virtualHost: true,
|
||||
addGlobalClass: true,
|
||||
styleIsolation: "shared"
|
||||
}
|
||||
});
|
||||
const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({
|
||||
...__default__,
|
||||
props: priceProps,
|
||||
setup(__props) {
|
||||
const props = __props;
|
||||
const classes = common_vendor.computed(() => {
|
||||
return uni_modules_nutuiUni_components__utils_style.getMainClass(props, componentName, {
|
||||
[`${componentName}--strike`]: props.strikeThrough
|
||||
});
|
||||
});
|
||||
function replaceSpecialChar(url) {
|
||||
url = url.replace(/"/g, '"');
|
||||
url = url.replace(/&/g, "&");
|
||||
url = url.replace(/</g, "<");
|
||||
url = url.replace(/>/g, ">");
|
||||
url = url.replace(/ /g, " ");
|
||||
url = url.replace(/¥/g, "¥");
|
||||
return url;
|
||||
}
|
||||
const showSymbol = common_vendor.computed(() => {
|
||||
const symbol = props.needSymbol ? replaceSpecialChar(props.symbol) : "";
|
||||
return symbol;
|
||||
});
|
||||
function checkPoint(price) {
|
||||
return String(price).indexOf(".") > 0;
|
||||
}
|
||||
function formatThousands(num) {
|
||||
if (Number(num) === 0)
|
||||
num = 0;
|
||||
if (checkPoint(num)) {
|
||||
num = Number(num).toFixed(props.decimalDigits);
|
||||
num = typeof num.split(".") === "string" ? num.split(".") : num.split(".")[0];
|
||||
} else {
|
||||
num = num.toString();
|
||||
}
|
||||
if (props.thousands)
|
||||
return (num || 0).toString().replace(/(\d)(?=(?:\d{3})+$)/g, "$1,");
|
||||
else
|
||||
return num;
|
||||
}
|
||||
function formatDecimal(decimalNum) {
|
||||
if (Number(decimalNum) === 0)
|
||||
decimalNum = 0;
|
||||
if (checkPoint(decimalNum)) {
|
||||
decimalNum = Number(decimalNum).toFixed(props.decimalDigits);
|
||||
decimalNum = typeof decimalNum.split(".") === "string" ? 0 : decimalNum.split(".")[1] ? decimalNum.split(".")[1] : 0;
|
||||
} else {
|
||||
decimalNum = 0;
|
||||
}
|
||||
const result = `0.${decimalNum}`;
|
||||
const resultFixed = Number(result).toFixed(props.decimalDigits);
|
||||
return String(resultFixed).substring(2, resultFixed.length);
|
||||
}
|
||||
return (_ctx, _cache) => {
|
||||
return common_vendor.e({
|
||||
a: _ctx.needSymbol && _ctx.position === "before"
|
||||
}, _ctx.needSymbol && _ctx.position === "before" ? {
|
||||
b: common_vendor.n(`nut-price--symbol-${_ctx.size}`),
|
||||
c: showSymbol.value
|
||||
} : {}, {
|
||||
d: common_vendor.t(formatThousands(_ctx.price)),
|
||||
e: common_vendor.n(`nut-price--${_ctx.size}`),
|
||||
f: _ctx.decimalDigits !== 0
|
||||
}, _ctx.decimalDigits !== 0 ? {
|
||||
g: common_vendor.n(`nut-price--decimal-${_ctx.size}`)
|
||||
} : {}, {
|
||||
h: common_vendor.t(formatDecimal(_ctx.price)),
|
||||
i: common_vendor.n(`nut-price--decimal-${_ctx.size}`),
|
||||
j: _ctx.needSymbol && _ctx.position === "after"
|
||||
}, _ctx.needSymbol && _ctx.position === "after" ? {
|
||||
k: common_vendor.n(`nut-price--symbol-${_ctx.size}`),
|
||||
l: showSymbol.value
|
||||
} : {}, {
|
||||
m: common_vendor.n(classes.value),
|
||||
n: common_vendor.s(_ctx.customStyle)
|
||||
});
|
||||
};
|
||||
}
|
||||
});
|
||||
wx.createComponent(_sfc_main);
|
||||
//# sourceMappingURL=../../../../../.sourcemap/mp-weixin/uni_modules/nutui-uni/components/price/price.js.map
|
||||
4
unpackage/dist/dev/mp-weixin/uni_modules/nutui-uni/components/price/price.json
vendored
Normal file
4
unpackage/dist/dev/mp-weixin/uni_modules/nutui-uni/components/price/price.json
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {}
|
||||
}
|
||||
1
unpackage/dist/dev/mp-weixin/uni_modules/nutui-uni/components/price/price.wxml
vendored
Normal file
1
unpackage/dist/dev/mp-weixin/uni_modules/nutui-uni/components/price/price.wxml
vendored
Normal file
@@ -0,0 +1 @@
|
||||
<view class="{{m}}" style="{{n}}"><rich-text wx:if="{{a}}" class="{{['nut-price--symbol', b]}}" nodes="{{c}}"/><view class="{{e}}">{{d}}</view><view wx:if="{{f}}" class="{{g}}"> . </view><view class="{{i}}">{{h}}</view><rich-text wx:if="{{j}}" class="{{['nut-price--symbol', k]}}" nodes="{{l}}"/></view>
|
||||
102
unpackage/dist/dev/mp-weixin/uni_modules/nutui-uni/components/price/price.wxss
vendored
Normal file
102
unpackage/dist/dev/mp-weixin/uni_modules/nutui-uni/components/price/price.wxss
vendored
Normal file
@@ -0,0 +1,102 @@
|
||||
/**
|
||||
* 这里是uni-app内置的常用样式变量
|
||||
*
|
||||
* uni-app 官方扩展插件及插件市场(https://ext.dcloud.net.cn)上很多三方插件均使用了这些样式变量
|
||||
* 如果你是插件开发者,建议你使用scss预处理,并在插件代码中直接使用这些变量(无需 import 这个文件),方便用户通过搭积木的方式开发整体风格一致的App
|
||||
*
|
||||
*/
|
||||
/**
|
||||
* 如果你是App开发者(插件使用者),你可以通过修改这些变量来定制自己的插件主题,实现自定义主题功能
|
||||
*
|
||||
* 如果你的项目同样使用了scss预处理,你也可以直接在你的 scss 代码中使用如下变量,同时无需 import 这个文件
|
||||
*/
|
||||
/* 颜色变量 */
|
||||
/* 行为相关颜色 */
|
||||
/* 文字基本颜色 */
|
||||
/* 背景颜色 */
|
||||
/* 边框颜色 */
|
||||
/* 尺寸变量 */
|
||||
/* 文字尺寸 */
|
||||
/* 图片尺寸 */
|
||||
/* Border Radius */
|
||||
/* 水平间距 */
|
||||
/* 垂直间距 */
|
||||
/* 透明度 */
|
||||
/* 文章场景相关 */
|
||||
/**
|
||||
* 这里是uni-app内置的常用样式变量
|
||||
*
|
||||
* uni-app 官方扩展插件及插件市场(https://ext.dcloud.net.cn)上很多三方插件均使用了这些样式变量
|
||||
* 如果你是插件开发者,建议你使用scss预处理,并在插件代码中直接使用这些变量(无需 import 这个文件),方便用户通过搭积木的方式开发整体风格一致的App
|
||||
*
|
||||
*/
|
||||
/**
|
||||
* 如果你是App开发者(插件使用者),你可以通过修改这些变量来定制自己的插件主题,实现自定义主题功能
|
||||
*
|
||||
* 如果你的项目同样使用了scss预处理,你也可以直接在你的 scss 代码中使用如下变量,同时无需 import 这个文件
|
||||
*/
|
||||
/* 颜色变量 */
|
||||
/* 行为相关颜色 */
|
||||
/* 文字基本颜色 */
|
||||
/* 背景颜色 */
|
||||
/* 边框颜色 */
|
||||
/* 尺寸变量 */
|
||||
/* 文字尺寸 */
|
||||
/* 图片尺寸 */
|
||||
/* Border Radius */
|
||||
/* 水平间距 */
|
||||
/* 垂直间距 */
|
||||
/* 透明度 */
|
||||
/* 文章场景相关 */
|
||||
.nut-price {
|
||||
display: inline;
|
||||
font-size: 0;
|
||||
color: var(--nut-primary-color, #fa2c19);
|
||||
}
|
||||
.nut-price--strike [class*=nut-price] {
|
||||
text-decoration: line-through;
|
||||
}
|
||||
.nut-price--symbol {
|
||||
display: inline-block;
|
||||
font-size: var(--nut-font-size-3, 16px);
|
||||
}
|
||||
.nut-price--large {
|
||||
display: inline-block;
|
||||
font-size: var(--nut-price-big-size, 24px);
|
||||
}
|
||||
.nut-price--point {
|
||||
display: inline-block;
|
||||
font-size: var(--nut-price-big-size, 24px);
|
||||
}
|
||||
.nut-price--decimal-large {
|
||||
display: inline-block;
|
||||
font-size: var(--nut-price-decimal-big-size, 18px);
|
||||
}
|
||||
.nut-price--symbol-large {
|
||||
display: inline-block;
|
||||
font-size: var(--nut-price-symbol-big-size, 18px);
|
||||
}
|
||||
.nut-price--normal {
|
||||
display: inline-block;
|
||||
font-size: var(--nut-price-medium-size, 16px);
|
||||
}
|
||||
.nut-price--decimal-normal {
|
||||
display: inline-block;
|
||||
font-size: var(--nut-price-decimal-medium-size, 14px);
|
||||
}
|
||||
.nut-price--symbol-normal {
|
||||
display: inline-block;
|
||||
font-size: var(--nut-price-symbol-medium-size, 14px);
|
||||
}
|
||||
.nut-price--small {
|
||||
display: inline-block;
|
||||
font-size: var(--nut-price-small-size, 12px);
|
||||
}
|
||||
.nut-price--decimal-small {
|
||||
display: inline-block;
|
||||
font-size: var(--nut-price-decimal-small-size, 10px);
|
||||
}
|
||||
.nut-price--symbol-small {
|
||||
display: inline-block;
|
||||
font-size: var(--nut-price-symbol-small-size, 10px);
|
||||
}
|
||||
Reference in New Issue
Block a user