Authored by 郭成尧

'数据校验'

@@ -26,10 +26,10 @@ const getSizeInfo = (sizeInfo) => { @@ -26,10 +26,10 @@ const getSizeInfo = (sizeInfo) => {
26 dest.goodsDescription.detail = {}; 26 dest.goodsDescription.detail = {};
27 dest.goodsDescription.detail.list = []; 27 dest.goodsDescription.detail.list = [];
28 28
29 - if (!_.isEmpty(sizeInfo.productDescBo.erpProductId)) { 29 + if (_.has(sizeInfo, 'productDescBo.erpProductId')) {
30 let sex = '通用'; 30 let sex = '通用';
31 31
32 - switch (sizeInfo.productDescBo.gender) { 32 + switch (_.get(sizeInfo, 'productDescBo.gender', 0)) {
33 case 1: 33 case 1:
34 sex = '男款'; 34 sex = '男款';
35 break; 35 break;
@@ -43,17 +43,17 @@ const getSizeInfo = (sizeInfo) => { @@ -43,17 +43,17 @@ const getSizeInfo = (sizeInfo) => {
43 dest.goodsDescription.title = '商品信息'; 43 dest.goodsDescription.title = '商品信息';
44 dest.goodsDescription.enTitle = 'DESCRIPTION'; 44 dest.goodsDescription.enTitle = 'DESCRIPTION';
45 temp = {}; 45 temp = {};
46 - temp.param = '编号:' + sizeInfo.productDescBo.erpProductId; 46 + temp.param = '编号:' + _.get(sizeInfo, 'productDescBo.erpProductId', '');
47 dest.goodsDescription.detail.list.push(temp); 47 dest.goodsDescription.detail.list.push(temp);
48 temp = {}; 48 temp = {};
49 - temp.param = '颜色:' + sizeInfo.productDescBo.colorName; 49 + temp.param = '颜色:' + _.get(sizeInfo, 'productDescBo.colorName', '');
50 dest.goodsDescription.detail.list.push(temp); 50 dest.goodsDescription.detail.list.push(temp);
51 temp = {}; 51 temp = {};
52 temp.param = '性别:' + sex; 52 temp.param = '性别:' + sex;
53 dest.goodsDescription.detail.list.push(temp); 53 dest.goodsDescription.detail.list.push(temp);
54 } 54 }
55 55
56 - if (!_.isEmpty(sizeInfo.productDescBo.standardBos)) { 56 + if (_.has(sizeInfo, 'productDescBo.standardBos')) {
57 _.forEach(sizeInfo.productDescBo.standardBos, function(value) { 57 _.forEach(sizeInfo.productDescBo.standardBos, function(value) {
58 temp = {}; 58 temp = {};
59 temp.param = value.standardName + ':' + 59 temp.param = value.standardName + ':' +
@@ -62,12 +62,12 @@ const getSizeInfo = (sizeInfo) => { @@ -62,12 +62,12 @@ const getSizeInfo = (sizeInfo) => {
62 dest.goodsDescription.detail.list.push(temp); 62 dest.goodsDescription.detail.list.push(temp);
63 }); 63 });
64 } 64 }
65 - if (_.isEmpty(sizeInfo.phrase)) { 65 + if (sizeInfo.phrase) {
66 dest.goodsDescription.desc = sizeInfo.phrase; 66 dest.goodsDescription.desc = sizeInfo.phrase;
67 } 67 }
68 68
69 // 尺码信息 69 // 尺码信息
70 - if (!_.isEmpty(sizeInfo.sizeInfoBo)) { 70 + if (sizeInfo.sizeInfoBo) {
71 dest.sizeInfo = {}; 71 dest.sizeInfo = {};
72 dest.sizeInfo.title = '尺码信息'; 72 dest.sizeInfo.title = '尺码信息';
73 dest.sizeInfo.enTitle = 'SIZE INFO'; 73 dest.sizeInfo.enTitle = 'SIZE INFO';
@@ -75,9 +75,9 @@ const getSizeInfo = (sizeInfo) => { @@ -75,9 +75,9 @@ const getSizeInfo = (sizeInfo) => {
75 dest.sizeInfo.detail.list = []; 75 dest.sizeInfo.detail.list = [];
76 76
77 // 参考尺码 77 // 参考尺码
78 - let boyReference = sizeInfo.productExtra.boyReference;  
79 - let girlReference = sizeInfo.productExtra.girlReference;  
80 - let gender = sizeInfo.productDescBo.gender ? sizeInfo.productDescBo.gender : 3; 78 + let boyReference = _.get(sizeInfo, 'productExtra.boyReference', null);
  79 + let girlReference = _.get(sizeInfo, 'productExtra.girlReference', null);
  80 + let gender = _.get(sizeInfo, 'productDescBo.gender', 3);
81 let referenceName = '参考尺码'; 81 let referenceName = '参考尺码';
82 82
83 if ((gender === 1 && boyReference) || (gender === 2 && girlReference)) { 83 if ((gender === 1 && boyReference) || (gender === 2 && girlReference)) {
@@ -91,16 +91,18 @@ const getSizeInfo = (sizeInfo) => { @@ -91,16 +91,18 @@ const getSizeInfo = (sizeInfo) => {
91 let referenceList = []; 91 let referenceList = [];
92 92
93 // 判断是否显示参考尺码 93 // 判断是否显示参考尺码
94 - let showReference = (boyReference &&  
95 - !_.isEmpty(sizeInfo.sizeInfoBo.sizeBoList[0].boyReferSize)) || (girlReference &&  
96 - !_.isEmpty(sizeInfo.sizeInfoBo.sizeBoList[0].girlReferSize)); 94 + let showReference = (boyReference && sizeInfo.sizeInfoBo &&
  95 + sizeInfo.sizeInfoBo.sizeBoList && sizeInfo.sizeInfoBo.sizeBoList[0] &&
  96 + sizeInfo.sizeInfoBo.sizeBoList[0].boyReferSize) ||
  97 + (girlReference && sizeInfo.sizeInfoBo && sizeInfo.sizeInfoBo.sizeBoList &&
  98 + sizeInfo.sizeInfoBo.sizeBoList[0] && sizeInfo.sizeInfoBo.sizeBoList[0].girlReferSize);
97 99
98 if (showReference) { 100 if (showReference) {
99 referenceList[0] = {}; 101 referenceList[0] = {};
100 referenceList[0].param = referenceName; 102 referenceList[0].param = referenceName;
101 } 103 }
102 104
103 - if (!_.isEmpty(sizeInfo.sizeInfoBo.sizeAttributeBos)) { 105 + if (_.has(sizeInfo, 'sizeInfoBo.sizeAttributeBos')) {
104 106
105 // [{param: attrName}] th 107 // [{param: attrName}] th
106 let sizeNameList = []; 108 let sizeNameList = [];
@@ -112,14 +114,15 @@ const getSizeInfo = (sizeInfo) => { @@ -112,14 +114,15 @@ const getSizeInfo = (sizeInfo) => {
112 // {id: [{param: str},......]} sizeBoGroup[id][0] 属性名, sizeBoGroup[id][index] 属性值 114 // {id: [{param: str},......]} sizeBoGroup[id][0] 属性名, sizeBoGroup[id][index] 属性值
113 let sizeBoGroup = {}; 115 let sizeBoGroup = {};
114 116
  117 + if (_.has(sizeInfo, 'sizeInfoBo.sizeAttributeBos')) {
115 _.forEach(sizeInfo.sizeInfoBo.sizeAttributeBos, function(attr) { 118 _.forEach(sizeInfo.sizeInfoBo.sizeAttributeBos, function(attr) {
116 sizeBoGroup[attr.id] = []; 119 sizeBoGroup[attr.id] = [];
117 sizeBoGroup[attr.id][0] = {}; 120 sizeBoGroup[attr.id][0] = {};
118 - sizeBoGroup[attr.id][0].param = _.isEmpty(attr.attributeName) ?  
119 - ' ' : attr.attributeName; 121 + sizeBoGroup[attr.id][0].param = attr.attributeName;
120 }); 122 });
  123 + }
121 124
122 - 125 + if (_.has(sizeInfo, 'sizeInfoBo.sizeBoList')) {
123 _.forEach(sizeInfo.sizeInfoBo.sizeBoList, function(value) { 126 _.forEach(sizeInfo.sizeInfoBo.sizeBoList, function(value) {
124 127
125 temp = {}; 128 temp = {};
@@ -144,6 +147,7 @@ const getSizeInfo = (sizeInfo) => { @@ -144,6 +147,7 @@ const getSizeInfo = (sizeInfo) => {
144 sizeBoGroup[attr.id].push(temp); 147 sizeBoGroup[attr.id].push(temp);
145 }); 148 });
146 }); 149 });
  150 + }
147 151
148 // 根据模板页面的显示,按表格一列一列来显示 152 // 根据模板页面的显示,按表格一列一列来显示
149 dest.sizeInfo.detail.list[0] = {}; 153 dest.sizeInfo.detail.list[0] = {};
@@ -163,7 +167,7 @@ const getSizeInfo = (sizeInfo) => { @@ -163,7 +167,7 @@ const getSizeInfo = (sizeInfo) => {
163 } 167 }
164 168
165 // 测量方式 169 // 测量方式
166 - if (!_.isEmpty(sizeInfo.sizeImage)) { 170 + if (sizeInfo.sizeImage) {
167 dest.measurementMethod = {}; 171 dest.measurementMethod = {};
168 172
169 dest.measurementMethod.title = '测量方式'; 173 dest.measurementMethod.title = '测量方式';
@@ -172,7 +176,7 @@ const getSizeInfo = (sizeInfo) => { @@ -172,7 +176,7 @@ const getSizeInfo = (sizeInfo) => {
172 } 176 }
173 177
174 // 模特试穿, 竖着输出排列显示 178 // 模特试穿, 竖着输出排列显示
175 - if (!_.isEmpty(sizeInfo.modelBos)) { 179 + if (sizeInfo.modelBos) {
176 let reference = { 180 let reference = {
177 title: '模特试穿', 181 title: '模特试穿',
178 enTitle: 'REFERENCE' 182 enTitle: 'REFERENCE'
@@ -263,7 +267,7 @@ const getSizeInfo = (sizeInfo) => { @@ -263,7 +267,7 @@ const getSizeInfo = (sizeInfo) => {
263 } 267 }
264 268
265 // 商品材质 269 // 商品材质
266 - if (!_.isEmpty(sizeInfo.productMaterialList)) { 270 + if (sizeInfo.productMaterialList) {
267 dest.materials = {}; 271 dest.materials = {};
268 dest.materials.title = '商品材质'; 272 dest.materials.title = '商品材质';
269 dest.materials.enTitle = 'MATERIALS'; 273 dest.materials.enTitle = 'MATERIALS';
@@ -279,7 +283,7 @@ const getSizeInfo = (sizeInfo) => { @@ -279,7 +283,7 @@ const getSizeInfo = (sizeInfo) => {
279 } 283 }
280 284
281 // 洗涤提示 285 // 洗涤提示
282 - if (!_.isEmpty(sizeInfo.washTipsBoList)) { 286 + if (sizeInfo.washTipsBoList) {
283 dest.washTips = {}; 287 dest.washTips = {};
284 dest.washTips.list = []; 288 dest.washTips.list = [];
285 _.forEach(sizeInfo.washTipsBoList, function(value) { 289 _.forEach(sizeInfo.washTipsBoList, function(value) {
@@ -288,16 +292,17 @@ const getSizeInfo = (sizeInfo) => { @@ -288,16 +292,17 @@ const getSizeInfo = (sizeInfo) => {
288 } 292 }
289 293
290 // 详情配图 294 // 详情配图
291 -  
292 - if (!_.isEmpty(sizeInfo.productIntroBo.productIntro)) { 295 + if (_.has(sizeInfo, 'productIntroBo.productIntro')) {
293 let productIntro = ''; 296 let productIntro = '';
294 297
295 - if (!_.isEmpty(sizeInfo.productDescBo.phrase)) { 298 + if (_.has(sizeInfo, 'productDescBo.phrase')) {
296 productIntro = productIntro + sizeInfo.productDescBo.phrase + 299 productIntro = productIntro + sizeInfo.productDescBo.phrase +
297 '<br />'; 300 '<br />';
298 } 301 }
  302 + if (_.has(sizeInfo, 'productIntroBo.productIntro')) {
299 productIntro = productIntro + sizeInfo.productIntroBo.productIntro; 303 productIntro = productIntro + sizeInfo.productIntroBo.productIntro;
300 - if (!_.isEmpty(productIntro) && productIntro !== '') { 304 + }
  305 + if (productIntro) {
301 dest.productDetail = {}; 306 dest.productDetail = {};
302 dest.productDetail.title = '商品详情'; 307 dest.productDetail.title = '商品详情';
303 dest.productDetail.enTitle = 'DETAILS'; 308 dest.productDetail.enTitle = 'DETAILS';