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.

241 lines
5.9 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">
2 years ago
<li v-for="(tab, i) in classifications.slice(0, 4)" :class="{active: active === tab.id}" @click="tabChange(tab)">{{ tab.classificationName }}</li>
1 year ago
<uni-icons class="icon" custom-prefix="iconfont" type="icon-filter" size="22" color="#007eff" @click="typeVisible = true"></uni-icons>
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(item)">
<view class="c-name ell">{{ item.title }}</view>
<view class="content">
<view class="info">
<view class="line">
3 years ago
<view class="name">产品</view>
<view class="val ell-wrap">
1 year ago
<view v-if="!item.toggle" class="product ell">{{ item.productNames }}</view>
<view v-else class="product" v-html="item.productNamesHtml"></view>
1 year ago
<view v-if="item.productNames && item.productNames.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>
2 years ago
1 year ago
<view :class="['type-popup', {active: typeVisible}]">
2 years ago
<uni-icons class="close" type="closeempty" size="20" color="#757575" @click="closeType"></uni-icons>
<view class="title">所属分类</view>
<view class="types">
<view v-for="(item, i) in classifications" :key="i" :class="['item', {active: active == item.id}]" @click="classificationClick(item)">{{ item.classificationName }}</view>
</view>
</view>
3 years ago
</view>
</template>
<script>
import { schemeList, queryClassificationByType } from '@/apis/modules/article.js'
3 years ago
export default {
data() {
return {
2 years ago
active: '',
typeVisible: false,
classifications: [],
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() {
2 years ago
this.keyword = ''
this.active = ''
this.initList()
this.getClassification()
},
3 years ago
methods: {
getList() {
2 years ago
uni.showLoading({
title: '加载中'
})
schemeList({
keyWord: this.keyword,
pageNum: this.page,
pageSize: this.pageSize,
querySource: 4,
2 years ago
classificationId: this.active
}).then(({ data }) => {
uni.hideLoading()
// 未加载完所有数据,并且不是筛选,则拼接list,否则直接赋值
const list = data.records
2 years ago
list.forEach(e => {
1 year ago
if (e.productNames) {
e.toggle = e.productNames.length < 14 // 超过了14个字才需要显示展开按钮
e.productNamesHtml = e.productNames.split(',').join('<br>')
}
2 years ago
})
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 }) => {
2 years ago
this.classifications = [
{
id: '',
classificationName: '不限'
}
]
this.classifications.push(...data)
}).catch(e => {})
3 years ago
},
2 years ago
// 所属分类点击回调
classificationClick(item, query) {
this.active = item.id
query && this.initList()
},
// 关闭所属分类弹框
closeType() {
this.typeVisible = false
this.initList()
},
3 years ago
// tab切换
tabChange(tab) {
2 years ago
this.active = tab.id
this.initList()
3 years ago
},
// 跳转详情
2 years ago
toDetail(item) {
this.$util.to(`/team/scheme/scheme?id=` + item.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">
2 years ago
.tab {
position: relative;
justify-content: flex-start;
li {
padding: 0 30rpx;
}
1 year ago
.icon {
2 years ago
position: absolute;
top: 32rpx;
right: 44rpx;
}
}
3 years ago
.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
font-size: 28rpx;
color: #333;
}
2 years ago
.product {
max-width: 67vw;
white-space: pre-wrap;
&.ell {
white-space: nowrap;
}
3 years ago
}
.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>