/** * 处理价格-以小数点分割价格(分成:整数+小数) */ function parsePrice(val) { val = val / 100 if (!val) { val = 0 } return val.toFixed(2).split('.') } /** * 裁剪日期 2020-03-20 15:04:40 -> 2020-03-20 */ function spliceDate(dateStr) { if (!dateStr) return return dateStr.split(' ')[0] } /** * @param discountId 满减id * @param discounts 满减活动列表 * @param lang 当前语言 */ function getCurrDiscountName(discountId, discounts, lang) { for (var i = 0; i < discounts.length; i++) { if (discounts[i].discountId === discountId) { return discounts[i].discountName } } return lang !== 'en' ? '不参与促销' : 'Not participating in promotion' } module.exports = { parsePrice: parsePrice, spliceDate: spliceDate, getCurrDiscountName: getCurrDiscountName }