From c6ac3cfd3097f9cbb917c55613c9033b9bc08f18 Mon Sep 17 00:00:00 2001 From: gongfuxiang Date: Sat, 6 Nov 2021 11:39:24 +0800 Subject: [PATCH] =?UTF-8?q?=E5=95=86=E5=93=81=E8=AF=84=E8=AE=BA=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E4=B8=8D=E5=AD=98=E5=9C=A8=E5=A4=B4=E5=83=8F=E5=A4=84?= =?UTF-8?q?=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/service/GoodsCommentsService.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/service/GoodsCommentsService.php b/app/service/GoodsCommentsService.php index 5bc9dc451..106b5ee4f 100644 --- a/app/service/GoodsCommentsService.php +++ b/app/service/GoodsCommentsService.php @@ -13,6 +13,7 @@ namespace app\service; use think\facade\Db; use app\service\UserService; use app\service\GoodsService; +use app\service\SystemBaseService; /** * 商品评论服务层 @@ -245,6 +246,9 @@ class GoodsCommentsService $comments_rating_list = MyConst('common_goods_comments_rating_list'); $comments_business_type_list = MyConst('common_goods_comments_business_type_list'); + // 用户默认头像 + $default_avatar = SystemBaseService::AttachmentHost().'/static/index/'.strtolower(MyFileConfig('common_default_theme', '', 'default', true)).'/images/default-user-avatar.jpg'; + // 数据处理 foreach($data as &$v) { @@ -255,7 +259,7 @@ class GoodsCommentsService if(!isset($params['is_public']) || $params['is_public'] == 1) { $v['user'] = [ - 'avatar' => isset($user['avatar']) ? $user['avatar'] : '', + 'avatar' => empty($user['avatar']) ? $default_avatar : $user['avatar'], 'user_name_view' => (!isset($v['is_anonymous']) || $v['is_anonymous'] == 1 || empty($user['user_name_view'])) ? '匿名' : mb_substr($user['user_name_view'], 0, 1, 'utf-8').'***'.mb_substr($user['user_name_view'], -1, null, 'utf-8'), ]; } else {