-
Notifications
You must be signed in to change notification settings - Fork 55
/
Copy pathdbmv.js
124 lines (115 loc) · 2.83 KB
/
dbmv.js
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
const category = {
"所有": "https://www.dbmeinv.com/dbgroup/show.htm?pager_offset=",
"大胸妹": "https://www.dbmeinv.com/dbgroup/show.htm?cid=2&pager_offset=",
"小翘臀": "https://www.dbmeinv.com/dbgroup/show.htm?cid=6&pager_offset=",
"黑丝袜": "https://www.dbmeinv.com/dbgroup/show.htm?cid=7&pager_offset=",
"美腿控": "https://www.dbmeinv.com/dbgroup/show.htm?cid=3&pager_offset=",
"有颜值": "https://www.dbmeinv.com/dbgroup/show.htm?cid=4&pager_offset=",
"大杂烩": "https://www.dbmeinv.com/dbgroup/show.htm?cid=5&pager_offset="
}
$ui.render({
props: {
title: "豆瓣妹子图"
},
views: [{
type: "menu",
props: {
id: "menu",
items: Object.keys(category),
},
layout: function(make) {
make.top.left.right.inset(0)
make.height.equalTo(40)
},
events: {
changed(sender) {
page = 0;
postTitle = [];
$("list").data = [];
getPostData()
}
}
}, {
type: "matrix",
props: {
id: "list",
columns: 2,
spacing: 1,
square: true,
template: [{
type: "image",
props: {
id: "image"
},
layout: $layout.fill
}]
},
layout: function(make) {
make.top.equalTo($("menu").bottom)
make.left.right.bottom.inset(0)
},
events: {
didReachBottom(sender) {
sender.endFetchingMore();
getPostData();
$delay(1, function() {
getPostData()
})
},
didSelect(sender, indexPath, data) {
postDetailView(data.detail)
}
}
}]
})
function getPostData() {
page++;
$http.get({
url: Object.values(category)[$("menu").index]+page,
handler: function(resp) {
var reg = /<div\sclass="img_single">[\s\S]*?<\/div>/g;
var match = resp.data.match(reg);
if (!match) {
return
};
var postData = [];
match.map(function(i) {
var title = /title="([\s\S]*?)"/.exec(i)[1];
var image = /src="([\s\S]*?)"/.exec(i)[1];
var detail = /href="([\s\S]*?)"/.exec(i)[1];
if (postTitle.indexOf(title) == -1) {
postTitle.push(title);
postData.push({
"image": image,
"detail": detail
})
}
});
$("list").data = $("list").data.concat(postData.map(function(i) {
return {
title: i.title,
detail: i.detail,
image: {
src: i.image
}
}
}));
}
})
}
function postDetailView(url) {
$http.get({
url: url,
handler: function(resp) {
var reg1 = /<div\sclass="topic-figure\scc">[\s\S]*?<\/div>/g;
var reg2 = /http.*?jpg/g;
var items = resp.data.match(reg1).toString().match(reg2);
$quicklook.open({
list: items
})
}
})
}
page = 0;
postTitle = [];
getPostData()