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