Authored by lijing

合并名称相同奖品

@@ -35,6 +35,18 @@ const activity = (params) => { @@ -35,6 +35,18 @@ const activity = (params) => {
35 35
36 let bgUrl = ''; 36 let bgUrl = '';
37 37
  38 + let prizesList = result[0].data.prizes;
  39 +
  40 + let newPrizes = [];
  41 +
  42 + let same = false;
  43 +
  44 + let i = 0;
  45 +
  46 + let x = 0;
  47 +
  48 + let y = 0;
  49 +
38 if (result) { 50 if (result) {
39 if (result[0] && result[0].data) { 51 if (result[0] && result[0].data) {
40 resu = result[0].data; 52 resu = result[0].data;
@@ -42,7 +54,39 @@ const activity = (params) => { @@ -42,7 +54,39 @@ const activity = (params) => {
42 Object.assign(resu, { 54 Object.assign(resu, {
43 bgUrl: bgUrl 55 bgUrl: bgUrl
44 }); 56 });
  57 +
  58 + // 合并名称相同奖项
  59 + prizesList.forEach((val, index) => {
  60 + if (newPrizes == '') {
  61 + newPrizes[0] = {
  62 + name: prizesList[0].name,
  63 + remark: prizesList[0].remark,
  64 + }
  65 + } else {
  66 + newPrizes.forEach((item, po) => {
  67 + if (prizesList[index].name == newPrizes[po].name) {
  68 + same = true;
  69 + x = index;
  70 + y = po;
  71 + }
  72 + });
  73 + if (same) {
  74 + newPrizes[y].remark = newPrizes[y].remark + '、' + prizesList[x].remark;
  75 + same = false;
  76 + } else {
  77 + i ++;
  78 + newPrizes[i] = {
  79 + name: prizesList[index].name,
  80 + remark: prizesList[index].remark,
  81 + };
  82 + same = false;
  83 + }
45 } 84 }
  85 + });
  86 +
  87 + resu.prizes = newPrizes;
  88 + }
  89 +
46 if (result[1] && result[1].data) { 90 if (result[1] && result[1].data) {
47 mobile = result[1].data.mobile; 91 mobile = result[1].data.mobile;
48 Object.assign(resu, { 92 Object.assign(resu, {