my_news.html
5.4 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
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
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
<script src="../../assets/js/fontsize.js"></script>
<link rel="stylesheet" href="../../assets/css/api.css"/>
<link rel="stylesheet" href="../../assets/css/style.css">
<link rel="stylesheet" href="../../assets/css/index.css">
<link rel="stylesheet" href="../../assets/css/doc.css">
<link rel="stylesheet" href="../../assets/css/pay.css">
<link rel="stylesheet" href="../../assets/css/my_news.css">
<link rel="stylesheet" href="../../assets/icon/iconfont.css">
<title></title>
<style>
body, html {
background-color: #F6F5F5;
height: 100%;
}
.dot {
position: absolute;
left: 0.3rem;
top: 50%;
width: 0.15rem;
height: 0.15rem;
background-color: #ce3c39;
border-radius: 50%;
}
</style>
</head>
<body>
<div id="loadStart"></div>
<div id="app">
<div class="new_top">
<div @click="alls" :class="{sapn_active:all}">全部</div>
<div @click="noRead" :class="{sapn_active:no_read}">未读
<span v-if='newList.unread.length!=0' :class="['news',newList.unread.length>=1?'new_num2':'']">{{newList.unread.length}}</span>
</div>
<div @click="reads" :class="{sapn_active:read}">已读</div>
</div>
<div class="all" v-show="all">
<div class="all_item" v-if="newList.all.length==0">
<div class="all_content">【暂无消息】</div>
</div>
<div class="all_item" v-for="(item,index) in newList.all" v-else @click="go_detail(item.title,item.message_id)">
<div class="all_content">【{{item.title}}】{{item.description}}</div>
<div class="all_time">{{timestampToTime(item.published_time)}}</div>
<div class="dot" v-if="item.status==0"></div>
</div>
</div>
<div class="all" v-show="no_read">
<div class="all_item" v-if="newList.unread.length==0">
<div class="all_content">【暂无消息】</div>
</div>
<div class="all_item" v-for="(item,index) in newList.unread" v-else
@click="go_detail(item.title,item.message_id)">
<div class="all_content">【{{item.title}}】{{item.description}}</div>
<div class="all_time">{{timestampToTime(item.published_time)}}</div>
</div>
</div>
<div class="all" v-show="read">
<div class="all_item" v-if="newList.readed.length==0">
<div class="all_content">【暂无消息】</div>
</div>
<div class="all_item" v-for="(item,index) in newList.readed" v-else
@click="go_detail(item.title,item.message_id)">
<div class="all_content">【{{item.title}}】{{item.description}}</div>
<div class="all_time">{{timestampToTime(item.published_time)}}</div>
</div>
</div>
</div>
</body>
</html>
<script type="text/javascript" src="../../assets/js/api.js"></script>
<script type="text/javascript" src="../../assets/js/public.js"></script>
<script type="text/javascript" src="../../assets/js/fastclick.js"></script>
<script>
new FastClick(document.body);
</script>
<script type="text/javascript" src="../../assets/js/vue.min.js"></script>
<script type="text/javascript" src="../../assets/js/axios.min.js"></script>
<script type="text/javascript" src="../../assets/icon/iconfont.js"></script>
<script>
var app = new Vue({
el: '#app',
data: {
all: true,
no_read: false,
read: false,
new_num: 0,
newList: [],
new_type: ''
},
created: function () {
apiready = function () {
app.new_type = api.pageParam.new_type;
app.getNews();
}
},
methods: {
alls: function () {
app.all = true;
app.no_read = false;
app.read = false;
},
noRead: function () {
app.all = false;
app.no_read = true;
app.read = false;
},
reads: function () {
app.all = false;
app.no_read = false;
app.read = true;
},
// 获取消息列表
getNews: function () {
var header = {
"XX-Device-Type": getDevice(),
'XX-Token': getToken()
};
var post={
user_type:app.new_type
}
getRequest('post', 'user/index/getUserMessageList', post, header).then(function (res) {
if (res.data.code == 1) {
app.newList = res.data.data;
} else {
toastMsg(res.data.msg)
}
loadEnd();
})
},
// 消息详情
go_detail: function (name, id) {
openView('new_detail', 'my/new_detail', name, 'new_detail', false, {message_id: id})
}
}
})
</script>