123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219 |
- <template>
- <div class="user-collections">
- <div class="user-collections-header">
- <span class="u-d-title">{{ title }}</span>
- </div>
- <div class="user-collections-content">
- <div class="user-d-list" v-loading="listState.loading">
- <doc-card
- v-for="(item, index) in listState.list"
- :key="index"
- :title="item.DocName"
- :desc="item.DocSummary"
- :docType="item.DocFileType"
- :productType="item.productType"
- :subInfo="calcSubInfo(item)"
- @onClick="toDocDetail(item)"
- >
- <template slot="price">
- <div class="bought" v-if="item.Cost === '已购买'">已购买</div>
- <!-- <Price v-else :price="item.Cost" /> -->
- </template>
- </doc-card>
- <no-data v-if="listState.list.length === 0 && listState.loaded">
- 暂无文库收藏
- <div class="go-collect-box">
- <el-button type="primary" @click="goCollect">前往收藏</el-button>
- </div>
- </no-data>
- </div>
- <div class="user-collections-pagination" v-if="listState.total > 0">
- <el-pagination
- popper-class="pagination-custom-select"
- background
- layout="prev, pager, next, sizes, jumper"
- :current-page="listState.pageNum"
- :page-size="listState.pageSize"
- :page-sizes="[5, 10, 50, 100]"
- :total="listState.total"
- :show-confirm-btn="true"
- @current-change="onPageChange"
- @size-change="onSizeChange"
- >
- </el-pagination>
- </div>
- </div>
- </div>
- </template>
- <script>
- import { Pagination, Button } from 'element-ui'
- import DocCard from '@/components/doc-item-card/Card'
- import Price from '@/components/doc-item-card/Price'
- import NoData from '@/components/NoData'
- import { getUserDocs } from '../api/modules/user'
- import { formatSize } from '@/utils/'
- import { mixinBackground } from '@/utils/mixins'
- export default {
- name: 'user-collections',
- mixins: [mixinBackground],
- components: {
- [Pagination.name]: Pagination,
- [Button.name]: Button,
- DocCard,
- Price,
- NoData
- },
- data () {
- return {
- title: '文库收藏',
- listState: {
- loaded: false, // 是否已经搜索过
- loading: false,
- pageNum: 1, // 当前页
- pageSize: 10, // 每页多少条数据
- total: 0, // 一共多少条数据
- list: [] // 查询请求返回的数据
- }
- }
- },
- created () {
- this.getList()
- },
- methods: {
- async getList () {
- const query = {
- sign: 1,
- num: this.listState.pageNum,
- size: this.listState.pageSize
- }
- console.log(query)
- this.listState.loading = true
- this.listState.loaded = false
- const r = await getUserDocs(query)
- this.listState.loading = false
- this.listState.loaded = true
- const res = r.data
- if (res.error_code === 0) {
- this.listState.total = res.data.total
- this.listState.list = res.data.list || []
- }
- },
- toDocDetail (item) {
- const { DocId: id } = item
- // this.$router.push({
- // name: 'content',
- // params: { id }
- // })
- window.open(`../content/${id}`) // 打开新窗口
- // window.open(`${process.env.VUE_APP_BASE_URL}/content/${id}`) // 打开新窗口
- },
- onPageChange (p) {
- this.listState.pageNum = p
- this.getList()
- },
- onSizeChange (size) {
- this.listState.pageSize = size
- this.listState.pageNum = 1
- this.getList()
- },
- calcSubInfo (item) {
- const { DocPageSize, DocFileSize } = item
- const subInfoArr = []
- if (DocPageSize !== undefined) {
- subInfoArr.push(`共${DocPageSize}页`)
- }
- if (DocFileSize !== undefined) {
- subInfoArr.push(formatSize(DocFileSize))
- }
- return subInfoArr
- },
- goCollect () {
- this.$router.push('/')
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .user-collections {
- background-color: #fff;
- margin: 0 auto;
- .user-collections-header {
- padding-top: 48px;
- .u-d-title {
- font-size: 24px;
- line-height: 36px;
- color: #1D1D1D;
- }
- }
- .user-collections-content {
- margin-top: 48px;
- .u-d-header {
- display: flex;
- align-items: center;
- justify-content: space-between;
- padding: 0 28px;
- height: 48px;
- font-size: 14px;
- line-height: 24px;
- color: #686868;
- border-radius: 4px;
- background-color: #F5F6F7;
- }
- .user-d-list {
- border-top: 1px solid transparent;
- min-height: 500px;
- ::v-deep {
- .docs-card {
- margin-left: -18px;
- box-sizing: content-box;
- width: 1200px;
- }
- }
- }
- .bought {
- color: #686868;
- }
- .u-d-h-r {
- display: inline-block;
- width: 170px;
- .u-d-h-item {
- display: inline-block;
- width: 50%;
- &.size {
- text-align: center;
- }
- }
- }
- }
- .user-collections-pagination {
- margin-top: 28px;
- padding-bottom: 60px;
- text-align: right;
- }
- .go-collect-box{
- margin-top: 24px;
- .el-button{
- width: 108px;
- height: 30px;
- padding: 0;
- border-radius: 4px;
- font-size: 14px;
- }
- }
- }
- .in-app{
- .user-d-list{
- ::v-deep{
- .docs-card{
- width: auto!important;
- }
- }
- }
- .user-collections{
- padding: 0 18px;
- }
- }
- </style>
|