From 99dde8510cff8f7d8a8b0ab158d86621dcd226f4 Mon Sep 17 00:00:00 2001 From: devil_gong Date: Fri, 11 Oct 2019 11:23:07 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AF=84=E8=AE=BA=E5=B1=95=E7=A4=BA=E5=9B=BE?= =?UTF-8?q?=E7=89=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/api/controller/Goods.php | 2 +- application/index/controller/Goods.php | 6 +-- .../index/view/default/goods/comments.html | 40 +++++++++++++++++++ .../index/view/default/goods/index.html | 2 +- application/service/GoodsCommentsService.php | 14 +++++++ public/appmini/old/alipay/app.json | 4 +- .../pages/goods-comment/goods-comment.acss | 18 +++++++-- .../pages/goods-comment/goods-comment.axml | 5 +++ .../pages/goods-comment/goods-comment.js | 12 +++++- .../pages/goods-comment/goods-comment.css | 18 +++++++-- .../pages/goods-comment/goods-comment.js | 14 ++++++- .../pages/goods-comment/goods-comment.swan | 5 +++ public/appmini/old/weixin/app.js | 2 +- .../pages/goods-comment/goods-comment.js | 14 ++++++- .../pages/goods-comment/goods-comment.wxml | 5 +++ .../pages/goods-comment/goods-comment.wxss | 18 +++++++-- public/static/index/default/css/goods.css | 5 ++- public/static/index/default/js/goods.js | 35 +--------------- 18 files changed, 162 insertions(+), 57 deletions(-) create mode 100644 application/index/view/default/goods/comments.html diff --git a/application/api/controller/Goods.php b/application/api/controller/Goods.php index 9daa350e3..f59ffbf8b 100755 --- a/application/api/controller/Goods.php +++ b/application/api/controller/Goods.php @@ -242,7 +242,7 @@ class Goods extends Common * @version 1.0.0 * @datetime 2019-05-13T21:47:41+0800 */ - public function Comment() + public function Comments() { // 参数 $params = $this->data_post; diff --git a/application/index/controller/Goods.php b/application/index/controller/Goods.php index 810118814..3ad3e4827 100755 --- a/application/index/controller/Goods.php +++ b/application/index/controller/Goods.php @@ -320,7 +320,7 @@ class Goods extends Common * @version 1.0.0 * @datetime 2019-05-13T21:47:41+0800 */ - public function Comment() + public function Comments() { // 是否ajax请求 if(!IS_AJAX) @@ -358,13 +358,13 @@ class Goods extends Common 'is_public' => 1, ); $data = GoodsCommentsService::GoodsCommentsList($data_params); - + // 返回数据 $result = [ 'number' => $number, 'total' => $total, 'page_total' => $page_total, - 'data' => $data['data'], + 'data' => $this->fetch(null, ['data'=>$data['data']]), ]; return DataReturn('请求成功', 0, $result); } diff --git a/application/index/view/default/goods/comments.html b/application/index/view/default/goods/comments.html new file mode 100644 index 000000000..8084effd5 --- /dev/null +++ b/application/index/view/default/goods/comments.html @@ -0,0 +1,40 @@ +{{if !empty($data)}} + {{foreach $data as $v}} +
+ {{$v.user.user_name_view}} +
+
+
+ {{$v.user.user_name_view}} 评论于 + +
+
+
+

{{$v.content}}

+ {{if !empty($v['images'])}} +
    + {{foreach $v.images as $img}} +
  • + +
  • + {{/foreach}} +
+ {{/if}} + {{if !empty($v['msg'])}} +

{{$v.msg}}

+ {{/if}} + {{if $v['is_reply'] eq 1 and !empty($v['reply'])}} +
+ 管理员回复: + {{$v.reply}} +
+ {{/if}} +
+
+
+ {{/foreach}} +{{/if}} \ No newline at end of file diff --git a/application/index/view/default/goods/index.html b/application/index/view/default/goods/index.html index 5465c4f28..2ae8a5b21 100755 --- a/application/index/view/default/goods/index.html +++ b/application/index/view/default/goods/index.html @@ -481,7 +481,7 @@ -
+

动态评分

diff --git a/application/service/GoodsCommentsService.php b/application/service/GoodsCommentsService.php index cb8d6655c..397431b04 100644 --- a/application/service/GoodsCommentsService.php +++ b/application/service/GoodsCommentsService.php @@ -220,6 +220,20 @@ class GoodsCommentsService $v['user'] = $user; } + // 图片 + if(isset($v['images'])) + { + if(!empty($v['images'])) + { + $images = json_decode($v['images'], true); + foreach($images as &$img) + { + $img = ResourcesService::AttachmentPathViewHandle($img); + } + $v['images'] = $images; + } + } + // 获取商品信息 $goods_params = [ 'where' => [ diff --git a/public/appmini/old/alipay/app.json b/public/appmini/old/alipay/app.json index 6a564a7ba..522812671 100644 --- a/public/appmini/old/alipay/app.json +++ b/public/appmini/old/alipay/app.json @@ -1,5 +1,5 @@ { - "pages": ["pages/user-order/user-order", + "pages": [ "pages/index/index", "pages/goods-category/goods-category", "pages/cart/cart", @@ -14,7 +14,7 @@ "pages/buy/buy", "pages/user-address/user-address", "pages/user-address-save/user-address-save", - + "pages/user-order/user-order", "pages/user-order-detail/user-order-detail", "pages/user-order-comments/user-order-comments", "pages/user-faovr/user-faovr", diff --git a/public/appmini/old/alipay/pages/goods-comment/goods-comment.acss b/public/appmini/old/alipay/pages/goods-comment/goods-comment.acss index 912526fbe..5706c5232 100644 --- a/public/appmini/old/alipay/pages/goods-comment/goods-comment.acss +++ b/public/appmini/old/alipay/pages/goods-comment/goods-comment.acss @@ -81,18 +81,30 @@ .base-content { padding: 10rpx; } -.base-content .content, .base-content .reply { +.base-content .content, +.base-content .reply { line-height: 46rpx; font-size: 30rpx; } -.base-content .spec { +.base-content .spec, +.base-content .reply, +.base-content .images { margin-top: 20rpx; +} +.base-content .spec { color: #B0B0B0; } .base-content .reply { - margin-top: 20rpx; padding-top: 20rpx; } .base-content .reply-desc { color: #905602; +} +.base-content .images image { + width: 100rpx; + height: 100rpx; + padding: 5rpx; +} +.base-content .images image:not(:last-child) { + margin-right: 10rpx; } \ No newline at end of file diff --git a/public/appmini/old/alipay/pages/goods-comment/goods-comment.axml b/public/appmini/old/alipay/pages/goods-comment/goods-comment.axml index fadbd77e9..c2a1ea218 100644 --- a/public/appmini/old/alipay/pages/goods-comment/goods-comment.axml +++ b/public/appmini/old/alipay/pages/goods-comment/goods-comment.axml @@ -27,6 +27,11 @@ {{item.content}} + + + + + {{item.msg}} 管理员回复: diff --git a/public/appmini/old/alipay/pages/goods-comment/goods-comment.js b/public/appmini/old/alipay/pages/goods-comment/goods-comment.js index 5be60751d..ae6e3a6a7 100644 --- a/public/appmini/old/alipay/pages/goods-comment/goods-comment.js +++ b/public/appmini/old/alipay/pages/goods-comment/goods-comment.js @@ -77,7 +77,7 @@ Page({ }); my.request({ - url: app.get_request_url("comment", "goods"), + url: app.get_request_url("comments", "goods"), method: "POST", data: { goods_id: this.data.params.goods_id, page: this.data.data_page }, dataType: "json", @@ -154,4 +154,14 @@ Page({ scroll_lower(e) { this.get_data_list(); }, + + // 图片预览 + images_show_event(e) { + var index = e.target.dataset.index; + var ix = e.target.dataset.ix; + my.previewImage({ + current: ix, + urls: this.data.data_list[index]['images'], + }); + }, }); diff --git a/public/appmini/old/baidu/pages/goods-comment/goods-comment.css b/public/appmini/old/baidu/pages/goods-comment/goods-comment.css index 912526fbe..5706c5232 100644 --- a/public/appmini/old/baidu/pages/goods-comment/goods-comment.css +++ b/public/appmini/old/baidu/pages/goods-comment/goods-comment.css @@ -81,18 +81,30 @@ .base-content { padding: 10rpx; } -.base-content .content, .base-content .reply { +.base-content .content, +.base-content .reply { line-height: 46rpx; font-size: 30rpx; } -.base-content .spec { +.base-content .spec, +.base-content .reply, +.base-content .images { margin-top: 20rpx; +} +.base-content .spec { color: #B0B0B0; } .base-content .reply { - margin-top: 20rpx; padding-top: 20rpx; } .base-content .reply-desc { color: #905602; +} +.base-content .images image { + width: 100rpx; + height: 100rpx; + padding: 5rpx; +} +.base-content .images image:not(:last-child) { + margin-right: 10rpx; } \ No newline at end of file diff --git a/public/appmini/old/baidu/pages/goods-comment/goods-comment.js b/public/appmini/old/baidu/pages/goods-comment/goods-comment.js index fd317c59f..58f4c082f 100644 --- a/public/appmini/old/baidu/pages/goods-comment/goods-comment.js +++ b/public/appmini/old/baidu/pages/goods-comment/goods-comment.js @@ -77,7 +77,7 @@ Page({ }); swan.request({ - url: app.get_request_url("comment", "goods"), + url: app.get_request_url("comments", "goods"), method: "POST", data: { goods_id: this.data.params.goods_id, page: this.data.data_page }, dataType: "json", @@ -153,5 +153,15 @@ Page({ // 滚动加载 scroll_lower(e) { this.get_data_list(); - } + }, + + // 图片预览 + images_show_event(e) { + var index = e.currentTarget.dataset.index; + var ix = e.currentTarget.dataset.ix; + swan.previewImage({ + current: this.data.data_list[index]['images'][ix], + urls: this.data.data_list[index]['images'], + }); + }, }); \ No newline at end of file diff --git a/public/appmini/old/baidu/pages/goods-comment/goods-comment.swan b/public/appmini/old/baidu/pages/goods-comment/goods-comment.swan index fb6e73f8d..8c369bd7d 100644 --- a/public/appmini/old/baidu/pages/goods-comment/goods-comment.swan +++ b/public/appmini/old/baidu/pages/goods-comment/goods-comment.swan @@ -27,6 +27,11 @@ {{item.content}} + + + + + {{item.msg}} 管理员回复: diff --git a/public/appmini/old/weixin/app.js b/public/appmini/old/weixin/app.js index 84783366d..429bdac69 100755 --- a/public/appmini/old/weixin/app.js +++ b/public/appmini/old/weixin/app.js @@ -65,7 +65,7 @@ App({ // 请求地址 request_url: "{{request_url}}", request_url: 'http://tp5-dev.com/', - request_url: 'https://test.shopxo.net/', + //request_url: 'https://test.shopxo.net/', // 基础信息 application_title: "{{application_title}}", diff --git a/public/appmini/old/weixin/pages/goods-comment/goods-comment.js b/public/appmini/old/weixin/pages/goods-comment/goods-comment.js index cd5221d0c..c80583892 100644 --- a/public/appmini/old/weixin/pages/goods-comment/goods-comment.js +++ b/public/appmini/old/weixin/pages/goods-comment/goods-comment.js @@ -12,7 +12,7 @@ Page({ }, onLoad(params) { - //params['goods_id']=2; + //params['goods_id']=9; this.setData({ params: params }); this.init(); }, @@ -77,7 +77,7 @@ Page({ }); wx.request({ - url: app.get_request_url("comment", "goods"), + url: app.get_request_url("comments", "goods"), method: "POST", data: { goods_id: this.data.params.goods_id, page: this.data.data_page }, dataType: "json", @@ -154,4 +154,14 @@ Page({ scroll_lower(e) { this.get_data_list(); }, + + // 图片预览 + images_show_event(e) { + var index = e.currentTarget.dataset.index; + var ix = e.currentTarget.dataset.ix; + wx.previewImage({ + current: this.data.data_list[index]['images'][ix], + urls: this.data.data_list[index]['images'], + }); + }, }); diff --git a/public/appmini/old/weixin/pages/goods-comment/goods-comment.wxml b/public/appmini/old/weixin/pages/goods-comment/goods-comment.wxml index cab4d853a..5a67e7c5b 100644 --- a/public/appmini/old/weixin/pages/goods-comment/goods-comment.wxml +++ b/public/appmini/old/weixin/pages/goods-comment/goods-comment.wxml @@ -27,6 +27,11 @@ {{item.content}} + + + + + {{item.msg}} 管理员回复: diff --git a/public/appmini/old/weixin/pages/goods-comment/goods-comment.wxss b/public/appmini/old/weixin/pages/goods-comment/goods-comment.wxss index 912526fbe..5706c5232 100644 --- a/public/appmini/old/weixin/pages/goods-comment/goods-comment.wxss +++ b/public/appmini/old/weixin/pages/goods-comment/goods-comment.wxss @@ -81,18 +81,30 @@ .base-content { padding: 10rpx; } -.base-content .content, .base-content .reply { +.base-content .content, +.base-content .reply { line-height: 46rpx; font-size: 30rpx; } -.base-content .spec { +.base-content .spec, +.base-content .reply, +.base-content .images { margin-top: 20rpx; +} +.base-content .spec { color: #B0B0B0; } .base-content .reply { - margin-top: 20rpx; padding-top: 20rpx; } .base-content .reply-desc { color: #905602; +} +.base-content .images image { + width: 100rpx; + height: 100rpx; + padding: 5rpx; +} +.base-content .images image:not(:last-child) { + margin-right: 10rpx; } \ No newline at end of file diff --git a/public/static/index/default/css/goods.css b/public/static/index/default/css/goods.css index 30a4eb544..9986d8556 100755 --- a/public/static/index/default/css/goods.css +++ b/public/static/index/default/css/goods.css @@ -64,10 +64,13 @@ input{font-size:12px;font-size:100%;outline:none;line-height:normal;color:#444;} /* 商品评论 */ .goods-comment .am-comment { margin-top: 15px; text-align: left; } .goods-comment .am-comment-main { border: 1px solid #eee; } -.goods-comment .comment-spec { margin-top: 5px; color: #B0B0B0; } +.goods-comment .comment-spec { color: #B0B0B0; } .comment-reply { border-top: 1px dashed #eee; margin-top: 10px; padding-top: 10px; } .goods-comment .am-comment .am-comment-hd { background: #fbfbfb; } .goods-comment .am-comment .am-comment-main:after { border-right-color: #fbfbfb; } +.goods-comment .comment-images, .goods-comment .comment-spec { margin-top: 5px; } +.goods-comment .comment-images img { width: 50px; height: 50px; border: 1px solid #eee; } +.goods-comment .comment-images li:not(:last-child) { margin-right: 5px; } .comment-reply-title { color: #666; } .comment-reply-desc { color: #905602; } diff --git a/public/static/index/default/js/goods.js b/public/static/index/default/js/goods.js index a8727adff..20b2c6c05 100755 --- a/public/static/index/default/js/goods.js +++ b/public/static/index/default/js/goods.js @@ -46,40 +46,7 @@ function GoodsCommentsHtml(page) $('.goods-page-no-data').addClass('none'); if(result.code == 0) { - var html = ''; - for(var i in result.data.data) - { - html += '
'; - html += ''+result.data.data[i]['user']['user_name_view']+''; - html += '
'; - html += '
'; - html += '
'; - html += ''+result.data.data[i]['user']['user_name_view']+''; - html += ' 评论于 '; - html += '
'; - html += '
'; - html += '
'; - html += '

'+result.data.data[i]['content']+'

'; - - // 规格 - if((result.data.data[i]['msg'] || null) != null) - { - html += '

'+result.data.data[i]['msg']+'

'; - } - - // 回复 - if(result.data.data[i]['is_reply'] == 1 && (result.data.data[i]['reply'] || null) != null) - { - html += '
'; - html += '管理员回复:'; - html += ''+result.data.data[i]['reply']+''; - html += '
'; - } - html += '
'; - html += '
'; - } - - $('.goods-comment-content').html(html); + $('.goods-comment-content').html(result.data.data); $('.goods-page-container').html(PageLibrary(result.data.total, result.data.number, page, 2)); } -- GitLab