"use strict"; const common_vendor = require("../../common/vendor.js"); const sheep_url_index = require("../url/index.js"); const sheep_util_index = require("../util/index.js"); function formatSales(type, num) { let prefix = type !== "exact" && num < 10 ? "销量" : "已售"; return formatNum(prefix, type, num); } function formatStock(type, num) { return formatNum("库存", type, num); } function formatNum(prefix, type, num) { num = num || 0; if (type === "exact") { return prefix + num; } if (num < 10) { return `${prefix}≤10`; } let pow = Math.pow(10, `${num}`.length - 1); return `${prefix}${num / pow * pow}+`; } const VIDEO_SUFFIX_LIST = [".avi", ".mp4"]; function formatGoodsSwiper(urlList) { return (urlList == null ? void 0 : urlList.filter((url) => url).map((url, key) => { const isVideo = VIDEO_SUFFIX_LIST.some((suffix) => url.includes(suffix)); const type = isVideo ? "video" : "image"; const src = sheep_url_index.$url.cdn(url); return { type, src }; })) || []; } function formatOrderColor(order) { if (order.status === 0) { return "info-color"; } if (order.status === 10 || order.status === 20 || order.status === 30 && !order.commentStatus) { return "warning-color"; } if (order.status === 30 && order.commentStatus) { return "success-color"; } return "danger-color"; } function formatOrderStatus(order) { if (order.status === 0) { return "待付款"; } if (order.status === 10 && order.deliveryType === 1 || order.status === 10 && order.deliveryType === 3) { return "待发货"; } if (order.status === 10 && order.deliveryType === 2) { return "待核销"; } if (order.status === 20) { return "待收货"; } if (order.status === 30 && !order.commentStatus) { return "待评价"; } if (order.status === 30 && order.commentStatus) { return "已完成"; } return "已关闭"; } function formatOrderStatusDescription(order) { if (order.status === 0) { return `请在 ${sheep_util_index.formatDate(order.payExpireTime)} 前完成支付`; } if (order.status === 10) { return "商家未发货,请耐心等待"; } if (order.status === 20) { return "商家已发货,请耐心等待"; } if (order.status === 30 && !order.commentStatus) { return "已收货,快去评价一下吧"; } if (order.status === 30 && order.commentStatus) { return "交易完成,感谢您的支持"; } return "交易关闭"; } function handleOrderButtons(order) { order.buttons = []; if (order.type === 3) { order.buttons.push("combination"); } if (order.status === 20) { order.buttons.push("express"); order.buttons.push("confirm"); } if (order.logisticsId > 0) { order.buttons.push("express"); } if (order.status === 0) { order.buttons.push("cancel"); order.buttons.push("pay"); } if (order.status === 30 && !order.commentStatus) { order.buttons.push("comment"); } if (order.status === 40) { order.buttons.push("delete"); } } function formatAfterSaleStatus(afterSale) { if (afterSale.status === 10) { return "申请售后"; } if (afterSale.status === 20) { return "商品待退货"; } if (afterSale.status === 30) { return "商家待收货"; } if (afterSale.status === 40) { return "等待退款"; } if (afterSale.status === 50) { return "退款成功"; } if (afterSale.status === 61) { return "买家取消"; } if (afterSale.status === 62) { return "商家拒绝"; } if (afterSale.status === 63) { return "商家拒收货"; } return "未知状态"; } function formatAfterSaleStatusDescription(afterSale) { if (afterSale.status === 10) { return "退款申请待商家处理"; } if (afterSale.status === 20) { return "请退货并填写物流信息"; } if (afterSale.status === 30) { return "退货退款申请待商家处理"; } if (afterSale.status === 40) { return "等待退款"; } if (afterSale.status === 50) { return "退款成功"; } if (afterSale.status === 61) { return "退款关闭"; } if (afterSale.status === 62) { return `商家不同意退款申请,拒绝原因:${afterSale.auditReason}`; } if (afterSale.status === 63) { return `商家拒绝收货,不同意退款,拒绝原因:${afterSale.auditReason}`; } return "未知状态"; } function handleAfterSaleButtons(afterSale) { afterSale.buttons = []; if ([10, 20, 30].includes(afterSale.status)) { afterSale.buttons.push("cancel"); } if (afterSale.status === 20) { afterSale.buttons.push("delivery"); } } function useDurationTime(toTime, fromTime = "") { toTime = getDayjsTime(toTime); if (fromTime === "") { fromTime = common_vendor.dayjs(); } let duration = common_vendor.ref(toTime - fromTime); if (duration.value > 0) { setTimeout(() => { if (duration.value > 0) { duration.value -= 1e3; } }, 1e3); } let durationTime = common_vendor.dayjs.duration(duration.value); return { h: (durationTime.months() * 30 * 24 + durationTime.days() * 24 + durationTime.hours()).toString().padStart(2, "0"), m: durationTime.minutes().toString().padStart(2, "0"), s: durationTime.seconds().toString().padStart(2, "0"), ms: durationTime.$ms }; } function getDayjsTime(time) { time = time.toString(); if (time.indexOf("-") > 0) { return common_vendor.dayjs(time); } if (time.length > 10) { return common_vendor.dayjs(parseInt(time)); } if (time.length === 10) { return common_vendor.dayjs.unix(parseInt(time)); } } function fen2yuan(price) { return (price / 100).toFixed(2); } function fen2yuan6(price) { return (price / 100).toFixed(6); } function points2point(point) { return (point / 1e6).toFixed(3).slice(0, -1); } function convertProductPropertyList(skus) { let result = []; for (const sku of skus) { if (!sku.properties) { continue; } for (const property of sku.properties) { let resultProperty = result.find((item) => item.id === property.propertyId); if (!resultProperty) { resultProperty = { id: property.propertyId, name: property.propertyName, values: [] }; result.push(resultProperty); } let resultValue = resultProperty.values.find((item) => item.id === property.valueId); if (!resultValue) { resultProperty.values.push({ id: property.valueId, name: property.valueName }); } } } return result; } function formatRewardActivityRule(activity, rule) { if (activity.conditionType === 10) { return `满 ${fen2yuan(rule.limit)} 元减 ${fen2yuan(rule.discountPrice)} 元`; } if (activity.conditionType === 20) { return `满 ${rule.limit} 件减 ${fen2yuan(rule.discountPrice)} 元`; } return ""; } exports.convertProductPropertyList = convertProductPropertyList; exports.fen2yuan = fen2yuan; exports.fen2yuan6 = fen2yuan6; exports.formatAfterSaleStatus = formatAfterSaleStatus; exports.formatAfterSaleStatusDescription = formatAfterSaleStatusDescription; exports.formatGoodsSwiper = formatGoodsSwiper; exports.formatOrderColor = formatOrderColor; exports.formatOrderStatus = formatOrderStatus; exports.formatOrderStatusDescription = formatOrderStatusDescription; exports.formatRewardActivityRule = formatRewardActivityRule; exports.formatSales = formatSales; exports.formatStock = formatStock; exports.handleAfterSaleButtons = handleAfterSaleButtons; exports.handleOrderButtons = handleOrderButtons; exports.points2point = points2point; exports.useDurationTime = useDurationTime;