|
|
/**
|
|
|
* 商品详情models
|
|
|
* @author: xuqi<qi.xu@yoho.cn>
|
|
|
* @date: 2016/5/6
|
|
|
*/
|
|
|
|
|
|
'use strict';
|
|
|
|
|
|
const library = '../../../library';
|
|
|
const API = require(`${library}/api`);
|
|
|
const sign = require(`${library}/sign`);
|
|
|
|
|
|
var api = new API;
|
|
|
|
|
|
/**
|
|
|
* 详情页数据格式化
|
|
|
* @param origin Object 原始数据
|
|
|
* @return dest Object 格式化数据
|
|
|
*/
|
|
|
const introDataPkg = (origin) => {
|
|
|
var dest = {};
|
|
|
|
|
|
var descBo = origin.productDescBo;
|
|
|
var sizeBo = origin.sizeInfoBo;
|
|
|
|
|
|
// 商品信息
|
|
|
if (descBo) {
|
|
|
|
|
|
// 编号、颜色、性别
|
|
|
let sex;
|
|
|
|
|
|
switch (descBo.gender) {
|
|
|
case 1:
|
|
|
sex = '男款';
|
|
|
break;
|
|
|
case 2:
|
|
|
sex = '女款';
|
|
|
break;
|
|
|
default:
|
|
|
sex = '通用';
|
|
|
}
|
|
|
|
|
|
dest.description.table = [
|
|
|
`编号:${descBo.erpProductId}`,
|
|
|
`颜色:${descBo.colorName}`,
|
|
|
`性别:${sex}`
|
|
|
];
|
|
|
|
|
|
// 其余参数
|
|
|
for (let standard of descBo.standardBos) {
|
|
|
dest.description.table.push(`${standard.standardName}:${standard.standardVal}`);
|
|
|
}
|
|
|
|
|
|
// 商品详情描述
|
|
|
dest.description.desc = descBo.phrase;
|
|
|
}
|
|
|
|
|
|
// 尺码信息
|
|
|
if (sizeBo) {
|
|
|
let gender = descBo.gender;
|
|
|
let boyReference = origin.productExtra.boyReference;
|
|
|
let girlReference = origin.productExtra.girlReference;
|
|
|
|
|
|
let reference = '参考尺码';
|
|
|
let showReference = false;
|
|
|
|
|
|
if (gender === 3) {
|
|
|
if (boyReference) {
|
|
|
reference = '参考尺码(男)';
|
|
|
} else if (girlReference) {
|
|
|
reference = '参考尺码(女)';
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// 是否显示参考尺码
|
|
|
showReference = (boyReference && sizeBo.sizeBoList[0].boyReferSize) ||
|
|
|
(girlReference && sizeBo.sizeBoList[0].girlReferSize);
|
|
|
|
|
|
}
|
|
|
}
|
|
|
|
|
|
module.exports = (data, cb) => {
|
|
|
|
|
|
api.get('', sign.apiSign({
|
|
|
productskn: data.id,
|
|
|
udid: 'f528764d624db129b32c21fbca0cb8d6',
|
|
|
uid: '11993475',
|
|
|
method: 'h5.product.intro'
|
|
|
})).then(data => {
|
|
|
var dJson = JSON.parse(data);
|
|
|
|
|
|
cb(data);
|
|
|
});
|
|
|
}; |
|
|
\ No newline at end of file |
...
|
...
|
|