Showing
3 changed files
with
144 additions
and
0 deletions
apps/guang/views/action/info/comments.hbs
0 → 100644
1 | +<div class="comments-title clearfix"> | ||
2 | + <div class="avatar-list"> | ||
3 | + <img src="" alt=""> | ||
4 | + <img src="" alt=""> | ||
5 | + <img src="" alt=""> | ||
6 | + </div> | ||
7 | + <div class="agree">210人点赞</div> | ||
8 | + <div class="seenum">9213人看过</div> | ||
9 | +</div> | ||
10 | +<div class="comments-num"><span>评论2</span></div> | ||
11 | +<div class="comments-list clearfix"> | ||
12 | + <div class="avatar"> | ||
13 | + <img src="" alt=""> | ||
14 | + </div> | ||
15 | + <div class="info-box"> | ||
16 | + <div class="info-top"> | ||
17 | + <div> | ||
18 | + <span class="username">缺心眼子</span> | ||
19 | + <span class="info-right"> | ||
20 | + <span class="iconfont"></span> | ||
21 | + <span>313</span> | ||
22 | + </span> | ||
23 | + </div> | ||
24 | + <div class="time"><span>4分钟前</span></div> | ||
25 | + </div> | ||
26 | + <div class="info-bottom"></div> | ||
27 | + </div> | ||
28 | +</div> |
public/js/guang/detail/guang-comments.js
0 → 100644
1 | +/* | ||
2 | + * @Author: Targaryen | ||
3 | + * @Date: 2017-05-25 14:36:33 | ||
4 | + * @Last Modified by: Targaryen | ||
5 | + * @Last Modified time: 2017-05-25 15:28:52 | ||
6 | + */ | ||
7 | +const $ = require('yoho-jquery'); | ||
8 | +const qs = window.queryString; | ||
9 | +const article_id = qs.id || $('.detail').data('id'); | ||
10 | +const $comments = $('#comments'); | ||
11 | + | ||
12 | +let page = 0; | ||
13 | +let beforeScroll = document.body.scrollTop; // 滚动前位置记录 | ||
14 | +let onLoading = false; // 是否正在加载 | ||
15 | + | ||
16 | +/** | ||
17 | + * 异步加载评论 | ||
18 | + */ | ||
19 | +const getComments = () => { | ||
20 | + if (!onLoading) { | ||
21 | + onLoading = true; | ||
22 | + } else { | ||
23 | + return false; | ||
24 | + } | ||
25 | + | ||
26 | + $.ajax({ | ||
27 | + type: 'get', | ||
28 | + url: '//guang.m.yohobuy.com/guang/info/getComments', | ||
29 | + data: { | ||
30 | + article_id: article_id, | ||
31 | + page: page++ | ||
32 | + }, | ||
33 | + success: function(result) { | ||
34 | + $comments.append(result); | ||
35 | + onLoading = false; | ||
36 | + } | ||
37 | + }); | ||
38 | +}; | ||
39 | + | ||
40 | +/** | ||
41 | + * 当scroll到1/2$goodsContainer高度后继续请求下一页数据 | ||
42 | + */ | ||
43 | +const scrollHandler = function() { | ||
44 | + if ($(window).scrollTop() > $comments.height() * 0.6) { | ||
45 | + getComments(); | ||
46 | + } | ||
47 | +}; | ||
48 | + | ||
49 | +/** | ||
50 | + * 滚动加载 | ||
51 | + */ | ||
52 | +$(window).scroll(function() { | ||
53 | + setTimeout(function() { | ||
54 | + let afterScroll = document.body.scrollTop; | ||
55 | + | ||
56 | + if (afterScroll - beforeScroll > 0) { | ||
57 | + window.requestAnimationFrame(scrollHandler); | ||
58 | + beforeScroll = afterScroll; | ||
59 | + } else { | ||
60 | + return false; | ||
61 | + } | ||
62 | + }, 5); | ||
63 | +}); | ||
64 | + | ||
65 | +getComments(); |
public/scss/guang/detail/_comments.css
0 → 100644
1 | +/* | ||
2 | + * @Author: Targaryen | ||
3 | + * @Date: 2017-05-25 15:49:46 | ||
4 | + * @Last Modified by: Targaryen | ||
5 | + * @Last Modified time: 2017-05-25 16:07:12 | ||
6 | + */ | ||
7 | + | ||
8 | +.guang-detail-page .comments { | ||
9 | + padding: 0 30px; | ||
10 | + margin-top: 30px; | ||
11 | + | ||
12 | + .comments-title { | ||
13 | + color: #444; | ||
14 | + | ||
15 | + .avatar-list { | ||
16 | + float: left; | ||
17 | + | ||
18 | + img { | ||
19 | + width: 70px; | ||
20 | + height: 70px; | ||
21 | + border-radius: 35px; | ||
22 | + } | ||
23 | + } | ||
24 | + | ||
25 | + .agree { | ||
26 | + float: left; | ||
27 | + } | ||
28 | + | ||
29 | + .seenum { | ||
30 | + float: right; | ||
31 | + } | ||
32 | + } | ||
33 | + | ||
34 | + .comments-num > span { | ||
35 | + float: left; | ||
36 | + color: #b0b0b0; | ||
37 | + } | ||
38 | + | ||
39 | + .comments-list { | ||
40 | + .avatar { | ||
41 | + float: left; | ||
42 | + width: 70px; | ||
43 | + margin-right: 30px; | ||
44 | + } | ||
45 | + | ||
46 | + .info-box > .info-top > .title { | ||
47 | + font-size: 16px; | ||
48 | + color: #b0b0b0; | ||
49 | + } | ||
50 | + } | ||
51 | +} |
-
Please register or login to post a comment