lrf 2 years ago
parent
commit
1106f4ce08
1 changed files with 7 additions and 0 deletions
  1. 7 0
      app/service/view/goods.js

+ 7 - 0
app/service/view/goods.js

@@ -27,12 +27,19 @@ class GoodsService extends CrudService {
     goods = _.omit(goods, [ 'meta', '__v' ]);
     const shop = _.pick(goods.shop, [ 'logo', 'name', 'person', 'phone', '_id' ]);
     delete goods.shop;
+    // 2022-10-17反馈问题6:将规格图片和商品图片合并,规格图片在前
+    for (const spec of specs) {
+      if (_.isArray(spec.file)) {
+        goods.file = [ ...spec.file, ..._.get(goods, 'file', []) ];
+      }
+    }
 
     // goods: 商品信息; specs:商品规格信息; shop:店铺信息
     const returnData = { goods, specs, shop };
 
     // 添加浏览次数
     await this.goodsModel.updateOne({ _id: id }, { view_num: (goods.view_num || 0) + 1 });
+
     return returnData;
   }