lrf 2 年 前
コミット
2639203882
2 ファイル変更10 行追加6 行削除
  1. 8 5
      app/service/system/platformAct.js
  2. 2 1
      app/service/view/goods.js

+ 8 - 5
app/service/system/platformAct.js

@@ -26,20 +26,23 @@ class PlatformActService extends CrudService {
 
   getActText(data) {
     const { type } = data;
+    let tag = '';
     let text = '';
     if (type === '2') {
-      text = '赠品';
+      tag = '赠品';
     } else if (type === '3') {
-      text = '特价';
+      tag = '特价';
     } else if (type === '4') {
-      text = '加价购';
+      tag = '加价购';
     } else if (type === '5') {
+      tag = '满减';
       const discount = _.get(data, 'config.discount', []);
       for (const i of discount) {
         const { limit, number } = i;
         text = `${text}满${limit}减${number};`;
       }
     } else if (type === '6') {
+      tag = '满折';
       const discount = _.get(data, 'config.discount', []);
       for (const i of discount) {
         const { limit, number, max } = i;
@@ -48,9 +51,9 @@ class PlatformActService extends CrudService {
         text = `${text};`;
       }
     } else if (type === '7') {
-      text = '套装';
+      tag = '套装';
     }
-    return text;
+    return { tag, text };
   }
 
 }

+ 2 - 1
app/service/view/goods.js

@@ -119,8 +119,9 @@ class GoodsService extends CrudService {
     let data = _.head(res);
     if (data) data = JSON.parse(JSON.stringify(data));
     for (const d of data.act) {
-      const text = this.ctx.service.system.platformAct.getActText(d);
+      const { tag, text } = this.ctx.service.system.platformAct.getActText(d);
       d.text = text;
+      d.tag = tag;
     }
     return data;
   }