diff --git a/application/service/GoodsService.php b/application/service/GoodsService.php
index a987f4287..8bad40a0a 100755
--- a/application/service/GoodsService.php
+++ b/application/service/GoodsService.php
@@ -347,9 +347,34 @@ class GoodsService
$v['goods_url'] = MyUrl('index/goods/index', ['id'=>$v['id']]);
}
+ // 获取相册
+ if($is_photo && !empty($v['id']))
+ {
+ $v['photo'] = Db::name('GoodsPhoto')->where(['goods_id'=>$v['id'], 'is_show'=>1])->order('sort asc')->select();
+ if(!empty($v['photo']))
+ {
+ foreach($v['photo'] as &$vs)
+ {
+ $vs['images_old'] = $vs['images'];
+ $vs['images'] = ResourcesService::AttachmentPathViewHandle($vs['images']);
+ }
+ }
+ }
+
// 商品封面图片
if(isset($v['images']))
{
+ // 不存在则读取相册第一张图片
+ if(empty($v['images']))
+ {
+ // 是否已存在相册
+ if(empty($v['photo']) || empty($v['photo'][0]) || empty($v['photo'][0]['images_old']))
+ {
+ $v['images'] = Db::name('GoodsPhoto')->where(['goods_id'=>$v['id'], 'is_show'=>0])->order('sort asc')->value('images');
+ } else {
+ $v['images'] = $v['photo'][0]['images_old'];
+ }
+ }
$v['images_old'] = $v['images'];
$v['images'] = ResourcesService::AttachmentPathViewHandle($v['images']);
}
@@ -361,27 +386,6 @@ class GoodsService
$v['video'] = ResourcesService::AttachmentPathViewHandle($v['video']);
}
- // 商品首页推荐图片,不存在则使用商品封面图片
- if(isset($v['home_recommended_images']))
- {
- if(empty($v['home_recommended_images']))
- {
- if(isset($v['images']))
- {
- $v['home_recommended_images'] = $v['images'];
- } else {
- if(!empty($v['id']))
- {
- $images = Db::name('Goods')->where(['id'=>$v['id']])->value('images');
- $v['home_recommended_images'] = ResourcesService::AttachmentPathViewHandle($images);
- }
- }
- } else {
- $v['home_recommended_images_old'] = $v['home_recommended_images'];
- $v['home_recommended_images'] = ResourcesService::AttachmentPathViewHandle($v['home_recommended_images']);
- }
- }
-
// PC内容处理
if(isset($v['content_web']))
{
@@ -424,20 +428,6 @@ class GoodsService
$v['category_text'] = implode(',', $category_name);
}
- // 获取相册
- if($is_photo && !empty($v['id']))
- {
- $v['photo'] = Db::name('GoodsPhoto')->where(['goods_id'=>$v['id'], 'is_show'=>1])->order('sort asc')->select();
- if(!empty($v['photo']))
- {
- foreach($v['photo'] as &$vs)
- {
- $vs['images_old'] = $vs['images'];
- $vs['images'] = ResourcesService::AttachmentPathViewHandle($vs['images']);
- }
- }
- }
-
// 规格基础
if(isset($v['spec_base']))
{
@@ -790,7 +780,7 @@ class GoodsService
}
// 其它附件
- $data_fields = ['home_recommended_images', 'video'];
+ $data_fields = ['images', 'video'];
$attachment = ResourcesService::AttachmentParams($params, $data_fields);
if($attachment['code'] != 0)
{
@@ -821,7 +811,7 @@ class GoodsService
'images' => isset($photo['data'][0]) ? $photo['data'][0] : '',
'photo_count' => count($photo['data']),
'is_home_recommended' => isset($params['is_home_recommended']) ? intval($params['is_home_recommended']) : 0,
- 'home_recommended_images' => $attachment['data']['home_recommended_images'],
+ 'images' => $attachment['data']['images'],
'brand_id' => isset($params['brand_id']) ? intval($params['brand_id']) : 0,
'video' => $attachment['data']['video'],
'seo_title' => empty($params['seo_title']) ? '' : $params['seo_title'],
diff --git a/sourcecode/alipay/pages/index/index.axml b/sourcecode/alipay/pages/index/index.axml
index eaf0b5eb8..115b8b7ea 100644
--- a/sourcecode/alipay/pages/index/index.axml
+++ b/sourcecode/alipay/pages/index/index.axml
@@ -48,7 +48,7 @@
-
+
{{goods.title}}
{{price_symbol}}{{goods.min_price}}
diff --git a/sourcecode/baidu/pages/index/index.swan b/sourcecode/baidu/pages/index/index.swan
index cb65b337d..b30601b3a 100755
--- a/sourcecode/baidu/pages/index/index.swan
+++ b/sourcecode/baidu/pages/index/index.swan
@@ -48,7 +48,7 @@
-
+
{{goods.title}}
{{price_symbol}}{{goods.min_price}}
diff --git a/sourcecode/qq/pages/index/index.qml b/sourcecode/qq/pages/index/index.qml
index ae92e2d62..915585f56 100755
--- a/sourcecode/qq/pages/index/index.qml
+++ b/sourcecode/qq/pages/index/index.qml
@@ -48,7 +48,7 @@
-
+
{{goods.title}}
{{price_symbol}}{{goods.min_price}}
diff --git a/sourcecode/toutiao/pages/index/index.ttml b/sourcecode/toutiao/pages/index/index.ttml
index 609b9fbcd..278e42555 100755
--- a/sourcecode/toutiao/pages/index/index.ttml
+++ b/sourcecode/toutiao/pages/index/index.ttml
@@ -51,7 +51,7 @@
-
+
{{goods.title}}
{{price_symbol}}{{goods.min_price}}
diff --git a/sourcecode/weixin/pages/index/index.wxml b/sourcecode/weixin/pages/index/index.wxml
index e6c58bfe4..db7ffbc23 100755
--- a/sourcecode/weixin/pages/index/index.wxml
+++ b/sourcecode/weixin/pages/index/index.wxml
@@ -48,7 +48,7 @@
-
+
{{goods.title}}
{{price_symbol}}{{goods.min_price}}