-
Notifications
You must be signed in to change notification settings - Fork 0
/
content_jc.html
601 lines (565 loc) · 20 KB
/
content_jc.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
<title></title>
<script src="js/mui.min.js"></script>
<link href="css/mui.min.css" rel="stylesheet" />
<link href="css/app.css" rel="stylesheet" />
<script type="text/javascript" src="js/mui.zoom.js"></script>
<script type="text/javascript" src="js/mui.previewimage.js"></script>
</head>
<body>
<header class="mui-bar mui-bar-nav">
<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
<h1 id="ccontent_title" class="mui-title"></h1>
</header>
<div style="height: 50px;"></div>
<div class="mui-content mui-scroll-wrapper mui-slider-group">
<div class="mui-scroll">
<div class="big_box">
<div class="big_box_p">
<!--用户信息-->
<div class="user_box">
<div class="user_box_p">
<div class="user_name">
<a id="ccontent_user_name" href="#"></a>
</div>
<div id="ccontent_time" class="user_time">
</div>
<div class="article_detaile">
人气/<span id="ccontent_browse"></span> 评论/<span id="ccontent_comments"></span> 赞/<span id="ccontent_zan"></span>
</div>
<div class="user_img">
<a href="#"><img id="ccontent_user_img" src="" /></a>
</div>
<!--<div class="article_guanzhu" data-user="">
关注
</div>-->
</div>
<div class="user_line">
<img src="images/line.png" />
</div>
</div>
<!--文章内容-->
<div class="article_box">
<!--<div id="ccontent_title" class="article_title">
</div>-->
<div id="ccontent_subtitle" class="article_content">
</div>
<div id="ccontent_content" class="article_img">
</div>
<div class="article_ly"><a id="article_jc_link" href=""><span id="article_link_name"></span> * 查看原文</a></div>
</div>
<!--点赞-->
<div id="article_zan" data-iarzan="" class="article_zan">
<div class="article_zan_bg">
<img src="images/zan_bg.png" />
</div>
<div class="article_zan_icon">
<img src="images/zan_icon.png" />
</div>
<div id="ccontent_zan_big" class="article_zan_namble">
</div>
</div>
</div>
<div class="daily_title_p">
<div class="daily_title">
<img src="images/comments_title.png" />
</div>
</div>
<div class="big_box_p">
<!--评论内容-->
<div id="hot" class="comments_list_box ">
</div>
</div>
<div style="height: 50px;"></div>
</div>
</div>
<!--添加评论-->
<div class="add_comment">
<div class="add_input">
<input id="addcomment" type="text" />
</div>
<div class="add_btn">
<button id="addbtn" type="button" class="mui-btn mui-btn-block mui-btn-blue">评论</button>
</div>
</div>
</div>
</body>
<script src="js/mui.pullToRefresh.js"></script>
<script src="js/mui.pullToRefresh.material.js"></script>
<script type="text/javascript" src="js/app.js"></script>
<script type="text/javascript">
mui.previewImage();
</script>
<script type="text/javascript">
mui.plusReady(function() {
mui.init();
var self = plus.webview.currentWebview();
var contentid = self.contentid;
var user_id; //文章作者id
var ifirst = 0; //开始条数
var ilast = 10; //结束条数
var maxid = 0; //评论最大id
var jc_link;
// console.log(contentid);
var url = "http://www.zjliang.com/index.php/Gapi/Content/";
mui.ajax(url, {
data: {
id: contentid
},
dataType: 'json', //服务器返回json格式数据
type: 'post', //HTTP请求类型
timeout: 10000, //超时时间设置为10秒;
success: function(data) {
var obo = eval(data);
user_id = obo[0].inid;
var ccontent_user_name = obo[0].user_name,
ccontent_user_img = obo[0].user_img,
ccontent_browse = obo[0].browse,
ccontent_comments = obo[0].comments,
ccontent_zan = obo[0].zan,
ccontent_time = obo[0].time,
ccontent_title = obo[0].title,
ccontent_subtitle = obo[0].subtitle,
ccontent_content = obo[0].content,
ccontent_jc_link = obo[0].jc_link,
ccontent_link_name = obo[0].link_name;
jc_link = ccontent_jc_link;
var ocontent_user_name = document.getElementById("ccontent_user_name");
var ocontent_user_img = document.getElementById("ccontent_user_img");
var ocontent_browse = document.getElementById("ccontent_browse");
var ocontent_comments = document.getElementById("ccontent_comments");
var ocontent_zan = document.getElementById("ccontent_zan");
var ocontent_zan_big = document.getElementById("ccontent_zan_big");
var ocontent_time = document.getElementById("ccontent_time");
var ocontent_title = document.getElementById("ccontent_title");
var ocontent_subtitle = document.getElementById("ccontent_subtitle");
var ocontent_content = document.getElementById("ccontent_content");
var ocontent_jc_link = document.getElementById("article_jc_link");
var ocontent_link_name = document.getElementById("article_link_name");
ocontent_user_name.innerHTML = ccontent_user_name;
ocontent_user_img.src = ccontent_user_img;
ocontent_browse.innerHTML = ccontent_browse;
ocontent_comments.innerHTML = ccontent_comments;
ocontent_zan.innerHTML = ccontent_zan;
document.getElementById("article_zan").dataset.iarzan = ccontent_zan;
ocontent_zan_big.innerHTML = ccontent_zan;
ocontent_time.innerHTML = ccontent_time;
ocontent_title.innerHTML = ccontent_title;
ocontent_subtitle.innerHTML = ccontent_subtitle;
ocontent_content.innerHTML = ccontent_content;
ocontent_jc_link.src = ccontent_jc_link;
ocontent_link_name.innerHTML = ccontent_link_name;
},
error: function(xhr, type, errorThrown) {
//异常处理;
console.log(type);
}
});
// 跟帖数据
var url = "http://www.zjliang.com/index.php/Gapi/Comment/";
mui.ajax(url, {
data: {
content_id: contentid, //获取文章id
first: ifirst,
last: ilast
},
dataType: 'json', //服务器返回json格式数据
type: 'post', //HTTP请求类型
timeout: 10000, //超时时间设置为10秒;
success: function(data) {
var obo = eval(data);
maxid = obo[0].id;
var list = document.getElementById("hot");
mui.each(obo, function(index, item) {
var cid = item.id,
time = item.time,
content = item.content,
zan = item.zan,
user_img = item.user_img,
user_name = item.user_name;
odiv = document.createElement('div');
odiv.className = 'comments_list';
odiv.innerHTML = '<div class="comments_list_p">' +
'<div class="comments_user_name">' +
user_name +
'</div>' +
'<div class="comments_user_time">' +
time +
'</div>' +
'<div class="comments_user_text">' +
content +
'</div>' +
'<div data-name=' + user_name + ' class="comments_user_huifu">' +
'回复' +
'</div>' +
'<div class="comments_user_logo">' +
'<img src="' + user_img + '"/>' +
'</div>' +
'<div data-id=' + cid + ' data-wzan=' + zan + ' class="comments_user_zan">' +
'<div class="comments_user_zan_nb">' +
'<div id="zan_' + parseInt(cid) + '" class="comments_user_zan_float">' + zan + '</div>' +
'<div class="comments_user_zan_float comments_user_zan_icon"><img src="images/zan.png"></div>' +
'</div>' +
'</div>' +
'</div>';
list.appendChild(odiv);
});
},
error: function(xhr, type, errorThrown) {
//异常处理;
console.log(type);
}
});
function pulldownRefresh() {
setTimeout(function() {
// 代码位置
var url = "http://www.zjliang.com/index.php/Gapi/Comment/two.html/";
mui.ajax(url, {
data: {
content_id: contentid, //获取文章id
maxid: maxid,
},
dataType: 'json', //服务器返回json格式数据
type: 'post', //HTTP请求类型
timeout: 10000, //超时时间设置为10秒;
success: function(data) {
var obo = eval(data);
var list = document.getElementById("hot");
// var macidl = obo.length;
mui.each(obo, function(index, item) {
var cid = item.id,
time = item.time,
content = item.content,
zan = item.zan,
user_img = item.user_img,
user_name = item.user_name;
maxid = cid;
odiv = document.createElement('div');
odiv.className = 'comments_list';
odiv.innerHTML = '<div class="comments_list_p">' +
'<div class="comments_user_name">' +
user_name +
'</div>' +
'<div class="comments_user_time">' +
time +
'</div>' +
'<div class="comments_user_text">' +
content +
'</div>' +
'<div data-name=' + user_name + ' class="comments_user_huifu">' +
'回复' +
'</div>' +
'<div class="comments_user_logo">' +
'<img src="' + user_img + '"/>' +
'</div>' +
'<div data-id=' + cid + ' data-wzan=' + zan + ' class="comments_user_zan">' +
'<div class="comments_user_zan_nb">' +
'<div id="zan_' + parseInt(cid) + '" class="comments_user_zan_float">' + zan + '</div>' +
'<div class="comments_user_zan_float comments_user_zan_icon"><img src="images/zan.png"></div>' +
'</div>' +
'</div>' +
'</div>';
list.insertBefore(odiv, list.firstChild);
});
},
error: function(xhr, type, errorThrown) {
//异常处理;
console.log(type);
}
});
}, 1500);
}
var count = 0;
/**
* 上拉加载具体业务实现
*/
function pullupRefresh() {
setTimeout(function() {
var cells = document.body.querySelectorAll('.comments_list');
var url = "http://www.zjliang.com/index.php/Gapi/Comment/";
mui.ajax(url, {
data: {
content_id: contentid, //获取文章id
first: cells.length,
last: cells.length + 10
},
dataType: 'json', //服务器返回json格式数据
type: 'post', //HTTP请求类型
timeout: 10000, //超时时间设置为10秒;
success: function(data) {
var obo = eval(data);
var list = document.getElementById("hot");
mui.each(obo, function(index, item) {
var cid = item.id,
time = item.time,
content = item.content,
zan = item.zan,
user_img = item.user_img,
user_name = item.user_name;
odiv = document.createElement('div');
odiv.className = 'comments_list';
odiv.innerHTML = '<div class="comments_list_p">' +
'<div class="comments_user_name">' +
user_name +
'</div>' +
'<div class="comments_user_time">' +
time +
'</div>' +
'<div class="comments_user_text">' +
content +
'</div>' +
'<div data-name=' + user_name + ' class="comments_user_huifu">' +
'回复' +
'</div>' +
'<div class="comments_user_logo">' +
'<img src="' + user_img + '"/>' +
'</div>' +
'<div data-id=' + cid + ' data-wzan=' + zan + ' class="comments_user_zan">' +
'<div class="comments_user_zan_nb">' +
'<div id="zan_' + parseInt(cid) + '" class="comments_user_zan_float">' + zan + '</div>' +
'<div class="comments_user_zan_float comments_user_zan_icon"><img src="images/zan.png"></div>' +
'</div>' +
'</div>' +
'</div>';
// console.log()
list.appendChild(odiv);
});
},
error: function(xhr, type, errorThrown) {
//异常处理;
console.log(type);
}
});
}, 1500);
}
mui('#hot').on('tap', 'a', function() {
var contentid = this.getAttribute("data-id");
var id = this.getAttribute("href");
var href = this.getAttribute('href');
mui.openWindow({
url: href,
extras: {
contentid: contentid //扩展参数
}
});
});
// 添加评论
var state = app.getState();
document.getElementById('addbtn').addEventListener('tap', function() {
//获取登录信息
if(state.token) {
var user_id = state.account.id; //用户id
var user_name = state.account.name; //用户名
var user_img2 = state.account.user_img2; //用户头像
// console.log(JSON.stringify(state))
var addcontent = document.getElementById('addcomment').value;
var ctitle = document.getElementById("hot");
var zan = 0;
var myDate = new Date();
var atime = myDate.toLocaleString();
if(addcontent.length <= 0) {
plus.nativeUI.toast("评论不得为空");
} else {
plus.nativeUI.toast("评论成功");
var addurl = "http://www.zjliang.com/index.php/Gapi/Comment/addcomment.html";
mui.ajax(addurl, {
data: {
content_id: contentid,
user_id: user_id,
time: atime,
content: addcontent,
zan: '0',
type: '1',
user_img: user_img2,
user_name: user_name
},
dataType: 'json', //服务器返回json格式数据
type: 'post', //HTTP请求类型
timeout: 10000, //超时时间设置为10秒;
success: function(data) {
// 刷新列表
var curl = "http://www.zjliang.com/index.php/Gapi/Comment/newcomment";
mui.ajax(curl, {
data: {
mid: maxid,
type: '1',
content_id: contentid
},
dataType: 'json', //服务器返回json格式数据
type: 'post', //HTTP请求类型
timeout: 10000, //超时时间设置为10秒;
success: function(data) {
var inbo = eval(data);
var comments_namebel = document.getElementById('ccontent_comments').innerHTML;
document.getElementById('ccontent_comments').innerHTML = parseInt(comments_namebel) + 1;
mui.each(inbo, function(index, item) {
var cid = item.id,
time = item.time,
content = item.content,
zan = item.zan,
user_img = item.user_img,
user_name = item.user_name;
maxid = cid;
console.log(maxid);
odiv = document.createElement('div');
odiv.className = 'comments_list';
odiv.innerHTML = '<div class="comments_list_p">' +
'<div class="comments_user_name">' +
user_name +
'</div>' +
'<div class="comments_user_time">' +
time +
'</div>' +
'<div class="comments_user_text">' +
content +
'</div>' +
'<div data-name=' + user_name + ' class="comments_user_huifu">' +
'回复' +
'</div>' +
'<div class="comments_user_logo">' +
'<img src="' + user_img + '"/>' +
'</div>' +
'<div data-id=' + cid + ' data-wzan=' + zan + ' class="comments_user_zan">' +
'<div class="comments_user_zan_nb">' +
'<div id="zan_' + parseInt(cid) + '" class="comments_user_zan_float">' + zan + '</div>' +
'<div class="comments_user_zan_float comments_user_zan_icon"><img src="images/zan.png"></div>' +
'</div>' +
'</div>' +
'</div>';
ctitle.insertBefore(odiv, ctitle.firstChild);
// ctitle.appendChild(cobj);
});
},
error: function(xhr, type, errorThrown) {
//异常处理;
console.log(type);
}
});
},
error: function(xhr, type, errorThrown) {
//异常处理;
console.log(type);
// console.log('未添加');
}
});
document.getElementById('addcomment').value = '';
}
} else {
plus.nativeUI.toast("请登录");
}
});
mui('#hot').on('tap', '.comments_user_huifu', function() {
if(state.token) {
var tname = this.getAttribute("data-name");
var addcontent = document.getElementById('addcomment');
addcontent.value = state.account.name + ' 回复 ' + tname + ':';
} else {
plus.nativeUI.toast("请登录");
}
});
//文章点赞
document.getElementById('article_zan').addEventListener("tap", function() {
var arzan = document.getElementById('ccontent_zan_big').innerHTML;
var iarzan = this.getAttribute("data-iarzan");
if(parseInt(arzan) == parseInt(iarzan)) {
document.getElementById('ccontent_zan_big').innerHTML = parseInt(arzan) + 1;
document.getElementById('ccontent_zan').innerHTML = parseInt(arzan) + 1;
var addurl = "http://www.zjliang.com/index.php/Gapi/Article/zan.html";
mui.ajax(addurl, {
data: {
id: contentid
},
dataType: 'json', //服务器返回json格式数据
type: 'post', //HTTP请求类型
timeout: 10000, //超时时间设置为10秒;
success: function(data) {
},
error: function(xhr, type, errorThrown) {
//异常处理;
console.log(type);
// console.log('未添加');
}
});
plus.nativeUI.toast("感谢您的认可,我会更加精进,谢谢");
} else {
plus.nativeUI.toast("已点赞");
}
});
// 评论点赞
mui('#hot').on('tap', '.comments_user_zan', function() {
var uid = this.getAttribute("data-id");
var wzan = this.getAttribute("data-wzan");
var inzan = 'zan_' + parseInt(uid);
var nzan = document.getElementById(inzan).innerHTML;
if(parseInt(nzan) == parseInt(wzan)) {
document.getElementById(inzan).innerHTML = parseInt(wzan) + 1;
var addurl = "http://www.zjliang.com/index.php/Gapi/Comment/Update.html";
mui.ajax(addurl, {
data: {
id: uid
},
dataType: 'json', //服务器返回json格式数据
type: 'post', //HTTP请求类型
timeout: 10000, //超时时间设置为10秒;
success: function(data) {
},
error: function(xhr, type, errorThrown) {
//异常处理;
console.log(type);
}
});
} else {
plus.nativeUI.toast("已点赞");
}
});
document.getElementById("article_jc_link").addEventListener("tap",function(){
// console.log(jc_link);
mui.openWindow({
url: 'content_jc_link.html',
extras:{
link_url:jc_link
}
});
});
(function($) {
//阻尼系数
var deceleration = mui.os.ios ? 0.003 : 0.0009;
$('.mui-scroll-wrapper').scroll({
bounce: false,
indicators: true, //是否显示滚动条
deceleration: deceleration
});
$.ready(function() {
//循环初始化所有下拉刷新,上拉加载。
$.each(document.querySelectorAll('.mui-slider-group .mui-scroll'), function(index, pullRefreshEl) {
$(pullRefreshEl).pullToRefresh({
down: {
callback: function() {
var self = this;
setTimeout(function() {
console.log(1);
pulldownRefresh(); //下拉刷新
self.endPullDownToRefresh();
}, 1000);
}
},
up: {
callback: function() {
var self = this;
setTimeout(function() {
pullupRefresh(); //上拉加载
self.endPullUpToRefresh();
}, 1000);
}
}
});
});
});
})(mui);
});
</script>
</html>