Toggle navigation
Toggle navigation
This project
Loading...
Sign in
fe
/
yohobuywap-node
·
Commits
Go to a project
GitLab
Go to group
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
0
Merge Requests
0
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Plain Diff
Browse Files
Authored by
ccbikai
9 years ago
Commit
a573ad5870cc756004485f5b5588da04f36907fc
2 parents
0df08b2a
ff18f61a
Merge branch 'feature/sale' into release/4.8
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
45 additions
and
13 deletions
config/common.js
doraemon/views/partial/common/filter.hbs
utils/product-process.js
config/common.js
View file @
a573ad5
...
...
@@ -15,8 +15,11 @@ module.exports = {
port
:
6001
,
siteUrl
:
'//m.yohobuy.com'
,
domains
:
{
api
:
'http://devapi.yoho.cn:58078/'
,
service
:
'http://devservice.yoho.cn:58077/'
api
:
'http://testapi.yoho.cn:28078/'
,
service
:
'http://testservice.yoho.cn:28077/'
// api: 'http://devapi.yoho.cn:58078/',
// service: 'http://devservice.yoho.cn:58077/'
},
subDomains
:
{
host
:
'.m.yohobuy.com'
,
...
...
@@ -31,9 +34,9 @@ module.exports = {
useOneapm
:
false
,
useCache
:
false
,
memcache
:
{
master
:
[
'192.168.102.161:11213'
],
slave
:
[
'192.168.102.161:11213'
],
session
:
[
'192.168.102.161:11213'
],
master
:
[
'192.168.102.222:12111'
],
slave
:
[
'192.168.102.222:12111'
],
session
:
[
'192.168.102.222:12111'
],
timeout
:
1000
,
retries
:
0
},
...
...
doraemon/views/partial/common/filter.hbs
View file @
a573ad5
...
...
@@ -21,4 +21,4 @@
</ul>
</div>
</div>
{{/
filter
}}
\ No newline at end of file
{{/
filter
}}
...
...
utils/product-process.js
View file @
a573ad5
...
...
@@ -19,6 +19,27 @@ const _procProductImg = (product, gender, yhChannel) => {
return
product
.
cover1
||
product
.
imagesUrl
||
product
.
cover2
||
''
;
};
const
toArray
=
(
obj
)
=>
{
if
(
_
.
isArray
(
obj
))
{
return
obj
;
}
let
arr
=
[];
_
.
forEach
(
obj
,
(
v
,
k
)
=>
{
if
(
_
.
isObject
(
v
))
{
v
.
_key
=
k
;
}
else
{
v
=
{
_key
:
k
,
_value
:
v
};
}
arr
.
push
(
v
);
});
return
arr
;
};
/**
* 按照数组中指定字段排序二维数组
*
...
...
@@ -27,8 +48,9 @@ const _procProductImg = (product, gender, yhChannel) => {
* @param boolean 有 desc 时候降序排列,默认为false
*/
const
_sortListByField
=
(
list
,
key
,
desc
)
=>
{
list
=
_
.
toArray
(
list
);
list
=
list
.
sort
((
a
,
b
)
=>
{
let
array
=
toArray
(
list
);
array
=
array
.
sort
((
a
,
b
)
=>
{
let
matchNumber
=
/
([\d]
+
)
/g
;
// 有键,使用键的值排序
...
...
@@ -40,12 +62,13 @@ const _sortListByField = (list, key, desc) => {
}
// 无键, 使用本身
let
numA
=
+
(
_
.
toArray
(
a
.
match
(
matchNumber
))[
0
]
||
0
);
let
numB
=
+
(
_
.
toArray
(
b
.
match
(
matchNumber
))[
0
]
||
0
);
let
numA
=
+
(
_
.
toArray
(
a
.
_value
.
match
(
matchNumber
))[
0
]
||
0
);
let
numB
=
+
(
_
.
toArray
(
b
.
_value
.
match
(
matchNumber
))[
0
]
||
0
);
return
numA
<
numB
?
-
1
:
1
;
});
return
list
;
return
array
;
};
/**
...
...
@@ -265,7 +288,11 @@ exports.processFilter = (list, options) => {
_
.
forEach
(
item
,
(
sub
,
index
)
=>
{
let
subs
=
{};
if
(
filtersType
[
key
].
dataId
===
'key'
)
{
if
(
key
===
'discount'
)
{
subs
.
dataId
=
sub
.
_key
;
}
else
if
(
key
===
'priceRange'
)
{
subs
.
dataId
=
sub
.
_key
;
}
else
if
(
filtersType
[
key
].
dataId
===
'key'
)
{
subs
.
dataId
=
index
;
}
else
if
(
filtersType
[
key
].
dataId
===
'relationParameter'
)
{
subs
.
dataId
=
sub
.
relationParameter
[
'sort'
];
// eslint-disable-line
...
...
@@ -273,7 +300,9 @@ exports.processFilter = (list, options) => {
subs
.
dataId
=
sub
[
filtersType
[
key
].
dataId
];
}
if
(
filtersType
[
key
].
subsName
===
'flag'
)
{
if
(
key
===
'priceRange'
)
{
subs
.
name
=
sub
.
_value
;
}
else
if
(
filtersType
[
key
].
subsName
===
'flag'
)
{
subs
.
name
=
sub
;
}
else
{
subs
.
name
=
sub
[
filtersType
[
key
].
subsName
];
...
...
Please
register
or
login
to post a comment