281 lines
9.2 KiB
Vue
281 lines
9.2 KiB
Vue
<template> <!-- 学堂 -->
|
|
<view class="wrap">
|
|
<!-- 吸顶 -->
|
|
<u-sticky offset-top="0" customNavHeight="0">
|
|
<!-- 顶部 -->
|
|
<uititle title="金久信学堂"></uititle>
|
|
<!-- 选项卡 -->
|
|
<view class="layout layout-tab flex justify-between align-center">
|
|
<view :class="['tab', {active: tabIndex == 0}]" @click="handTab(0)">我的上传</view>
|
|
<view :class="['tab', {active: tabIndex == 1}]" @click="handTab(1)">我的收藏</view>
|
|
<view :class="['tab', {active: tabIndex == 2}]" @click="handTab(2)">我的下载</view>
|
|
</view>
|
|
<!-- 统计数量和操作按钮 -->
|
|
<view class="layout layout-total flex justify-start align-center bg-white">
|
|
<template v-if="tabIndex == 0">
|
|
<view class="text">累计上传
|
|
<text class="red">{{ list.length }}</text>
|
|
篇
|
|
</view>
|
|
<!-- <view class="upload m-left-20">我要上传</view>-->
|
|
</template>
|
|
<template v-else-if="tabIndex == 1">
|
|
<view class="text">共计收藏
|
|
<text class="red">{{ list.length }}</text>
|
|
篇
|
|
</view>
|
|
</template>
|
|
<template v-else>
|
|
<view class="text">累计下载
|
|
<text class="red">{{ list.length }}</text>
|
|
篇
|
|
</view>
|
|
</template>
|
|
</view>
|
|
</u-sticky>
|
|
<!-- 材料专业资料列表 -->
|
|
<view class="layout layout-list">
|
|
<view class="item flex" v-for="(item, index) in list" :key="index" @click="jump(item._id)">
|
|
<view class="img" v-if="item.files && item.files.length > 0">
|
|
<template v-if="['doc', 'docx'].includes(item.files[0].split('.').pop())">
|
|
<file-word theme="outline" class="pointer" size="60" fill="#4a90e2" strokeLinecap="square"/>
|
|
</template>
|
|
<template v-else-if="['xls', 'xlsx'].includes(item.files[0].split('.').pop())">
|
|
<file-excel theme="outline" class="pointer" size="60" fill="#417505" strokeLinecap="square"/>
|
|
</template>
|
|
<template v-else-if="['pdf'].includes(item.files[0].split('.').pop())">
|
|
<file-pdf-one theme="outline" class="pointer" size="60" fill="#f5a623" strokeLinecap="square"/>
|
|
</template>
|
|
<template v-else>
|
|
<el-image :src="item.files[0]" style="width: 100px; height: 100px" fit="cover"
|
|
:preview-src-list="[item.files]"/>
|
|
</template>
|
|
</view>
|
|
<view class="info flex-1 p-left-30">
|
|
<view class="flex justify-between">
|
|
<view class="name flex-1">{{ item.name }}</view>
|
|
<!-- <view class="operate flex justify-center">-->
|
|
<!-- <u-button color="#A92924" size="mini" :plain="true" text="删除上传"></u-button>-->
|
|
<!-- <u-button class="m-left-20" color="#A92924" size="mini" :plain="true"-->
|
|
<!-- text="编辑修改"></u-button>-->
|
|
<!-- </view>-->
|
|
</view>
|
|
<view class="other">
|
|
<text>{{ item._add_time_str }}</text>
|
|
<text class="line">|</text>
|
|
<text>{{ item.viewNum }}人浏览</text>
|
|
<text class="line">|</text>
|
|
<text>{{ item.downloadNum }}次下载</text>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
<view class="issue" @click="toAdd">
|
|
<u-icon name="plus" color="#fff" size="24"></u-icon>
|
|
</view>
|
|
<!-- 没有数据 u-empty是框架组件 cmempty是自己封装组件 -->
|
|
<u-empty mode="list" text="暂无更多内容~" v-if="list.length === 0"></u-empty>
|
|
<!-- <cmempty></cmempty> -->
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
import uititle from '@/components/common/title'
|
|
import cmsearch from '@/components/common/search'
|
|
import cmempty from '@/components/common/empty'
|
|
import {FileExcel, FilePdfOne, FileWord} from "@icon-park/vue";
|
|
|
|
export default {
|
|
components: {
|
|
uititle,
|
|
cmsearch,
|
|
cmempty,
|
|
FilePdfOne, FileExcel, FileWord
|
|
},
|
|
data() {
|
|
return {
|
|
tabIndex: 0,
|
|
total: 0,
|
|
pageSize: 500,
|
|
activeIndex: 0,
|
|
mode: 'list',
|
|
list: [],
|
|
cateList: [],
|
|
}
|
|
},
|
|
methods: {
|
|
handTab(index) {
|
|
this.tabIndex = index
|
|
this.list = []
|
|
this.mode = 'list'
|
|
if (index === 0) this.getList()
|
|
else if (index === 1) this.getCollectList()
|
|
else if (index === 2) this.getDownloadList()
|
|
},
|
|
async getList(pageIndex = 1) {
|
|
const {rows} = await vk.callFunction({
|
|
url: 'client/article/list/kh/getUserList',
|
|
pageIndex,
|
|
pageSize: this.pageSize
|
|
})
|
|
this.list = rows
|
|
},
|
|
async getCollectList(pageIndex = 1) {
|
|
const {rows} = await vk.callFunction({
|
|
url: 'client/article/collect/kh/getList',
|
|
pageIndex,
|
|
pageSize: this.pageSize
|
|
})
|
|
this.list = rows.map(item => {
|
|
if (item.article) {
|
|
item._id = item.article._id
|
|
item.name = item.article.name
|
|
item._add_time_str = item.article._add_time_str
|
|
item.viewNum = item.article.viewNum
|
|
item.downloadNum = item.article.downloadNum
|
|
}
|
|
return item
|
|
})
|
|
},
|
|
async getDownloadList(pageIndex = 1) {
|
|
const {rows} = await vk.callFunction({
|
|
url: 'client/article/list/kh/getDownloadList',
|
|
pageIndex,
|
|
pageSize: this.pageSize
|
|
})
|
|
this.list = rows.map(item => {
|
|
if (item.article) {
|
|
item._id = item.article._id
|
|
item.name = item.article.name
|
|
item._add_time_str = item.article._add_time_str
|
|
item.viewNum = item.article.viewNum
|
|
item.downloadNum = item.article.downloadNum
|
|
}
|
|
return item
|
|
})
|
|
},
|
|
changePage(page) {
|
|
if (this.activeIndex === 0) this.getList(page)
|
|
else if (this.activeIndex === 1) this.getCollectList(page)
|
|
else if (this.activeIndex === 2) this.getDownloadList(page)
|
|
},
|
|
changeActive(index) {
|
|
this.list = []
|
|
this.mode = 'list'
|
|
this.activeIndex = index
|
|
if (index === 0) this.getList()
|
|
else if (index === 1) this.getCollectList()
|
|
else if (index === 2) this.getDownloadList()
|
|
},
|
|
showAction() {
|
|
this.mode = 'action'
|
|
this.activeIndex = null
|
|
},
|
|
addSuccess() {
|
|
this.mode = 'list'
|
|
this.activeIndex = 0
|
|
this.getList()
|
|
},
|
|
toAdd(){
|
|
vk.navigateTo('/pages/school/add')
|
|
},
|
|
jump(id){
|
|
vk.navigateTo(`/pages/school/detail?id=${id}`)
|
|
}
|
|
},
|
|
onLoad() {
|
|
this.getList()
|
|
},
|
|
}
|
|
</script>
|
|
|
|
<style lang="scss">
|
|
.layout-tab {
|
|
height: 100rpx;
|
|
padding: 0 30rpx;
|
|
background: #f1f1f1;
|
|
|
|
.tab {
|
|
margin: 0 20rpx;
|
|
padding: 10rpx 0rpx;
|
|
font-size: 28rpx;
|
|
line-height: 40rpx;
|
|
color: #666666;
|
|
}
|
|
|
|
.active {
|
|
position: relative;
|
|
color: #A92924;
|
|
|
|
&::after {
|
|
position: absolute;
|
|
left: 0;
|
|
bottom: 0;
|
|
z-index: 9;
|
|
content: '';
|
|
width: 100%;
|
|
height: 1px;
|
|
background: #A92924;
|
|
}
|
|
}
|
|
}
|
|
|
|
.layout-total {
|
|
height: 60rpx;
|
|
padding: 10rpx 30rpx;
|
|
|
|
.text {
|
|
font-size: 26rpx;
|
|
line-height: 40rpx;
|
|
color: #333333;
|
|
}
|
|
|
|
.upload {
|
|
padding: 4rpx 16rpx;
|
|
font-size: 24rpx;
|
|
line-height: 40rpx;
|
|
color: #ffffff;
|
|
background: #A92924;
|
|
}
|
|
}
|
|
|
|
.layout-list {
|
|
margin: 20rpx 30rpx;
|
|
|
|
.item {
|
|
padding: 30rpx 20rpx;
|
|
border-bottom: 1px solid #f2f2f2;
|
|
background: #ffffff;
|
|
|
|
.img {
|
|
width: 130rpx;
|
|
height: 130rpx;
|
|
}
|
|
|
|
.name {
|
|
font-size: 32rpx;
|
|
font-weight: 500;
|
|
line-height: 44rpx;
|
|
color: #111111;
|
|
}
|
|
|
|
.text {
|
|
padding: 6rpx 0;
|
|
font-size: 26rpx;
|
|
line-height: 40rpx;
|
|
color: #666666;
|
|
}
|
|
|
|
.other {
|
|
font-size: 24rpx;
|
|
line-height: 32rpx;
|
|
color: #999999;
|
|
}
|
|
|
|
.line {
|
|
margin: 0 8rpx;
|
|
}
|
|
}
|
|
}
|
|
</style>
|