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
yyq
9 years ago
Commit
ea4dab67209772c57cac0a24ac15baf9844347d3
1 parent
cbab79dc
尺码信息
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
197 additions
and
10 deletions
apps/product/models/item-api.js
apps/product/models/item-handler.js
apps/product/models/item.js
config/common.js
apps/product/models/item-api.js
View file @
ea4dab6
...
...
@@ -31,7 +31,7 @@ const getsizeInfoAsync = (skn) => {
},
{
cache
:
true
});
};
const
get
ProductComfort
=
productId
=>
{
const
get
ComfortAsync
=
productId
=>
{
return
api
.
get
(
''
,
{
method
:
'web.productComfort.data'
,
product_id
:
productId
...
...
@@ -42,8 +42,19 @@ const getProductComfort = productId => {
};
const
getModelTryAsync
=
skn
=>
{
return
api
.
get
(
''
,
{
method
:
'web.productModelTry.data'
,
product_skn
:
skn
},
{
cache
:
true
,
code
:
200
});
};
module
.
exports
=
{
getProductBaseAsync
,
getsizeInfoAsync
,
getProductComfort
getComfortAsync
,
getModelTryAsync
};
...
...
apps/product/models/item-handler.js
View file @
ea4dab6
...
...
@@ -9,6 +9,42 @@ const _ = require('lodash');
const
helpers
=
global
.
yoho
.
helpers
;
/**
* 使sizeBoList id以 sizeAttributeBos id顺序一样
* @param sizeInfoBo
*/
const
_sizeInfoBoSort
=
sizeInfoBo
=>
{
if
(
!
sizeInfoBo
.
sizeBoList
||
!
sizeInfoBo
.
sizeAttributeBos
)
{
return
{};
}
// TODO: 这里的排序代码很乱
_
.
forEach
(
sizeInfoBo
.
sizeBoList
,
(
sizeBoList
,
sizek
)
=>
{
let
sortAttr
=
{};
_
.
forEach
(
sizeBoList
.
sortAttributes
,
sortAttributes
=>
{
sortAttr
[
sortAttributes
.
id
]
=
sortAttributes
;
});
sizeInfoBo
.
sizeBoList
[
sizek
].
sortAttributes
=
sortAttr
;
});
_
.
forEach
(
sizeInfoBo
.
sizeBoList
,
(
sizeBoList
,
sizek
)
=>
{
let
sortAttr
=
[];
_
.
forEach
(
sizeInfoBo
.
sizeAttributeBos
,
val
=>
{
sortAttr
.
push
(
sizeBoList
.
sortAttributes
[
val
.
id
]);
});
sizeInfoBo
.
sizeBoList
[
sizek
].
sortAttributes
=
sortAttr
;
});
return
sizeInfoBo
;
};
/**
* 设置品牌banner数据
* @param brand 品牌相关数据
* @return Object
...
...
@@ -166,7 +202,8 @@ const setBrandIntro = brand => {
/**
* 设置商品描述
* @param brand 品牌相关数据
* @param sizeInfo
* @param comfortInfo
* @return Object
*/
const
setDescriptionInfo
=
(
sizeInfo
,
comfortInfo
)
=>
{
...
...
@@ -198,7 +235,7 @@ const setDescriptionInfo = (sizeInfo, comfortInfo) => {
];
if
(
_
.
isArray
(
sizeInfo
.
productDescBo
.
standardBos
))
{
_
.
forEach
(
sizeInfo
.
productDescBo
.
standardBos
,
function
(
value
)
{
_
.
forEach
(
sizeInfo
.
productDescBo
.
standardBos
,
value
=>
{
basic
.
push
({
key
:
value
.
standardName
,
value
:
value
.
standardVal
...
...
@@ -211,7 +248,7 @@ const setDescriptionInfo = (sizeInfo, comfortInfo) => {
if
(
comfortInfo
)
{
let
comfort
=
[];
_
.
forEach
(
comfortInfo
,
function
(
value
)
{
_
.
forEach
(
comfortInfo
,
value
=>
{
let
i
=
1
;
let
blocks
=
[];
let
flag
=
false
;
...
...
@@ -249,9 +286,142 @@ const setDescriptionInfo = (sizeInfo, comfortInfo) => {
return
resData
;
};
/**
* 设置尺寸信息
* @param sizeInfo
* @return Object
*/
const
setSizeData
=
(
sizeInfo
)
=>
{
let
resData
=
{};
if
(
sizeInfo
.
sizeInfoBo
)
{
let
referenceName
,
boyReference
,
girlReference
,
gender
;
let
size
=
{
titleEn
:
'SIZEINFO'
,
titleCn
:
'尺码信息'
};
sizeInfo
.
sizeInfoBo
=
_sizeInfoBoSort
(
sizeInfo
.
sizeInfoBo
);
// 参考尺码
if
(
_
.
has
(
sizeInfo
,
'productExtra'
))
{
boyReference
=
sizeInfo
.
productExtra
.
boyReference
;
girlReference
=
sizeInfo
.
productExtra
.
girlReference
;
}
gender
=
_
.
has
(
sizeInfo
,
'productDescBo.gender'
)
?
sizeInfo
.
productDescBo
.
gender
:
3
;
if
(
gender
===
3
&&
boyReference
)
{
referenceName
=
'参考尺码(男)'
;
}
else
if
(
gender
===
3
&&
girlReference
)
{
referenceName
=
'参考尺码(女)'
;
}
else
{
referenceName
=
'参考尺码'
;
}
// 判断是否显示参考尺码
let
showReference
=
(
boyReference
&&
_
.
get
(
sizeInfo
.
sizeInfoBo
,
'sizeBoList[0].boyReferSize'
,
false
))
||
(
girlReference
&&
_
.
get
(
sizeInfo
.
sizeInfoBo
,
'sizeBoList[0].girlReferSize'
,
false
));
if
(
sizeInfo
.
sizeInfoBo
.
sizeAttributeBos
)
{
let
sizeTable
=
{};
// 尺码信息头部
sizeTable
.
thead
=
[{
name
:
'吊牌尺码'
,
id
:
''
,
width
:
126
}];
// 显示参考尺码
if
(
showReference
)
{
sizeTable
.
thead
.
push
({
name
:
referenceName
,
id
:
''
,
width
:
126
});
}
_
.
forEach
(
sizeInfo
.
sizeInfoBo
.
sizeAttributeBos
,
value
=>
{
sizeTable
.
thead
.
push
({
name
:
value
.
attributeName
||
' '
,
id
:
value
.
id
,
width
:
126
});
});
sizeTable
.
tbody
=
[];
_
.
forEach
(
sizeInfo
.
sizeInfoBo
.
sizeBoList
,
value
=>
{
let
sizes
=
[];
// 吊牌尺码
sizes
.
push
(
value
.
sizeName
);
// 判断是否显示参考尺码
if
(
boyReference
&&
(
gender
===
1
||
gender
===
3
)
&&
showReference
)
{
sizes
.
push
(
value
.
boyReferSize
.
referenceName
||
' '
);
}
else
if
(
girlReference
&&
(
gender
===
2
||
gender
===
3
)
&&
showReference
)
{
sizes
.
push
(
value
.
girlReferSize
.
referenceName
||
' '
);
}
else
{
if
(
sizeTable
.
thead
[
1
]
&&
showReference
)
{
sizeTable
.
thead
[
1
]
=
{};
}
}
// 其他尺码信息
value
.
sortAttributes
.
forEach
(
attr
=>
{
sizes
.
push
((
attr
.
sizeValue
||
' '
));
});
// 尺码信息
sizeTable
.
tbody
.
push
(
sizes
);
});
// 参考尺码为空
if
(
_
.
isEmpty
(
sizeTable
.
thead
[
1
])
&&
showReference
)
{
// 移除这个值
sizeTable
.
thead
.
splice
(
1
,
1
);
}
size
.
param
=
sizeTable
;
}
if
(
!
_
.
isEmpty
(
sizeInfo
.
modelBos
))
{
let
tasteTable
=
{};
tasteTable
.
thead
=
[
{
name
:
'模特'
,
width
:
170
},
{
name
:
'身高'
,
width
:
126
},
{
name
:
'体重'
,
width
:
126
},
{
name
:
'三围'
,
width
:
126
},
{
name
:
'吊牌尺码'
,
width
:
126
},
{
name
:
'试穿描述'
,
width
:
126
}
];
tasteTable
.
tbody
=
[];
_
.
forEach
(
sizeInfo
.
modelBos
,
value
=>
{
let
modelInfo
=
[
value
.
avatar
,
value
.
modelName
,
value
.
height
,
value
.
weight
,
value
.
vitalStatistics
,
value
.
fitModelBo
.
fit_size
,
value
.
fitModelBo
.
feel
];
// 是否有备注
if
(
_
.
get
(
value
,
'fitModelBo.fit_remark'
,
false
))
{
modelInfo
.
push
(
value
.
fitModelBo
.
fit_remark
);
tasteTable
.
thead
[
7
]
=
{
name
:
'备注'
,
width
:
170
};
}
tasteTable
.
tbody
.
push
(
modelInfo
);
});
console
.
log
(
tasteTable
);
size
.
taste
=
tasteTable
;
}
resData
.
sizeInfo
=
size
;
}
return
resData
;
};
module
.
exports
=
{
setBrandBanner
,
setProductData
,
setBrandIntro
,
setDescriptionInfo
setDescriptionInfo
,
setSizeData
};
...
...
apps/product/models/item.js
View file @
ea4dab6
...
...
@@ -17,7 +17,8 @@ const _getMultiResourceByBaseInfo = (base, uid) => {
// 获取相关数据
let
promiseData
=
[
itemAPI
.
getsizeInfoAsync
(
skn
),
itemAPI
.
getProductComfort
(
productId
)
itemAPI
.
getComfortAsync
(
productId
),
itemAPI
.
getModelTryAsync
(
skn
)
];
if
(
uid
)
{
...
...
@@ -61,9 +62,14 @@ let getProductItemData = (params) => {
}
return
_getMultiResourceByBaseInfo
(
result
).
then
(
mulRes
=>
{
//
设置
商品描述
//
DESCRIPTION
商品描述
Object
.
assign
(
data
,
itemFUN
.
setDescriptionInfo
(
mulRes
.
sizeInfo
,
mulRes
.
comfort
));
// SIZEINFO尺码信息
Object
.
assign
(
data
,
itemFUN
.
setSizeData
(
mulRes
.
sizeInfo
));
return
data
;
});
...
...
config/common.js
View file @
ea4dab6
...
...
@@ -19,8 +19,8 @@ module.exports = {
},
cookieDomain
:
'yohoblk.com'
,
domains
:
{
api
:
'http://api.yoho.cn/'
,
// devapi.yoho.cn:58078 testapi.yoho.cn:28078 devapi.yoho.cn:58078
service
:
'http://service.yoho.cn/'
,
// testservice.yoho.cn:28077 devservice.yoho.cn:58077
api
:
'http://testapi.yoho.cn:28078/'
,
// devapi.yoho.cn:58078 testapi.yoho.cn:28078 devapi.yoho.cn:58078
service
:
'http://testservice.yoho.cn:28077/'
,
// testservice.yoho.cn:28077 devservice.yoho.cn:58077
search
:
'http://192.168.102.216:8080/yohosearch/'
},
useOneapm
:
false
,
...
...
Please
register
or
login
to post a comment