# 封装公共列表组件(下)
<template>
<view class="common-list animated fadeInLeft fast">
<!-- 左边头像 -->
<view class="common-list-l">
<image :src="item.userpic" mode="widthFix" lazy-load></image>
</view>
<!-- 右边内容 -->
<view class="common-list-r">
<!-- 作者 -->
<view class="author-area">
<view>{{item.username}}
<view class="icon iconfont tag-sex" :class="[item.sex===0?'icon-nan':'icon-nv']">{{item.age}}</view>
</view>
<view class="icon iconfont icon-zengjia guanzhu" v-if="!isguanzhu" @tap="guanzhu">关注</view>
</view>
<!-- 标题 -->
<view class="title-area">{{item.title}}</view>
<!-- 图片 -->
<view class="image-area u-f-ajc">
<!-- 图片 -->
<image v-if="item.titlepic" :src="item.titlepic" mode="widthFix" lazy-load=""></image>
<!-- 视频 -->
<template v-if="item.video">
<view class="common-list-play icon iconfont icon-bofang">
</view>
<view class="common-list-playinfo">{{item.video.loopnum}} 次播放 {{item.video.long}}</view>
</template>
<!-- 分享 -->
<view class="common-list-share u-f" v-if="item.share">
<image :src="item.share.titlepic" mode="widthFix" lazy-load></image>
<view>{{item.share.title}}</view>
</view>
</view>
<!-- 其它信息 -->
<view class="address-area">
<view>{{item.path}}</view>
<view>
<view class="icon iconfont icon-zhuanfa">{{item.sharenum}}</view>
<view class="icon iconfont icon-pinglun1">{{item.commentnum}}</view>
<view class="icon iconfont icon-dianzan1">{{item.goodnum}}</view>
</view>
</view>
</view>
</view>
</template>
<script>
export default {
props: {
item: Object,
index: Number
},
data() {
return {
isguanzhu: this.item.isguanzhu
}
},
methods: {
guanzhu() {
this.isguanzhu = true
uni.showToast({
title:'关注成功'
})
}
}
}
</script>
<style lang="less" scoped>
.common-list {
padding: 20rpx;
display: flex;
.common-list-l {
margin-right: 15rpx;
image {
width: 90rpx;
border-radius: 50%;
}
}
.common-list-r {
border-bottom: 1rpx solid #eee;
padding-bottom: 10rpx;
.author-area {
display: flex;
justify-content: space-between;
.guanzhu {
background-color: #f4f4f4;
padding: 0 10rpx;
font-size: 32rpx;
}
view {
display: flex;
align-items: center;
&:first-child {
color: #999;
font-size: 32rpx;
.icon-nv {
background-color: #FF00FF
}
.icon-nan {
background-color: #007aff;
}
.tag-sex {
color: #fff;
font-size: 26rpx;
padding: 0 20rpx;
margin-left: 10rpx;
border-radius: 20rpx;
height: 40rpx;
line-height: 40rpx;
}
}
&:last-child {
}
}
}
.title-area {
width: calc(100vw - 145rpx);
font-size: 32rpx;
padding: 12rpx 0;
}
.image-area {
position: relative;
image {
width: 100%;
border-radius: 20rpx;
}
.common-list-play {
position: absolute;
color: #fff;
font-size: 130rpx;
}
.common-list-playinfo {
position: absolute;
right: 10rpx;
bottom: 10rpx;
color: #fff;
background-color: rgba(51, 51, 51, 0.73);
border-radius: 20rpx;
padding: 0 20rpx;
font-size: 26rpx;
}
}
.address-area {
display: flex;
justify-content: space-between;
view {
color: #aaa;
&:last-child {
display: flex;
view {
margin-right: 20rpx;
&:last-child {
margin-right: 0;
}
}
}
}
}
}
}
.common-list-share {
background-color: #eee;
width: 100%;
padding: 10rpx;
border-radius: 20rpx;
image {
width: 200rpx !important;
height: 150rpx !important;
margin-right: 10rpx;
}
}
</style>
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
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