2024-09-15 09:32:29 +00:00
|
|
|
|
import {
|
|
|
|
|
ref
|
|
|
|
|
} from 'vue';
|
2022-11-22 07:45:36 +00:00
|
|
|
|
import dayjs from 'dayjs';
|
|
|
|
|
import $url from '@/sheep/url';
|
2024-09-15 09:32:29 +00:00
|
|
|
|
import {
|
|
|
|
|
formatDate
|
|
|
|
|
} from '@/sheep/util';
|
2022-11-22 07:45:36 +00:00
|
|
|
|
|
2023-12-01 12:24:54 +00:00
|
|
|
|
/**
|
|
|
|
|
* 格式化销量
|
|
|
|
|
* @param {'exact' | string} type 格式类型:exact=精确值,其它=大致数量
|
|
|
|
|
* @param {number} num 销量
|
|
|
|
|
* @return {string} 格式化后的销量字符串
|
|
|
|
|
*/
|
2022-11-22 07:45:36 +00:00
|
|
|
|
export function formatSales(type, num) {
|
2023-12-13 12:06:40 +00:00
|
|
|
|
let prefix = type !== 'exact' && num < 10 ? '销量' : '已售';
|
2023-12-01 12:24:54 +00:00
|
|
|
|
return formatNum(prefix, type, num)
|
2022-11-22 07:45:36 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-12-01 12:24:54 +00:00
|
|
|
|
/**
|
|
|
|
|
* 格式化兑换量
|
|
|
|
|
* @param {'exact' | string} type 格式类型:exact=精确值,其它=大致数量
|
|
|
|
|
* @param {number} num 销量
|
|
|
|
|
* @return {string} 格式化后的销量字符串
|
|
|
|
|
*/
|
2022-11-22 07:45:36 +00:00
|
|
|
|
export function formatExchange(type, num) {
|
2023-12-01 12:24:54 +00:00
|
|
|
|
return formatNum('已兑换', type, num)
|
2022-11-22 07:45:36 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-12-01 12:24:54 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 格式化库存
|
|
|
|
|
* @param {'exact' | any} type 格式类型:exact=精确值,其它=大致数量
|
|
|
|
|
* @param {number} num 销量
|
|
|
|
|
* @return {string} 格式化后的销量字符串
|
|
|
|
|
*/
|
2022-11-22 07:45:36 +00:00
|
|
|
|
export function formatStock(type, num) {
|
2023-12-01 12:24:54 +00:00
|
|
|
|
return formatNum('库存', type, num)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 格式化数字
|
|
|
|
|
* @param {string} prefix 前缀
|
|
|
|
|
* @param {'exact' | string} type 格式类型:exact=精确值,其它=大致数量
|
|
|
|
|
* @param {number} num 销量
|
|
|
|
|
* @return {string} 格式化后的销量字符串
|
|
|
|
|
*/
|
|
|
|
|
export function formatNum(prefix, type, num) {
|
|
|
|
|
num = (num || 0);
|
|
|
|
|
// 情况一:精确数值
|
2022-11-22 07:45:36 +00:00
|
|
|
|
if (type === 'exact') {
|
2023-12-01 12:24:54 +00:00
|
|
|
|
return prefix + num;
|
|
|
|
|
}
|
|
|
|
|
// 情况二:小于等于 10
|
|
|
|
|
if (num < 10) {
|
|
|
|
|
return `${prefix}≤10`;
|
2022-11-22 07:45:36 +00:00
|
|
|
|
}
|
2023-12-01 12:24:54 +00:00
|
|
|
|
// 情况三:大于 10,除第一位外,其它位都显示为0
|
|
|
|
|
// 例如:100 - 199 显示为 100+
|
|
|
|
|
// 9000 - 9999 显示为 9000+
|
2024-01-29 01:34:51 +00:00
|
|
|
|
const numStr = num.toString();
|
|
|
|
|
const first = numStr[0];
|
|
|
|
|
const other = '0'.repeat(numStr.length - 1);
|
|
|
|
|
return `${prefix}${first}${other}+`;
|
2022-11-22 07:45:36 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 格式化价格
|
|
|
|
|
export function formatPrice(e) {
|
|
|
|
|
return e.length === 1 ? e[0] : e.join('~');
|
|
|
|
|
}
|
|
|
|
|
|
2023-12-01 12:24:54 +00:00
|
|
|
|
// 视频格式后缀列表
|
|
|
|
|
const VIDEO_SUFFIX_LIST = ['.avi', '.mp4']
|
2023-12-13 12:06:40 +00:00
|
|
|
|
|
2023-12-01 12:24:54 +00:00
|
|
|
|
/**
|
|
|
|
|
* 转换商品轮播的链接列表:根据链接的后缀,判断是视频链接还是图片链接
|
|
|
|
|
*
|
|
|
|
|
* @param {string[]} urlList 链接列表
|
|
|
|
|
* @return {{src: string, type: 'video' | 'image' }[]} 转换后的链接列表
|
|
|
|
|
*/
|
|
|
|
|
export function formatGoodsSwiper(urlList) {
|
2024-01-10 16:25:13 +00:00
|
|
|
|
return urlList?.filter(url => url).map((url, key) => {
|
2023-12-01 12:24:54 +00:00
|
|
|
|
const isVideo = VIDEO_SUFFIX_LIST.some(suffix => url.includes(suffix));
|
2023-12-13 12:06:40 +00:00
|
|
|
|
const type = isVideo ? 'video' : 'image'
|
2023-12-01 12:24:54 +00:00
|
|
|
|
const src = $url.cdn(url);
|
2024-09-15 09:32:29 +00:00
|
|
|
|
return {
|
|
|
|
|
type,
|
|
|
|
|
src
|
|
|
|
|
}
|
2024-01-10 16:25:13 +00:00
|
|
|
|
}) || [];
|
2022-11-22 07:45:36 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-12-01 12:24:54 +00:00
|
|
|
|
/**
|
|
|
|
|
* 格式化订单状态的颜色
|
2023-12-12 15:26:02 +00:00
|
|
|
|
*
|
|
|
|
|
* @param order 订单
|
2023-12-01 12:24:54 +00:00
|
|
|
|
* @return {string} 颜色的 class 名称
|
|
|
|
|
*/
|
2023-12-12 15:26:02 +00:00
|
|
|
|
export function formatOrderColor(order) {
|
|
|
|
|
if (order.status === 0) {
|
|
|
|
|
return 'info-color';
|
|
|
|
|
}
|
2024-09-15 09:32:29 +00:00
|
|
|
|
if (order.status === 10 ||
|
|
|
|
|
order.status === 20 ||
|
|
|
|
|
(order.status === 30 && !order.commentStatus)) {
|
2023-12-12 15:26:02 +00:00
|
|
|
|
return 'warning-color';
|
|
|
|
|
}
|
|
|
|
|
if (order.status === 30 && order.commentStatus) {
|
|
|
|
|
return 'success-color';
|
|
|
|
|
}
|
|
|
|
|
return 'danger-color';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 格式化订单状态
|
|
|
|
|
*
|
|
|
|
|
* @param order 订单
|
|
|
|
|
*/
|
|
|
|
|
export function formatOrderStatus(order) {
|
|
|
|
|
if (order.status === 0) {
|
|
|
|
|
return '待付款';
|
|
|
|
|
}
|
|
|
|
|
if (order.status === 10 && order.deliveryType === 1) {
|
|
|
|
|
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 '已关闭';
|
|
|
|
|
}
|
|
|
|
|
|
2023-12-13 12:06:40 +00:00
|
|
|
|
/**
|
|
|
|
|
* 格式化订单状态的描述
|
|
|
|
|
*
|
|
|
|
|
* @param order 订单
|
|
|
|
|
*/
|
|
|
|
|
export function formatOrderStatusDescription(order) {
|
|
|
|
|
if (order.status === 0) {
|
2024-03-01 09:31:59 +00:00
|
|
|
|
return `请在 ${ formatDate(order.payExpireTime) } 前完成支付`;
|
2023-12-13 12:06:40 +00:00
|
|
|
|
}
|
|
|
|
|
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 '交易关闭';
|
|
|
|
|
}
|
|
|
|
|
|
2023-12-12 15:26:02 +00:00
|
|
|
|
/**
|
|
|
|
|
* 处理订单的 button 操作按钮数组
|
|
|
|
|
*
|
|
|
|
|
* @param order 订单
|
|
|
|
|
*/
|
|
|
|
|
export function handleOrderButtons(order) {
|
|
|
|
|
order.buttons = []
|
|
|
|
|
if (order.type === 3) { // 查看拼团
|
|
|
|
|
order.buttons.push('combination');
|
|
|
|
|
}
|
|
|
|
|
if (order.status === 20) { // 确认收货
|
|
|
|
|
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');
|
2022-11-22 07:45:36 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-12-14 11:44:01 +00:00
|
|
|
|
/**
|
|
|
|
|
* 格式化售后状态
|
|
|
|
|
*
|
|
|
|
|
* @param afterSale 售后
|
|
|
|
|
*/
|
|
|
|
|
export 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 '未知状态';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 格式化售后状态的描述
|
|
|
|
|
*
|
|
|
|
|
* @param afterSale 售后
|
|
|
|
|
*/
|
|
|
|
|
export 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 '未知状态';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 处理售后的 button 操作按钮数组
|
|
|
|
|
*
|
|
|
|
|
* @param afterSale 售后
|
|
|
|
|
*/
|
|
|
|
|
export function handleAfterSaleButtons(afterSale) {
|
|
|
|
|
afterSale.buttons = [];
|
|
|
|
|
if ([10, 20, 30].includes(afterSale.status)) { // 取消订单
|
|
|
|
|
afterSale.buttons.push('cancel');
|
|
|
|
|
}
|
|
|
|
|
if (afterSale.status === 20) { // 退货信息
|
|
|
|
|
afterSale.buttons.push('delivery');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-12-01 12:24:54 +00:00
|
|
|
|
/**
|
|
|
|
|
* 倒计时
|
|
|
|
|
* @param toTime 截止时间
|
|
|
|
|
* @param fromTime 起始时间,默认当前时间
|
|
|
|
|
* @return {{s: string, ms: number, h: string, m: string}} 持续时间
|
|
|
|
|
*/
|
2022-11-22 07:45:36 +00:00
|
|
|
|
export function useDurationTime(toTime, fromTime = '') {
|
|
|
|
|
toTime = getDayjsTime(toTime);
|
|
|
|
|
if (fromTime === '') {
|
|
|
|
|
fromTime = dayjs();
|
|
|
|
|
}
|
|
|
|
|
let duration = ref(toTime - fromTime);
|
|
|
|
|
if (duration.value > 0) {
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
if (duration.value > 0) {
|
|
|
|
|
duration.value -= 1000;
|
|
|
|
|
}
|
|
|
|
|
}, 1000);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let durationTime = 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,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2023-12-01 12:24:54 +00:00
|
|
|
|
/**
|
|
|
|
|
* 转换为 Dayjs
|
|
|
|
|
* @param {any} time 时间
|
|
|
|
|
* @return {dayjs.Dayjs}
|
|
|
|
|
*/
|
2022-11-22 07:45:36 +00:00
|
|
|
|
function getDayjsTime(time) {
|
|
|
|
|
time = time.toString();
|
|
|
|
|
if (time.indexOf('-') > 0) {
|
|
|
|
|
// 'date'
|
|
|
|
|
return dayjs(time);
|
|
|
|
|
}
|
|
|
|
|
if (time.length > 10) {
|
|
|
|
|
// 'timestamp'
|
|
|
|
|
return dayjs(parseInt(time));
|
|
|
|
|
}
|
|
|
|
|
if (time.length === 10) {
|
2023-12-01 12:24:54 +00:00
|
|
|
|
// 'unixTime'
|
2022-11-22 07:45:36 +00:00
|
|
|
|
return dayjs.unix(parseInt(time));
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-12-09 12:04:51 +00:00
|
|
|
|
|
2023-12-10 09:25:15 +00:00
|
|
|
|
/**
|
|
|
|
|
* 将分转成元
|
|
|
|
|
*
|
|
|
|
|
* @param price 分,例如说 100 分
|
|
|
|
|
* @returns {string} 元,例如说 1.00 元
|
|
|
|
|
*/
|
|
|
|
|
export function fen2yuan(price) {
|
|
|
|
|
return (price / 100.0).toFixed(2)
|
|
|
|
|
}
|
|
|
|
|
|
2023-12-09 12:04:51 +00:00
|
|
|
|
/**
|
|
|
|
|
* 从商品 SKU 数组中,转换出商品属性的数组
|
|
|
|
|
*
|
|
|
|
|
* 类似结构:[{
|
|
|
|
|
* id: // 属性的编号
|
|
|
|
|
* name: // 属性的名字
|
|
|
|
|
* values: [{
|
|
|
|
|
* id: // 属性值的编号
|
|
|
|
|
* name: // 属性值的名字
|
|
|
|
|
* }]
|
|
|
|
|
* }]
|
|
|
|
|
*
|
|
|
|
|
* @param skus 商品 SKU 数组
|
|
|
|
|
*/
|
|
|
|
|
export 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;
|
2023-12-23 14:27:09 +00:00
|
|
|
|
}
|
2024-01-06 12:40:39 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 格式化满减送活动的规则
|
|
|
|
|
*
|
|
|
|
|
* @param activity 活动信息
|
|
|
|
|
* @param rule 优惠规格
|
|
|
|
|
* @returns {string} 规格字符串
|
|
|
|
|
*/
|
|
|
|
|
export 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 '';
|
2024-01-10 14:57:06 +00:00
|
|
|
|
}
|
2024-09-15 09:32:29 +00:00
|
|
|
|
// 新增将时间搓转换为开始时间-结束时间的格式
|
|
|
|
|
export function formatDateRange(startTimestamp, endTimestamp) {
|
|
|
|
|
// 定义一个辅助函数来格式化时间戳为 YYYY.MM.DD 格式
|
|
|
|
|
const formatDate = (timestamp) => {
|
|
|
|
|
const date = new Date(timestamp);
|
|
|
|
|
const year = date.getFullYear();
|
|
|
|
|
const month = String(date.getMonth() + 1).padStart(2, '0'); // 月份从0开始,所以需要+1
|
|
|
|
|
const day = String(date.getDate()).padStart(2, '0');
|
|
|
|
|
return `${year}.${month}.${day}`;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// 格式化开始和结束时间
|
|
|
|
|
const start = formatDate(startTimestamp);
|
|
|
|
|
const end = formatDate(endTimestamp);
|
|
|
|
|
|
|
|
|
|
// 返回格式化的日期范围
|
|
|
|
|
return `${start}-${end}`;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//处理活动信息
|
|
|
|
|
export function handList(orders) {
|
|
|
|
|
const typeMap = {
|
|
|
|
|
'1': '秒杀活动',
|
|
|
|
|
'2': '砍价活动',
|
|
|
|
|
'3': '拼团活动',
|
|
|
|
|
'4': '限时折扣',
|
|
|
|
|
'5': '满减送',
|
|
|
|
|
'6': '会员折扣',
|
|
|
|
|
'7': '优惠券',
|
|
|
|
|
'8': '积分'
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// 给每个订单对象添加 typeName 属性
|
|
|
|
|
let updatedOrders = orders.map(order => {
|
|
|
|
|
return {
|
|
|
|
|
...order, // 展开现有的订单对象属性
|
|
|
|
|
typeName: typeMap[order.type] // 添加 typeName 属性
|
|
|
|
|
};
|
|
|
|
|
});
|
|
|
|
|
return updatedOrders
|
|
|
|
|
};
|
|
|
|
|
//根据skuid来修改价格并添加时间
|
|
|
|
|
export function handListPrice(array,array2) {
|
|
|
|
|
// 将 array2 转换为一个以 skuId 为键的对象,以便于快速查找
|
|
|
|
|
const array2Map = array2.reduce((acc, item) => {
|
|
|
|
|
acc[item.skuId] = { price: item.price, type: item.type,endTime:item.endTime };
|
|
|
|
|
return acc;
|
|
|
|
|
}, {});
|
|
|
|
|
|
|
|
|
|
// 遍历 array 数组并更新 price 和 type
|
|
|
|
|
array.forEach(item => {
|
|
|
|
|
if (array2Map[item.id]) {
|
|
|
|
|
item.oldPrice = item.price
|
|
|
|
|
// 如果在 array2Map 中找到了对应的 skuId(即 id)
|
|
|
|
|
item.price = array2Map[item.id].price;
|
|
|
|
|
item.type = array2Map[item.id].type;
|
|
|
|
|
item.endTime = array2Map[item.id].endTime;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// 返回更新后的 array
|
|
|
|
|
return array;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
//处理活动数据
|
|
|
|
|
export function handActitList(rules) {
|
|
|
|
|
const rules2 = {
|
|
|
|
|
reduc: rules.map(item => ({
|
|
|
|
|
discountPrice: item.discountPrice,
|
|
|
|
|
limit: item.limit,
|
|
|
|
|
bull: true // 默认为 true
|
|
|
|
|
})),
|
|
|
|
|
cou: rules.map(item => ({
|
|
|
|
|
discountPrice: item.discountPrice,
|
|
|
|
|
value: item.couponCounts.reduce((acc, count) => acc + count, 0), // 计算 couponCounts 中各项之和
|
|
|
|
|
bull: item.givePoint // 对应 givePoint
|
|
|
|
|
})),
|
|
|
|
|
ship: rules.map(item => ({
|
|
|
|
|
discountPrice: item.discountPrice,
|
|
|
|
|
bull: item.freeDelivery // 对应 freeDelivery
|
|
|
|
|
})),
|
|
|
|
|
scor: rules.map(item => ({
|
|
|
|
|
discountPrice: item.discountPrice,
|
|
|
|
|
value: item.point, // 直接使用 point
|
|
|
|
|
bull: item.givePoint // 对应 givePoint
|
|
|
|
|
}))
|
|
|
|
|
};
|
|
|
|
|
return rules2
|
|
|
|
|
};
|