Showing
1 changed file
with
18 additions
and
14 deletions
@@ -149,8 +149,9 @@ class familyModel extends global.yoho.BaseModel { | @@ -149,8 +149,9 @@ class familyModel extends global.yoho.BaseModel { | ||
149 | code: 200 | 149 | code: 200 |
150 | }).then((result) => { | 150 | }).then((result) => { |
151 | 151 | ||
152 | - if (result.data && result.data.mars && result.data.mars.vipLevelList.length > 0) { | ||
153 | - _.forEach(result.data.mars.vipLevelList, function(val) { | 152 | + if (result.data && _.get(result, 'data.mars', '') && |
153 | + _.get(result, 'data.mars.vipLevelList', []).length > 0) { | ||
154 | + _.forEach(_.get(result, 'data.mars.vipLevelList', []), function(val) { | ||
154 | val.name = 'Lv.' + val.level; | 155 | val.name = 'Lv.' + val.level; |
155 | }); | 156 | }); |
156 | } | 157 | } |
@@ -402,16 +403,18 @@ class familyModel extends global.yoho.BaseModel { | @@ -402,16 +403,18 @@ class familyModel extends global.yoho.BaseModel { | ||
402 | let list = []; | 403 | let list = []; |
403 | let colorList = []; | 404 | let colorList = []; |
404 | 405 | ||
405 | - if (result && result.data) { | ||
406 | - result.data.data.sort(function(a, b) { | 406 | + if (result && result.data && result.code === 200) { |
407 | + let integralData = _.get(result, 'data', {}); | ||
408 | + | ||
409 | + integralData.data.sort(function(a, b) { | ||
407 | return b.proportion - a.proportion; | 410 | return b.proportion - a.proportion; |
408 | }); | 411 | }); |
409 | 412 | ||
410 | - if (_.get(result.data, 'total', 0)) { | 413 | + if (integralData.total) { |
411 | chartsData.total = parseInt(result.data.total, 10) < 99999 ? result.data.total : '99999+'; | 414 | chartsData.total = parseInt(result.data.total, 10) < 99999 ? result.data.total : '99999+'; |
412 | } | 415 | } |
413 | 416 | ||
414 | - _.forEach(result.data.data, function(data) { | 417 | + _.forEach(integralData.data, function(data) { |
415 | list.push({ | 418 | list.push({ |
416 | value: data.num, | 419 | value: data.num, |
417 | name: data.source, | 420 | name: data.source, |
@@ -444,19 +447,20 @@ class familyModel extends global.yoho.BaseModel { | @@ -444,19 +447,20 @@ class familyModel extends global.yoho.BaseModel { | ||
444 | ]).then((result) => { | 447 | ]).then((result) => { |
445 | let familyIndexData = {}; | 448 | let familyIndexData = {}; |
446 | 449 | ||
447 | - if (result[0] && result[0].data) { | 450 | + if (result[0] && result[0].data && _.get(result, '[0].code', '') === 200) { |
451 | + let perInfo = _.get(result, '[0].data', {}); | ||
448 | 452 | ||
449 | - if (result[0].data.headIco) { | 453 | + if (perInfo.headIco) { |
450 | result[0].data.headIco = result[0].data.headIco.replace('img01.yohomars.com', 'imgmars.yohobuy.com').replace('img02.yohomars.com', 'imgmars.yohobuy.com'); // eslint-disable-line | 454 | result[0].data.headIco = result[0].data.headIco.replace('img01.yohomars.com', 'imgmars.yohobuy.com').replace('img02.yohomars.com', 'imgmars.yohobuy.com'); // eslint-disable-line |
451 | } | 455 | } |
452 | 456 | ||
453 | familyIndexData = _.assign(familyIndexData, { | 457 | familyIndexData = _.assign(familyIndexData, { |
454 | - head_ico: result[0].data.headIco, | ||
455 | - nickname: result[0].data.nickName, | ||
456 | - gender: parseInt(result[0].data.gender, 10), | ||
457 | - birthday: result[0].data.birthday ? moment(result[0].data.birthday).format('MM-DD') : '', | ||
458 | - province: result[0].data.province, | ||
459 | - city: result[0].data.city | 458 | + head_ico: perInfo.headIco, |
459 | + nickname: perInfo.nickName, | ||
460 | + gender: parseInt(perInfo.gender, 10), | ||
461 | + birthday: perInfo.birthday ? moment(perInfo.birthday).format('MM-DD') : '', | ||
462 | + province: perInfo.province, | ||
463 | + city: perInfo.city | ||
460 | }); | 464 | }); |
461 | } | 465 | } |
462 | 466 |
-
Please register or login to post a comment