oneNews.vue
2.9 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
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
<template>
<view class="oneNews">
<!-- 中志要闻 -->
<view class="header-wrap"></view>
<view class="news-wrap">
<view class="news-item area flex" v-for="(item,index) in datas" :key="index"
@tap="$service.jump" :data-url="'/pagesB/oneNewsDetails/oneNewsDetails?id='+item.id">
<view>
<view class="news-day flex">
<view class="spot"></view>
<view class="news-day-time">
{{item.create_time}}
</view>
</view>
<view class="news-text text-retain">
{{item.title}}
</view>
</view>
</view>
<u-empty v-if="datas.length==0"
mode="data"
text="暂无记录"
icon="/static/images/tch/img_blank.png"
>
</u-empty>
</view>
</view>
</template>
<script>
import Vue from 'vue'
import {
mapState,
mapMutations
} from 'vuex'
var that
export default {
data() {
return {
datas: [],
page:1
}
},
onLoad() {
that=this
that.onRetry()
},
onShow() {
},
onReachBottom() {
that.getdata()
},
methods: {
onRetry(){
that.page=1
that.datas = []
that.getdata()
},
getdata() {
var datas = {
page:that.page,
limit:20
}
var jkurl = '/student/news'
if (that.btnkg == 1) {
return
} else {
that.btnkg = 1
}
var page_now=that.page
that.$service.P_post(jkurl, datas).then(res => {
that.btnkg = 0
console.log(res)
if (res.code == 1) {
var datas = res.data
console.log(typeof datas)
if (typeof datas == 'string') {
datas = JSON.parse(datas)
}
if (page_now == 1) {
that.datas = datas.data
} else {
if (datas.data.length == 0) {
that.data_last = true
return
}
that.data_last = false
that.datas = that.datas.concat(datas.data)
}
that.allnum=datas.allnum
that.page++
} else {
if (res.msg) {
uni.showToast({
icon: 'none',
title: res.msg
})
} else {
uni.showToast({
icon: 'none',
title: '操作失败'
})
}
}
}).catch(e => {
that.btnkg = 0
console.log(e)
uni.showToast({
icon: 'none',
title: '操作失败'
})
})
},
}
}
</script>
<style lang="scss" scoped>
.oneNews {
position: relative;
}
.news-wrap {
position: absolute;
top: 28rpx;
left: 50%;
transform: translate(-50%, 0);
}
.news-item {
height: 196rpx;
background: #FFFFFF;
border-radius: 20rpx;
margin-bottom: 20rpx;
align-items: center;
padding: 0 34rpx;
.news-day {
height: 28rpx;
line-height: 28rpx;
font-size: 28rpx;
font-family: PingFang SC;
font-weight: 400;
color: #A9B1C0;
margin-bottom: 20rpx;
align-items: center;
.news-day-time {
margin-left: 12rpx;
}
}
.news-text {
font-size: 32rpx;
font-family: PingFang SC;
font-weight: 400;
color: #545D71;
}
}
</style>