Authored by 李奇

删除废弃文件

... ... @@ -49,8 +49,6 @@ let logEvent = function (eventId, data, appData) {
complete: function () {
wx.getNetworkType({
success: function (res) {
// 返回网络类型, 有效值:
// wifi/2g/3g/4g/unknown(Android下不常见的网络类型)/none(无网络)
var networkType = res.networkType
if (networkType === 'wifi') {
net = '1';
... ... @@ -82,15 +80,11 @@ let logEvent = function (eventId, data, appData) {
userParam.UNION_ID = union_id;
let eventParam = [{'param': userParam, 'ts': ts, 'op': eventId, 'uid': uid, 'sid': sid}]
let parameters = {'status': statusParam, 'device': deviceParam, 'events': eventParam}
// console.log(parameters)
UPLOAD_LOG(LOG_EVENT_HOST, parameters)
.then(function (data) {
// console.log(data)
})
.catch(function (error) {
// console.log(error)
});
}
})
... ...
'use strict'
function parseActivityListData(data, bannerWidth, bannerHeight, listImageWidth, listImageHeight) {
let newData = [];
data && data.map((item, index) => {
if (index > 10) {
return;
}
item.src = item.src.replace(/{width}/g, bannerWidth).replace(/{height}/g, bannerHeight).replace('{mode}', 2);
for (var i = 0; i < item.productList.length; i++) {
item.productList[i].default_images = item.productList[i].default_images.replace(/{width}/g, listImageWidth).replace(/{height}/g, listImageHeight).replace('{mode}', 2);
}
newData.push(item);
});
return newData;
}
module.exports = {
parseActivityListData
}
'use strict'
var util = require('/util.js')
//商品详情页晒单评价需预处理的数据
function parseEvaluateListDataDetailWith(data, picWidth, picHeight, icoWidth, icoHeight, imageWidth) {
let newData = [];
if (data.length > 2) {
return newData;
}
if (data.length == 1) {
newData = data;
} else {
for (var i = 0; i < data.length; i++) {
let item = data[i];
if (i == 0 && item.url) {
newData.push(item);
break;
}
item.url = '';
newData.push(item);
}
}
return parseEvaluateListData(newData, picWidth, picHeight, icoWidth, icoHeight, imageWidth);
}
//晒单列表需处理的数据
function parseEvaluateListData(data, picWidth, picHeight, icoWidth, icoHeight, imageWidth) {
let newData = [];
data && data.map((item, index) => {
let headIco = ''; // 头像
let nickName = ''; // 昵称
let vipLevelImg = ''; // 等级
let factory_goods_name = ''; // 颜色
let size_name = ''; // 尺码
if (item.userInfo) {
nickName = getNickName(item.userInfo.nickName, item.anonymous);
headIco = item.userInfo.headIco ? item.userInfo.headIco.replace(new RegExp('{width}'), icoWidth).replace(new RegExp('{height}'), icoHeight).replace(new RegExp('{mode}'), 2) : '../userCenter/images/mine_default_head.png';
let vipLevel = item.userInfo.vipLevel;
if (vipLevel == 1) {
vipLevelImg = '../userCenter/images/yin-vip@2x.png';
} else if (vipLevel == 2) {
vipLevelImg = '../userCenter/images/jin-vip@2x.png';
} else if (vipLevel == 3) {
vipLevelImg = '../userCenter/images/baijin-vip@2x.png';
}
}
if (item.goods) {
size_name = item.goods.size_name ? '尺码: ' + item.goods.size_name : '';
factory_goods_name = item.goods.factory_goods_name ? '颜色: ' + item.goods.factory_goods_name : '';
}
let url = item.url ? item.url.replace(new RegExp('{width}'), picWidth).replace(new RegExp('{height}'), picHeight).replace(new RegExp('{mode}'), 2) : ''; //缩略图
let src = item.url ? item.url.replace(new RegExp('{width}'), imageWidth).replace(new RegExp('{height}'), imageWidth).replace(new RegExp('{mode}'), 2) : ''; //放大图
let createTime = util.formatTimeByDefined(item.createTime, 'Y.M.D');
let satisfiedArr = [];
if (item.satisfied > 0) {
for (let i = 0; i < item.satisfied; i++) {
satisfiedArr.push(i);
}
}
let sizeName = '';
if (item.size == 'SMALL') {
sizeName = '偏小';
} else if (item.size == 'MIDDLE') {
sizeName = '适中';
} else if (item.size == 'BIG') {
sizeName = '偏大';
}
let newItem = {
headIco,
nickName,
vipLevelImg,
weight: item.weight ? '体重:' + item.weight + 'kg' : '',
height: item.height ? '身高:' + item.height + 'cm' : '',
satisfied: satisfiedArr,
size: sizeName,
content: item.content,
url,
src,
createTime,
factory_goods_name,
size_name
};
newData.push(newItem);
});
return newData;
}
function getNickName(nickName, anoymous){
if (nickName == null || nickName == '') {
return '***';
}
if (!anoymous) {
if (getStrLength(nickName) <= 11) {
return nickName;
}
return subString(nickName) + '...';
} else {
if (nickName.length <= 3) {
return '***';
}
return nickName.charAt(0).toString() + '***' + nickName.charAt(nickName.length-1).toString();
}
}
//获取中英文字符串的长度
function getStrLength(value) {
let valueLength = 0;
let chinese = "[\u0391-\uFFE5]";
/* 获取字段值的长度,如果含中文字符,则每个中文字符长度为2,否则为1 */
for (let i = 0; i < value.length; i++) {
/* 获取一个字符 */
let temp = value.substring(i, i + 1);
/* 判断是否为中文字符 */
if (temp.match(chinese)) {
/* 中文字符长度为2 */
valueLength += 2;
} else {
/* 其他字符长度为1 */
valueLength += 1;
}
}
return valueLength;
}
function subString(str) {
var newLength = 0;
var newStr = "";
var chineseRegex = /[^\x00-\xff]/g;
var singleChar = "";
var strLength = str.replace(chineseRegex, "**").length;
for (var i = 0; i < strLength; i++) {
singleChar = str.charAt(i).toString();
newStr += singleChar;
if (singleChar.match(chineseRegex) != null) {
newLength += 2;
} else {
newLength++;
}
if (newLength >= 10) {
break;
}
}
return newStr;
}
module.exports = {
parseEvaluateListData,
parseEvaluateListDataDetailWith
}
\ No newline at end of file
'use strict'
function getChannelCode(channel) {
let config = {
boy: 1,
girl: 2,
child: 3,
lifestyle: 4,
};
return config[channel] ? config[channel] : config['boy'];
}
function getGenderCode(channel) {
let config = {
boy: '1,3',
girl: '2,3',
child: '',
lifestyle: '',
};
return config[channel] ? config[channel] : config['boy'];
}
function getRecPosCode(channel) {
let config = {
boy: '100001',
girl: '100002',
child: '',
lifestyle: '',
};
return config[channel] ? config[channel] : config['boy'];
}
function getRecommandContentCode(channel) {
let config = {
boy: '201504091403001',
girl: '201504091403002',
child: '201504091403002',
lifestyle: '201504091403002',
};
return config[channel] ? config[channel] : config['boy'];
}
function getResourceCode(channel){
let config = {
boy: '9cb6138be8e60c96f48107da481816c2',
girl: 'b1fa86320d3f9d9e89153129aeea1b3e',
child: 'e9875682c1599a886bfbdb965b740022',
lifestyle: '9aa25f5133f011ec96c2045eb15ae425',
};
return config[channel] ? config[channel] : config['boy'];
}
//获取首页的contentcode
function getHomeContentCode(channel){
let config = {
boy:'305e0a7a4aba32b08c6dd6dc5da47fa9',
girl:'5d9665e6a0a8ec5b2f0c126b36364d24'
}
return config[channel]?config[channel]:config['boy'];
}
module.exports = {
getChannelCode,
getGenderCode,
getRecPosCode,
getRecommandContentCode,
getResourceCode,
getHomeContentCode
}
import { getGoodDetailParam,getImageUrl } from './util';
function parseHomeList(json, windowWidth, windowHeight, listImageWidth, listImageHeight){
let newList=[];
let index = 1;
json && json.map((item,index)=>{
if (item.template_name == 'focus' || item.template_name == 'newFocus'){
//焦点图 -- 只需要对列表中的图片url进行格式化 默认宽高: 750 : 500
for(var i =0;i<item.data.length;i++){
let src = item.data[i].src;
item.data[i].src = getImageUrl(item.data[i].src,750,500);
let param = getGoodDetailParam(item.data[i].url);
if(param){
let json = JSON.parse(param);
item.data[i].title = json.title;
item.data[i]._src = json.cover_url
}
}
} else if (item.template_name == 'newSingleImage'){
//新一张图片 ratio 为 高/宽 抽取出 src title ratio
item.ratio = item.data.imageWidth <= 0 || item.data.imageHeight<=0?0: item.data.imageHeight / item.data.imageWidth
item.ratio = Math.ceil(750 * item.ratio);
item.title = item.data.title;
// if(item.title != '精彩活动' && item.title!='热门品类' && item.title !='潮流品牌'){
// item.title = '';
// }
if(item.data.list && item.data.list[0]){
item.src = getImageUrl(item.data.list[0].src, item.data.imageWidth, item.data.imageHeight)
item.url = item.data.list[0].url
}
} else if (item.template_name =='new_recommend_content_five'){
//热门品类楼层
item.title = item.data.title.title;
item.moreUrl = item.data.more.url;
item.list = item.data.list;
for(var i=0;i<item.list.length;i++){
item.list[i].src = getImageUrl(item.list[i].src, 188, 198);
}
} else if (item.template_name == '3:4ImageListFloor'){
//潮流品牌图片列表
item.title = item.data.title;
item.list = item.data.list;
for(var i=0;i<item.list.length;i++){
item.list[i].src = getImageUrl(item.list[i].src,220,220);
}
let more = item.data.more;
if(more && more.url){
item.moreUrl = more.url;
}
} else if (item.template_name == 'popularListFloor' || item.template_name == 'newProductListFloor'){
//商品列表
for(var i = 0;i<item.data.list.length;i++){
try{
item.data.list[i].default_images = item.data.list[i].default_images.replace(/{width}/g, listImageWidth).replace(/{height}/g, listImageHeight).replace('{mode}', 2);
}catch(e){
console.log('--ReplaceError--')
}
item.data.list[i].index = index;
item.data.list[i].display_type = item.data.display_type; //1显示价格2显示店铺
}
} else if (item.template_name == 'image_list') {
//商品列表
for (var i = 0; i < item.data.list.length; i++) {
try{
item.data.list[i].src = item.data.list[i].src.replace(/{width}/g, 150).replace(/{height}/g, 150).replace('{mode}', 2);
}catch(e){
console.log('--ReplaceError--')
}
}
} else if (item.template_name == 'sv_new_user_floor') {
// 新人楼层
if (item.data && item.data.banner_image && item.data.banner_image.length > 0) {
for(var i = 0;i<item.data.banner_image.length;i++){
if (item.data.banner_image[i].src) {
try{
item.data.banner_image[i].src = item.data.banner_image[i].src.replace(/{width}/g, 1500).replace(/{height}/g, 720).replace('{mode}', 2);
}catch(e){
console.log('--ReplaceError--')
}
}
}
}
}
else{
item.template_name = "undefine";
}
index++;
newList.push(item);
})
return newList;
}
export{
parseHomeList
}
\ No newline at end of file
'use strict'
function getGoodInfo(data) {
let newData = [];
let idElement = '编号: '+data.erpProductId
newData.push(idElement)
newData.push('颜色: ' + data.colorName)
let gender = ''
if (data.gender == 1) {
gender = '男款'
} else if (data.gender == 2) {
gender = '女款'
} else if (data.gender == 3) {
gender = '通用'
}
if (gender) {
newData.push('性别: ' + gender)
}
data && data.standardBos.map((item, index) => {
let newItem=item.standardName+': '+item.standardVal
newData.push(newItem);
});
return newData;
}
function getGoodSize(data) {
let titleList = ['吊牌尺码']
data && data.sizeAttributeBos.map((item, index) => {
let newItem=item.attributeName;
titleList.push(newItem);
});
let sizeList=[]
data && data.sizeBoList.map((item, index) => {
let itemList=[];
itemList.push(item.sizeName)
item.sortAttributes.map((subItem,subIndex)=>{
itemList.push(subItem.sizeValue)
})
sizeList.push(itemList)
});
return {titleList,sizeList};
}
function getGoodImages(data,listImageWidth,listImageHeight){
let imageList=[]
data && data.map((item, index) => {
item=item.image_url.replace(/{width}/g, listImageWidth).replace(/{height}/g, listImageHeight).replace('{mode}',2);
imageList.push(item);
});
return imageList;
}
function getModelList(data){
let modelList=[]
let model = {}
data&&data.map((item,index) => {
model.name = item.modelName
model.height = item.height
model.weight = item.weight
model.vital =item.vitalStatistics
model.size = item.fitModelBo.fit_size
model.feel = item.fitModelBo.feel
modelList.push(item)
});
return modelList
}
module.exports = {
getGoodInfo,
getGoodSize,
getGoodImages,
getModelList,
}
\ No newline at end of file
'use strict'
//获取应用实例
let app = getApp();
const screenHeight = app.globalData.systemInfo.screenHeight;
const windowWidth = app.globalData.systemInfo.windowWidth;
const windowHeight = app.globalData.systemInfo.windowHeight;
const DEVICE_WIDTH_RATIO = windowWidth / 320;
let listWidth = Math.ceil(137.5 * DEVICE_WIDTH_RATIO);
let listHeight = Math.ceil(254 * DEVICE_WIDTH_RATIO);
const IMAGE_WIDTH = 145;
const IMAGE_HEIGHT = 193;
const IMAGE_RATIO = IMAGE_HEIGHT / IMAGE_WIDTH;
let listImageTop = 31;
let listImageWidthDefault = listWidth;
let listImageHeightDefault = Math.ceil(listWidth * IMAGE_RATIO);
function parseBrandListData(data, listImageWidth, listImageHeight) {
let newData = [];
let imageWidth = listImageWidth ? listImageWidth : listImageWidthDefault;
let imageHeight = listImageHeight ? listImageHeight : listImageHeightDefault;
data && data.map((item, index) => {
let salePrice = 0; // 售卖价
let originPrice = 0; // 原价
let salePriceStr = ''; // 拼接的售卖价
let originPriceStr = ''; // 拼接的原价
let showOriginPrice = true; // 是否显示原价
let salePriceFixed2 = '';
let originPriceFixed2 = '';
let isGlobalProduct = item.is_global && item.is_global == 'Y'; // 是否全球购商品
if (isGlobalProduct) {
salePrice = parseFloat(item.final_price);
originPrice = parseFloat(item.orign_price);
salePriceStr = item.formart_final_price;
originPriceStr = item.formart_orign_price;
} else {
salePrice = parseFloat(item.sales_price);
originPrice = parseFloat(item.market_price);
salePriceStr = '¥' + salePrice.toFixed(2);
originPriceStr = '¥' + originPrice.toFixed(2);
salePriceFixed2 = salePrice.toFixed(2);
originPriceFixed2 = originPrice.toFixed(2);
}
if (!originPrice || (salePrice == originPrice)) {
showOriginPrice = false;
}
item.showOriginPrice = showOriginPrice;
item.salePriceStr = salePriceStr;
item.originPriceStr = originPriceStr;
item.salePriceFixed2 = salePriceFixed2;
item.originPriceFixed2 = originPriceFixed2;
let default_images = item.default_images.replace(/{width}/g, imageWidth*2).replace(/{height}/g, imageHeight*2).replace('{mode}',2);
let shop_id = item.shop_id;
let shop_name = item.shop_name;
let newItem = {
product_skn: item.product_skn,
default_images,
product_name: item.product_name,
showOriginPrice,
shop_id,
shop_name,
salePriceStr,
originPriceStr,
originPriceFixed2,
salePriceFixed2,
is_shop_cart_add: item.is_shop_cart_add,//是否应该展示右侧的加入购物车按钮 默认不展示
};
newData.push(newItem);
});
return newData;
}
function cancelFilterSelectState(filters, exceptKey) {
let newFilters = {};
for (let itemKey in filters) {
if (filters.hasOwnProperty(itemKey)) {
if (itemKey != exceptKey) {
let newFilter = filters[itemKey];
newFilter.selected = false;
newFilters[itemKey] = newFilter;
}
}
}
return newFilters;
}
module.exports = {
parseBrandListData,
cancelFilterSelectState,
}
'use strict'
import { getImageUrlWithWH } from './util';
function toDecimal2(x) {
var f = parseFloat(x);
if (isNaN(f)) {
return false;
}
var f = Math.round(x * 100) / 100;
var s = f.toString();
var rs = s.indexOf('.');
if (rs < 0) {
rs = s.length;
s += '.';
}
while (s.length <= rs + 2) {
s += '0';
}
return s;
}
function processGiftOrPriceGift(giftList, isGift) {
let selledOutGiftTypeCount = 0;
giftList.map((item, index) => {
let statusString = "";
if (item.status == 0) {
statusString = "去凑单";
} else if (item.status == 10) {
if (item.promotion_type == "Gift") {//Cashreduce,Degressdiscount,Cheapestfree,Discount,Gift,Needpaygift,SpecifiedAmount
statusString = "领赠品";
} else if (item.promotion_type == "Needpaygift") {
statusString = "去换购";
}
} else if (item.status == 20) {
selledOutGiftTypeCount++;
statusString = "已抢光";
} else if (item.status == 30) {
statusString = "更换";
}
item.statusString = statusString;
item.isGift = isGift;
});
if (selledOutGiftTypeCount == giftList.height) {
giftList.map((item, index) => {
item.statusString = "已抢光";
});
};
return giftList;
}
function processGoodsItem(goodsItem) {
let imagesUrl = getImageUrlWithWH(goodsItem.goods_images, 75, 100);
goodsItem.goods_images = imagesUrl;
goodsItem.goodColorSizeString = "颜色:" + goodsItem.factory_goods_name + " " + "尺码:" + goodsItem.size_name;
let isShowOldPrice = true;
let priceString = '';
let shoppingProductType = goodsItem.goods_type;
if (shoppingProductType == 'price_gift') {
priceString = goodsItem.last_price;
} else if (shoppingProductType == 'gift') {
priceString = '0.00';
} else {
if (goodsItem.last_vip_price < goodsItem.sales_price) {
priceString = goodsItem.last_vip_price;
} else {
priceString = goodsItem.sales_price;
}
isShowOldPrice = false;
}
priceString = '¥' + toDecimal2(priceString);
let oldPricString = goodsItem.sales_price;
oldPricString = '¥' + toDecimal2(oldPricString);
if (goodsItem.price_down > 0) {
goodsItem.price_down = toDecimal2(goodsItem.price_down);
}
if (parseInt(goodsItem.buy_number) > parseInt(goodsItem.storage_number)) {
goodsItem.bLackStorage = true;
}
if (goodsItem.selected == "Y") {
goodsItem.bSelected = true;
}
goodsItem.priceString = priceString;
goodsItem.oldPricString = oldPricString;
goodsItem.isShowOldPrice = isShowOldPrice;
var unique_identifier = goodsItem.product_sku + goodsItem.batch_no.toString() + goodsItem.bundle_activity_id.toString();
goodsItem.unique_identifier = unique_identifier;
return goodsItem;
}
function isGoodsSelectAll(goodsList) {
if (!goodsList || !goodsList.length) {
return false;
}
let allGoodsSelect = true;
goodsList.map((goodsItem, index) => {
if (!goodsItem.bLackStorage && goodsItem.goods_type !== 'gift') {
if (goodsItem.selected !== 'Y') {
allGoodsSelect = false;
}
}
});
return allGoodsSelect;
}
function processPromotionItem(promotionItem, isSubPromotion) {
let promotionStatusString = "";
if (promotionItem.status == 0) {
promotionStatusString = "去凑单";
} else if (promotionItem.status == 10) {
if (promotionItem.promotion_type == "Gift") {//Cashreduce,Degressdiscount,Cheapestfree,Discount,Gift,Needpaygift,SpecifiedAmount
promotionStatusString = "领赠品";
} else if (promotionItem.promotion_type == "Needpaygift") {
promotionStatusString = "去换购";
}
} else if (promotionItem.status == 20) {
promotionStatusString = "已抢光";
} else if (promotionItem.status == 30) {
promotionStatusString = "更换";
}
if (promotionStatusString == "已抢光") {
promotionItem.seldoutStyle = true;
}
promotionItem.statuString = promotionStatusString;
if (isSubPromotion) {
let typeString = '';
if (promotionItem.promotion_type == "Gift") {
typeString = '赠品';
} else if (promotionItem.promotion_type == 'Needpaygift') {
typeString = '加价购';
} else if (promotionItem.promotion_type == 'Cashreduce') {
typeString = '满减';
} else {
typeString = '折扣';
}
promotionItem.typeString = typeString;
}
return promotionItem;
}
function curShoppingCartDataAddExpandedFlag(curShoppingCartData) {
let goodsList = curShoppingCartData.goods_list;
let validGoodsList = [];
if (goodsList) {
goodsList.map((goodsItem, index) => {
goodsItem = processGoodsItem(goodsItem);
validGoodsList.push(goodsItem);
})
}
curShoppingCartData.goods_list = goodsList;
let goodsPoolList = curShoppingCartData.goods_pool_list;
if (goodsPoolList) {
goodsPoolList.map((item, index) => {
if (item.pool_batch_no && item.pool_id) {
//套餐商品参数转换
item.int_pool_buy_number = parseInt(item.pool_buy_number);
item.int_pool_storage_number = parseInt(item.pool_storage_number);
}
let goodsPoolGoodsList = item.goods_list;
if (goodsPoolGoodsList) {
goodsPoolGoodsList.map((goodsItem, index) => {
goodsItem = processGoodsItem(goodsItem);
validGoodsList.push(goodsItem);
})
}
item.isPromotionExpanded = false;
let promotionList = item.promotion_list;
if (promotionList) {
promotionList.map((promotionItem, promotionIndex) => {
promotionItem = processPromotionItem(promotionItem, false);
})
item.promotion_list = promotionList;
}
let subPool = item.sub_pool;
if (subPool) {
subPool.map((subPoolItem, index) => {
let promotionList = subPoolItem.promotion_list;
if (promotionList) {
promotionList.map((promotionItem, promotionIndex) => {
promotionItem = processPromotionItem(promotionItem, true);
})
subPoolItem.promotion_list = promotionList;
}
let subPoolGoodsList = subPoolItem.goods_list;
if (subPoolGoodsList) {
subPoolGoodsList.map((subPoolGoodsItem, index) => {
subPoolGoodsItem = processGoodsItem(subPoolGoodsItem);
validGoodsList.push(subPoolGoodsItem);
})
}
})
}
item.sub_pool = subPool;
});
}
curShoppingCartData.validGoodsList = validGoodsList;
curShoppingCartData.isValidGoodsSelectAll = isGoodsSelectAll(validGoodsList);
// let newgPriceGiftList = [];
let gPriceGiftList = curShoppingCartData.g_price_gift_list;
// if (gPriceGiftList && gPriceGiftList.length && canShowGiftEntrance(gPriceGiftList)) {
// newgPriceGiftList = processGiftOrPriceGift(gPriceGiftList, false);
// }
// curShoppingCartData.g_price_gift_list = newgPriceGiftList;
// let newgGiftList = [];
let gGiftList = curShoppingCartData.g_gift_list;
// if (gGiftList && gGiftList.length && canShowGiftEntrance(gGiftList)) {
// newgGiftList = processGiftOrPriceGift(gGiftList, true);
// }
// curShoppingCartData.g_gift_list = newgGiftList;
let gGiftAndPriceGiftList = [];
if (gGiftList && gGiftList.length) {
let giftItem = transformToGiftModelWithGiftList(gGiftList,true);
if (giftItem.canShow) {
gGiftAndPriceGiftList.push(giftItem);
}
}
if (gPriceGiftList && gPriceGiftList.length) {
let priceGiftItem = transformToGiftModelWithGiftList(gPriceGiftList,false);
if (priceGiftItem.canShow) {
gGiftAndPriceGiftList.push(priceGiftItem);
}
}
// if (newgPriceGiftList.length && newgGiftList.length) {
// gGiftAndPriceGiftList = [newgGiftList[0], newgPriceGiftList[0]];
// } else if (newgPriceGiftList.length) {
// gGiftAndPriceGiftList = [newgPriceGiftList[0]];
// } else if (newgGiftList.length) {
// gGiftAndPriceGiftList = [newgGiftList[0]];
// }
curShoppingCartData.gGiftAndPriceGiftList = gGiftAndPriceGiftList;
//失效商品
let offShelvesGoodsList = curShoppingCartData.off_shelves_goods_list;
let soldOutGoodsList = curShoppingCartData.sold_out_goods_list;
let invalidGoodsList = [...offShelvesGoodsList, ...soldOutGoodsList];
if (invalidGoodsList && invalidGoodsList.length) {
invalidGoodsList.map((invalidGoodsItem, index) => {
let imagesUrl = getImageUrlWithWH(invalidGoodsItem.goods_images, 75, 100);;
invalidGoodsItem.goods_images = imagesUrl;
})
}
let last_order_amount = curShoppingCartData.shopping_cart_data.last_order_amount;
last_order_amount = '¥' + toDecimal2(last_order_amount);
curShoppingCartData.shopping_cart_data.last_order_amount = last_order_amount;
curShoppingCartData.invalidGoodsList = invalidGoodsList;
let has_product_in_shop_cart = (curShoppingCartData.goods_list.length + curShoppingCartData.goods_pool_list.length + curShoppingCartData.off_shelves_goods_list.length + curShoppingCartData.sold_out_goods_list.length > 0);
curShoppingCartData.has_product_in_shop_cart = has_product_in_shop_cart;
return curShoppingCartData;
}
function canShowGiftEntrance(items) {
let result = false;
let statusCount_10 = 0;//已满足
let statusCount_20 = 0;//已售罄
items.map((item, index) => {
if (item.status == 10) {
statusCount_10++;
} else if (item.status == 20) {
statusCount_20++;
}
});
if (statusCount_10 > 0 || (items.length > 0 && statusCount_20 == items.length)) {
result = true;
}
return result;
}
function transformToGiftModelWithGiftList(list,isGift) {
let resultItem = {};
resultItem.isGift = isGift;
resultItem.title = isGift ? '赠品' : '全场加价购';
let promotion_ids = '';
list.map((item, index) => {
if (item.status == 10) {
promotion_ids = promotion_ids + (promotion_ids.length == 0 ? '' : ',') + item.promotion_id;
}
});
resultItem.promotion_ids = promotion_ids;
if (promotion_ids.length > 0) {
if (isGift) {
resultItem.statusString = '领赠品';
} else {
resultItem.statusString = '去换购';
}
resultItem.showArrow = true;
} else {
resultItem.statusString = '已抢光';
resultItem.showArrow = false;
}
resultItem.canShow = canShowGiftEntrance(list);
return resultItem;
}
function curPageDataAllSelectWhenEditing(curShoppingCartData,allSelect) {
let goodsList = curShoppingCartData.goods_list;
let validGoodsList = [];
if (goodsList) {
goodsList.map((goodsItem, index) => {
goodsItem = processGoodsItem(goodsItem);
if(allSelect){
goodsItem.selected = 'Y';
goodsItem.bSelected = true;
}else {
goodsItem.selected = 'N';
goodsItem.bSelected = false;
}
})
}
let goodsPoolList = curShoppingCartData.goods_pool_list;
if (goodsPoolList) {
goodsPoolList.map((item, index) => {
if (item.pool_type == '3' && item.pool_batch_no) {
item.selected = allSelect ? 'Y' : 'N';
}
let goodsPoolGoodsList = item.goods_list;
if (goodsPoolGoodsList) {
goodsPoolGoodsList.map((goodsItem, index) => {
goodsItem = processGoodsItem(goodsItem);
if (allSelect) {
goodsItem.selected = 'Y';
goodsItem.bSelected = true;
} else {
goodsItem.selected = 'N';
goodsItem.bSelected = false;
}
})
}
let subPool = item.sub_pool;
if (subPool) {
subPool.map((subPoolItem, index) => {
let subPoolGoodsList = subPoolItem.goods_list;
if (subPoolGoodsList) {
subPoolGoodsList.map((subPoolGoodsItem, index) => {
subPoolGoodsItem = processGoodsItem(subPoolGoodsItem);
if (allSelect) {
subPoolGoodsItem.selected = 'Y';
subPoolGoodsItem.bSelected = true;
} else {
subPoolGoodsItem.selected = 'N';
subPoolGoodsItem.bSelected = false;
}
})
}
})
}
item.sub_pool = subPool;
});
}
return curShoppingCartData;
}
function curPageDataSingleSelectWhenEditing(curShoppingCartData, selectItem) {
let isValidGoodsSelectAll = true;
let goodsList = curShoppingCartData.goods_list;
let validGoodsList = [];
if (goodsList) {
goodsList.map((goodsItem, index) => {
goodsItem = processGoodsItem(goodsItem);
if (goodsItem.unique_identifier == selectItem.unique_identifier) {
if (goodsItem.selected == 'Y'){
goodsItem.selected = 'N';
goodsItem.bSelected = false;
}else {
goodsItem.selected = 'Y';
goodsItem.bSelected = true;
}
}
if (isValidGoodsSelectAll && (!goodsItem.bSelected)) {
isValidGoodsSelectAll = false;
}
})
}
curShoppingCartData.goods_list = goodsList;
let goodsPoolList = curShoppingCartData.goods_pool_list;
if (goodsPoolList) {
goodsPoolList.map((item, index) => {
let goodsPoolGoodsList = item.goods_list;
if (goodsPoolGoodsList) {
goodsPoolGoodsList.map((goodsItem, index) => {
goodsItem = processGoodsItem(goodsItem);
if (goodsItem.unique_identifier == selectItem.unique_identifier) {
if (goodsItem.selected == 'Y') {
goodsItem.selected = 'N';
goodsItem.bSelected = false;
} else {
goodsItem.selected = 'Y';
goodsItem.bSelected = true;
}
}
if (isValidGoodsSelectAll && (!goodsItem.bSelected)) {
isValidGoodsSelectAll = false;
}
})
}
let subPool = item.sub_pool;
if (subPool) {
subPool.map((subPoolItem, index) => {
let subPoolGoodsList = subPoolItem.goods_list;
if (subPoolGoodsList) {
subPoolGoodsList.map((subPoolGoodsItem, index) => {
subPoolGoodsItem = processGoodsItem(subPoolGoodsItem);
if (subPoolGoodsItem.unique_identifier == selectItem.unique_identifier) {
if (subPoolGoodsItem.selected == 'Y') {
subPoolGoodsItem.selected = 'N';
subPoolGoodsItem.bSelected = false;
} else {
subPoolGoodsItem.selected = 'Y';
subPoolGoodsItem.bSelected = true;
}
}
if (isValidGoodsSelectAll && (!subPoolGoodsItem.bSelected)) {
isValidGoodsSelectAll = false;
}
})
}
})
}
item.sub_pool = subPool;
});
curShoppingCartData.goods_pool_list = goodsPoolList;
}
curShoppingCartData.isValidGoodsSelectAll = isValidGoodsSelectAll;
return curShoppingCartData;
}
function curPageDataSingleSelectBundleProductWhenEditing(curShoppingCartData, selectBundleItem) {
if (curShoppingCartData.goods_pool_list) {
curShoppingCartData.goods_pool_list.map((item, index) => {
if (item.pool_type == 3 && item.pool_batch_no) {
item.selected = selectBundleItem.selected;
let goodsPoolGoodsList = item.goods_list;
if (goodsPoolGoodsList) {
goodsPoolGoodsList.map((goodsItem, index) => {
goodsItem = processGoodsItem(goodsItem);
if (item.selected == 'Y') {
goodsItem.selected = 'Y';
goodsItem.bSelected = true;
} else {
goodsItem.selected = 'N';
goodsItem.bSelected = false;
}
})
}
}
});
}
return curShoppingCartData;
}
function editInfoDicFromGoodsList(goodsList, isSelectAll){
if (!goodsList || !goodsList.length) {
return [];
}
let editInfoDicArray = [];
goodsList.map((goodsItem, index) => {
if (!goodsItem.bLackStorage && goodsItem.goods_type !== 'gift') {
editInfoDicArray.push({
buy_number: goodsItem.buy_number ? goodsItem.buy_number : 0,
goods_type: goodsItem.goods_type ? goodsItem.goods_type : "",
product_sku: goodsItem.product_sku ? goodsItem.product_sku : "",
promotion_id: goodsItem.promotion_id ? goodsItem.promotion_id : 0,
selected: isSelectAll ? "Y" : "N",
activity_id: goodsItem.bundle_activity_id ? goodsItem.bundle_activity_id : 0,
batch_no: goodsItem.batch_no ? goodsItem.batch_no : 0,
})
}
});
return editInfoDicArray;
}
function editInfoDicFromBundleItem(bundleItem) {
if (!bundleItem || !bundleItem.goods_list.length) {
return [];
}
let editInfoDicArray = [];
bundleItem.goods_list.map((goodsItem, index) => {
editInfoDicArray.push({
buy_number: goodsItem.buy_number ? goodsItem.buy_number : 0,
goods_type: goodsItem.goods_type ? goodsItem.goods_type : "",
product_sku: goodsItem.product_sku ? goodsItem.product_sku : "",
promotion_id: goodsItem.promotion_id ? goodsItem.promotion_id : 0,
selected: bundleItem.selected,
activity_id: goodsItem.bundle_activity_id ? goodsItem.bundle_activity_id : 0,
batch_no: goodsItem.batch_no ? goodsItem.batch_no : 0,
})
});
return editInfoDicArray;
}
function editInfoSelectedGoodsList(goodsList) {
if (!goodsList || !goodsList.length) {
return [];
}
let editInfoDicArray = [];
goodsList.map((goodsItem, index) => {
if (!goodsItem.bLackStorage && goodsItem.goods_type !== 'gift') {
if (goodsItem.selected == 'Y') {
editInfoDicArray.push({
buy_number: goodsItem.buy_number ? goodsItem.buy_number : 0,
goods_type: goodsItem.goods_type ? goodsItem.goods_type : "",
product_sku: goodsItem.product_sku ? goodsItem.product_sku : "",
promotion_id: goodsItem.promotion_id ? goodsItem.promotion_id : 0,
selected: "Y",
activity_id: goodsItem.bundle_activity_id ? goodsItem.bundle_activity_id : 0,
batch_no: goodsItem.batch_no ? goodsItem.batch_no : 0,
})
}
}
});
return editInfoDicArray;
}
function editInfoOfAllGoods(goodsList) {
if (!goodsList || !goodsList.length) {
return [];
}
let editInfoDicArray = [];
goodsList.map((goodsItem, index) => {
editInfoDicArray.push({
buy_number: goodsItem.buy_number ? goodsItem.buy_number:0,
goods_type: goodsItem.goods_type ? goodsItem.goods_type:"",
product_sku: goodsItem.product_sku ? goodsItem.product_sku:"",
promotion_id: goodsItem.promotion_id ? goodsItem.promotion_id:0,
selected: goodsItem.selected,
activity_id: goodsItem.bundle_activity_id ? goodsItem.bundle_activity_id:0,
batch_no: goodsItem.batch_no ? goodsItem.batch_no:0,
})
});
return editInfoDicArray;
}
function hasLackStorageGoodsInList(goodsList) {
if (!goodsList || !goodsList.length) {
return false;
}
let hasLackStorageGoods = false;
goodsList.map((goodsItem, index) => {
if (goodsItem.bLackStorage) {
hasLackStorageGoods = true;
}
});
return hasLackStorageGoods;
}
module.exports = {
curShoppingCartDataAddExpandedFlag,
editInfoDicFromGoodsList,
hasLackStorageGoodsInList,
curPageDataAllSelectWhenEditing,
curPageDataSingleSelectWhenEditing,
editInfoOfAllGoods,
editInfoSelectedGoodsList,
curPageDataSingleSelectBundleProductWhenEditing,
editInfoDicFromBundleItem,
}
\ No newline at end of file