list-dynamic.js
1.05 KB
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
/**
* 动态获取页面数据
* @author liuchuanyang
* @date 2016/10/09
*/
var $ = require('yoho-jquery');
function getDynamicByIds(ids) {
'use strict';
var param = {
return_type: 'jsonp',
ids: ids
};
return $.getJSON('//guang.yohobuy.com/guang/info/listData?callback=?', param);
}
function renderData(data) {
'use strict';
var i, it, $it;
if (data && data.code === 200 && data.list) {
for (i = 0; i < data.list.length; i++) {
it = data.list[i];
if (it && it.id) {
$it = $('#msg-list .msg-content[data-id=' + it.id + ']');
$it.find('.page-view');
$it.find('.like-num');
$it.find('.comment');
}
}
}
}
function refreshData() {
'use strict';
var idArr = [];
$('#msg-list .msg-content').each(function() {
var id = $(this).attr('data-id');
if (id) {
idArr.push(id);
}
});
getDynamicByIds(idArr.join(',')).done(renderData);
}
refreshData();