Authored by runner

discount bug update

... ... @@ -30,6 +30,20 @@ const dateFormate = (str) =>{
return y + '年' + m + '月' + d + '日' + h + '时';
};
const transDiscountToArr = (discount) => {
return discount.replace(/(?:\d+[.\d]?)([\u4e00-\u9fa5]{1})/g, function(fullMatch, capture) {
if(capture) {
const arr = [];
arr.push(fullMatch.replace(capture,''));
arr.push(capture);
return arr;
} else {
return fullMatch;
}
}).split(',');
}
const getOutletResource = (channel, contentcode) => {
const params = {
content_code: contentcode || 'c19ffa03f053f4cac3690b22c8da26b7',
... ... @@ -93,11 +107,11 @@ const convertActicityData = (data) => {
_.forEach(data, (item) => {
discountArr = item.promotionName.split('~');
if (discountArr.length === 1) {
discountNum = discountArr[0].replace(/[^0-9]/g, '');
discountText = discountArr[0].replace(/[0-9]/g, '');
discountNum = transDiscountToArr(discountArr[0])[0];
discountText = transDiscountToArr(discountArr[0])[1];
} else {
discountNum = discountArr[0] + '~' + discountArr[1].replace(/[^0-9]/g, '');
discountText = discountArr[1].replace(/[0-9]/g, '');
discountNum = discountArr[0] + '~' + transDiscountToArr(discountArr[1])[0];
discountText = transDiscountToArr(discountArr[1])[1];
}
formatData.push({
... ...