Toggle navigation
Toggle navigation
This project
Loading...
Sign in
fe
/
yoho-blk
·
Commits
Go to a project
GitLab
Go to group
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
0
Merge Requests
1
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Email Patches
Plain Diff
Browse Files
Authored by
biao
9 years ago
Commit
dbfb9844035966e4db4b31e2e5972151fc0da512
1 parent
883688a0
optimise code
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
65 additions
and
37 deletions
utils/product-process.js
utils/resources-process.js
utils/product-process.js
View file @
dbfb984
/**
* 商品处理
* @author:
* @date:
*/
'use strict'
;
const
_
=
require
(
'lodash'
);
const
camelCase
=
global
.
yoho
.
camelCase
;
...
...
@@ -114,35 +121,39 @@ exports.processProductList = (list, options) => {
}
if
(
options
.
showTags
)
{
product
.
tags
=
{};
product
.
tags
.
isNew
=
options
.
showNew
&&
product
.
isNew
===
'Y'
;
// 新品
product
.
tags
.
isDiscount
=
options
.
showSale
&&
product
.
isDiscount
===
'Y'
;
// 在售
product
.
tags
.
isLimited
=
product
.
isLimited
===
'Y'
;
// 限量
product
.
tags
.
isYohood
=
product
.
isYohood
===
'Y'
;
// YOHOOD
product
.
tags
.
midYear
=
product
.
midYear
===
'Y'
;
// 年中
product
.
tags
.
yearEnd
=
product
.
yearEnd
===
'Y'
;
// 年末
product
.
tags
.
isAdvance
=
product
.
isAdvance
===
'Y'
;
// 再到着
let
tags
=
{};
Object
.
assign
(
tags
,
{
isNew
:
options
.
showNew
&&
product
.
isNew
===
'Y'
,
// 新品
isDiscount
:
options
.
showSale
&&
product
.
isDiscount
===
'Y'
,
// 在售
isLimited
:
product
.
isLimited
===
'Y'
,
// 限量
isYohood
:
product
.
isYohood
===
'Y'
,
// YOHOOD
midYear
:
product
.
midYear
===
'Y'
,
// 年中
yearEnd
:
product
.
yearEnd
===
'Y'
,
// 年末
isAdvance
:
product
.
isAdvance
===
'Y'
// 再到着
})
// 打折与即将售完组合显示打折
if
(
product
.
isSoonSoldOut
&&
product
.
tags
.
isDiscount
)
{
product
.
tags
.
isFew
=
false
;
}
else
if
(
product
.
tags
.
isDiscount
&&
(
product
.
tags
.
isFew
||
product
.
tags
.
isLimited
||
product
.
tags
.
isYohood
||
product
.
tags
.
isAdvance
))
{
if
(
product
.
isSoonSoldOut
&&
tags
.
isDiscount
)
{
tags
.
isFew
=
false
;
}
else
if
(
tags
.
isDiscount
&&
(
tags
.
isFew
||
tags
.
isLimited
||
tags
.
isYohood
||
tags
.
isAdvance
))
{
// 打折与其它组合则隐藏打折
product
.
tags
.
isDiscount
=
false
;
}
else
if
(
product
.
tags
.
isYohood
&&
product
.
tags
.
isFew
)
{
tags
.
isDiscount
=
false
;
}
else
if
(
tags
.
isYohood
&&
tags
.
isFew
)
{
// YOHOOD和新品组合显示YOHOOD
product
.
tags
.
isFew
=
false
;
tags
.
isFew
=
false
;
}
product
.
tags
=
tags
;
}
pruductList
.
push
(
product
);
});
return
handleGoodsListData
(
pruductList
);
};
/**
* 处理筛选数据
* @param list
...
...
@@ -311,34 +322,43 @@ exports.processProduct = (productData, options) => {
result
.
name
=
productData
.
product_name
;
result
.
price
=
!
productData
.
market_price
?
false
:
productData
.
market_price
;
result
.
salePrice
=
productData
.
sales_price
;
if
(
options
.
showPoint
)
{
result
.
price
+=
'.00'
;
result
.
salePrice
+=
'.00'
;
result
.
price
=
parseInt
(
result
.
price
,
10
).
toFixed
(
2
);
result
.
salePrice
=
parseInt
(
result
.
salePrice
,
10
).
toFixed
(
2
);
}
result
.
is_soon_sold_out
=
(
productData
.
is_soon_sold_out
===
'Y'
);
result
.
url
=
helpers
.
urlFormat
(
`
/
product
/
pro_$
{
productData
.
product_id
}
_$
{
productData
.
goods_list
[
0
].
goods_id
}
/${productData.cn_alphabet}.html`, null, 'list'
)
; // eslint-disable-lin
e
result
.
url
=
helpers
.
urlFormat
(
`
/
product
/
pro_$
{
productData
.
product_id
}
_$
{
productData
.
goods_list
[
0
].
goods_id
}
/${productData.cn_alphabet}.htm
l
`
,
null
,
'list'
);
if
(
options
.
showTags
)
{
result
.
tags
=
{};
result
.
tags
.
is_new
=
options
.
showNew
&&
productData
.
is_new
&&
productData
.
is_new
===
'Y'
;
// 新品
result
.
tags
.
is_discount
=
options
.
showSale
&&
productData
.
is_discount
&&
productData
.
is_discount
===
'Y'
;
// 在售
result
.
tags
.
is_limited
=
productData
.
is_limited
&&
productData
.
is_limited
===
'Y'
;
// 限量
result
.
tags
.
is_yohood
=
productData
.
is_yohood
&&
productData
.
is_yohood
===
'Y'
;
// YOHOOD
result
.
tags
.
midYear
=
productData
[
'mid-year'
]
&&
productData
[
'mid-year'
]
===
'Y'
;
// 年中
result
.
tags
.
yearEnd
=
productData
[
'year-end'
]
&&
productData
[
'year-end'
]
===
'Y'
;
// 年末
result
.
tags
.
is_advance
=
productData
.
is_advance
&&
productData
.
is_advance
===
'Y'
;
// 再到着
if
(
result
.
is_soon_sold_out
&&
result
.
tags
.
is_discount
)
{
result
.
tags
.
is_new
=
false
;
// 打折与即将售完组合显示打折
}
else
if
(
result
.
tags
.
is_discount
&&
(
result
.
tags
.
is_new
||
result
.
tags
.
is_limited
||
result
.
tags
.
is_yohood
||
result
.
tags
.
is_advance
))
{
result
.
tags
.
is_discount
=
false
;
// 打折与其它组合则隐藏打折
}
else
if
(
result
.
tags
.
is_yohood
&&
result
.
tags
.
is_new
)
{
result
.
tags
.
is_new
=
false
;
// YOHOOD和新品组合显示YOHOOD
let
tags
=
{};
Object
.
assign
(
tags
,
{
is_new
:
options
.
showNew
&&
productData
.
is_new
&&
productData
.
is_new
===
'Y'
,
// 新品
is_discount
:
options
.
showSale
&&
productData
.
is_discount
&&
productData
.
is_discount
===
'Y'
,
// 在售
is_limited
:
productData
.
is_limited
&&
productData
.
is_limited
===
'Y'
,
// 限量
is_yohood
:
productData
.
is_yohood
&&
productData
.
is_yohood
===
'Y'
,
// YOHOOD
midYear
:
productData
[
'mid-year'
]
&&
productData
[
'mid-year'
]
===
'Y'
,
// 年中
yearEnd
:
productData
[
'year-end'
]
&&
productData
[
'year-end'
]
===
'Y'
,
// 年末
is_advance
:
productData
.
is_advance
&&
productData
.
is_advance
===
'Y'
// 再到着
});
if
(
result
.
is_soon_sold_out
&&
tags
.
is_discount
)
{
tags
.
is_new
=
false
;
// 打折与即将售完组合显示打折
}
else
if
(
tags
.
is_discount
&&
(
tags
.
is_new
||
tags
.
is_limited
||
tags
.
is_yohood
||
tags
.
is_advance
))
{
tags
.
is_discount
=
false
;
// 打折与其它组合则隐藏打折
}
else
if
(
tags
.
is_yohood
&&
tags
.
is_new
)
{
tags
.
is_new
=
false
;
// YOHOOD和新品组合显示YOHOOD
}
result
.
tags
=
tags
;
}
return
result
;
};
...
...
utils/resources-process.js
View file @
dbfb984
/**
* 特殊资源位处理
* @author: bikai<bikai@yoho.cn>
* @date: 2016/4/25
*/
'use strict'
;
const
_
=
require
(
'lodash'
);
const
camelCase
=
global
.
yoho
.
camelCase
;
...
...
Please
register
or
login
to post a comment