|
@@ -75,144 +75,3 @@ exports.upperCase = (str) => { |
|
@@ -75,144 +75,3 @@ exports.upperCase = (str) => { |
75
|
str = str || '';
|
75
|
str = str || '';
|
76
|
return str.toUpperCase();
|
76
|
return str.toUpperCase();
|
77
|
}; |
77
|
}; |
78
|
-
|
|
|
79
|
-/**
|
|
|
80
|
- * 格式化商品信息 待处理 没有测试过
|
|
|
81
|
- * @param {array} productData 需要格式化的商品数据
|
|
|
82
|
- * @param {Boolean} showTags 控制是否显示标签
|
|
|
83
|
- * @param {Boolean} showNew 控制是否显示NEW图标
|
|
|
84
|
- * @param {Boolean} showSale 控制是否显示SALE图标
|
|
|
85
|
- * @param {Boolean} isApp 判断是不是APP访问
|
|
|
86
|
- * @param {[type]} showPoint 商品价格是否显示小数位,默认显示
|
|
|
87
|
- * @return {array} [description]
|
|
|
88
|
- */
|
|
|
89
|
-exports.formatProduct = (productData, showTags, showNew, showSale, isApp, showPoint) => {
|
|
|
90
|
-
|
|
|
91
|
- if (_.isEmpty(productData)) {
|
|
|
92
|
- return;
|
|
|
93
|
- }
|
|
|
94
|
-
|
|
|
95
|
- showTags = _.isEmpty(showTags) ? true : showTags;
|
|
|
96
|
- showNew = _.isEmpty(showNew) ? true : showNew;
|
|
|
97
|
- showSale = _.isEmpty(showSale) ? true : showSale;
|
|
|
98
|
- isApp = _.isEmpty(isApp) ? false : isApp;
|
|
|
99
|
- showPoint = _.isEmpty(showPoint) ? true : showPoint;
|
|
|
100
|
-
|
|
|
101
|
- // 商品信息有问题,则不显示
|
|
|
102
|
- if (_.isEmpty(productData.product_skn) ||
|
|
|
103
|
- _.isEmpty(productData.goods_list[0])) {
|
|
|
104
|
- return;
|
|
|
105
|
- }
|
|
|
106
|
-
|
|
|
107
|
- // 市场价和售价一样,则不显示市场价
|
|
|
108
|
- if (parseInt(productData.market_price, 10) ===
|
|
|
109
|
- parseInt(productData.sales_price, 10)) {
|
|
|
110
|
- productData.market_price = false;
|
|
|
111
|
- }
|
|
|
112
|
-
|
|
|
113
|
- // 判别默认的商品是否将默认的图片URL赋值到skn
|
|
|
114
|
- let flag = false;
|
|
|
115
|
-
|
|
|
116
|
- // 如果设置了默认图片,就取默认的图片
|
|
|
117
|
- _.forEach(productData.goods_list, function(oneGoods) {
|
|
|
118
|
-
|
|
|
119
|
- // 此skc是默认的,则将图片赋值给skn
|
|
|
120
|
- if (oneGoods.is_default === 'Y') {
|
|
|
121
|
- // productData.default_images = procProductImg(oneGoods);
|
|
|
122
|
- flag = true;
|
|
|
123
|
- return;
|
|
|
124
|
- }
|
|
|
125
|
- });
|
|
|
126
|
-
|
|
|
127
|
- // 如果还未赋值,则取第一个skc产品的默认图片
|
|
|
128
|
- if (!flag) {
|
|
|
129
|
- // productData.default_images = procProductImg(productData.goods_list[0]);
|
|
|
130
|
- }
|
|
|
131
|
-
|
|
|
132
|
- let result = {};
|
|
|
133
|
-
|
|
|
134
|
- result.id = productData.product_skn;
|
|
|
135
|
- result.product_id = productData.product_id;
|
|
|
136
|
- result.thumb = productData.default_images;
|
|
|
137
|
- result.name = productData.product_name;
|
|
|
138
|
- result.price = _.isEmpty(productData.market_price) ? false : productData.market_price;
|
|
|
139
|
- result.salePrice = productData.sales_price;
|
|
|
140
|
-
|
|
|
141
|
- if (showPoint) {
|
|
|
142
|
- result.price = result.price + '.00';
|
|
|
143
|
- result.salePrice = result.salePrice + '.00';
|
|
|
144
|
- }
|
|
|
145
|
-
|
|
|
146
|
- result.is_soon_sold_out = (productData.is_soon_sold_out === 'Y');
|
|
|
147
|
-
|
|
|
148
|
- // result.url = url('/product/pro_' + productData.product_id +
|
|
|
149
|
- // '_' + productData.goods_list[0].goods_id +
|
|
|
150
|
- // '/' + productData.cn_alphabet + '.html');
|
|
|
151
|
-
|
|
|
152
|
- // APP访问需要加附加的参数
|
|
|
153
|
- if (isApp) {
|
|
|
154
|
- result.url = result.url +
|
|
|
155
|
- '?openby:yohobuy={"action":"go.productDetail","params":{"product_skn":' +
|
|
|
156
|
- productData.product_skn + '}}';
|
|
|
157
|
- }
|
|
|
158
|
-
|
|
|
159
|
- if (showTags) {
|
|
|
160
|
- result.tags = {};
|
|
|
161
|
-
|
|
|
162
|
- result.tags.is_new = showNew && !_.isEmpty(productData.is_new) &&
|
|
|
163
|
- productData.is_new === 'Y'; // 新品
|
|
|
164
|
- result.tags.is_discount = showSale && !_.isEmpty(productData.is_discount) &&
|
|
|
165
|
- productData.is_discount === 'Y'; // 限量
|
|
|
166
|
- result.tags.is_limited = !_.isEmpty(productData.is_limited) &&
|
|
|
167
|
- productData.is_limited === 'Y'; // YOHOOD
|
|
|
168
|
- result.tags.is_yohood = !_.isEmpty(productData.is_yohood) &&
|
|
|
169
|
- productData.is_yohood === 'Y';
|
|
|
170
|
- result.tags.midYear = !_.isEmpty(productData.midYear) &&
|
|
|
171
|
- productData.midYear === 'Y'; // 年中
|
|
|
172
|
- result.tags.yearEnd = !_.isEmpty(productData.yearEnd) &&
|
|
|
173
|
- productData.yearEnd === 'Y'; // 年末
|
|
|
174
|
- result.tags.is_advance = !_.isEmpty(productData.is_advance) &&
|
|
|
175
|
- productData.is_advance === 'Y'; // 再到着
|
|
|
176
|
-
|
|
|
177
|
- // 打折与即将售完组合显示打折
|
|
|
178
|
- // 打折与其它组合则隐藏打折
|
|
|
179
|
- // YOHOOD和新品组合显示YOHOOD
|
|
|
180
|
- if (!_.isEmpty(result.is_soon_sold_out) && !_.isEmpty(result.tags.is_discount)) {
|
|
|
181
|
- result.tags.is_new = false;
|
|
|
182
|
- } else if (result.tags.is_discount && (result.tags.is_new) || result.tags.is_advance) {
|
|
|
183
|
- result.tags.is_discount = false;
|
|
|
184
|
- } else if (!_.isEmpty(result.tags.is_yohood) && !_.isEmpty(result.tags.is_new)) {
|
|
|
185
|
- result.tags.is_new = false;
|
|
|
186
|
- }
|
|
|
187
|
- }
|
|
|
188
|
-
|
|
|
189
|
- return result;
|
|
|
190
|
-};
|
|
|
191
|
-
|
|
|
192
|
-/**
|
|
|
193
|
- * 根据性别来决定 默认图片获取字段 如果是 2、3
|
|
|
194
|
- * @param {[type]} images [description]
|
|
|
195
|
- * @return {[type]} [description]
|
|
|
196
|
- */
|
|
|
197
|
-/* exports.procProductImg = (images) => {
|
|
|
198
|
- let imgUrl = (!_.isEmpty(images.images_url)) ? images.images_url : '';
|
|
|
199
|
- let cover1 = (!_.isEmpty(images.cover_1)) ? images.cover_1 : '';
|
|
|
200
|
- let cover2 = (!_.isEmpty(images.cover_2)) ? images.cover_2 : '';
|
|
|
201
|
- // let gender = getGenderByCookie();
|
|
|
202
|
-
|
|
|
203
|
- if (gender === '2,3') {
|
|
|
204
|
- let temp = !_.isEmpty(cover1) ? cover1 : imgUrl;
|
|
|
205
|
- return !_.isEmpty(cover2) ? cover2 : temp;
|
|
|
206
|
- } else {
|
|
|
207
|
- let temp = !_.isEmpty(cover2) ? cover2 : imgUrl;
|
|
|
208
|
- return !_.isEmpty(cover1) ? cover1 : temp;
|
|
|
209
|
- }
|
|
|
210
|
-};*/
|
|
|
211
|
-
|
|
|
212
|
-/**
|
|
|
213
|
- * 根据用户访问的COOKIE判断出性别 待处理
|
|
|
214
|
- * @return {[type]} [description]
|
|
|
215
|
- */
|
|
|
216
|
-exports.getGenderByCookie = () => {
|
|
|
217
|
- return '2,3';
|
|
|
218
|
-}; |
|
|