list.vue
4.8 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
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
<template>
<view>
<!-- 顶部navbar -->
<u-sticky bgColor="#fff">
<u-navbar @rightClick="rightClick" placeholder :autoBack="true">
<template #center>
<view class="topSearchBox">
<u-search
placeholder="请输入商家名称"
:clearabled="true"
:showAction="false"
v-model="searchValue"
@search="getList"
></u-search>
</view>
</template>
</u-navbar>
<!-- 粘性tabs -->
<u-tabs
:list="list1"
:lineWidth="40"
lineColor="#6E16FF"
:inactiveStyle="inactiveStyle"
:activeStyle="activeStyle"
:scrollable="false"
></u-tabs>
</u-sticky>
<!-- 列表版心 -->
<template v-if="searchState == 1">
<view class="mainBox">
<custom-waterfalls-flow :value="list" imageKey="image" :seat="2">
<view class="item" v-for="(item, index) in list" :key="index" slot="slot{{index}}">
<view class="title flexC">{{ item.title }}</view>
<view class="flexJ">
<view class="flexA headerBox">
<image src="/static/headImg.jpg" mode="scaleToFill" />
<view>桥志三</view>
</view>
<view class="flexA">
<u-rate activeIcon="heart-fill" inactiveIcon="heart" :count="count" v-model="value"></u-rate>
<view class="numText">{{ item.id }}</view>
</view>
</view>
</view>
</custom-waterfalls-flow>
</view>
</template>
<template v-if="searchState == 0">
<view style="margin-top: 300rpx">
<u-empty />
</view>
<!-- <u-empty mode="car" icon="http://cdn.uviewui.com/uview/empty/car.png"></u-empty> -->
</template>
<!-- <template v-if="searchState == 1">
<view v-for="item in searchList1" :key="item.id">
{{ item.title }}
{{ item.id }}
{{ item.content }}
</view>
</template> -->
</view>
</template>
<script>
import { getList } from '@/api'
export default {
data() {
return {
list1: [
{
name: '美容美发',
},
{
name: '长发造型',
},
{
name: '好物分享',
},
{
name: '吹风机',
},
{
name: '好物评测',
},
],
list: [],
// 未选择样式
inactiveStyle: {
color: 'rgba(0,0,0,0.4)',
fontSize: '27rpx',
},
// 选择样式
activeStyle: {
color: 'rgba(50, 50, 51, 1)',
fontSize: '27rpx',
fontWeight: '700',
},
count: 1,
value: 1,
searchState: 1,
//
searchValue: '',
searchList1: [],
curPage: 1,
last_page: 1,
}
},
created() {
this.getList()
console.log(
JSON.parse(
'{"video":"","imgList":["https:\\/\\/image.hairshop.vip\\/uploads\\/20220616\\/5998d3e20a0035e7874c4ae953659675.jpg"],"cover":"https:\\/\\/image.hairshop.vip\\/uploads\\/20220616\\/5998d3e20a0035e7874c4ae953659675.jpg"}'
)
)
},
onReachBottom() {
console.log('到底了')
if (this.curPage === this.last_page) {
uni.showToast({
title: '没有更多数据了',
icon: 'none',
mask: true,
})
} else {
this.curPage = this.curPage + 1
this.getList()
}
},
methods: {
async getList(val) {
const { data } = await getList({
type_id: '', // integer 否 论坛类型
keywords: val || '', // string 否 关键词
order: 1, // string 是 排序,1:评论,0:时间
page: this.curPage, // integer 是 页码
rows: 13, // integer 是 条数
})
console.log(data)
if (data.data.length == 0) {
this.searchState = 0
} else {
this.searchState = 1
setTimeout(() => {
this.last_page = data.last_page
// this.list = this.list.concat(data.data)
this.list = data.data
this.list.forEach((item, index) => {
item.image = JSON.parse(data.data[index].file).imgList[0]
})
}, 300)
}
},
},
}
</script>
<style lang="scss">
.topSearchBox {
margin-right: 118rpx;
}
page {
background: #f7f8fa;
}
.u-search__content {
min-width: 426rpx !important;
}
.title {
color: rgba(0, 0, 0, 0.9);
font-size: 28rpx;
margin: 16rpx 0;
}
.headerBox {
color: rgba(0, 0, 0, 0.6);
font-size: 24rpx;
image {
width: 48rpx;
height: 48rpx;
border-radius: 50%;
margin-right: 8rpx;
}
}
.item {
padding: 0 16rpx 16rpx;
box-sizing: border-box;
}
.numText {
color: rgba(0, 0, 0, 0.4);
font-size: 24rpx;
margin-left: 8rpx;
}
.mainBox {
width: 100%;
height: 100%;
padding: 16rpx;
box-sizing: border-box;
}
</style>