UserDocs.vue 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431
  1. <template>
  2. <div class="user-docs">
  3. <h1 class="user-docs-header">
  4. <span class="u-d-title">{{ title }}</span>
  5. </h1>
  6. <div class="user-docs-content">
  7. <div class="u-d-header">
  8. <span class="u-d-h-l">文件名</span>
  9. <span class="u-d-h-r">
  10. <span class="u-d-h-item time">下载时间</span>
  11. <span class="u-d-h-item size">大小</span>
  12. </span>
  13. </div>
  14. <div class="user-d-list" v-loading="listState.loading">
  15. <doc-card
  16. v-for="(item, index) in listState.list"
  17. cardType="oneline"
  18. :key="index"
  19. :title="item.DocName"
  20. :productType="item.product_type ? 1 : 0"
  21. :docType="item.DocFileType + ''"
  22. :subInfo="calcSubInfo(item)"
  23. @onClick="toDocDetail(item)"
  24. ></doc-card>
  25. <no-data v-if="listState.list.length === 0 && listState.loaded">暂无我的文库</no-data>
  26. </div>
  27. <div class="user-docs-pagination" v-if="listState.total > 0">
  28. <el-pagination
  29. popper-class="pagination-custom-select"
  30. background
  31. layout="prev, pager, next, sizes, jumper"
  32. :current-page="listState.pageNum"
  33. :page-size="listState.pageSize"
  34. :page-sizes="[5, 10, 50, 100]"
  35. :total="listState.total"
  36. :show-confirm-btn="true"
  37. @current-change="onPageChange"
  38. @size-change="onSizeChange"
  39. >
  40. </el-pagination>
  41. </div>
  42. </div>
  43. <selected-recommend
  44. :options="recommendList"
  45. @click="goContent"
  46. ></selected-recommend>
  47. </div>
  48. </template>
  49. <script>
  50. import { Pagination } from 'element-ui'
  51. import DocCard from '@/components/doc-item-card/Card'
  52. import NoData from '@/components/NoData'
  53. import { getUserDocs } from '../api/modules/user'
  54. import { getSearch } from '../api/modules/search'
  55. import { dateFormatter, formatSize } from '@/utils/index'
  56. import { mixinBackground } from '@/utils/mixins'
  57. import SelectedRecommend from '@/components/SelectedRecommend.vue'
  58. function checkType (type) {
  59. let typeStr = type
  60. switch (type) {
  61. case 1: {
  62. typeStr = 'word'
  63. break
  64. }
  65. case 2: {
  66. typeStr = 'pdf'
  67. break
  68. }
  69. case 3: {
  70. typeStr = 'excel'
  71. break
  72. }
  73. case 4: {
  74. typeStr = 'ppt'
  75. break
  76. }
  77. case 'doc': {
  78. typeStr = 'word'
  79. break
  80. }
  81. case 'xls': {
  82. typeStr = 'excel'
  83. break
  84. }
  85. }
  86. return typeStr
  87. }
  88. function formatData (v) {
  89. return {
  90. img: v?.docImg || v?.previewImgId,
  91. type: checkType(v?.docFileType),
  92. id: v.docId,
  93. title: v?.docName || v?.docTitle,
  94. money: v.price,
  95. docTags: v?.docTags,
  96. size: v?.docFileSize,
  97. page: v?.docPageSize,
  98. down: v?.downTimes,
  99. contribution: v?.sourceUserId,
  100. productType: v?.productType,
  101. viewTimes: v?.viewTimes
  102. }
  103. }
  104. export default {
  105. name: 'user-docs',
  106. mixins: [mixinBackground],
  107. components: {
  108. [Pagination.name]: Pagination,
  109. DocCard,
  110. NoData,
  111. SelectedRecommend
  112. },
  113. data () {
  114. return {
  115. title: '我的文库',
  116. listState: {
  117. loaded: false, // 是否已经搜索过
  118. loading: false,
  119. pageNum: 1, // 当前页
  120. pageSize: 10, // 每页多少条数据
  121. total: 0, // 一共多少条数据
  122. list: [] // 查询请求返回的数据
  123. },
  124. recommendList: []
  125. }
  126. },
  127. created () {
  128. this.getList()
  129. this.getRecommendList()
  130. },
  131. methods: {
  132. async getList () {
  133. const query = {
  134. sign: 0,
  135. num: this.listState.pageNum,
  136. size: this.listState.pageSize
  137. }
  138. console.log(query)
  139. this.listState.loading = true
  140. this.listState.loaded = false
  141. const r = await getUserDocs(query)
  142. this.listState.loading = false
  143. this.listState.loaded = true
  144. const res = r.data
  145. if (res.error_code === 0) {
  146. this.listState.total = res.data.total
  147. this.listState.list = res.data.list || []
  148. }
  149. },
  150. toDocDetail (item) {
  151. const { DocId: id } = item
  152. // this.$router.push({
  153. // name: 'content',
  154. // params: { id }
  155. // })
  156. window.open(`../content/${id}`) // 打开新窗口
  157. // window.open(`${process.env.VUE_APP_BASE_URL}/content/${id}`) // 打开新窗口
  158. },
  159. onPageChange (p) {
  160. this.listState.pageNum = p
  161. this.getList()
  162. },
  163. onSizeChange (size) {
  164. this.listState.pageSize = size
  165. this.listState.pageNum = 1
  166. this.getList()
  167. },
  168. calcSubInfo (item) {
  169. const { UpdateAt, DocFileSize } = item
  170. const subInfoArr = []
  171. if (UpdateAt !== undefined) {
  172. subInfoArr.push(dateFormatter(UpdateAt * 1000, 'yyyy-MM-dd'))
  173. }
  174. if (DocFileSize !== undefined) {
  175. subInfoArr.push(formatSize(DocFileSize))
  176. }
  177. return subInfoArr
  178. },
  179. getRecommendList () {
  180. getSearch({ productType: 2, sort: 'vSort', num: 1, size: 8 }).then(res => {
  181. const data = res.data
  182. if (data && data.error_code === 0) {
  183. this.recommendList = data.data.list.map((v) => formatData(v))
  184. }
  185. })
  186. },
  187. goContent (item) {
  188. const routeData = this.$router.resolve({
  189. name: 'content',
  190. params: {
  191. id: item.id
  192. }
  193. })
  194. window.open(routeData.href, '_blank')
  195. }
  196. }
  197. }
  198. </script>
  199. <style lang="scss" scoped>
  200. @include diy-icon('iconJianYu', 24, 24);
  201. @include diy-icon('pdf', 24);
  202. @include diy-icon('word', 24);
  203. @include diy-icon('excel', 24);
  204. @include diy-icon('ppt', 24);
  205. @include diy-icon('txt', 24);
  206. .user-docs {
  207. background-color: #fff;
  208. margin: 0 auto;
  209. .user-docs-header {
  210. padding-top: 48px;
  211. .u-d-title {
  212. font-size: 24px;
  213. line-height: 36px;
  214. color: #1D1D1D;
  215. }
  216. }
  217. .user-docs-content {
  218. margin-top: 48px;
  219. .u-d-header {
  220. display: flex;
  221. align-items: center;
  222. justify-content: space-between;
  223. padding: 0 28px;
  224. height: 48px;
  225. font-size: 14px;
  226. line-height: 24px;
  227. color: #686868;
  228. border-radius: 4px;
  229. background-color: #F5F6F7;
  230. }
  231. .user-d-list {
  232. border-top: 1px solid transparent;
  233. // min-height: 500px;
  234. ::v-deep {
  235. .docs-card {
  236. margin-left: -18px;
  237. box-sizing: content-box;
  238. width: 1200px;
  239. }
  240. }
  241. }
  242. .bought {
  243. color: #686868;
  244. }
  245. .u-d-h-r {
  246. display: inline-block;
  247. width: 155px;
  248. .u-d-h-item {
  249. display: inline-block;
  250. width: 55%;
  251. &.size {
  252. width: 45%;
  253. text-align: center;
  254. }
  255. }
  256. }
  257. ::v-deep {
  258. .subinfo-container {
  259. display: inline-block;
  260. margin-right: 10px;
  261. width: 170px;
  262. .subinfo-item {
  263. display: inline-block;
  264. margin-right: 0;
  265. width: 50%;
  266. &.last {
  267. text-align: center;
  268. }
  269. }
  270. }
  271. }
  272. }
  273. .user-docs-pagination {
  274. margin-top: 28px;
  275. padding-bottom: 60px;
  276. text-align: right;
  277. }
  278. .keep-group{
  279. margin-top: 38px;
  280. padding-bottom: 50px;
  281. .hot-keep-group {
  282. .card-item {
  283. width: 33.33%;
  284. overflow: hidden;
  285. }
  286. }
  287. .card-item {
  288. cursor: pointer;
  289. justify-content: flex-start;
  290. padding: 8px 16px 12px 0;
  291. box-sizing: border-box;
  292. &:hover {
  293. .title-text {
  294. color: #2ABED1;
  295. }
  296. }
  297. .money-group {
  298. margin-bottom: 8px;
  299. font-size: 14px;
  300. line-height: 22px;
  301. color: #999999;
  302. }
  303. .mini-img-group {
  304. flex-shrink: 0;
  305. position: relative;
  306. border-radius: 4px;
  307. border: 1px solid #ececec;
  308. width: 100px;
  309. height: 124px;
  310. margin-right: 12px;
  311. overflow: hidden;
  312. display: flex;
  313. flex-direction: row;
  314. align-items: center;
  315. justify-content: center;
  316. img {
  317. width: 100%;
  318. }
  319. i {
  320. position: absolute;
  321. right: 0;
  322. bottom: 0;
  323. }
  324. }
  325. .info-text-group {
  326. span {
  327. display: inline-block;
  328. &:last-child {
  329. &::after {
  330. content: unset;
  331. }
  332. }
  333. &::after {
  334. content: "|";
  335. padding: 0 8px;
  336. color: #ececec;
  337. }
  338. }
  339. }
  340. .info-text {
  341. font-family: Microsoft YaHei;
  342. font-style: normal;
  343. font-weight: normal;
  344. font-size: 14px;
  345. line-height: 24px;
  346. color: #999999;
  347. }
  348. .red-text {
  349. color: #FF3A20;
  350. font-family: Microsoft YaHei;
  351. font-style: normal;
  352. font-weight: normal;
  353. font-size: 18px;
  354. line-height: 28px;
  355. }
  356. .title-text {
  357. font-family: Microsoft YaHei;
  358. font-style: normal;
  359. font-weight: normal;
  360. font-size: 16px;
  361. line-height: 24px;
  362. color: #1D1D1D;
  363. }
  364. }
  365. .van-ellipsis {
  366. overflow: hidden;
  367. white-space: nowrap;
  368. text-overflow: ellipsis;
  369. }
  370. .van-multi-ellipsis--l2 {
  371. display: -webkit-box;
  372. overflow: hidden;
  373. text-overflow: ellipsis;
  374. -webkit-line-clamp: 2;
  375. -webkit-box-orient: vertical;
  376. }
  377. .title-group {
  378. margin-bottom: 16px;
  379. h5 {
  380. color: #1D1D1D;
  381. font-family: Microsoft YaHei;
  382. font-size: 18px;
  383. line-height: 28px;
  384. letter-spacing: 0px;
  385. text-align: left;
  386. margin-right: 9px;
  387. }
  388. }
  389. }
  390. }
  391. .in-app{
  392. .user-d-list{
  393. ::v-deep{
  394. .docs-card{
  395. width: auto!important;
  396. box-sizing: border-box!important;
  397. }
  398. }
  399. }
  400. .user-docs{
  401. // padding: 0 18px;
  402. background-color: rgb(242, 242, 244) ;
  403. .user-docs-header{
  404. padding-top: 0;
  405. }
  406. .user-docs-content{
  407. padding: 24px;
  408. background-color: #fff;
  409. margin-top: 16px;
  410. border-radius: 8px;
  411. }
  412. .keep-group{
  413. padding: 24px;
  414. background-color: #fff;
  415. margin-top: 16px;
  416. border-radius: 8px;
  417. }
  418. }
  419. }
  420. </style>