You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

199 lines
4.5 KiB

3 years ago
<template>
<view>
<view class="filter">
<uni-search-bar class="search" radius="30" placeholder="请输入方案名称" clearButton="auto" cancelButton="none" v-model="keyword" />
3 years ago
</view>
<ul class="tab">
<li v-for="(tab, i) in classifications" :class="{active: curTab === tab.id}" @click="tabChange(tab)">{{ tab.classificationName }}</li>
3 years ago
</ul>
3 years ago
<view v-if="list.length" class="list">
2 years ago
<view v-for="(item, i) in list" class="item" @click="toDetail(i + 2)">
<view class="c-name">{{ item.title }}</view>
<view class="content">
<view class="info">
<view class="line">
3 years ago
<view class="name">产品</view>
<view class="val ell-wrap">
<view :class="{ell: !item.toggle}" v-html="item.product"></view>
2 years ago
<view v-if="item.product.length > 14" class="toggle" @click.stop="toggle(item)">{{ item.toggle ? '收起' : '展开' }}</view>
3 years ago
</view>
</view>
<view class="line">
3 years ago
<view class="name">更新日期</view>
<view class="val">{{ item.updateTime }}</view>
</view>
<view class="line">
3 years ago
<view class="name">适用专业</view>
<view class="val">{{ item.applicableMajor }}</view>
3 years ago
</view>
</view>
2 years ago
<view class="detail" @click.stop="toEmail(i)">下载</view>
</view>
3 years ago
</view>
</view>
<empty v-else></empty>
3 years ago
</view>
</template>
<script>
import { schemeList, queryClassificationByType } from '@/apis/modules/article.js'
3 years ago
export default {
data() {
return {
curTab: '',
classifications: [
3 years ago
{
id: '',
classificationName: '不限'
3 years ago
}
],
reachBottom: 0, // 是否是上拉加载。0->否,1->是,-1->加载完所有数据
status: 'more', // 上拉加载状态 more|loading|noMore
searchTimer: null,
articleNameSort: 'desc',
keyword: '',
list: [],
page: 1,
pageSize: 10,
}
},
watch: {
keyword () {
clearTimeout(this.searchTimer)
this.searchTimer = setTimeout(() => {
this.initList()
}, 500)
}
},
// 下拉刷新
onPullDownRefresh() {
this.initList()
setTimeout(() => {
uni.stopPullDownRefresh()
}, 1500)
},
// 上拉加载
onReachBottom() {
if (this.reachBottom >= 0) {
this.reachBottom = 1
this.status = 'loading'
this.getList()
3 years ago
}
},
onShow() {
this.initList()
this.getClassification()
},
3 years ago
methods: {
getList() {
const data = {
keyWord: this.keyword,
pageNum: this.page,
pageSize: this.pageSize,
querySource: 4,
classificationId: this.curTab
}
uni.showLoading({
title: '加载中'
3 years ago
})
schemeList(data).then(({ data }) => {
uni.hideLoading()
// 未加载完所有数据,并且不是筛选,则拼接list,否则直接赋值
const list = data.records
this.list = this.reachBottom > 0 ? [...this.list, ...list] : list
this.page++ // 每次获取了数据后page+1
const noMore = this.list.length === data.total // 是否加载完所有数据
this.status = noMore ? 'noMore' : 'more' // 加载完了则设置为noMore
this.reachBottom = noMore ? -1 : 0 // 加载完了则设置为-1
}).catch(e => {
uni.hideLoading()
})
},
initList() {
this.page = 1
this.reachBottom = 0
this.getList()
},
// 获取所属分类
getClassification() {
queryClassificationByType(3).then(({ data }) => {
this.classifications.push(...data)
}).catch(e => {})
3 years ago
},
// tab切换
tabChange(tab) {
this.curTab = tab.id
this.initList()
3 years ago
},
// 跳转详情
toDetail(id) {
this.$util.openFile(id)
3 years ago
},
2 years ago
// 发送邮箱
toEmail(id) {
this.$util.to(`../send/send?id=${id}`)
},
3 years ago
// 展开
toggle(item) {
item.toggle = !item.toggle
3 years ago
}
}
}
</script>
<style scoped lang="scss">
.list {
background-color: #fff;
3 years ago
.item {
padding: 20rpx 40rpx;
border-bottom: 1px solid #f1f1f1;
3 years ago
}
3 years ago
.c-name {
font-size: 30rpx;
3 years ago
color: #333;
}
.line {
display: flex;
3 years ago
padding: 10rpx 0;
3 years ago
}
.content {
3 years ago
display: flex;
justify-content: space-between;
align-items: center;
margin-top: 20rpx;
3 years ago
}
3 years ago
.name {
width: 140rpx;
3 years ago
margin-right: 10rpx;
white-space: nowrap;
font-size: 28rpx;
color: #999;
3 years ago
}
.val {
3 years ago
max-width: 88%;
font-size: 28rpx;
color: #333;
}
.ell {
height: 38rpx;
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;
}
.toggle {
margin-top: 10rpx;
white-space: nowrap;
font-size: 24rpx;
3 years ago
color: #0e92ef;
3 years ago
}
.detail {
margin-left: 20rpx;
font-size: 26rpx;
3 years ago
color: #1f83ff;
white-space: nowrap;
3 years ago
}
}
</style>