message.vue
3.6 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
<template>
<view class="main">
<u-swiper
:list="imgList"
@change="change"
@click="click"
></u-swiper>
<view class="items" v-for="item in list">
<view class="">
<image src="/static/icon/1816.png" v-if="item.type == 1"
style="width: 80rpx; height: 80rpx;margin-right:16rpx" mode=""></image>
<image src="/static/icon/1815.png" v-else-if="item.type == 2"
style="width: 80rpx; height: 80rpx;margin-right:16rpx" mode=""></image>
<image src="/static/image/1813.png" v-else style="width: 80rpx; height: 80rpx;margin-right:16rpx"
mode=""></image>
</view>
<view style="display: flex;flex-direction: column;width: 100%;">
<view class=" flexB" style="margin-bottom: 10rpx;">
<p style="color: #0d1013e6;font-size: 32rpx;font-weight: 500;">{{item.title}}</p>
<p class="font">{{item.createtime}}</p>
</view>
<view class="flexB">
<p class="one font">{{item.content}}</p>
<p class="dian"></p>
</view>
</view>
</view>
<view class="">
<u-loadmore :status="status" :load-text="loadText" />
</view>
</view>
</template>
<script>
export default {
data() {
return {
list: [],
imgList:[],
status: 'loadmore',
loadText: {
loadmore: '轻轻上拉加载更多...',
loading: '努力加载中...',
nomore: '没有更多了'
},
page: 1,
}
},
methods: {
formattedDate(timestamp) {
const date = new Date(timestamp);
const year = date.getFullYear();
const month = (date.getMonth() + 1).toString().padStart(2, '0');
const day = date.getDate().toString().padStart(2, '0');
const formattedDate = `${year}-${month}-${day}`;
return formattedDate
},
change(){
},
click(e){
console.log(e);
if(this.imgList[e].type == 2){
uni.navigateTo({
url: `/pages/subPages/outer?url=${this.imgList[e].image}`
})
}else{
uni.navigateTo({
url: `/pages/subPages/detail?id=${this.imgList[e].equip_id}`
})
}
},
getList() {
uni.$u.http.post('/api/message/msg_list', {
page: this.page,
pagenum: 10
}).then(res => {
this.status ='loadmore'
if (this.page === 1) {
this.list = []
}
res.data.data.forEach(data => {
this.list.push(data)
})
if (this.list.length < 10) this.status = 'nomore';
else this.status = 'loading';
}).catch(err => {
console.log(err);
})
},
getBanner(){
uni.$u.http.get('/api/message/banner').then(res => {
console.log(res);
this.imgList = res.data.map(item => {
return{
url: item.image_url,
image: item.url,
equip_id: item.equip_id,
type: item.type
}
})
}).catch(err => {
console.log(err);
})
}
},
onReachBottom() {
this.status = 'loading';
this.page = this.page + 1;
this.getList()
},
onLoad() {
this.getList()
this.getBanner()
}
}
</script>
<style scoped lang="scss">
.font {
color: #0d101366;
font-size: 26rpx;
font-weight: 400;
}
.flexB {
display: flex;
align-items: center;
justify-content: space-between;
}
.main {
padding: 24rpx;
}
.one {
width: 450rpx;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
.items {
display: flex;
align-items: center;
height: 156rpx;
border-radius: 12rpx;
opacity: 1;
background: #ffffffff;
padding: 0 24rpx;
margin-top: 20rpx;
}
.dian {
width: 14.4rpx;
height: 14.4rpx;
border-radius: 35.2rpx;
opacity: 1;
border: 2rpx solid #ffffffff;
background: #fc4338ff;
}
</style>