Home.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474
  1. <template>
  2. <div class="pages--home">
  3. <div class="top-search-group flex-c-c center">
  4. <h5>剑鱼文库,最实用的招投标资料库</h5>
  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 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 = ''
  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. this.$router.push({
  231. name: 'search',
  232. query: search
  233. })
  234. },
  235. getLoginStatus: function () {
  236. alert(loginflag)
  237. }
  238. }
  239. }
  240. </script>
  241. <style lang="scss">
  242. .page--docs--index.view_index {
  243. .page-container {
  244. background-image: url("~@/assets/images/wenkuBanner.png");
  245. background-repeat: no-repeat;
  246. background-color: #fff;
  247. }
  248. }
  249. </style>
  250. <style scoped lang="scss">
  251. .pages--home {
  252. padding-bottom: 40px;
  253. box-sizing: border-box;
  254. @include diy-icon('iconJianYu', 24, 24);
  255. @include diy-icon('pdf', 24);
  256. @include diy-icon('word', 24);
  257. @include diy-icon('excel', 24);
  258. @include diy-icon('ppt', 24);
  259. .list-item {
  260. cursor: pointer;
  261. padding: 18px 0;
  262. box-sizing: border-box;
  263. border-bottom: 1px solid rgba(0, 0, 0, 0.05);
  264. &:hover {
  265. background: #F5F6F7;
  266. }
  267. &:last-child {
  268. border-bottom-color: transparent;
  269. }
  270. i {
  271. flex-shrink: 0;
  272. margin-right: 4px;
  273. }
  274. .flex {
  275. min-width: 0;
  276. }
  277. .right-info {
  278. margin-left: 4px;
  279. flex-shrink: 0;
  280. color: #1D1D1D;
  281. font-family: Microsoft YaHei;
  282. font-size: 16px;
  283. letter-spacing: 0px;
  284. text-align: right;
  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. background: #F5F6F7;
  294. }
  295. .money-group {
  296. margin-top: 8px;
  297. }
  298. .mini-img-group {
  299. flex-shrink: 0;
  300. position: relative;
  301. border-radius: 4px;
  302. border: 1px solid rgba(0, 0, 0, 0.1);
  303. width: 100px;
  304. height: 124px;
  305. margin-right: 12px;
  306. overflow: hidden;
  307. img {
  308. width: 100%;
  309. height: 100%;
  310. }
  311. i {
  312. position: absolute;
  313. right: 0;
  314. bottom: 0;
  315. }
  316. }
  317. .info-text-group {
  318. span {
  319. display: inline-block;
  320. &:last-child {
  321. &::after {
  322. content: unset;
  323. }
  324. }
  325. &::after {
  326. content: "|";
  327. padding: 0 8px;
  328. }
  329. }
  330. }
  331. .info-text {
  332. color: #9B9CA3;
  333. font-family: PingFang SC;
  334. font-size: 12px;
  335. line-height: 18px;
  336. letter-spacing: 0px;
  337. text-align: left;
  338. }
  339. .red-text {
  340. color: #FB483D;
  341. font-family: PingFang SC;
  342. font-size: 14px;
  343. line-height: 20px;
  344. letter-spacing: 0px;
  345. text-align: left;
  346. }
  347. .title-text {
  348. color: #171826;
  349. font-family: PingFang SC;
  350. font-weight: bold;
  351. font-size: 14px;
  352. line-height: 20px;
  353. letter-spacing: 0px;
  354. text-align: left;
  355. }
  356. }
  357. .van-ellipsis {
  358. overflow: hidden;
  359. white-space: nowrap;
  360. text-overflow: ellipsis;
  361. }
  362. .van-multi-ellipsis--l2 {
  363. display: -webkit-box;
  364. overflow: hidden;
  365. text-overflow: ellipsis;
  366. -webkit-line-clamp: 2;
  367. -webkit-box-orient: vertical;
  368. }
  369. .hot-keep-group {
  370. .card-item {
  371. width: 33.33%;
  372. }
  373. }
  374. }
  375. @include diy-icon('search', 24);
  376. @include diy-icon('Frame', 24);
  377. @include diy-icon('Frame-1', 24);
  378. .keep-group {
  379. margin-top: 38px;
  380. padding-bottom: 50px;
  381. }
  382. .new-group {
  383. margin-top: 54px;
  384. .flex-c-c {
  385. padding-right: 24px;
  386. box-sizing: border-box;
  387. & + .flex-c-c {
  388. padding-right: 0;
  389. padding-left: 24px;
  390. }
  391. }
  392. }
  393. .hot-down-group {
  394. border-radius: 12px;
  395. background: radial-gradient(circle at 50% 50%, #FAEACD 0%, #FFF8EA 100%);
  396. background-image: url("~@/assets/images/dateGetBg.png");
  397. background-repeat: no-repeat;
  398. background-size: 100% 100%;
  399. width: 100%;
  400. height: auto;
  401. padding: 24px;
  402. padding-bottom: 34px;
  403. box-sizing: border-box;
  404. margin-top: 40px;
  405. .title-group h5 {
  406. color: #863700;
  407. }
  408. .new-list-group {
  409. background-color: white;
  410. border-radius: 8px;
  411. .flex-c-c {
  412. padding: 20px;
  413. box-sizing: border-box;
  414. }
  415. }
  416. }
  417. .title-group {
  418. margin-bottom: 16px;
  419. h5 {
  420. color: #1D1D1D;
  421. font-family: Microsoft YaHei;
  422. font-size: 18px;
  423. line-height: 28px;
  424. letter-spacing: 0px;
  425. text-align: left;
  426. margin-right: 9px;
  427. }
  428. }
  429. .top-search-group {
  430. width: 100%;
  431. height: 323px;
  432. h5 {
  433. color: #1D1D1D;
  434. font-family: Microsoft YaHei;
  435. font-size: 20px;
  436. line-height: normal;
  437. letter-spacing: 0px;
  438. text-align: left;
  439. margin-bottom: 40px;
  440. }
  441. }
  442. .new-list-group {
  443. > .flex {
  444. max-width: 50%;
  445. }
  446. }
  447. </style>