mirror of
https://gitee.com/zongzhige/shopxo.git
synced 2026-06-07 10:22:38 +08:00
评论展示图片
This commit is contained in:
@ -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;
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
40
application/index/view/default/goods/comments.html
Normal file
40
application/index/view/default/goods/comments.html
Normal file
@ -0,0 +1,40 @@
|
||||
{{if !empty($data)}}
|
||||
{{foreach $data as $v}}
|
||||
<article class="am-comment">
|
||||
<img src="{{$v.user.avatar}}" class="am-comment-avatar" alt="{{$v.user.user_name_view}}" />
|
||||
<div class="am-comment-main">
|
||||
<header class="am-comment-hd">
|
||||
<div class="am-comment-meta">
|
||||
<span class="am-comment-author">{{$v.user.user_name_view}}</span> 评论于
|
||||
<time>{{$v.add_time_time}}</time>
|
||||
</div>
|
||||
</header>
|
||||
<div class="am-comment-bd">
|
||||
<p>{{$v.content}}</p>
|
||||
{{if !empty($v['images'])}}
|
||||
<ul class="am-cf comment-images">
|
||||
{{foreach $v.images as $img}}
|
||||
<li class="am-fl">
|
||||
<div class="am-gallery-item">
|
||||
<a href="{{$img}}" target="_blank">
|
||||
<img src="{{$img}}" class="am-img-thumbnail am-radius" />
|
||||
</a>
|
||||
</div>
|
||||
</li>
|
||||
{{/foreach}}
|
||||
</ul>
|
||||
{{/if}}
|
||||
{{if !empty($v['msg'])}}
|
||||
<p class="comment-spec">{{$v.msg}}</p>
|
||||
{{/if}}
|
||||
{{if $v['is_reply'] eq 1 and !empty($v['reply'])}}
|
||||
<div class="comment-reply">
|
||||
<span class="comment-reply-title">管理员回复:</span>
|
||||
<span class="comment-reply-desc">{{$v.reply}}</span>
|
||||
</div>
|
||||
{{/if}}
|
||||
</div>
|
||||
</div>
|
||||
</article>
|
||||
{{/foreach}}
|
||||
{{/if}}
|
||||
@ -481,7 +481,7 @@
|
||||
</div>
|
||||
|
||||
<!-- 评论 -->
|
||||
<div class="am-tab-panel am-fade goods-comment" data-goods-id="{{$goods.id}}" data-url="{{:MyUrl('index/goods/comment')}}">
|
||||
<div class="am-tab-panel am-fade goods-comment" data-goods-id="{{$goods.id}}" data-url="{{:MyUrl('index/goods/comments')}}">
|
||||
<div class="am-cf score-container">
|
||||
<div class="score am-fl">
|
||||
<p class="name">动态评分</p>
|
||||
|
||||
@ -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' => [
|
||||
|
||||
@ -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",
|
||||
|
||||
@ -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;
|
||||
}
|
||||
@ -27,6 +27,11 @@
|
||||
</view>
|
||||
<view class="base-content oh">
|
||||
<view class="content cr-666">{{item.content}}</view>
|
||||
<view a:if="{{(item.images || null) != null && item.images.length > 0}}" class="images oh">
|
||||
<block a:for="{{item.images}}" a:for-index="ix" a:for-item="iv">
|
||||
<image class="br" onTap="images_show_event" data-index="{{index}}" data-ix="{{ix}}" src="{{iv}}" mode="aspectFit"></image>
|
||||
</block>
|
||||
</view>
|
||||
<view a:if="{{(item.msg || null) != null}}" class="spec">{{item.msg}}</view>
|
||||
<view a:if="{{item.is_reply == 1 && (item.reply || null) != null}}" class="reply br-t-dashed">
|
||||
<text class="cr-888">管理员回复:</text>
|
||||
|
||||
@ -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'],
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
@ -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;
|
||||
}
|
||||
@ -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'],
|
||||
});
|
||||
},
|
||||
});
|
||||
@ -27,6 +27,11 @@
|
||||
</view>
|
||||
<view class="base-content oh">
|
||||
<view class="content cr-666">{{item.content}}</view>
|
||||
<view s-if="(item.images || null) != null && item.images.length > 0" class="images oh">
|
||||
<block s-for="iv,ix in item.images" s-key="key">
|
||||
<image class="br" bindtap="images_show_event" data-index="{{index}}" data-ix="{{ix}}" src="{{iv}}" mode="aspectFit"></image>
|
||||
</block>
|
||||
</view>
|
||||
<view s-if="(item.msg || null) != null" class="spec">{{item.msg}}</view>
|
||||
<view s-if="item.is_reply == 1 && (item.reply || null) != null" class="reply br-t-dashed">
|
||||
<text class="cr-888">管理员回复:</text>
|
||||
|
||||
@ -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}}",
|
||||
|
||||
@ -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'],
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
@ -27,6 +27,11 @@
|
||||
</view>
|
||||
<view class="base-content oh">
|
||||
<view class="content cr-666">{{item.content}}</view>
|
||||
<view wx:if="{{(item.images || null) != null && item.images.length > 0}}" class="images oh">
|
||||
<block wx:for="{{item.images}}" wx:key="iv" wx:for-index="ix" wx:for-item="iv">
|
||||
<image class="br" bindtap="images_show_event" data-index="{{index}}" data-ix="{{ix}}" src="{{iv}}" mode="aspectFit"></image>
|
||||
</block>
|
||||
</view>
|
||||
<view wx:if="{{(item.msg || null) != null}}" class="spec">{{item.msg}}</view>
|
||||
<view wx:if="{{item.is_reply == 1 && (item.reply || null) != null}}" class="reply br-t-dashed">
|
||||
<text class="cr-888">管理员回复:</text>
|
||||
|
||||
@ -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;
|
||||
}
|
||||
@ -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; }
|
||||
|
||||
|
||||
@ -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 += '<article class="am-comment">';
|
||||
html += '<img src="'+result.data.data[i]['user']['avatar']+'" class="am-comment-avatar" alt="'+result.data.data[i]['user']['user_name_view']+'" />';
|
||||
html += '<div class="am-comment-main">';
|
||||
html += '<header class="am-comment-hd">';
|
||||
html += '<div class="am-comment-meta">';
|
||||
html += '<span class="am-comment-author">'+result.data.data[i]['user']['user_name_view']+'</span>';
|
||||
html += ' 评论于 <time datetime="">'+result.data.data[i]['add_time_time']+'</time>';
|
||||
html += '</div>';
|
||||
html += '</header>';
|
||||
html += '<div class="am-comment-bd">';
|
||||
html += '<p>'+result.data.data[i]['content']+'</p>';
|
||||
|
||||
// 规格
|
||||
if((result.data.data[i]['msg'] || null) != null)
|
||||
{
|
||||
html += '<p class="comment-spec">'+result.data.data[i]['msg']+'</p>';
|
||||
}
|
||||
|
||||
// 回复
|
||||
if(result.data.data[i]['is_reply'] == 1 && (result.data.data[i]['reply'] || null) != null)
|
||||
{
|
||||
html += '<div class="comment-reply">';
|
||||
html += '<span class="comment-reply-title">管理员回复:</span>';
|
||||
html += '<span class="comment-reply-desc">'+result.data.data[i]['reply']+'</span>';
|
||||
html += '</div>';
|
||||
}
|
||||
html += '</div>';
|
||||
html += '</article>';
|
||||
}
|
||||
|
||||
$('.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));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user