Showing
8 changed files
with
0 additions
and
1122 deletions
@@ -49,8 +49,6 @@ let logEvent = function (eventId, data, appData) { | @@ -49,8 +49,6 @@ let logEvent = function (eventId, data, appData) { | ||
49 | complete: function () { | 49 | complete: function () { |
50 | wx.getNetworkType({ | 50 | wx.getNetworkType({ |
51 | success: function (res) { | 51 | success: function (res) { |
52 | - // 返回网络类型, 有效值: | ||
53 | - // wifi/2g/3g/4g/unknown(Android下不常见的网络类型)/none(无网络) | ||
54 | var networkType = res.networkType | 52 | var networkType = res.networkType |
55 | if (networkType === 'wifi') { | 53 | if (networkType === 'wifi') { |
56 | net = '1'; | 54 | net = '1'; |
@@ -82,15 +80,11 @@ let logEvent = function (eventId, data, appData) { | @@ -82,15 +80,11 @@ let logEvent = function (eventId, data, appData) { | ||
82 | userParam.UNION_ID = union_id; | 80 | userParam.UNION_ID = union_id; |
83 | let eventParam = [{'param': userParam, 'ts': ts, 'op': eventId, 'uid': uid, 'sid': sid}] | 81 | let eventParam = [{'param': userParam, 'ts': ts, 'op': eventId, 'uid': uid, 'sid': sid}] |
84 | let parameters = {'status': statusParam, 'device': deviceParam, 'events': eventParam} | 82 | let parameters = {'status': statusParam, 'device': deviceParam, 'events': eventParam} |
85 | - // console.log(parameters) | ||
86 | 83 | ||
87 | UPLOAD_LOG(LOG_EVENT_HOST, parameters) | 84 | UPLOAD_LOG(LOG_EVENT_HOST, parameters) |
88 | .then(function (data) { | 85 | .then(function (data) { |
89 | - // console.log(data) | ||
90 | }) | 86 | }) |
91 | .catch(function (error) { | 87 | .catch(function (error) { |
92 | - // console.log(error) | ||
93 | - | ||
94 | }); | 88 | }); |
95 | } | 89 | } |
96 | }) | 90 | }) |
utils/activityList.js
deleted
100644 → 0
1 | -'use strict' | ||
2 | - | ||
3 | -function parseActivityListData(data, bannerWidth, bannerHeight, listImageWidth, listImageHeight) { | ||
4 | - let newData = []; | ||
5 | - data && data.map((item, index) => { | ||
6 | - if (index > 10) { | ||
7 | - return; | ||
8 | - } | ||
9 | - item.src = item.src.replace(/{width}/g, bannerWidth).replace(/{height}/g, bannerHeight).replace('{mode}', 2); | ||
10 | - | ||
11 | - | ||
12 | - for (var i = 0; i < item.productList.length; i++) { | ||
13 | - item.productList[i].default_images = item.productList[i].default_images.replace(/{width}/g, listImageWidth).replace(/{height}/g, listImageHeight).replace('{mode}', 2); | ||
14 | - | ||
15 | - } | ||
16 | - | ||
17 | - newData.push(item); | ||
18 | - }); | ||
19 | - | ||
20 | - return newData; | ||
21 | -} | ||
22 | - | ||
23 | -module.exports = { | ||
24 | - parseActivityListData | ||
25 | -} |
utils/evaluateList.js
deleted
100644 → 0
1 | -'use strict' | ||
2 | -var util = require('/util.js') | ||
3 | - | ||
4 | -//商品详情页晒单评价需预处理的数据 | ||
5 | -function parseEvaluateListDataDetailWith(data, picWidth, picHeight, icoWidth, icoHeight, imageWidth) { | ||
6 | - let newData = []; | ||
7 | - if (data.length > 2) { | ||
8 | - return newData; | ||
9 | - } | ||
10 | - if (data.length == 1) { | ||
11 | - newData = data; | ||
12 | - } else { | ||
13 | - for (var i = 0; i < data.length; i++) { | ||
14 | - let item = data[i]; | ||
15 | - if (i == 0 && item.url) { | ||
16 | - newData.push(item); | ||
17 | - break; | ||
18 | - } | ||
19 | - item.url = ''; | ||
20 | - newData.push(item); | ||
21 | - } | ||
22 | - } | ||
23 | - return parseEvaluateListData(newData, picWidth, picHeight, icoWidth, icoHeight, imageWidth); | ||
24 | -} | ||
25 | - | ||
26 | -//晒单列表需处理的数据 | ||
27 | -function parseEvaluateListData(data, picWidth, picHeight, icoWidth, icoHeight, imageWidth) { | ||
28 | - let newData = []; | ||
29 | - data && data.map((item, index) => { | ||
30 | - let headIco = ''; // 头像 | ||
31 | - let nickName = ''; // 昵称 | ||
32 | - let vipLevelImg = ''; // 等级 | ||
33 | - let factory_goods_name = ''; // 颜色 | ||
34 | - let size_name = ''; // 尺码 | ||
35 | - | ||
36 | - if (item.userInfo) { | ||
37 | - nickName = getNickName(item.userInfo.nickName, item.anonymous); | ||
38 | - 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'; | ||
39 | - let vipLevel = item.userInfo.vipLevel; | ||
40 | - if (vipLevel == 1) { | ||
41 | - vipLevelImg = '../userCenter/images/yin-vip@2x.png'; | ||
42 | - } else if (vipLevel == 2) { | ||
43 | - vipLevelImg = '../userCenter/images/jin-vip@2x.png'; | ||
44 | - } else if (vipLevel == 3) { | ||
45 | - vipLevelImg = '../userCenter/images/baijin-vip@2x.png'; | ||
46 | - } | ||
47 | - } | ||
48 | - | ||
49 | - if (item.goods) { | ||
50 | - size_name = item.goods.size_name ? '尺码: ' + item.goods.size_name : ''; | ||
51 | - factory_goods_name = item.goods.factory_goods_name ? '颜色: ' + item.goods.factory_goods_name : ''; | ||
52 | - } | ||
53 | - | ||
54 | - let url = item.url ? item.url.replace(new RegExp('{width}'), picWidth).replace(new RegExp('{height}'), picHeight).replace(new RegExp('{mode}'), 2) : ''; //缩略图 | ||
55 | - let src = item.url ? item.url.replace(new RegExp('{width}'), imageWidth).replace(new RegExp('{height}'), imageWidth).replace(new RegExp('{mode}'), 2) : ''; //放大图 | ||
56 | - let createTime = util.formatTimeByDefined(item.createTime, 'Y.M.D'); | ||
57 | - let satisfiedArr = []; | ||
58 | - if (item.satisfied > 0) { | ||
59 | - for (let i = 0; i < item.satisfied; i++) { | ||
60 | - satisfiedArr.push(i); | ||
61 | - } | ||
62 | - } | ||
63 | - | ||
64 | - let sizeName = ''; | ||
65 | - if (item.size == 'SMALL') { | ||
66 | - sizeName = '偏小'; | ||
67 | - } else if (item.size == 'MIDDLE') { | ||
68 | - sizeName = '适中'; | ||
69 | - } else if (item.size == 'BIG') { | ||
70 | - sizeName = '偏大'; | ||
71 | - } | ||
72 | - | ||
73 | - let newItem = { | ||
74 | - headIco, | ||
75 | - nickName, | ||
76 | - vipLevelImg, | ||
77 | - weight: item.weight ? '体重:' + item.weight + 'kg' : '', | ||
78 | - height: item.height ? '身高:' + item.height + 'cm' : '', | ||
79 | - satisfied: satisfiedArr, | ||
80 | - size: sizeName, | ||
81 | - content: item.content, | ||
82 | - url, | ||
83 | - src, | ||
84 | - createTime, | ||
85 | - factory_goods_name, | ||
86 | - size_name | ||
87 | - }; | ||
88 | - newData.push(newItem); | ||
89 | - }); | ||
90 | - | ||
91 | - return newData; | ||
92 | -} | ||
93 | - | ||
94 | -function getNickName(nickName, anoymous){ | ||
95 | - if (nickName == null || nickName == '') { | ||
96 | - return '***'; | ||
97 | - } | ||
98 | - if (!anoymous) { | ||
99 | - if (getStrLength(nickName) <= 11) { | ||
100 | - return nickName; | ||
101 | - } | ||
102 | - return subString(nickName) + '...'; | ||
103 | - } else { | ||
104 | - if (nickName.length <= 3) { | ||
105 | - return '***'; | ||
106 | - } | ||
107 | - return nickName.charAt(0).toString() + '***' + nickName.charAt(nickName.length-1).toString(); | ||
108 | - } | ||
109 | -} | ||
110 | - | ||
111 | -//获取中英文字符串的长度 | ||
112 | -function getStrLength(value) { | ||
113 | - let valueLength = 0; | ||
114 | - let chinese = "[\u0391-\uFFE5]"; | ||
115 | - /* 获取字段值的长度,如果含中文字符,则每个中文字符长度为2,否则为1 */ | ||
116 | - for (let i = 0; i < value.length; i++) { | ||
117 | - /* 获取一个字符 */ | ||
118 | - let temp = value.substring(i, i + 1); | ||
119 | - /* 判断是否为中文字符 */ | ||
120 | - if (temp.match(chinese)) { | ||
121 | - /* 中文字符长度为2 */ | ||
122 | - valueLength += 2; | ||
123 | - } else { | ||
124 | - /* 其他字符长度为1 */ | ||
125 | - valueLength += 1; | ||
126 | - } | ||
127 | - } | ||
128 | - return valueLength; | ||
129 | -} | ||
130 | - | ||
131 | -function subString(str) { | ||
132 | - var newLength = 0; | ||
133 | - var newStr = ""; | ||
134 | - var chineseRegex = /[^\x00-\xff]/g; | ||
135 | - var singleChar = ""; | ||
136 | - var strLength = str.replace(chineseRegex, "**").length; | ||
137 | - for (var i = 0; i < strLength; i++) { | ||
138 | - singleChar = str.charAt(i).toString(); | ||
139 | - newStr += singleChar; | ||
140 | - if (singleChar.match(chineseRegex) != null) { | ||
141 | - newLength += 2; | ||
142 | - } else { | ||
143 | - newLength++; | ||
144 | - } | ||
145 | - if (newLength >= 10) { | ||
146 | - break; | ||
147 | - } | ||
148 | - } | ||
149 | - return newStr; | ||
150 | -} | ||
151 | - | ||
152 | -module.exports = { | ||
153 | - parseEvaluateListData, | ||
154 | - parseEvaluateListDataDetailWith | ||
155 | -} |
utils/home.js
deleted
100644 → 0
1 | -'use strict' | ||
2 | - | ||
3 | -function getChannelCode(channel) { | ||
4 | - let config = { | ||
5 | - boy: 1, | ||
6 | - girl: 2, | ||
7 | - child: 3, | ||
8 | - lifestyle: 4, | ||
9 | - }; | ||
10 | - | ||
11 | - return config[channel] ? config[channel] : config['boy']; | ||
12 | -} | ||
13 | - | ||
14 | - | ||
15 | -function getGenderCode(channel) { | ||
16 | - let config = { | ||
17 | - boy: '1,3', | ||
18 | - girl: '2,3', | ||
19 | - child: '', | ||
20 | - lifestyle: '', | ||
21 | - }; | ||
22 | - | ||
23 | - return config[channel] ? config[channel] : config['boy']; | ||
24 | -} | ||
25 | - | ||
26 | - | ||
27 | -function getRecPosCode(channel) { | ||
28 | - let config = { | ||
29 | - boy: '100001', | ||
30 | - girl: '100002', | ||
31 | - child: '', | ||
32 | - lifestyle: '', | ||
33 | - }; | ||
34 | - | ||
35 | - return config[channel] ? config[channel] : config['boy']; | ||
36 | -} | ||
37 | - | ||
38 | - | ||
39 | -function getRecommandContentCode(channel) { | ||
40 | - let config = { | ||
41 | - boy: '201504091403001', | ||
42 | - girl: '201504091403002', | ||
43 | - child: '201504091403002', | ||
44 | - lifestyle: '201504091403002', | ||
45 | - }; | ||
46 | - | ||
47 | - return config[channel] ? config[channel] : config['boy']; | ||
48 | -} | ||
49 | - | ||
50 | -function getResourceCode(channel){ | ||
51 | - let config = { | ||
52 | - boy: '9cb6138be8e60c96f48107da481816c2', | ||
53 | - girl: 'b1fa86320d3f9d9e89153129aeea1b3e', | ||
54 | - child: 'e9875682c1599a886bfbdb965b740022', | ||
55 | - lifestyle: '9aa25f5133f011ec96c2045eb15ae425', | ||
56 | - }; | ||
57 | - return config[channel] ? config[channel] : config['boy']; | ||
58 | -} | ||
59 | - | ||
60 | -//获取首页的contentcode | ||
61 | -function getHomeContentCode(channel){ | ||
62 | - let config = { | ||
63 | - boy:'305e0a7a4aba32b08c6dd6dc5da47fa9', | ||
64 | - girl:'5d9665e6a0a8ec5b2f0c126b36364d24' | ||
65 | - } | ||
66 | - return config[channel]?config[channel]:config['boy']; | ||
67 | -} | ||
68 | -module.exports = { | ||
69 | - getChannelCode, | ||
70 | - getGenderCode, | ||
71 | - getRecPosCode, | ||
72 | - getRecommandContentCode, | ||
73 | - getResourceCode, | ||
74 | - getHomeContentCode | ||
75 | -} |
utils/newHome.js
deleted
100644 → 0
1 | -import { getGoodDetailParam,getImageUrl } from './util'; | ||
2 | -function parseHomeList(json, windowWidth, windowHeight, listImageWidth, listImageHeight){ | ||
3 | - let newList=[]; | ||
4 | - let index = 1; | ||
5 | - json && json.map((item,index)=>{ | ||
6 | - if (item.template_name == 'focus' || item.template_name == 'newFocus'){ | ||
7 | - //焦点图 -- 只需要对列表中的图片url进行格式化 默认宽高: 750 : 500 | ||
8 | - for(var i =0;i<item.data.length;i++){ | ||
9 | - let src = item.data[i].src; | ||
10 | - item.data[i].src = getImageUrl(item.data[i].src,750,500); | ||
11 | - let param = getGoodDetailParam(item.data[i].url); | ||
12 | - if(param){ | ||
13 | - let json = JSON.parse(param); | ||
14 | - item.data[i].title = json.title; | ||
15 | - item.data[i]._src = json.cover_url | ||
16 | - } | ||
17 | - } | ||
18 | - } else if (item.template_name == 'newSingleImage'){ | ||
19 | - //新一张图片 ratio 为 高/宽 抽取出 src title ratio | ||
20 | - item.ratio = item.data.imageWidth <= 0 || item.data.imageHeight<=0?0: item.data.imageHeight / item.data.imageWidth | ||
21 | - item.ratio = Math.ceil(750 * item.ratio); | ||
22 | - item.title = item.data.title; | ||
23 | - // if(item.title != '精彩活动' && item.title!='热门品类' && item.title !='潮流品牌'){ | ||
24 | - // item.title = ''; | ||
25 | - // } | ||
26 | - if(item.data.list && item.data.list[0]){ | ||
27 | - item.src = getImageUrl(item.data.list[0].src, item.data.imageWidth, item.data.imageHeight) | ||
28 | - item.url = item.data.list[0].url | ||
29 | - } | ||
30 | - } else if (item.template_name =='new_recommend_content_five'){ | ||
31 | - //热门品类楼层 | ||
32 | - item.title = item.data.title.title; | ||
33 | - item.moreUrl = item.data.more.url; | ||
34 | - item.list = item.data.list; | ||
35 | - for(var i=0;i<item.list.length;i++){ | ||
36 | - item.list[i].src = getImageUrl(item.list[i].src, 188, 198); | ||
37 | - } | ||
38 | - } else if (item.template_name == '3:4ImageListFloor'){ | ||
39 | - //潮流品牌图片列表 | ||
40 | - item.title = item.data.title; | ||
41 | - item.list = item.data.list; | ||
42 | - for(var i=0;i<item.list.length;i++){ | ||
43 | - item.list[i].src = getImageUrl(item.list[i].src,220,220); | ||
44 | - } | ||
45 | - let more = item.data.more; | ||
46 | - if(more && more.url){ | ||
47 | - item.moreUrl = more.url; | ||
48 | - } | ||
49 | - } else if (item.template_name == 'popularListFloor' || item.template_name == 'newProductListFloor'){ | ||
50 | - //商品列表 | ||
51 | - for(var i = 0;i<item.data.list.length;i++){ | ||
52 | - try{ | ||
53 | - item.data.list[i].default_images = item.data.list[i].default_images.replace(/{width}/g, listImageWidth).replace(/{height}/g, listImageHeight).replace('{mode}', 2); | ||
54 | - }catch(e){ | ||
55 | - console.log('--ReplaceError--') | ||
56 | - } | ||
57 | - | ||
58 | - item.data.list[i].index = index; | ||
59 | - item.data.list[i].display_type = item.data.display_type; //1显示价格2显示店铺 | ||
60 | - } | ||
61 | - } else if (item.template_name == 'image_list') { | ||
62 | - //商品列表 | ||
63 | - for (var i = 0; i < item.data.list.length; i++) { | ||
64 | - try{ | ||
65 | - item.data.list[i].src = item.data.list[i].src.replace(/{width}/g, 150).replace(/{height}/g, 150).replace('{mode}', 2); | ||
66 | - }catch(e){ | ||
67 | - console.log('--ReplaceError--') | ||
68 | - } | ||
69 | - } | ||
70 | - } else if (item.template_name == 'sv_new_user_floor') { | ||
71 | - // 新人楼层 | ||
72 | - if (item.data && item.data.banner_image && item.data.banner_image.length > 0) { | ||
73 | - for(var i = 0;i<item.data.banner_image.length;i++){ | ||
74 | - if (item.data.banner_image[i].src) { | ||
75 | - try{ | ||
76 | - item.data.banner_image[i].src = item.data.banner_image[i].src.replace(/{width}/g, 1500).replace(/{height}/g, 720).replace('{mode}', 2); | ||
77 | - }catch(e){ | ||
78 | - console.log('--ReplaceError--') | ||
79 | - } | ||
80 | - | ||
81 | - } | ||
82 | - } | ||
83 | - } | ||
84 | - } | ||
85 | - else{ | ||
86 | - item.template_name = "undefine"; | ||
87 | - } | ||
88 | - index++; | ||
89 | - newList.push(item); | ||
90 | - }) | ||
91 | - return newList; | ||
92 | -} | ||
93 | - | ||
94 | -export{ | ||
95 | - parseHomeList | ||
96 | -} |
utils/productDetail.js
deleted
100644 → 0
1 | -'use strict' | ||
2 | -function getGoodInfo(data) { | ||
3 | - let newData = []; | ||
4 | - let idElement = '编号: '+data.erpProductId | ||
5 | - newData.push(idElement) | ||
6 | - newData.push('颜色: ' + data.colorName) | ||
7 | - let gender = '' | ||
8 | - if (data.gender == 1) { | ||
9 | - gender = '男款' | ||
10 | - } else if (data.gender == 2) { | ||
11 | - gender = '女款' | ||
12 | - } else if (data.gender == 3) { | ||
13 | - gender = '通用' | ||
14 | - } | ||
15 | - if (gender) { | ||
16 | - newData.push('性别: ' + gender) | ||
17 | - } | ||
18 | - | ||
19 | - data && data.standardBos.map((item, index) => { | ||
20 | - let newItem=item.standardName+': '+item.standardVal | ||
21 | - newData.push(newItem); | ||
22 | - }); | ||
23 | - return newData; | ||
24 | -} | ||
25 | - | ||
26 | -function getGoodSize(data) { | ||
27 | - let titleList = ['吊牌尺码'] | ||
28 | - data && data.sizeAttributeBos.map((item, index) => { | ||
29 | - let newItem=item.attributeName; | ||
30 | - titleList.push(newItem); | ||
31 | - }); | ||
32 | - | ||
33 | - let sizeList=[] | ||
34 | - data && data.sizeBoList.map((item, index) => { | ||
35 | - let itemList=[]; | ||
36 | - itemList.push(item.sizeName) | ||
37 | - item.sortAttributes.map((subItem,subIndex)=>{ | ||
38 | - itemList.push(subItem.sizeValue) | ||
39 | - }) | ||
40 | - sizeList.push(itemList) | ||
41 | - }); | ||
42 | - return {titleList,sizeList}; | ||
43 | -} | ||
44 | - | ||
45 | -function getGoodImages(data,listImageWidth,listImageHeight){ | ||
46 | - let imageList=[] | ||
47 | - data && data.map((item, index) => { | ||
48 | - item=item.image_url.replace(/{width}/g, listImageWidth).replace(/{height}/g, listImageHeight).replace('{mode}',2); | ||
49 | - imageList.push(item); | ||
50 | - }); | ||
51 | - return imageList; | ||
52 | -} | ||
53 | - | ||
54 | -function getModelList(data){ | ||
55 | - let modelList=[] | ||
56 | - let model = {} | ||
57 | - data&&data.map((item,index) => { | ||
58 | - model.name = item.modelName | ||
59 | - model.height = item.height | ||
60 | - model.weight = item.weight | ||
61 | - model.vital =item.vitalStatistics | ||
62 | - model.size = item.fitModelBo.fit_size | ||
63 | - model.feel = item.fitModelBo.feel | ||
64 | - modelList.push(item) | ||
65 | - }); | ||
66 | - | ||
67 | - return modelList | ||
68 | -} | ||
69 | - | ||
70 | -module.exports = { | ||
71 | - getGoodInfo, | ||
72 | - getGoodSize, | ||
73 | - getGoodImages, | ||
74 | - getModelList, | ||
75 | -} |
utils/productList.js
deleted
100644 → 0
1 | -'use strict' | ||
2 | - | ||
3 | -//获取应用实例 | ||
4 | -let app = getApp(); | ||
5 | - | ||
6 | -const screenHeight = app.globalData.systemInfo.screenHeight; | ||
7 | -const windowWidth = app.globalData.systemInfo.windowWidth; | ||
8 | -const windowHeight = app.globalData.systemInfo.windowHeight; | ||
9 | - | ||
10 | -const DEVICE_WIDTH_RATIO = windowWidth / 320; | ||
11 | - | ||
12 | -let listWidth = Math.ceil(137.5 * DEVICE_WIDTH_RATIO); | ||
13 | -let listHeight = Math.ceil(254 * DEVICE_WIDTH_RATIO); | ||
14 | - | ||
15 | -const IMAGE_WIDTH = 145; | ||
16 | -const IMAGE_HEIGHT = 193; | ||
17 | -const IMAGE_RATIO = IMAGE_HEIGHT / IMAGE_WIDTH; | ||
18 | -let listImageTop = 31; | ||
19 | -let listImageWidthDefault = listWidth; | ||
20 | -let listImageHeightDefault = Math.ceil(listWidth * IMAGE_RATIO); | ||
21 | - | ||
22 | -function parseBrandListData(data, listImageWidth, listImageHeight) { | ||
23 | - let newData = []; | ||
24 | - let imageWidth = listImageWidth ? listImageWidth : listImageWidthDefault; | ||
25 | - let imageHeight = listImageHeight ? listImageHeight : listImageHeightDefault; | ||
26 | - | ||
27 | - data && data.map((item, index) => { | ||
28 | - let salePrice = 0; // 售卖价 | ||
29 | - let originPrice = 0; // 原价 | ||
30 | - let salePriceStr = ''; // 拼接的售卖价 | ||
31 | - let originPriceStr = ''; // 拼接的原价 | ||
32 | - let showOriginPrice = true; // 是否显示原价 | ||
33 | - | ||
34 | - let salePriceFixed2 = ''; | ||
35 | - let originPriceFixed2 = ''; | ||
36 | - | ||
37 | - let isGlobalProduct = item.is_global && item.is_global == 'Y'; // 是否全球购商品 | ||
38 | - if (isGlobalProduct) { | ||
39 | - salePrice = parseFloat(item.final_price); | ||
40 | - originPrice = parseFloat(item.orign_price); | ||
41 | - salePriceStr = item.formart_final_price; | ||
42 | - originPriceStr = item.formart_orign_price; | ||
43 | - } else { | ||
44 | - salePrice = parseFloat(item.sales_price); | ||
45 | - originPrice = parseFloat(item.market_price); | ||
46 | - salePriceStr = '¥' + salePrice.toFixed(2); | ||
47 | - originPriceStr = '¥' + originPrice.toFixed(2); | ||
48 | - | ||
49 | - salePriceFixed2 = salePrice.toFixed(2); | ||
50 | - originPriceFixed2 = originPrice.toFixed(2); | ||
51 | - | ||
52 | - } | ||
53 | - | ||
54 | - if (!originPrice || (salePrice == originPrice)) { | ||
55 | - showOriginPrice = false; | ||
56 | - } | ||
57 | - | ||
58 | - item.showOriginPrice = showOriginPrice; | ||
59 | - item.salePriceStr = salePriceStr; | ||
60 | - item.originPriceStr = originPriceStr; | ||
61 | - item.salePriceFixed2 = salePriceFixed2; | ||
62 | - item.originPriceFixed2 = originPriceFixed2; | ||
63 | - | ||
64 | - let default_images = item.default_images.replace(/{width}/g, imageWidth*2).replace(/{height}/g, imageHeight*2).replace('{mode}',2); | ||
65 | - | ||
66 | - let shop_id = item.shop_id; | ||
67 | - let shop_name = item.shop_name; | ||
68 | - | ||
69 | - let newItem = { | ||
70 | - product_skn: item.product_skn, | ||
71 | - default_images, | ||
72 | - product_name: item.product_name, | ||
73 | - showOriginPrice, | ||
74 | - shop_id, | ||
75 | - shop_name, | ||
76 | - salePriceStr, | ||
77 | - originPriceStr, | ||
78 | - originPriceFixed2, | ||
79 | - salePriceFixed2, | ||
80 | - is_shop_cart_add: item.is_shop_cart_add,//是否应该展示右侧的加入购物车按钮 默认不展示 | ||
81 | - }; | ||
82 | - | ||
83 | - newData.push(newItem); | ||
84 | - }); | ||
85 | - | ||
86 | - return newData; | ||
87 | -} | ||
88 | - | ||
89 | -function cancelFilterSelectState(filters, exceptKey) { | ||
90 | - let newFilters = {}; | ||
91 | - for (let itemKey in filters) { | ||
92 | - if (filters.hasOwnProperty(itemKey)) { | ||
93 | - if (itemKey != exceptKey) { | ||
94 | - let newFilter = filters[itemKey]; | ||
95 | - newFilter.selected = false; | ||
96 | - newFilters[itemKey] = newFilter; | ||
97 | - } | ||
98 | - } | ||
99 | - } | ||
100 | - | ||
101 | - return newFilters; | ||
102 | -} | ||
103 | - | ||
104 | - | ||
105 | -module.exports = { | ||
106 | - parseBrandListData, | ||
107 | - cancelFilterSelectState, | ||
108 | -} |
utils/shopCartContent.js
deleted
100644 → 0
1 | -'use strict' | ||
2 | - | ||
3 | -import { getImageUrlWithWH } from './util'; | ||
4 | - | ||
5 | -function toDecimal2(x) { | ||
6 | - var f = parseFloat(x); | ||
7 | - if (isNaN(f)) { | ||
8 | - return false; | ||
9 | - } | ||
10 | - var f = Math.round(x * 100) / 100; | ||
11 | - var s = f.toString(); | ||
12 | - var rs = s.indexOf('.'); | ||
13 | - if (rs < 0) { | ||
14 | - rs = s.length; | ||
15 | - s += '.'; | ||
16 | - } | ||
17 | - while (s.length <= rs + 2) { | ||
18 | - s += '0'; | ||
19 | - } | ||
20 | - return s; | ||
21 | -} | ||
22 | - | ||
23 | -function processGiftOrPriceGift(giftList, isGift) { | ||
24 | - let selledOutGiftTypeCount = 0; | ||
25 | - giftList.map((item, index) => { | ||
26 | - let statusString = ""; | ||
27 | - if (item.status == 0) { | ||
28 | - statusString = "去凑单"; | ||
29 | - } else if (item.status == 10) { | ||
30 | - if (item.promotion_type == "Gift") {//Cashreduce,Degressdiscount,Cheapestfree,Discount,Gift,Needpaygift,SpecifiedAmount | ||
31 | - statusString = "领赠品"; | ||
32 | - } else if (item.promotion_type == "Needpaygift") { | ||
33 | - statusString = "去换购"; | ||
34 | - } | ||
35 | - } else if (item.status == 20) { | ||
36 | - selledOutGiftTypeCount++; | ||
37 | - statusString = "已抢光"; | ||
38 | - } else if (item.status == 30) { | ||
39 | - statusString = "更换"; | ||
40 | - } | ||
41 | - item.statusString = statusString; | ||
42 | - item.isGift = isGift; | ||
43 | - }); | ||
44 | - if (selledOutGiftTypeCount == giftList.height) { | ||
45 | - giftList.map((item, index) => { | ||
46 | - item.statusString = "已抢光"; | ||
47 | - }); | ||
48 | - }; | ||
49 | - return giftList; | ||
50 | -} | ||
51 | - | ||
52 | -function processGoodsItem(goodsItem) { | ||
53 | - let imagesUrl = getImageUrlWithWH(goodsItem.goods_images, 75, 100); | ||
54 | - goodsItem.goods_images = imagesUrl; | ||
55 | - goodsItem.goodColorSizeString = "颜色:" + goodsItem.factory_goods_name + " " + "尺码:" + goodsItem.size_name; | ||
56 | - let isShowOldPrice = true; | ||
57 | - let priceString = ''; | ||
58 | - let shoppingProductType = goodsItem.goods_type; | ||
59 | - if (shoppingProductType == 'price_gift') { | ||
60 | - priceString = goodsItem.last_price; | ||
61 | - } else if (shoppingProductType == 'gift') { | ||
62 | - priceString = '0.00'; | ||
63 | - } else { | ||
64 | - if (goodsItem.last_vip_price < goodsItem.sales_price) { | ||
65 | - priceString = goodsItem.last_vip_price; | ||
66 | - } else { | ||
67 | - priceString = goodsItem.sales_price; | ||
68 | - } | ||
69 | - isShowOldPrice = false; | ||
70 | - } | ||
71 | - priceString = '¥' + toDecimal2(priceString); | ||
72 | - let oldPricString = goodsItem.sales_price; | ||
73 | - oldPricString = '¥' + toDecimal2(oldPricString); | ||
74 | - if (goodsItem.price_down > 0) { | ||
75 | - goodsItem.price_down = toDecimal2(goodsItem.price_down); | ||
76 | - } | ||
77 | - if (parseInt(goodsItem.buy_number) > parseInt(goodsItem.storage_number)) { | ||
78 | - goodsItem.bLackStorage = true; | ||
79 | - } | ||
80 | - if (goodsItem.selected == "Y") { | ||
81 | - goodsItem.bSelected = true; | ||
82 | - } | ||
83 | - goodsItem.priceString = priceString; | ||
84 | - goodsItem.oldPricString = oldPricString; | ||
85 | - goodsItem.isShowOldPrice = isShowOldPrice; | ||
86 | - var unique_identifier = goodsItem.product_sku + goodsItem.batch_no.toString() + goodsItem.bundle_activity_id.toString(); | ||
87 | - goodsItem.unique_identifier = unique_identifier; | ||
88 | - return goodsItem; | ||
89 | -} | ||
90 | - | ||
91 | -function isGoodsSelectAll(goodsList) { | ||
92 | - if (!goodsList || !goodsList.length) { | ||
93 | - return false; | ||
94 | - } | ||
95 | - let allGoodsSelect = true; | ||
96 | - goodsList.map((goodsItem, index) => { | ||
97 | - if (!goodsItem.bLackStorage && goodsItem.goods_type !== 'gift') { | ||
98 | - if (goodsItem.selected !== 'Y') { | ||
99 | - allGoodsSelect = false; | ||
100 | - } | ||
101 | - } | ||
102 | - }); | ||
103 | - return allGoodsSelect; | ||
104 | -} | ||
105 | - | ||
106 | -function processPromotionItem(promotionItem, isSubPromotion) { | ||
107 | - let promotionStatusString = ""; | ||
108 | - if (promotionItem.status == 0) { | ||
109 | - promotionStatusString = "去凑单"; | ||
110 | - } else if (promotionItem.status == 10) { | ||
111 | - if (promotionItem.promotion_type == "Gift") {//Cashreduce,Degressdiscount,Cheapestfree,Discount,Gift,Needpaygift,SpecifiedAmount | ||
112 | - promotionStatusString = "领赠品"; | ||
113 | - } else if (promotionItem.promotion_type == "Needpaygift") { | ||
114 | - promotionStatusString = "去换购"; | ||
115 | - } | ||
116 | - } else if (promotionItem.status == 20) { | ||
117 | - promotionStatusString = "已抢光"; | ||
118 | - } else if (promotionItem.status == 30) { | ||
119 | - promotionStatusString = "更换"; | ||
120 | - } | ||
121 | - if (promotionStatusString == "已抢光") { | ||
122 | - promotionItem.seldoutStyle = true; | ||
123 | - } | ||
124 | - promotionItem.statuString = promotionStatusString; | ||
125 | - if (isSubPromotion) { | ||
126 | - let typeString = ''; | ||
127 | - if (promotionItem.promotion_type == "Gift") { | ||
128 | - typeString = '赠品'; | ||
129 | - } else if (promotionItem.promotion_type == 'Needpaygift') { | ||
130 | - typeString = '加价购'; | ||
131 | - } else if (promotionItem.promotion_type == 'Cashreduce') { | ||
132 | - typeString = '满减'; | ||
133 | - } else { | ||
134 | - typeString = '折扣'; | ||
135 | - } | ||
136 | - promotionItem.typeString = typeString; | ||
137 | - } | ||
138 | - return promotionItem; | ||
139 | -} | ||
140 | - | ||
141 | -function curShoppingCartDataAddExpandedFlag(curShoppingCartData) { | ||
142 | - let goodsList = curShoppingCartData.goods_list; | ||
143 | - let validGoodsList = []; | ||
144 | - if (goodsList) { | ||
145 | - goodsList.map((goodsItem, index) => { | ||
146 | - goodsItem = processGoodsItem(goodsItem); | ||
147 | - validGoodsList.push(goodsItem); | ||
148 | - }) | ||
149 | - } | ||
150 | - curShoppingCartData.goods_list = goodsList; | ||
151 | - | ||
152 | - let goodsPoolList = curShoppingCartData.goods_pool_list; | ||
153 | - if (goodsPoolList) { | ||
154 | - goodsPoolList.map((item, index) => { | ||
155 | - | ||
156 | - if (item.pool_batch_no && item.pool_id) { | ||
157 | - //套餐商品参数转换 | ||
158 | - item.int_pool_buy_number = parseInt(item.pool_buy_number); | ||
159 | - item.int_pool_storage_number = parseInt(item.pool_storage_number); | ||
160 | - } | ||
161 | - | ||
162 | - let goodsPoolGoodsList = item.goods_list; | ||
163 | - if (goodsPoolGoodsList) { | ||
164 | - goodsPoolGoodsList.map((goodsItem, index) => { | ||
165 | - goodsItem = processGoodsItem(goodsItem); | ||
166 | - validGoodsList.push(goodsItem); | ||
167 | - }) | ||
168 | - } | ||
169 | - item.isPromotionExpanded = false; | ||
170 | - let promotionList = item.promotion_list; | ||
171 | - if (promotionList) { | ||
172 | - promotionList.map((promotionItem, promotionIndex) => { | ||
173 | - promotionItem = processPromotionItem(promotionItem, false); | ||
174 | - }) | ||
175 | - item.promotion_list = promotionList; | ||
176 | - } | ||
177 | - | ||
178 | - let subPool = item.sub_pool; | ||
179 | - if (subPool) { | ||
180 | - subPool.map((subPoolItem, index) => { | ||
181 | - let promotionList = subPoolItem.promotion_list; | ||
182 | - if (promotionList) { | ||
183 | - promotionList.map((promotionItem, promotionIndex) => { | ||
184 | - promotionItem = processPromotionItem(promotionItem, true); | ||
185 | - }) | ||
186 | - subPoolItem.promotion_list = promotionList; | ||
187 | - } | ||
188 | - let subPoolGoodsList = subPoolItem.goods_list; | ||
189 | - if (subPoolGoodsList) { | ||
190 | - subPoolGoodsList.map((subPoolGoodsItem, index) => { | ||
191 | - subPoolGoodsItem = processGoodsItem(subPoolGoodsItem); | ||
192 | - validGoodsList.push(subPoolGoodsItem); | ||
193 | - }) | ||
194 | - } | ||
195 | - }) | ||
196 | - } | ||
197 | - item.sub_pool = subPool; | ||
198 | - }); | ||
199 | - } | ||
200 | - curShoppingCartData.validGoodsList = validGoodsList; | ||
201 | - curShoppingCartData.isValidGoodsSelectAll = isGoodsSelectAll(validGoodsList); | ||
202 | - | ||
203 | - // let newgPriceGiftList = []; | ||
204 | - let gPriceGiftList = curShoppingCartData.g_price_gift_list; | ||
205 | - // if (gPriceGiftList && gPriceGiftList.length && canShowGiftEntrance(gPriceGiftList)) { | ||
206 | - // newgPriceGiftList = processGiftOrPriceGift(gPriceGiftList, false); | ||
207 | - // } | ||
208 | - // curShoppingCartData.g_price_gift_list = newgPriceGiftList; | ||
209 | - | ||
210 | - // let newgGiftList = []; | ||
211 | - let gGiftList = curShoppingCartData.g_gift_list; | ||
212 | - // if (gGiftList && gGiftList.length && canShowGiftEntrance(gGiftList)) { | ||
213 | - // newgGiftList = processGiftOrPriceGift(gGiftList, true); | ||
214 | - // } | ||
215 | - // curShoppingCartData.g_gift_list = newgGiftList; | ||
216 | - | ||
217 | - | ||
218 | - let gGiftAndPriceGiftList = []; | ||
219 | - if (gGiftList && gGiftList.length) { | ||
220 | - let giftItem = transformToGiftModelWithGiftList(gGiftList,true); | ||
221 | - if (giftItem.canShow) { | ||
222 | - gGiftAndPriceGiftList.push(giftItem); | ||
223 | - } | ||
224 | - } | ||
225 | - | ||
226 | - if (gPriceGiftList && gPriceGiftList.length) { | ||
227 | - let priceGiftItem = transformToGiftModelWithGiftList(gPriceGiftList,false); | ||
228 | - if (priceGiftItem.canShow) { | ||
229 | - gGiftAndPriceGiftList.push(priceGiftItem); | ||
230 | - } | ||
231 | - } | ||
232 | - | ||
233 | - | ||
234 | - | ||
235 | - // if (newgPriceGiftList.length && newgGiftList.length) { | ||
236 | - // gGiftAndPriceGiftList = [newgGiftList[0], newgPriceGiftList[0]]; | ||
237 | - // } else if (newgPriceGiftList.length) { | ||
238 | - // gGiftAndPriceGiftList = [newgPriceGiftList[0]]; | ||
239 | - // } else if (newgGiftList.length) { | ||
240 | - // gGiftAndPriceGiftList = [newgGiftList[0]]; | ||
241 | - // } | ||
242 | - curShoppingCartData.gGiftAndPriceGiftList = gGiftAndPriceGiftList; | ||
243 | - | ||
244 | - | ||
245 | - //失效商品 | ||
246 | - let offShelvesGoodsList = curShoppingCartData.off_shelves_goods_list; | ||
247 | - let soldOutGoodsList = curShoppingCartData.sold_out_goods_list; | ||
248 | - let invalidGoodsList = [...offShelvesGoodsList, ...soldOutGoodsList]; | ||
249 | - if (invalidGoodsList && invalidGoodsList.length) { | ||
250 | - invalidGoodsList.map((invalidGoodsItem, index) => { | ||
251 | - let imagesUrl = getImageUrlWithWH(invalidGoodsItem.goods_images, 75, 100);; | ||
252 | - invalidGoodsItem.goods_images = imagesUrl; | ||
253 | - }) | ||
254 | - } | ||
255 | - let last_order_amount = curShoppingCartData.shopping_cart_data.last_order_amount; | ||
256 | - last_order_amount = '¥' + toDecimal2(last_order_amount); | ||
257 | - curShoppingCartData.shopping_cart_data.last_order_amount = last_order_amount; | ||
258 | - | ||
259 | - curShoppingCartData.invalidGoodsList = invalidGoodsList; | ||
260 | - | ||
261 | - 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); | ||
262 | - curShoppingCartData.has_product_in_shop_cart = has_product_in_shop_cart; | ||
263 | - | ||
264 | - return curShoppingCartData; | ||
265 | -} | ||
266 | - | ||
267 | -function canShowGiftEntrance(items) { | ||
268 | - let result = false; | ||
269 | - | ||
270 | - let statusCount_10 = 0;//已满足 | ||
271 | - let statusCount_20 = 0;//已售罄 | ||
272 | - items.map((item, index) => { | ||
273 | - if (item.status == 10) { | ||
274 | - statusCount_10++; | ||
275 | - } else if (item.status == 20) { | ||
276 | - statusCount_20++; | ||
277 | - } | ||
278 | - }); | ||
279 | - | ||
280 | - if (statusCount_10 > 0 || (items.length > 0 && statusCount_20 == items.length)) { | ||
281 | - result = true; | ||
282 | - } | ||
283 | - return result; | ||
284 | -} | ||
285 | - | ||
286 | -function transformToGiftModelWithGiftList(list,isGift) { | ||
287 | - let resultItem = {}; | ||
288 | - resultItem.isGift = isGift; | ||
289 | - resultItem.title = isGift ? '赠品' : '全场加价购'; | ||
290 | - let promotion_ids = ''; | ||
291 | - list.map((item, index) => { | ||
292 | - if (item.status == 10) { | ||
293 | - promotion_ids = promotion_ids + (promotion_ids.length == 0 ? '' : ',') + item.promotion_id; | ||
294 | - } | ||
295 | - }); | ||
296 | - resultItem.promotion_ids = promotion_ids; | ||
297 | - if (promotion_ids.length > 0) { | ||
298 | - if (isGift) { | ||
299 | - resultItem.statusString = '领赠品'; | ||
300 | - } else { | ||
301 | - resultItem.statusString = '去换购'; | ||
302 | - } | ||
303 | - resultItem.showArrow = true; | ||
304 | - } else { | ||
305 | - resultItem.statusString = '已抢光'; | ||
306 | - resultItem.showArrow = false; | ||
307 | - } | ||
308 | - | ||
309 | - resultItem.canShow = canShowGiftEntrance(list); | ||
310 | - return resultItem; | ||
311 | -} | ||
312 | - | ||
313 | -function curPageDataAllSelectWhenEditing(curShoppingCartData,allSelect) { | ||
314 | - let goodsList = curShoppingCartData.goods_list; | ||
315 | - let validGoodsList = []; | ||
316 | - if (goodsList) { | ||
317 | - goodsList.map((goodsItem, index) => { | ||
318 | - goodsItem = processGoodsItem(goodsItem); | ||
319 | - if(allSelect){ | ||
320 | - goodsItem.selected = 'Y'; | ||
321 | - goodsItem.bSelected = true; | ||
322 | - }else { | ||
323 | - goodsItem.selected = 'N'; | ||
324 | - goodsItem.bSelected = false; | ||
325 | - } | ||
326 | - }) | ||
327 | - } | ||
328 | - | ||
329 | - let goodsPoolList = curShoppingCartData.goods_pool_list; | ||
330 | - if (goodsPoolList) { | ||
331 | - goodsPoolList.map((item, index) => { | ||
332 | - | ||
333 | - if (item.pool_type == '3' && item.pool_batch_no) { | ||
334 | - item.selected = allSelect ? 'Y' : 'N'; | ||
335 | - } | ||
336 | - | ||
337 | - let goodsPoolGoodsList = item.goods_list; | ||
338 | - if (goodsPoolGoodsList) { | ||
339 | - goodsPoolGoodsList.map((goodsItem, index) => { | ||
340 | - goodsItem = processGoodsItem(goodsItem); | ||
341 | - if (allSelect) { | ||
342 | - goodsItem.selected = 'Y'; | ||
343 | - goodsItem.bSelected = true; | ||
344 | - } else { | ||
345 | - goodsItem.selected = 'N'; | ||
346 | - goodsItem.bSelected = false; | ||
347 | - } | ||
348 | - }) | ||
349 | - } | ||
350 | - | ||
351 | - let subPool = item.sub_pool; | ||
352 | - if (subPool) { | ||
353 | - subPool.map((subPoolItem, index) => { | ||
354 | - let subPoolGoodsList = subPoolItem.goods_list; | ||
355 | - if (subPoolGoodsList) { | ||
356 | - subPoolGoodsList.map((subPoolGoodsItem, index) => { | ||
357 | - subPoolGoodsItem = processGoodsItem(subPoolGoodsItem); | ||
358 | - if (allSelect) { | ||
359 | - subPoolGoodsItem.selected = 'Y'; | ||
360 | - subPoolGoodsItem.bSelected = true; | ||
361 | - } else { | ||
362 | - subPoolGoodsItem.selected = 'N'; | ||
363 | - subPoolGoodsItem.bSelected = false; | ||
364 | - } | ||
365 | - }) | ||
366 | - } | ||
367 | - }) | ||
368 | - } | ||
369 | - item.sub_pool = subPool; | ||
370 | - }); | ||
371 | - } | ||
372 | - return curShoppingCartData; | ||
373 | -} | ||
374 | - | ||
375 | -function curPageDataSingleSelectWhenEditing(curShoppingCartData, selectItem) { | ||
376 | - let isValidGoodsSelectAll = true; | ||
377 | - let goodsList = curShoppingCartData.goods_list; | ||
378 | - let validGoodsList = []; | ||
379 | - if (goodsList) { | ||
380 | - goodsList.map((goodsItem, index) => { | ||
381 | - goodsItem = processGoodsItem(goodsItem); | ||
382 | - if (goodsItem.unique_identifier == selectItem.unique_identifier) { | ||
383 | - if (goodsItem.selected == 'Y'){ | ||
384 | - goodsItem.selected = 'N'; | ||
385 | - goodsItem.bSelected = false; | ||
386 | - }else { | ||
387 | - goodsItem.selected = 'Y'; | ||
388 | - goodsItem.bSelected = true; | ||
389 | - } | ||
390 | - } | ||
391 | - if (isValidGoodsSelectAll && (!goodsItem.bSelected)) { | ||
392 | - isValidGoodsSelectAll = false; | ||
393 | - } | ||
394 | - }) | ||
395 | - } | ||
396 | - curShoppingCartData.goods_list = goodsList; | ||
397 | - let goodsPoolList = curShoppingCartData.goods_pool_list; | ||
398 | - if (goodsPoolList) { | ||
399 | - goodsPoolList.map((item, index) => { | ||
400 | - let goodsPoolGoodsList = item.goods_list; | ||
401 | - if (goodsPoolGoodsList) { | ||
402 | - goodsPoolGoodsList.map((goodsItem, index) => { | ||
403 | - goodsItem = processGoodsItem(goodsItem); | ||
404 | - if (goodsItem.unique_identifier == selectItem.unique_identifier) { | ||
405 | - if (goodsItem.selected == 'Y') { | ||
406 | - goodsItem.selected = 'N'; | ||
407 | - goodsItem.bSelected = false; | ||
408 | - } else { | ||
409 | - goodsItem.selected = 'Y'; | ||
410 | - goodsItem.bSelected = true; | ||
411 | - } | ||
412 | - } | ||
413 | - if (isValidGoodsSelectAll && (!goodsItem.bSelected)) { | ||
414 | - isValidGoodsSelectAll = false; | ||
415 | - } | ||
416 | - }) | ||
417 | - } | ||
418 | - | ||
419 | - let subPool = item.sub_pool; | ||
420 | - if (subPool) { | ||
421 | - subPool.map((subPoolItem, index) => { | ||
422 | - let subPoolGoodsList = subPoolItem.goods_list; | ||
423 | - if (subPoolGoodsList) { | ||
424 | - subPoolGoodsList.map((subPoolGoodsItem, index) => { | ||
425 | - subPoolGoodsItem = processGoodsItem(subPoolGoodsItem); | ||
426 | - if (subPoolGoodsItem.unique_identifier == selectItem.unique_identifier) { | ||
427 | - if (subPoolGoodsItem.selected == 'Y') { | ||
428 | - subPoolGoodsItem.selected = 'N'; | ||
429 | - subPoolGoodsItem.bSelected = false; | ||
430 | - } else { | ||
431 | - subPoolGoodsItem.selected = 'Y'; | ||
432 | - subPoolGoodsItem.bSelected = true; | ||
433 | - } | ||
434 | - } | ||
435 | - if (isValidGoodsSelectAll && (!subPoolGoodsItem.bSelected)) { | ||
436 | - isValidGoodsSelectAll = false; | ||
437 | - } | ||
438 | - }) | ||
439 | - } | ||
440 | - }) | ||
441 | - } | ||
442 | - item.sub_pool = subPool; | ||
443 | - }); | ||
444 | - curShoppingCartData.goods_pool_list = goodsPoolList; | ||
445 | - } | ||
446 | - curShoppingCartData.isValidGoodsSelectAll = isValidGoodsSelectAll; | ||
447 | - return curShoppingCartData; | ||
448 | -} | ||
449 | - | ||
450 | -function curPageDataSingleSelectBundleProductWhenEditing(curShoppingCartData, selectBundleItem) { | ||
451 | - | ||
452 | - if (curShoppingCartData.goods_pool_list) { | ||
453 | - curShoppingCartData.goods_pool_list.map((item, index) => { | ||
454 | - | ||
455 | - if (item.pool_type == 3 && item.pool_batch_no) { | ||
456 | - item.selected = selectBundleItem.selected; | ||
457 | - let goodsPoolGoodsList = item.goods_list; | ||
458 | - if (goodsPoolGoodsList) { | ||
459 | - goodsPoolGoodsList.map((goodsItem, index) => { | ||
460 | - goodsItem = processGoodsItem(goodsItem); | ||
461 | - if (item.selected == 'Y') { | ||
462 | - goodsItem.selected = 'Y'; | ||
463 | - goodsItem.bSelected = true; | ||
464 | - } else { | ||
465 | - goodsItem.selected = 'N'; | ||
466 | - goodsItem.bSelected = false; | ||
467 | - } | ||
468 | - }) | ||
469 | - } | ||
470 | - } | ||
471 | - }); | ||
472 | - | ||
473 | - } | ||
474 | - return curShoppingCartData; | ||
475 | -} | ||
476 | - | ||
477 | -function editInfoDicFromGoodsList(goodsList, isSelectAll){ | ||
478 | - if (!goodsList || !goodsList.length) { | ||
479 | - return []; | ||
480 | - } | ||
481 | - let editInfoDicArray = []; | ||
482 | - goodsList.map((goodsItem, index) => { | ||
483 | - if (!goodsItem.bLackStorage && goodsItem.goods_type !== 'gift') { | ||
484 | - editInfoDicArray.push({ | ||
485 | - buy_number: goodsItem.buy_number ? goodsItem.buy_number : 0, | ||
486 | - goods_type: goodsItem.goods_type ? goodsItem.goods_type : "", | ||
487 | - product_sku: goodsItem.product_sku ? goodsItem.product_sku : "", | ||
488 | - promotion_id: goodsItem.promotion_id ? goodsItem.promotion_id : 0, | ||
489 | - selected: isSelectAll ? "Y" : "N", | ||
490 | - activity_id: goodsItem.bundle_activity_id ? goodsItem.bundle_activity_id : 0, | ||
491 | - batch_no: goodsItem.batch_no ? goodsItem.batch_no : 0, | ||
492 | - }) | ||
493 | - } | ||
494 | - }); | ||
495 | - return editInfoDicArray; | ||
496 | -} | ||
497 | - | ||
498 | -function editInfoDicFromBundleItem(bundleItem) { | ||
499 | - if (!bundleItem || !bundleItem.goods_list.length) { | ||
500 | - return []; | ||
501 | - } | ||
502 | - let editInfoDicArray = []; | ||
503 | - bundleItem.goods_list.map((goodsItem, index) => { | ||
504 | - editInfoDicArray.push({ | ||
505 | - buy_number: goodsItem.buy_number ? goodsItem.buy_number : 0, | ||
506 | - goods_type: goodsItem.goods_type ? goodsItem.goods_type : "", | ||
507 | - product_sku: goodsItem.product_sku ? goodsItem.product_sku : "", | ||
508 | - promotion_id: goodsItem.promotion_id ? goodsItem.promotion_id : 0, | ||
509 | - selected: bundleItem.selected, | ||
510 | - activity_id: goodsItem.bundle_activity_id ? goodsItem.bundle_activity_id : 0, | ||
511 | - batch_no: goodsItem.batch_no ? goodsItem.batch_no : 0, | ||
512 | - }) | ||
513 | - }); | ||
514 | - return editInfoDicArray; | ||
515 | -} | ||
516 | - | ||
517 | -function editInfoSelectedGoodsList(goodsList) { | ||
518 | - if (!goodsList || !goodsList.length) { | ||
519 | - return []; | ||
520 | - } | ||
521 | - let editInfoDicArray = []; | ||
522 | - goodsList.map((goodsItem, index) => { | ||
523 | - if (!goodsItem.bLackStorage && goodsItem.goods_type !== 'gift') { | ||
524 | - if (goodsItem.selected == 'Y') { | ||
525 | - editInfoDicArray.push({ | ||
526 | - buy_number: goodsItem.buy_number ? goodsItem.buy_number : 0, | ||
527 | - goods_type: goodsItem.goods_type ? goodsItem.goods_type : "", | ||
528 | - product_sku: goodsItem.product_sku ? goodsItem.product_sku : "", | ||
529 | - promotion_id: goodsItem.promotion_id ? goodsItem.promotion_id : 0, | ||
530 | - selected: "Y", | ||
531 | - activity_id: goodsItem.bundle_activity_id ? goodsItem.bundle_activity_id : 0, | ||
532 | - batch_no: goodsItem.batch_no ? goodsItem.batch_no : 0, | ||
533 | - }) | ||
534 | - } | ||
535 | - } | ||
536 | - }); | ||
537 | - return editInfoDicArray; | ||
538 | -} | ||
539 | - | ||
540 | -function editInfoOfAllGoods(goodsList) { | ||
541 | - if (!goodsList || !goodsList.length) { | ||
542 | - return []; | ||
543 | - } | ||
544 | - let editInfoDicArray = []; | ||
545 | - goodsList.map((goodsItem, index) => { | ||
546 | - editInfoDicArray.push({ | ||
547 | - buy_number: goodsItem.buy_number ? goodsItem.buy_number:0, | ||
548 | - goods_type: goodsItem.goods_type ? goodsItem.goods_type:"", | ||
549 | - product_sku: goodsItem.product_sku ? goodsItem.product_sku:"", | ||
550 | - promotion_id: goodsItem.promotion_id ? goodsItem.promotion_id:0, | ||
551 | - selected: goodsItem.selected, | ||
552 | - activity_id: goodsItem.bundle_activity_id ? goodsItem.bundle_activity_id:0, | ||
553 | - batch_no: goodsItem.batch_no ? goodsItem.batch_no:0, | ||
554 | - }) | ||
555 | - }); | ||
556 | - return editInfoDicArray; | ||
557 | -} | ||
558 | - | ||
559 | -function hasLackStorageGoodsInList(goodsList) { | ||
560 | - if (!goodsList || !goodsList.length) { | ||
561 | - return false; | ||
562 | - } | ||
563 | - let hasLackStorageGoods = false; | ||
564 | - goodsList.map((goodsItem, index) => { | ||
565 | - if (goodsItem.bLackStorage) { | ||
566 | - hasLackStorageGoods = true; | ||
567 | - } | ||
568 | - }); | ||
569 | - return hasLackStorageGoods; | ||
570 | -} | ||
571 | - | ||
572 | -module.exports = { | ||
573 | - curShoppingCartDataAddExpandedFlag, | ||
574 | - editInfoDicFromGoodsList, | ||
575 | - hasLackStorageGoodsInList, | ||
576 | - curPageDataAllSelectWhenEditing, | ||
577 | - curPageDataSingleSelectWhenEditing, | ||
578 | - editInfoOfAllGoods, | ||
579 | - editInfoSelectedGoodsList, | ||
580 | - curPageDataSingleSelectBundleProductWhenEditing, | ||
581 | - editInfoDicFromBundleItem, | ||
582 | -} |
-
Please register or login to post a comment