164 lines
3.6 KiB
Vue
164 lines
3.6 KiB
Vue
<template>
|
|
<view>
|
|
<view class="search-box">
|
|
<uni-search-bar placeholder="输入搜索关键词" @confirm="search" @clear="clearName"></uni-search-bar>
|
|
</view>
|
|
|
|
<view class="list" v-if="list.length">
|
|
<custom-waterfalls-flow :value="list" imageKey="imageInput">
|
|
<view class="item" v-for="(item,index) in list" :key="index" slot="slot{{index}}" @click="goNewsDetail(item)">
|
|
<image class="cover" :src="item.imageInput" mode="scaleToFill"></image>
|
|
<view class="content">
|
|
<view class="title more-t">{{item.title}}</view>
|
|
<view class="mark more-t">{{item.synopsis}}</view>
|
|
<view class="footer flex jc-between ai-center">
|
|
<view class="visit flex ai-center">
|
|
<image class="icon" :src="webUrl+'/20220609111928828152.png'" mode="scaleToFill"></image>
|
|
{{item.visit}}
|
|
</view>
|
|
<view class="time">{{item.addTime.substring(0,10)}}</view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</custom-waterfalls-flow>
|
|
</view>
|
|
|
|
<view class="v4-nodata" v-else>
|
|
<image src="@/static/images/img_nodata.png" mode="scaleToFill" />
|
|
<view class="text">暂无数据</view>
|
|
</view>
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
import {
|
|
getArticleList
|
|
} from "@/api/public";
|
|
export default {
|
|
data() {
|
|
return {
|
|
webUrl: this.$VUE_APP_RESOURCES_URL,
|
|
page: 1,
|
|
limit: 8,
|
|
keyword: "",
|
|
list: [],
|
|
isWait: false
|
|
}
|
|
},
|
|
onLoad() {
|
|
this.fetchList();
|
|
},
|
|
onReachBottom() {
|
|
this.page++;
|
|
this.fetchList();
|
|
},
|
|
methods: {
|
|
search(e) {
|
|
this.keyword = e.value;
|
|
this.page = 1;
|
|
this.list = [];
|
|
this.fetchList();
|
|
},
|
|
|
|
clearName() {
|
|
this.keyword = "";
|
|
this.page = 1;
|
|
this.list = [];
|
|
this.fetchList();
|
|
},
|
|
|
|
fetchList() {
|
|
if (this.isWait) return;
|
|
this.isWait = true;
|
|
|
|
let params = {
|
|
keyword: this.keyword,
|
|
page: this.page,
|
|
limit: this.limit
|
|
};
|
|
|
|
getArticleList(params).then(res => {
|
|
if (res.status === 200) {
|
|
for (let i = 0; i < res.data.length; i++) {
|
|
res.data[i].hide = true;
|
|
this.list.push(res.data[i])
|
|
}
|
|
}
|
|
this.isWait = false;
|
|
});
|
|
},
|
|
|
|
goNewsDetail(item) {
|
|
this.$yrouter.push({
|
|
path: "/pages/foodInfomation/foodInfomationDetail",
|
|
query: {
|
|
id: item.id
|
|
}
|
|
});
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style lang="less">
|
|
.search-box {
|
|
padding: 0 12rpx;
|
|
background: #fff;
|
|
|
|
/deep/.uni-searchbar__box {
|
|
border-radius: 44rpx !important;
|
|
}
|
|
}
|
|
|
|
.list {
|
|
margin: 28rpx 32rpx;
|
|
|
|
.item {
|
|
border-radius: 4rpx;
|
|
background: #fff;
|
|
|
|
.cover {
|
|
width: 332rpx;
|
|
height: 200rpx;
|
|
vertical-align: middle;
|
|
}
|
|
|
|
.title {
|
|
padding: 12rpx 16rpx 0;
|
|
font-size: 26rpx;
|
|
font-weight: bold;
|
|
line-height: 38rpx;
|
|
color: #333;
|
|
}
|
|
|
|
.mark {
|
|
margin: 14rpx 16rpx;
|
|
font-size: 22rpx;
|
|
line-height: 32rpx;
|
|
color: #999;
|
|
}
|
|
|
|
.footer {
|
|
padding: 12rpx 16rpx 16rpx;
|
|
border-top: 1rpx solid #E1E1E1;
|
|
font-size: 22rpx;
|
|
}
|
|
|
|
.icon {
|
|
width: 28rpx;
|
|
height: 28rpx;
|
|
vertical-align: middle;
|
|
margin-right: 4rpx;
|
|
}
|
|
|
|
.visit {
|
|
color: #333;
|
|
}
|
|
|
|
.time {
|
|
color: #999;
|
|
}
|
|
}
|
|
}
|
|
</style>
|