|
@@ -3,100 +3,101 @@ |
|
@@ -3,100 +3,101 @@ |
3
|
* @author: Lynnic
|
3
|
* @author: Lynnic
|
4
|
* @date: 2015/11/25
|
4
|
* @date: 2015/11/25
|
5
|
*/
|
5
|
*/
|
6
|
-var $ = require('jquery'),
|
|
|
7
|
- loading = require('../../plugin/loading'),
|
|
|
8
|
- tip = require('../../plugin/tip');
|
|
|
9
|
-
|
|
|
10
|
-var loadMoreUrl = $('#loadMoreUrl').val(),
|
|
|
11
|
- $commentsDiv = $('#goods-comments'),
|
|
|
12
|
- $consultsDiv = $('#goods-consults'),
|
|
|
13
|
- winH = $(window).height(),
|
|
|
14
|
- searching = false,
|
|
|
15
|
- end = false;
|
|
|
16
|
-
|
|
|
17
|
-var jsonObj;
|
|
|
18
|
-
|
|
|
19
|
-//插入评论列表底部
|
|
|
20
|
-function insertCommentsDiv(json) {
|
|
|
21
|
- var html = '';
|
|
|
22
|
- var i;
|
|
|
23
|
-
|
|
|
24
|
-
|
|
|
25
|
- for (i = 0; i < json.length; i++) {
|
|
|
26
|
- html += '<div class="comment-item">';
|
|
|
27
|
- html += '<span class="user-name">' + json[i].userName + '</span>';
|
|
|
28
|
- html += '<span class="goods-spec">' + json[i].desc + '</span>';
|
|
|
29
|
- html += '<span class="goods-spec">' + json[i].content + '</span>';
|
|
|
30
|
- html += '<span class="goods-spec">' + json[i].time + '</span>';
|
|
|
31
|
- }
|
|
|
32
|
- $commentsDiv.append(html);
|
|
|
33
|
-}
|
|
|
34
|
-
|
|
|
35
|
-//插入咨询列表底部
|
|
|
36
|
-function insertConsultsDiv(json) {
|
|
|
37
|
- var html = '';
|
|
|
38
|
- var i;
|
|
|
39
|
-
|
|
|
40
|
-
|
|
|
41
|
- for (i = 0; i < json.length; i++) {
|
|
|
42
|
- html += '<div class="consult-item"> ';
|
|
|
43
|
- html += '<div class="question"> ';
|
|
|
44
|
- html += '<span class="iconfont"></span> ';
|
|
|
45
|
- html += '<p> ';
|
|
|
46
|
- html += json[i].question + '<br> ';
|
|
|
47
|
- html += '<span class="time">' + json[i].time + '</span> ';
|
|
|
48
|
- html += '</p> ';
|
|
|
49
|
- html += '</div> ';
|
|
|
50
|
-
|
|
|
51
|
- html += '<div class="answer"> ';
|
|
|
52
|
- html += '<span class="iconfont"></span> ';
|
|
|
53
|
- html += '<p>' + json[i].answer + '</p> ';
|
|
|
54
|
- html += '</div> ';
|
|
|
55
|
- html += '</div> ';
|
|
|
56
|
- }
|
|
|
57
|
- $consultsDiv.append(html);
|
|
|
58
|
-}
|
|
|
59
|
-
|
|
|
60
|
-function search() {
|
|
|
61
|
- if (searching || end) {
|
|
|
62
|
- return;
|
|
|
63
|
- }
|
|
|
64
|
- searching = true;
|
|
|
65
|
-
|
|
|
66
|
- loading.showLoadingMask();
|
|
|
67
|
-
|
|
|
68
|
- $.ajax({
|
|
|
69
|
- type: 'GET',
|
|
|
70
|
- url: loadMoreUrl,
|
|
|
71
|
- success: function(data) {
|
|
|
72
|
- if (data.length > 0) {
|
|
|
73
|
- jsonObj = JSON.parse(data);
|
|
|
74
|
- if ($commentsDiv.length > 0) {
|
|
|
75
|
- insertCommentsDiv(jsonObj);
|
|
|
76
|
- } else if ($consultsDiv.length > 0) {
|
|
|
77
|
- insertConsultsDiv(jsonObj);
|
|
|
78
|
- }
|
|
|
79
|
- }
|
|
|
80
|
- searching = false;
|
|
|
81
|
- end = true;
|
|
|
82
|
- loading.hideLoadingMask();
|
|
|
83
|
- },
|
|
|
84
|
- error: function() {
|
|
|
85
|
- tip.show('网络断开连接了~');
|
|
|
86
|
- searching = false;
|
|
|
87
|
- loading.hideLoadingMask();
|
|
|
88
|
- }
|
|
|
89
|
- });
|
|
|
90
|
-}
|
|
|
91
|
-
|
|
|
92
|
-
|
|
|
93
|
-function scrollHandler() {
|
|
|
94
|
- if (!end || $(window).scrollTop() + winH >= $(document).height() - 50) {
|
|
|
95
|
- search();
|
|
|
96
|
- }
|
|
|
97
|
-}
|
|
|
98
|
-
|
|
|
99
|
-//srcoll to load more
|
|
|
100
|
-$(window).scroll(function() {
|
|
|
101
|
- window.requestAnimationFrame(scrollHandler);
|
|
|
102
|
-}); |
|
|
|
|
6
|
+
|
|
|
7
|
+// var $ = require('jquery'),
|
|
|
8
|
+// loading = require('../../plugin/loading'),
|
|
|
9
|
+// tip = require('../../plugin/tip');
|
|
|
10
|
+
|
|
|
11
|
+// var loadMoreUrl = $('#loadMoreUrl').val(),
|
|
|
12
|
+// $commentsDiv = $('#goods-comments'),
|
|
|
13
|
+// $consultsDiv = $('#goods-consults'),
|
|
|
14
|
+// winH = $(window).height(),
|
|
|
15
|
+// searching = false,
|
|
|
16
|
+// end = false;
|
|
|
17
|
+
|
|
|
18
|
+// var jsonObj;
|
|
|
19
|
+
|
|
|
20
|
+// //插入评论列表底部
|
|
|
21
|
+// function insertCommentsDiv(json) {
|
|
|
22
|
+// var html = '';
|
|
|
23
|
+// var i;
|
|
|
24
|
+
|
|
|
25
|
+
|
|
|
26
|
+// for (i = 0; i < json.length; i++) {
|
|
|
27
|
+// html += '<div class="comment-item">';
|
|
|
28
|
+// html += '<span class="user-name">' + json[i].userName + '</span>';
|
|
|
29
|
+// html += '<span class="goods-spec">' + json[i].desc + '</span>';
|
|
|
30
|
+// html += '<span class="goods-spec">' + json[i].content + '</span>';
|
|
|
31
|
+// html += '<span class="goods-spec">' + json[i].time + '</span>';
|
|
|
32
|
+// }
|
|
|
33
|
+// $commentsDiv.append(html);
|
|
|
34
|
+// }
|
|
|
35
|
+
|
|
|
36
|
+// //插入咨询列表底部
|
|
|
37
|
+// function insertConsultsDiv(json) {
|
|
|
38
|
+// var html = '';
|
|
|
39
|
+// var i;
|
|
|
40
|
+
|
|
|
41
|
+
|
|
|
42
|
+// for (i = 0; i < json.length; i++) {
|
|
|
43
|
+// html += '<div class="consult-item"> ';
|
|
|
44
|
+// html += '<div class="question"> ';
|
|
|
45
|
+// html += '<span class="iconfont"></span> ';
|
|
|
46
|
+// html += '<p> ';
|
|
|
47
|
+// html += json[i].question + '<br> ';
|
|
|
48
|
+// html += '<span class="time">' + json[i].time + '</span> ';
|
|
|
49
|
+// html += '</p> ';
|
|
|
50
|
+// html += '</div> ';
|
|
|
51
|
+
|
|
|
52
|
+// html += '<div class="answer"> ';
|
|
|
53
|
+// html += '<span class="iconfont"></span> ';
|
|
|
54
|
+// html += '<p>' + json[i].answer + '</p> ';
|
|
|
55
|
+// html += '</div> ';
|
|
|
56
|
+// html += '</div> ';
|
|
|
57
|
+// }
|
|
|
58
|
+// $consultsDiv.append(html);
|
|
|
59
|
+// }
|
|
|
60
|
+
|
|
|
61
|
+// function search() {
|
|
|
62
|
+// if (searching || end) {
|
|
|
63
|
+// return;
|
|
|
64
|
+// }
|
|
|
65
|
+// searching = true;
|
|
|
66
|
+
|
|
|
67
|
+// loading.showLoadingMask();
|
|
|
68
|
+
|
|
|
69
|
+// $.ajax({
|
|
|
70
|
+// type: 'GET',
|
|
|
71
|
+// url: loadMoreUrl,
|
|
|
72
|
+// success: function(data) {
|
|
|
73
|
+// if (data.length > 0) {
|
|
|
74
|
+// jsonObj = JSON.parse(data);
|
|
|
75
|
+// if ($commentsDiv.length > 0) {
|
|
|
76
|
+// insertCommentsDiv(jsonObj);
|
|
|
77
|
+// } else if ($consultsDiv.length > 0) {
|
|
|
78
|
+// insertConsultsDiv(jsonObj);
|
|
|
79
|
+// }
|
|
|
80
|
+// }
|
|
|
81
|
+// searching = false;
|
|
|
82
|
+// end = true;
|
|
|
83
|
+// loading.hideLoadingMask();
|
|
|
84
|
+// },
|
|
|
85
|
+// error: function() {
|
|
|
86
|
+// tip.show('网络断开连接了~');
|
|
|
87
|
+// searching = false;
|
|
|
88
|
+// loading.hideLoadingMask();
|
|
|
89
|
+// }
|
|
|
90
|
+// });
|
|
|
91
|
+// }
|
|
|
92
|
+
|
|
|
93
|
+
|
|
|
94
|
+// function scrollHandler() {
|
|
|
95
|
+// if (!end || $(window).scrollTop() + winH >= $(document).height() - 50) {
|
|
|
96
|
+// search();
|
|
|
97
|
+// }
|
|
|
98
|
+// }
|
|
|
99
|
+
|
|
|
100
|
+// //srcoll to load more
|
|
|
101
|
+// $(window).scroll(function() {
|
|
|
102
|
+// window.requestAnimationFrame(scrollHandler);
|
|
|
103
|
+// }); |