forked from aOrz/Wordpress-Mobile-Application
-
Notifications
You must be signed in to change notification settings - Fork 0
/
detail.html
265 lines (242 loc) · 7.02 KB
/
detail.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
<!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>
<link href="css/mui.min.css" rel="stylesheet" />
<link href="./css/prism.css" rel="stylesheet">
<link rel="stylesheet" href="css/mystyle.css" />
<style>
h1 {
font-size: 24px;
}
h2 {
font-size: 21px;
}
h3 {
font-size: 19px;
}
h4 {
font-size: 17px;
}
h5 {
font-size: 15px;
}
p {
color: #000;
}
.title {
padding: 10px 0;
/*border-bottom:1px solid #BBBBBB;*/
}
.page-content {
display: block;
font-family: 'Helvetica Neue', Helvetica, 'Hiragino Sans GB', 'Microsoft YaHei', Arial, sans-serif;
font-size: 16px;
line-height 25.6px;
margin: 0px;
padding: 0 10px 10px 10px;
word-wrap: break-word;
}
img {
max-width: 100%;
height: auto;
}
.aligncenter {
display: block;
margin: 0 auto 10px;
}
.alignleft {
display: block;
margin: 0 0 10px auto;
}
body,
#content {
background-color: white;
}
.title h1{
line-height: 1.3;
}
.time {
margin-bottom: 6px;
}
.time time {
color: #BBBBBB;
}
</style>
</head>
<body>
<div id="detail">
<my-header title="文章详情"
righticon="mui-icon-pengyouquan"
lefticon="mui-action-back mui-icon-left-nav"></my-header>
<div id="content" class="mui-content page-content mui-soll">
<div class="spinner" v-if="loading">
<div class="bounce1"></div>
<div class="bounce2"></div>
<div class="bounce3"></div>
</div>
<div class="title">
<h1 v-html="title"></h1>
</div>
<div class="time" v-if="!loading">
<time>{{time}}</time>
<a v-on:click="authorpage"
:data-id="author_id"
:data-name="author">{{author}}</a>
</div>
<div >
<div v-html="content">
</div>
</div>
<div class="hot" v-if="tags[1]&&!loading">
<div class="title">
<h5>标签</h5>
</div>
<a v-for="item in tags" :data-id="item.id" :data-name="item.name" v-on:click="tagspage" :key="item.id">
<span :data-name="item.name"
:data-id="item.id"
:class="'mui-badge' + style[parseInt(Math.random()*6)]">{{item.name}}</span>
</a>
</div>
</div>
</div>
<script src="js/mui.min.js"></script>
<script type="text/javascript" src="js/vue.min.js"></script>
<script src="js/prism.js"></script>
<script type="text/javascript" src="js/app.js"></script>
<script type="text/javascript" charset="UTF-8">
mui.init();
var artical = '';
var detailVm = new Vue({
el: '#detail',
data: {
title: '',
content: '',
time: '',
author: '',
tags: '',
url: '',
author_id:'',
loading: 1,
style: ['', 'mui-badge-primary', 'mui-badge-success', 'mui-badge-warning', 'mui-badge-danger', 'mui-badge-purple', ]
},
methods: {
tagspage: function(event) {
var id = event.target.dataset.id;
var name = event.target.dataset.name;
var index = plus.webview.getLaunchWebview();
mui.fire(index, 'title', {
title_name: name
})
// console.log(id)
var list = plus.webview.getWebviewById('list.html');
mui.fire(list, 'reload', {
page: 1,
context: 'embed',
tags: id,
});
mui.back()
},
authorpage: function(event) {
var id = event.target.dataset.id;
var name = event.target.dataset.name;
var index = plus.webview.getLaunchWebview();
mui.fire(index, 'title', {
title_name: name
})
// console.log(id)
var list = plus.webview.getWebviewById('list.html');
mui.fire(list, 'reload', {
page: 1,
context: 'embed',
user: id,
});
mui.back()
}
}
})
var wp = new WP();
window.addEventListener('getDetail', function(event) {
if(artical === event.detail.id){
return;
}
detailVm.title = '';
detailVm.content = '';
detailVm.time = '';
detailVm.author = '';
detailVm.loading = 1;
//获得事件参数
var id = artical = event.detail.id;
var author = event.detail.author;
wp.getData({
route: 'posts/' + id,
data: {},
success: function(data) {
detailVm.title = data.title.rendered;
detailVm.content = data.content.rendered;
detailVm.time = data.date;
detailVm.url = data.link;
detailVm.loading = 0;
Vue.nextTick(function() {
Prism.highlightAll();
})
},
error: function() {
detailVm.loading = 0;
mui.alert('文章找不到了~')
}
})
wp.getData({
route: 'users/' + author,
data: {},
success: function(data) {
detailVm.author = data.name;
detailVm.author_id = data.id;
},
error: function() {}
})
wp.getData({
route: 'tags/',
data: {
post: id
},
success: function(data) {
detailVm.tags = data;
},
error: function() {}
})
});
mui('body').on('tap', 'a', function(e) {
var url = this.getAttribute("href");
if(url) {
localStorage.setItem('newurl', url)
var browser = mui.openWindow({
url: 'browser/index.html',
})
}
});
var shares = null,
bhref = false;
var Intent = null,
File = null,
Uri = null,
main = null;
document.getElementById('righticon').addEventListener('tap', function() {
shareSystem(detailVm.title + ' 地址:' + detailVm.url);
})
mui.plusReady(function() {
// H5 plus事件处理
updateSerivces();
if(plus.os.name == "Android") {
Intent = plus.android.importClass("android.content.Intent");
File = plus.android.importClass("java.io.File");
Uri = plus.android.importClass("android.net.Uri");
main = plus.android.runtimeMainActivity();
}
})
//Prism
</script>
</body>
</html>