Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
jcy2004x
ShopXO
提交
ed941686
ShopXO
项目概览
jcy2004x
/
ShopXO
与 Fork 源项目一致
Fork自
纵之格 / ShopXO
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
ShopXO
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
ed941686
编写于
5月 13, 2019
作者:
G
gongfuxiang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
商品评论
上级
0b260593
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
251 addition
and
71 deletion
+251
-71
application/index/controller/Goods.php
application/index/controller/Goods.php
+55
-10
application/index/view/default/goods/index.html
application/index/view/default/goods/index.html
+11
-58
application/plugins/newuserreduction/Hook.php
application/plugins/newuserreduction/Hook.php
+8
-2
application/service/GoodsCommentsService.php
application/service/GoodsCommentsService.php
+15
-1
public/static/common/js/common.js
public/static/common/js/common.js
+60
-0
public/static/index/default/css/goods.css
public/static/index/default/css/goods.css
+2
-0
public/static/index/default/js/goods.js
public/static/index/default/js/goods.js
+100
-0
未找到文件。
application/index/controller/Goods.php
浏览文件 @
ed941686
...
...
@@ -12,6 +12,7 @@ namespace app\index\controller;
use
think\facade\Hook
;
use
app\service\GoodsService
;
use
app\service\GoodsCommentsService
;
use
app\service\SeoService
;
/**
...
...
@@ -45,10 +46,10 @@ class Goods extends Common
*/
public
function
Index
()
{
$id
=
input
(
'id'
);
$
goods_
id
=
input
(
'id'
);
$params
=
[
'where'
=>
[
'id'
=>
$id
,
'id'
=>
$
goods_
id
,
'is_delete_time'
=>
0
,
],
'is_photo'
=>
true
,
...
...
@@ -61,17 +62,17 @@ class Goods extends Common
return
$this
->
fetch
(
'/public/tips_error'
);
}
else
{
// 当前登录用户是否已收藏
$ret_favor
=
GoodsService
::
IsUserGoodsFavor
([
'goods_id'
=>
$id
,
'user'
=>
$this
->
user
]);
$ret_favor
=
GoodsService
::
IsUserGoodsFavor
([
'goods_id'
=>
$
goods_
id
,
'user'
=>
$this
->
user
]);
$ret
[
'data'
][
0
][
'is_favor'
]
=
(
$ret_favor
[
'code'
]
==
0
)
?
$ret_favor
[
'data'
]
:
0
;
// 商品评价总数
$ret
[
'data'
][
0
][
'comments_count'
]
=
GoodsService
::
GoodsCommentsTotal
(
$id
);
$ret
[
'data'
][
0
][
'comments_count'
]
=
GoodsService
::
GoodsCommentsTotal
(
$
goods_
id
);
// 商品收藏总数
$ret
[
'data'
][
0
][
'favor_count'
]
=
GoodsService
::
GoodsFavorTotal
([
'goods_id'
=>
$id
]);
$ret
[
'data'
][
0
][
'favor_count'
]
=
GoodsService
::
GoodsFavorTotal
([
'goods_id'
=>
$
goods_
id
]);
// 钩子
$this
->
PluginsHook
(
$id
,
$ret
[
'data'
][
0
]);
$this
->
PluginsHook
(
$
goods_
id
,
$ret
[
'data'
][
0
]);
// 商品数据
$this
->
assign
(
'goods'
,
$ret
[
'data'
][
0
]);
...
...
@@ -88,13 +89,13 @@ class Goods extends Common
}
// 二维码
$this
->
assign
(
'qrcode_url'
,
MyUrl
(
'index/qrcode/index'
,
[
'content'
=>
urlencode
(
base64_encode
(
MyUrl
(
'index/goods/index'
,
[
'id'
=>
$id
],
true
,
true
)))]));
$this
->
assign
(
'qrcode_url'
,
MyUrl
(
'index/qrcode/index'
,
[
'content'
=>
urlencode
(
base64_encode
(
MyUrl
(
'index/goods/index'
,
[
'id'
=>
$
goods_
id
],
true
,
true
)))]));
// 商品访问统计
GoodsService
::
GoodsAccessCountInc
([
'goods_id'
=>
$id
]);
GoodsService
::
GoodsAccessCountInc
([
'goods_id'
=>
$
goods_
id
]);
// 用户商品浏览
GoodsService
::
GoodsBrowseSave
([
'goods_id'
=>
$id
,
'user'
=>
$this
->
user
]);
GoodsService
::
GoodsBrowseSave
([
'goods_id'
=>
$
goods_
id
,
'user'
=>
$this
->
user
]);
// 左侧商品 看了又看
$params
=
[
...
...
@@ -134,7 +135,8 @@ class Goods extends Common
* @version 1.0.0
* @date 2019-04-22
* @desc description
* @param [array] $params [输入参数]
* @param [int] $goods_id [商品id]
* @param [array] $params [输入参数]
*/
private
function
PluginsHook
(
$goods_id
,
&
$goods
)
{
...
...
@@ -259,4 +261,47 @@ class Goods extends Common
$params
=
input
(
'post.'
);
return
GoodsService
::
GoodsSpecDetail
(
$params
);
}
/**
* 商品评论
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @datetime 2019-05-13T21:47:41+0800
*/
public
function
Comment
()
{
// 参数
$params
=
input
();
// 分页
$number
=
10
;
$page
=
max
(
1
,
isset
(
$params
[
'page'
])
?
intval
(
$params
[
'page'
])
:
1
);
// 条件
$where
=
[
'goods_id'
=>
$params
[
'goods_id'
]];
// 获取总数
$total
=
GoodsCommentsService
::
GoodsCommentsTotal
(
$where
);
$page_total
=
ceil
(
$total
/
$number
);
$start
=
intval
((
$page
-
1
)
*
$number
);
// 获取列表
$data_params
=
array
(
'm'
=>
$start
,
'n'
=>
$number
,
'where'
=>
$where
,
'is_public'
=>
1
,
);
$data
=
GoodsCommentsService
::
GoodsCommentsList
(
$data_params
);
// 返回数据
$result
=
[
'number'
=>
$number
,
'total'
=>
$total
,
'page_total'
=>
$page_total
,
'data'
=>
$data
[
'data'
],
];
return
DataReturn
(
'请求成功'
,
0
,
$result
);
}
}
application/index/view/default/goods/index.html
浏览文件 @
ed941686
...
...
@@ -184,7 +184,7 @@
<li
class=
"tm-ind-item"
>
<div
class=
"tm-indcon"
><span
class=
"tm-label"
>
浏览次数
</span><span
class=
"tm-count"
>
{{$goods.access_count}}
</span></div>
</li>
<li
class=
"tm-ind-item"
>
<li
class=
"tm-ind-item
ind-panel-comment
"
>
<div
class=
"tm-indcon"
><span
class=
"tm-label"
>
累计评价
</span><span
class=
"tm-count"
>
{{$goods.comments_count}}
</span></div>
</li>
</ul>
...
...
@@ -383,14 +383,14 @@
{{/if}}
<!-- tab -->
<div
class=
"am-tabs"
data-am-tabs
>
<div
class=
"am-tabs"
data-am-tabs
id=
"goods-tabs"
>
<ul
class=
"am-avg-sm-3 am-tabs-nav am-nav am-nav-tabs"
data-am-sticky=
"{animation: 'slide-top'}"
>
<li
class=
"am-active"
>
<a
href=
"javascript:;"
>
<span
class=
"index-needs-dt-txt"
>
详情
</span>
</a>
</li>
<li>
<li
class=
"tabs-comment"
>
<a
href=
"javascript:;"
>
<span
class=
"index-needs-dt-txt"
>
评价({{$goods.comments_count}})
</span>
</a>
...
...
@@ -402,6 +402,7 @@
</li>
</ul>
<!-- 详情 -->
<div
class=
"am-tabs-bd"
>
<div
class=
"am-tab-panel am-fade am-in am-active"
>
{{if !empty($goods['attribute'])}}
...
...
@@ -430,61 +431,13 @@
</div>
<!-- 评论 -->
<div
class=
"am-tab-panel am-fade goods-comment"
>
<article
class=
"am-comment"
>
<a
href=
"#"
>
<img
src=
"http://tp5-dev.com/static/index/default/images/default-user-avatar.jpg"
class=
"am-comment-avatar"
alt=
""
/>
</a>
<div
class=
"am-comment-main"
>
<!-- 评论内容容器 -->
<header
class=
"am-comment-hd"
>
<!--<h3 class="am-comment-title">评论标题</h3>-->
<div
class=
"am-comment-meta"
>
<!-- 评论元数据 -->
<a
href=
"#link-to-user"
class=
"am-comment-author"
>
魔鬼
</a>
<!-- 评论者 -->
评论于
<time
datetime=
""
>
2019-05-13 15:32
</time>
</div>
</header>
<div
class=
"am-comment-bd"
>
<p>
那,那是一封写给南部母亲的信。我茫然站在骑楼下,我又看到永远的樱子走到街心。其实雨下得并不大,却是一生一世中最大的一场雨。而那封信是这样写的,年轻的樱子知不知道呢?
</p>
<p
class=
"comment-spec"
>
颜色:红色,尺码:M
</p>
<div
class=
"comment-reply"
>
<span
class=
"comment-reply-title"
>
管理员回复:
</span>
<span
class=
"comment-reply-desc"
>
我打算在下个月和樱子结婚。
</span>
</div>
</div>
</article>
<article
class=
"am-comment"
>
<a
href=
"#"
>
<img
src=
"http://tp5-dev.com/static/index/default/images/default-user-avatar.jpg"
class=
"am-comment-avatar"
alt=
""
/>
</a>
<div
class=
"am-comment-main"
>
<!-- 评论内容容器 -->
<header
class=
"am-comment-hd"
>
<!--<h3 class="am-comment-title">评论标题</h3>-->
<div
class=
"am-comment-meta"
>
<!-- 评论元数据 -->
<a
href=
"#link-to-user"
class=
"am-comment-author"
>
魔鬼
</a>
<!-- 评论者 -->
评论于
<time
datetime=
""
>
2019-05-13 15:32
</time>
</div>
</header>
<div
class=
"am-comment-bd"
>
<p>
那,那是一封写给南部母亲的信。我茫然站在骑楼下,我又看到永远的樱子走到街心。其实雨下得并不大,却是一生一世中最大的一场雨。而那封信是这样写的,年轻的樱子知不知道呢?
</p>
<p
class=
"comment-spec"
>
颜色:红色,尺码:M
</p>
</div>
</article>
<article
class=
"am-comment"
>
<a
href=
"#"
>
<img
src=
"http://tp5-dev.com/static/index/default/images/default-user-avatar.jpg"
class=
"am-comment-avatar"
alt=
""
/>
</a>
<div
class=
"am-comment-main"
>
<!-- 评论内容容器 -->
<header
class=
"am-comment-hd"
>
<!--<h3 class="am-comment-title">评论标题</h3>-->
<div
class=
"am-comment-meta"
>
<!-- 评论元数据 -->
<a
href=
"#link-to-user"
class=
"am-comment-author"
>
魔鬼
</a>
<!-- 评论者 -->
评论于
<time
datetime=
""
>
2019-05-13 15:32
</time>
</div>
</header>
<div
class=
"am-comment-bd"
>
<p>
那,那是一封写给南部母亲的信。我茫然站在骑楼下,我又看到永远的樱子走到街心。其实雨下得并不大,却是一生一世中最大的一场雨。而那封信是这样写的,年轻的樱子知不知道呢?
</p>
</div>
</article>
<div
class=
"am-tab-panel am-fade goods-comment"
data-goods-id=
"{{$goods.id}}"
data-url=
"{{:MyUrl('index/goods/comment')}}"
>
<div
class=
"goods-comment-content"
></div>
<div
class=
"goods-page-container"
></div>
<div
class=
"table-no goods-page-no-data none"
>
<i
class=
"am-icon-warning"
></i>
<span>
没有评论数据
</span>
</div>
</div>
<!-- 猜你喜欢 -->
...
...
application/plugins/newuserreduction/Hook.php
浏览文件 @
ed941686
...
...
@@ -99,8 +99,14 @@ class Hook
];
// 金额
$params
[
'data'
][
'base'
][
'increase_price'
]
-=
$price
;
$params
[
'data'
][
'base'
][
'actual_price'
]
-=
$price
;
if
(
$params
[
'data'
][
'base'
][
'increase_price'
]
>
0
)
{
$params
[
'data'
][
'base'
][
'increase_price'
]
-=
$price
;
}
if
(
$params
[
'data'
][
'base'
][
'actual_price'
]
>
0
)
{
$params
[
'data'
][
'base'
][
'actual_price'
]
-=
$price
;
}
}
return
DataReturn
(
'无需处理'
,
0
);
}
else
{
...
...
application/service/GoodsCommentsService.php
浏览文件 @
ed941686
...
...
@@ -156,7 +156,21 @@ class GoodsCommentsService
foreach
(
$data
as
&
$v
)
{
// 用户信息
$v
[
'user'
]
=
UserService
::
GetUserViewInfo
(
$v
[
'user_id'
]);
$user
=
UserService
::
GetUserViewInfo
(
$v
[
'user_id'
]);
if
(
!
isset
(
$params
[
'is_public'
])
||
$params
[
'is_public'
]
==
1
)
{
$v
[
'user'
]
=
[
'avatar'
=>
$user
[
'avatar'
],
'user_name_view'
=>
(
$v
[
'is_anonymous'
]
==
1
)
?
'匿名'
:
substr
(
$user
[
'user_name_view'
],
0
,
3
)
.
'***'
.
substr
(
$user
[
'user_name_view'
],
-
3
),
];
}
else
{
$v
[
'user'
]
=
$user
;
}
// 订单规格
$spec
=
Db
::
name
(
'OrderDetail'
)
->
where
([
'order_id'
=>
$v
[
'order_id'
],
'goods_id'
=>
$v
[
'goods_id'
]])
->
value
(
'spec'
);
$v
[
'spec'
]
=
empty
(
$spec
)
?
null
:
json_decode
(
$spec
);
// 是否
$v
[
'is_reply_text'
]
=
isset
(
$common_is_text_list
[
$v
[
'is_reply'
]])
?
$common_is_text_list
[
$v
[
'is_reply'
]][
'name'
]
:
''
;
...
...
public/static/common/js/common.js
浏览文件 @
ed941686
...
...
@@ -1194,6 +1194,66 @@ function MobileBrowserEnvironment()
return
null
;
}
/**
* [pagelibrary 分页按钮获取]
* @param {[int]} total [数据总条数]
* @param {[int]} number [页面数据显示条数]
* @param {[int]} page [当前页码数]
* @param {[int]} sub_number [按钮生成个数]
* @return {[string]} [html代码]
*/
function
PageLibrary
(
total
,
number
,
page
,
sub_number
)
{
if
((
total
||
null
)
==
null
)
return
''
;
if
((
page
||
null
)
==
null
)
page
=
1
;
if
((
number
||
null
)
==
null
)
number
=
15
;
if
((
sub_number
||
null
)
==
null
)
sub_number
=
2
;
var
page_total
=
Math
.
ceil
(
total
/
number
);
if
(
page
>
page_total
)
page
=
page_total
;
page
=
(
page
<=
0
)
?
1
:
parseInt
(
page
);
var
html
=
'
<ul class="am-pagination am-pagination-centered pagelibrary"><li
'
;
html
+=
(
page
>
1
)
?
''
:
'
class="am-disabled"
'
;
page_x
=
page
-
1
;
html
+=
'
><a data-page="
'
+
page_x
+
'
" class="am-radius">«</a></li>
'
;
var
html_before
=
''
;
var
html_after
=
''
;
var
html_page
=
'
<li class="am-active"><a class="am-radius">
'
+
page
+
'
</a></li>
'
;
if
(
sub_number
>
0
)
{
/* 前按钮 */
if
(
page
>
1
)
{
total
=
(
page
-
sub_number
<
1
)
?
1
:
page
-
sub_number
;
for
(
var
i
=
page
-
1
;
i
>=
total
;
i
--
)
{
html_before
=
'
<li><a data-page="
'
+
i
+
'
" class="am-radius">
'
+
i
+
'
</a></li>
'
+
html_before
;
}
}
/* 后按钮 */
if
(
page_total
>
page
)
{
total
=
(
page
+
sub_number
>
page_total
)
?
page_total
:
page
+
sub_number
;
for
(
var
i
=
page
+
1
;
i
<=
total
;
i
++
)
{
html_after
+=
'
<li><a data-page="
'
+
i
+
'
" class="am-radius">
'
+
i
+
'
</a></li>
'
;
}
}
}
html
+=
html_before
+
html_page
+
html_after
;
html
+=
'
<li
'
;
html
+=
(
page
>
0
&&
page
<
page_total
)
?
''
:
'
class="am-disabled"
'
;
page_y
=
page
+
1
;
html
+=
'
><a data-page="
'
+
page_y
+
'
" class="am-radius">»</a></li></ul>
'
;
return
html
;
}
// 公共数据操作
$
(
function
()
{
...
...
public/static/index/default/css/goods.css
浏览文件 @
ed941686
...
...
@@ -66,6 +66,8 @@ input{font-size:12px;font-size:100%;outline:none;line-height:normal;color:#444;}
.goods-comment
.am-comment-main
{
border
:
1px
solid
#eee
;
}
.goods-comment
.comment-spec
{
margin-top
:
5px
;
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
;
}
.comment-reply-title
{
color
:
#666
;
}
.comment-reply-desc
{
color
:
#905602
;
}
...
...
public/static/index/default/js/goods.js
浏览文件 @
ed941686
...
...
@@ -18,6 +18,82 @@ function poptit_close()
}
}
/**
* 评论记录ajax请求
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @datetime 2019-05-13T21:39:55+0800
* @param {[int]} page [分页值]
*/
function
GoodsCommentsHtml
(
page
)
{
$
(
'
.goods-page-no-data
'
).
addClass
(
'
none
'
);
$
.
ajax
({
url
:
$
(
'
.goods-comment
'
).
data
(
'
url
'
),
type
:
'
POST
'
,
data
:{
"
goods_id
"
:
$
(
'
.goods-comment
'
).
data
(
'
goods-id
'
),
"
page
"
:
page
},
dataType
:
'
json
'
,
success
:
function
(
result
)
{
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
][
'
spec
'
]
||
null
)
!=
null
)
{
var
spec_string
=
''
;
for
(
var
s
in
result
.
data
.
data
[
i
][
'
spec
'
])
{
if
(
s
>
0
)
{
spec_string
+=
'
|
'
;
}
spec_string
+=
result
.
data
.
data
[
i
][
'
spec
'
][
s
][
'
type
'
]
+
'
:
'
+
result
.
data
.
data
[
i
][
'
spec
'
][
s
][
'
value
'
];
}
html
+=
'
<p class="comment-spec">
'
+
spec_string
+
'
</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-page-container
'
).
html
(
PageLibrary
(
result
.
data
.
total
,
result
.
data
.
number
,
page
,
2
));
}
// 没有数据
if
(
$
(
'
.goods-comment-content article
'
).
length
<=
0
)
{
$
(
'
.goods-page-no-data
'
).
removeClass
(
'
none
'
);
}
}
});
}
/**
* 购买/加入购物车
* @author Devil
...
...
@@ -513,6 +589,30 @@ $(function() {
t
.
val
((
value
<=
1
)
?
1
:
value
);
});
// 评论
GoodsCommentsHtml
(
1
);
$
(
document
).
on
(
'
click
'
,
'
.goods-page-container .pagelibrary a
'
,
function
()
{
var
page
=
$
(
this
).
data
(
'
page
'
)
||
null
;
if
(
page
!=
null
)
{
// 获取数据
GoodsCommentsHtml
(
page
);
// 回到评论顶部位置
var
top
=
$
(
'
.introduce-main
'
).
offset
().
top
;
$
(
window
).
smoothScroll
({
position
:
top
});
}
});
// 累计评价点击事件
$
(
'
.tm-ind-panel .ind-panel-comment
'
).
on
(
'
click
'
,
function
()
{
var
top
=
$
(
'
.introduce-main
'
).
offset
().
top
;
$
(
window
).
smoothScroll
({
position
:
top
});
$
(
'
.introduce-main .am-tabs
'
).
tabs
(
'
open
'
,
1
);
});
});
// 浏览器窗口实时事件
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录