Home.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493
  1. <template>
  2. <div class="pages--home">
  3. <div class="top-search-group flex-c-c center">
  4. <h1>剑鱼文库,最实用的招投标资料库</h1>
  5. <search-input @submit="goSubmit"></search-input>
  6. </div>
  7. <div class="new-group">
  8. <div class="flex-r-c">
  9. <div class="title-group flex-r-c center left">
  10. <h5>最新文档</h5>
  11. <i class="el-icon-jy-Frame"></i>
  12. </div>
  13. </div>
  14. <div class="new-list-group must-bottom flex-r-c">
  15. <div class="flex flex-c-c">
  16. <div class="list-item flex-r-c" v-for="item in newList1" :key="item.id" @click="goContent(item)">
  17. <div class="flex flex-r-c center left">
  18. <i :class="'el-icon-jy-' + item.type" />
  19. <div class="flex">
  20. <div class="van-ellipsis">{{item.title}}</div>
  21. </div>
  22. </div>
  23. <div class="right-info flex-r-c center right">
  24. <i class="el-icon-jy-iconJianYu" />
  25. <span>{{item.money}}</span>
  26. </div>
  27. </div>
  28. </div>
  29. <div class="flex flex-c-c">
  30. <div class="list-item flex-r-c" v-for="item in newList2" :key="item.id" @click="goContent(item)">
  31. <div class="flex flex-r-c center left">
  32. <i :class="'el-icon-jy-' + item.type" />
  33. <div class="flex">
  34. <div class="van-ellipsis">{{item.title}}</div>
  35. </div>
  36. </div>
  37. <div class="right-info flex-r-c center right">
  38. <i class="el-icon-jy-iconJianYu" />
  39. <span>{{item.money}}</span>
  40. </div>
  41. </div>
  42. </div>
  43. </div>
  44. </div>
  45. <div class="hot-down-group">
  46. <div class="flex-r-c">
  47. <div class="title-group flex-r-c center left">
  48. <h5>热门下载</h5>
  49. <i class="el-icon-jy-Frame-1"></i>
  50. </div>
  51. </div>
  52. <div class="new-list-group flex-r-c">
  53. <div class="flex flex-c-c">
  54. <div class="list-item flex-r-c" v-for="item in hotList1" :key="item.id" @click="goContent(item)">
  55. <div class="flex flex-r-c center left">
  56. <i :class="'el-icon-jy-' + item.type" />
  57. <div class="flex">
  58. <div class="van-ellipsis">{{item.title}}</div>
  59. </div>
  60. </div>
  61. <div class="right-info flex-r-c center right">
  62. <i class="el-icon-jy-iconJianYu" />
  63. <span>{{item.money}}</span>
  64. </div>
  65. </div>
  66. </div>
  67. <div class="flex flex-c-c">
  68. <div class="list-item flex-r-c" v-for="item in hotList2" :key="item.id" @click="goContent(item)">
  69. <div class="flex flex-r-c center left">
  70. <i :class="'el-icon-jy-' + item.type" />
  71. <div class="flex">
  72. <div class="van-ellipsis">{{item.title}}</div>
  73. </div>
  74. </div>
  75. <div class="right-info flex-r-c center right">
  76. <i class="el-icon-jy-iconJianYu" />
  77. <span>{{item.money}}</span>
  78. </div>
  79. </div>
  80. </div>
  81. </div>
  82. </div>
  83. <div class="keep-group">
  84. <div class="flex-r-c">
  85. <div class="title-group flex-r-c center left">
  86. <h5>精选推荐</h5>
  87. </div>
  88. </div>
  89. <div class="hot-keep-group flex-r-c wrap">
  90. <div class="card-item flex-r-c" v-for="item in pageData.keep" :key="item.id" @click="goContent(item)">
  91. <div class="mini-img-group">
  92. <img :src="item.img" alt="">
  93. <i :class="'el-icon-jy-' + item.type" />
  94. </div>
  95. <div class="flex-c-c">
  96. <div class="flex">
  97. <div class="title-text van-multi-ellipsis--l2">{{item.title}}</div>
  98. </div>
  99. <div class="flex-c-c info-text">
  100. <span v-if="item.contribution">贡献者: {{item.contribution}}</span>
  101. <div class="info-text-group flex-r-c center left">
  102. <span v-if="item.down">{{item.down}}次下载</span>
  103. <span v-if="item.page">共{{item.page}}页</span>
  104. <span v-if="item.size">{{item.size | sizeFormatter}}</span>
  105. </div>
  106. </div>
  107. <div class="money-group flex-r-c center left">
  108. <i class="el-icon-jy-iconJianYu s20" />
  109. <span class="red-text">{{item.money}}</span>
  110. </div>
  111. </div>
  112. </div>
  113. </div>
  114. </div>
  115. </div>
  116. </template>
  117. <script>
  118. import { Button } from 'element-ui'
  119. import SearchInput from '../components/Search'
  120. import { getHomeActivity, getHomeHot } from '../api/modules/home'
  121. import { recoveryPageData } from '../utils'
  122. function checkType (type) {
  123. let typeStr = type
  124. switch (type) {
  125. case 1: {
  126. typeStr = 'word'
  127. break
  128. }
  129. case 2: {
  130. typeStr = 'pdf'
  131. break
  132. }
  133. case 3: {
  134. typeStr = 'excel'
  135. break
  136. }
  137. case 4: {
  138. typeStr = 'ppt'
  139. break
  140. }
  141. case 'doc': {
  142. typeStr = 'word'
  143. break
  144. }
  145. case 'xls': {
  146. typeStr = 'excel'
  147. break
  148. }
  149. }
  150. return typeStr
  151. }
  152. function formatData (v) {
  153. return {
  154. img: v?.docImg,
  155. type: checkType(v?.docFileType),
  156. id: v.docId,
  157. title: v?.docName || v?.docTitle,
  158. money: v.price,
  159. size: v?.docFileSize,
  160. page: v?.docPageSize,
  161. down: v?.downTimes,
  162. contribution: v?.sourceUserId
  163. }
  164. }
  165. export default {
  166. name: 'home',
  167. components: {
  168. SearchInput,
  169. [Button.name]: Button
  170. },
  171. data () {
  172. return {
  173. fullscreenLoading: false,
  174. pageData: {}
  175. }
  176. },
  177. created () {
  178. this.pageData = recoveryPageData('jy-docs-home-page-pc')
  179. this.getHome()
  180. },
  181. beforeCreate: function () {
  182. $('body').addClass('view_index')
  183. },
  184. beforeDestroy: function () {
  185. $('body').removeClass('view_index')
  186. sessionStorage.setItem('jy-docs-home-page-pc', JSON.stringify(this.pageData))
  187. },
  188. computed: {
  189. newList1 () {
  190. return this.pageData?.new && this.pageData?.new.slice(0, 5)
  191. },
  192. newList2 () {
  193. return this.pageData?.new && this.pageData?.new.slice(5)
  194. },
  195. hotList1 () {
  196. return this.pageData?.hot && this.pageData?.hot.slice(0, 5)
  197. },
  198. hotList2 () {
  199. return this.pageData?.hot && this.pageData?.hot.slice(5)
  200. }
  201. },
  202. methods: {
  203. goContent (item) {
  204. const routeData = this.$router.resolve({
  205. name: 'content',
  206. params: {
  207. id: item.id
  208. }
  209. })
  210. window.open(routeData.href, '_blank')
  211. },
  212. async getHome () {
  213. getHomeHot({ sign: 'new', num: 10 }).then(res => {
  214. if (!res.data.error_msg.length) {
  215. this.$set(this.pageData, 'new', res.data.data.map((v) => formatData(v)))
  216. }
  217. })
  218. getHomeHot({ sign: 'hot', num: 10 }).then(res => {
  219. if (!res.data.error_msg.length) {
  220. this.$set(this.pageData, 'hot', res.data.data.map((v) => formatData(v)))
  221. }
  222. })
  223. getHomeActivity({ code: 3, size: 6, num: 1 }).then(res => {
  224. if (!res.data.error_msg.length) {
  225. this.$set(this.pageData, 'keep', res.data.data.map((v) => formatData(v)))
  226. }
  227. })
  228. },
  229. goSubmit (search) {
  230. if (!search.text.replace(/\s+/g, '')) {
  231. return
  232. }
  233. this.$router.push({
  234. name: 'search',
  235. query: {
  236. type: search.type,
  237. text: search.text
  238. }
  239. })
  240. },
  241. getLoginStatus: function () {
  242. alert(loginflag)
  243. }
  244. }
  245. }
  246. </script>
  247. <style lang="scss">
  248. .page--docs--index.view_index {
  249. .page-container {
  250. background-image: url("~@/assets/images/wenkuBanner.png");
  251. background-repeat: no-repeat;
  252. background-color: #fff;
  253. }
  254. }
  255. </style>
  256. <style scoped lang="scss">
  257. .pages--home {
  258. padding-bottom: 40px;
  259. box-sizing: border-box;
  260. @include diy-icon('iconJianYu', 24, 24);
  261. @include diy-icon('pdf', 24);
  262. @include diy-icon('word', 24);
  263. @include diy-icon('excel', 24);
  264. @include diy-icon('ppt', 24);
  265. .list-item {
  266. cursor: pointer;
  267. padding: 18px 0;
  268. box-sizing: border-box;
  269. border-bottom: 1px solid #ececec;
  270. &:hover {
  271. color: #2CB7CA;
  272. }
  273. &:last-child {
  274. border-bottom-color: transparent;
  275. }
  276. i {
  277. flex-shrink: 0;
  278. margin-right: 4px;
  279. }
  280. .flex {
  281. min-width: 0;
  282. }
  283. .right-info {
  284. margin-left: 4px;
  285. flex-shrink: 0;
  286. color: #1D1D1D;
  287. font-family: Microsoft YaHei;
  288. font-size: 16px;
  289. letter-spacing: 0px;
  290. text-align: right;
  291. }
  292. }
  293. .card-item {
  294. cursor: pointer;
  295. justify-content: flex-start;
  296. padding: 8px 16px 12px 0;
  297. box-sizing: border-box;
  298. &:hover {
  299. .title-text {
  300. color: #2ABED1;
  301. }
  302. }
  303. .money-group {
  304. margin-top: 8px;
  305. }
  306. .mini-img-group {
  307. flex-shrink: 0;
  308. position: relative;
  309. border-radius: 4px;
  310. border: 1px solid #ececec;
  311. width: 100px;
  312. height: 124px;
  313. margin-right: 12px;
  314. overflow: hidden;
  315. display: flex;
  316. flex-direction: row;
  317. align-items: center;
  318. justify-content: center;
  319. img {
  320. width: 100%;
  321. }
  322. i {
  323. position: absolute;
  324. right: 0;
  325. bottom: 0;
  326. }
  327. }
  328. .info-text-group {
  329. span {
  330. display: inline-block;
  331. &:last-child {
  332. &::after {
  333. content: unset;
  334. }
  335. }
  336. &::after {
  337. content: "|";
  338. padding: 0 8px;
  339. color: #ececec;
  340. }
  341. }
  342. }
  343. .info-text {
  344. font-family: Microsoft YaHei;
  345. font-style: normal;
  346. font-weight: normal;
  347. font-size: 14px;
  348. line-height: 24px;
  349. color: #999999;
  350. }
  351. .red-text {
  352. color: #FF3A20;
  353. font-family: Microsoft YaHei;
  354. font-style: normal;
  355. font-weight: normal;
  356. font-size: 18px;
  357. line-height: 28px;
  358. }
  359. .title-text {
  360. font-family: Microsoft YaHei;
  361. font-style: normal;
  362. font-weight: normal;
  363. font-size: 16px;
  364. line-height: 24px;
  365. color: #1D1D1D;
  366. }
  367. }
  368. .van-ellipsis {
  369. overflow: hidden;
  370. white-space: nowrap;
  371. text-overflow: ellipsis;
  372. }
  373. .van-multi-ellipsis--l2 {
  374. display: -webkit-box;
  375. overflow: hidden;
  376. text-overflow: ellipsis;
  377. -webkit-line-clamp: 2;
  378. -webkit-box-orient: vertical;
  379. }
  380. .hot-keep-group {
  381. .card-item {
  382. width: 33.33%;
  383. overflow: hidden;
  384. }
  385. }
  386. }
  387. @include diy-icon('search', 24);
  388. @include diy-icon('Frame', 24);
  389. @include diy-icon('Frame-1', 24);
  390. .keep-group {
  391. margin-top: 38px;
  392. padding-bottom: 50px;
  393. }
  394. .new-group {
  395. margin-top: 54px;
  396. .flex-c-c {
  397. padding-right: 24px;
  398. box-sizing: border-box;
  399. & + .flex-c-c {
  400. padding-right: 0;
  401. padding-left: 24px;
  402. }
  403. }
  404. }
  405. .hot-down-group {
  406. border-radius: 12px;
  407. background: radial-gradient(circle at 50% 50%, #FAEACD 0%, #FFF8EA 100%);
  408. background-image: url("~@/assets/images/dateGetBg.png");
  409. background-repeat: no-repeat;
  410. background-size: 100% 100%;
  411. width: 100%;
  412. height: auto;
  413. padding: 24px;
  414. padding-bottom: 34px;
  415. box-sizing: border-box;
  416. margin-top: 40px;
  417. .title-group h5 {
  418. color: #863700;
  419. }
  420. .new-list-group {
  421. background-color: white;
  422. border-radius: 8px;
  423. .flex-c-c {
  424. padding: 20px;
  425. box-sizing: border-box;
  426. }
  427. }
  428. }
  429. .title-group {
  430. margin-bottom: 16px;
  431. h5 {
  432. color: #1D1D1D;
  433. font-family: Microsoft YaHei;
  434. font-size: 18px;
  435. line-height: 28px;
  436. letter-spacing: 0px;
  437. text-align: left;
  438. margin-right: 9px;
  439. }
  440. }
  441. .top-search-group {
  442. width: 100%;
  443. height: 323px;
  444. h1 {
  445. color: #1D1D1D;
  446. font-family: Microsoft YaHei;
  447. font-size: 20px;
  448. line-height: normal;
  449. letter-spacing: 0px;
  450. text-align: left;
  451. margin-bottom: 40px;
  452. }
  453. }
  454. .new-list-group {
  455. > .flex {
  456. max-width: 50%;
  457. }
  458. &.must-bottom {
  459. .list-item:last-child {
  460. border-bottom-color: #ececec;
  461. }
  462. }
  463. }
  464. </style>