Home.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299
  1. <template>
  2. <div class="pages--home">
  3. <search type="click" @click="goSearch"></search>
  4. <div class="new-group base-group">
  5. <div class="title-group flex-r-c center left">
  6. <span></span>
  7. <h5>最新文档</h5>
  8. </div>
  9. <div class="list-group flex-c-c">
  10. <van-skeleton class="van-loading-skeleton line-style" :row="5" :loading="showLoading.new">
  11. <div class="list-item flex-r-c" v-for="item in pageData.new" :key="item.id" @click="goContent(item)">
  12. <div class="flex flex-r-c center left">
  13. <van-icon :name="'diy-' + item.type" />
  14. <div class="flex">
  15. <div class="van-ellipsis">{{item.title}}</div>
  16. </div>
  17. </div>
  18. <div class="right-info flex-r-c center right">
  19. <van-icon name="diy-iconJianYu" />
  20. <span>{{item.money}}</span>
  21. </div>
  22. </div>
  23. </van-skeleton>
  24. </div>
  25. </div>
  26. <div class="hot-group base-group">
  27. <div class="title-group flex-r-c center left">
  28. <span></span>
  29. <h5>热门下载</h5>
  30. </div>
  31. <div class="list-group flex-c-c">
  32. <van-skeleton class="van-loading-skeleton line-style" :row="5" :loading="showLoading.hot">
  33. <div class="list-item flex-r-c" v-for="item in pageData.hot" :key="item.id" @click="goContent(item)">
  34. <div class="flex flex-r-c center left">
  35. <van-icon :name="'diy-' + item.type" />
  36. <div class="flex">
  37. <div class="van-ellipsis">{{item.title}}</div>
  38. </div>
  39. </div>
  40. <div class="right-info flex-r-c center right">
  41. <van-icon name="diy-iconJianYu" />
  42. <span>{{item.money}}</span>
  43. </div>
  44. </div>
  45. </van-skeleton>
  46. </div>
  47. </div>
  48. <div class="keep-group base-group">
  49. <div class="title-group flex-r-c center left">
  50. <span></span>
  51. <h5>精选推荐</h5>
  52. </div>
  53. <div class="list-group card-group flex-c-c">
  54. <van-skeleton avatar avatar-shape="square" class="van-loading-skeleton card-style"
  55. :row="4"
  56. :row-width="rowWidth"
  57. :loading="showLoading.keep">
  58. <div class="card-item flex-r-c" v-for="item in pageData.keep" :key="item.id" @click="goContent(item)">
  59. <div class="mini-img-group">
  60. <img :src="item.img" alt="">
  61. <van-icon :name="'diy-' + item.type" />
  62. </div>
  63. <div class="flex-c-c">
  64. <div class="flex">
  65. <div class="title-text van-multi-ellipsis--l2">{{item.title}}</div>
  66. </div>
  67. <div class="flex-c-c info-text">
  68. <span v-if="item.contribution">贡献者: {{item.contribution}}</span>
  69. <div class="info-text-group flex-r-c center left">
  70. <span v-if="item.down">{{item.down}}次下载</span>
  71. <span v-if="item.page">共{{item.page}}页</span>
  72. <span v-if="item.size">{{item.size | sizeFormatter}}</span>
  73. </div>
  74. </div>
  75. <div class="money-group flex-r-c center left">
  76. <van-icon class="s20" name="diy-iconJianYu" />
  77. <span class="red-text">{{item.money}}</span>
  78. </div>
  79. </div>
  80. </div>
  81. </van-skeleton>
  82. </div>
  83. </div>
  84. </div>
  85. </template>
  86. <script lang="ts">
  87. import { Component, Vue } from 'vue-property-decorator'
  88. import Search from '@/components/Search.vue'
  89. import { Icon, Skeleton } from 'vant'
  90. import { mapActions, mapState } from 'vuex'
  91. @Component({
  92. name: 'home',
  93. components: {
  94. [Icon.name]: Icon,
  95. [Skeleton.name]: Skeleton,
  96. Search
  97. },
  98. computed: {
  99. ...mapState('main', {
  100. pageData: (state: any) => state.homePageData
  101. })
  102. },
  103. methods: {
  104. ...mapActions({
  105. ajaxData: 'main/getHome'
  106. })
  107. }
  108. })
  109. export default class extends Vue {
  110. ajaxData: any
  111. pageData: any
  112. rowWidth = ['100%', '20%', '40%', '15%']
  113. created () {
  114. this.ajaxData()
  115. }
  116. get showLoading () {
  117. const s = this.pageData
  118. return {
  119. new: !s?.new,
  120. hot: !s?.hot,
  121. keep: !s?.keep
  122. }
  123. }
  124. goSearch () {
  125. this.$router.push({
  126. name: 'search'
  127. })
  128. }
  129. goContent (item: any) {
  130. this.$router.push({
  131. name: 'details',
  132. params: {
  133. id: item.id
  134. }
  135. })
  136. }
  137. }
  138. </script>
  139. <style scoped lang="scss">
  140. .pages--home {
  141. background: #F5F6F7;
  142. padding-bottom: 40px;
  143. box-sizing: border-box;
  144. ::v-deep .van-loading-skeleton {
  145. &.line-style {
  146. .van-skeleton__row {
  147. width: 100% !important;
  148. height: 28px;
  149. }
  150. }
  151. &.card-style {
  152. .van-skeleton__avatar {
  153. width: 100px !important;
  154. height: 124px !important;
  155. }
  156. }
  157. }
  158. @include diy-icon('iconJianYu', 16, 16);
  159. .van-icon-diy-iconJianYu.s20 {
  160. width: 20px;
  161. height: 20px;
  162. }
  163. @include diy-icon('pdf', 24);
  164. @include diy-icon('word', 24);
  165. @include diy-icon('excel', 24);
  166. @include diy-icon('ppt', 24);
  167. .base-group {
  168. padding: 4px 19px 4px 16px;
  169. box-sizing: border-box;
  170. .list-group {
  171. border-radius: 8px;
  172. background: #FFFFFF;
  173. box-sizing: border-box;
  174. padding: 8px 0;
  175. &.card-group {
  176. padding-left: 12px;
  177. }
  178. .list-item {
  179. padding: 6px 12px;
  180. box-sizing: border-box;
  181. i {
  182. flex-shrink: 0;
  183. margin-right: 4px;
  184. }
  185. .flex {
  186. min-width: 0;
  187. }
  188. .right-info {
  189. margin-left: 4px;
  190. flex-shrink: 0;
  191. }
  192. }
  193. .card-item {
  194. justify-content: flex-start;
  195. padding: 8px 16px 12px 0;
  196. box-sizing: border-box;
  197. border-bottom: 1px solid rgba(0, 0, 0, 0.05);
  198. &:nth-last-child(1) {
  199. border-bottom-color: transparent;
  200. padding-bottom: 8px;
  201. }
  202. .money-group {
  203. margin-top: 8px;
  204. }
  205. .mini-img-group {
  206. flex-shrink: 0;
  207. position: relative;
  208. border-radius: 4px;
  209. border: 1px solid rgba(0, 0, 0, 0.1);
  210. width: 100px;
  211. height: 124px;
  212. margin-right: 12px;
  213. overflow: hidden;
  214. img {
  215. width: 100%;
  216. height: 100%;
  217. }
  218. i {
  219. position: absolute;
  220. right: 0;
  221. bottom: 0;
  222. }
  223. }
  224. .info-text-group {
  225. span {
  226. display: inline-block;
  227. &:last-child {
  228. &::after {
  229. content: unset;
  230. }
  231. }
  232. &::after {
  233. content: "|";
  234. padding: 0 8px;
  235. }
  236. }
  237. }
  238. .info-text {
  239. color: #9B9CA3;
  240. font-family: PingFang SC;
  241. font-size: 12px;
  242. line-height: 18px;
  243. letter-spacing: 0px;
  244. text-align: left;
  245. }
  246. .red-text {
  247. color: #FB483D;
  248. font-family: PingFang SC;
  249. font-size: 14px;
  250. line-height: 20px;
  251. letter-spacing: 0px;
  252. text-align: left;
  253. }
  254. .title-text {
  255. color: #171826;
  256. font-family: PingFang SC;
  257. font-weight: bold;
  258. font-size: 14px;
  259. line-height: 20px;
  260. letter-spacing: 0px;
  261. text-align: left;
  262. }
  263. }
  264. }
  265. .title-group {
  266. padding: 16px 0 6px 0;
  267. margin-bottom: 4px;
  268. box-sizing: border-box;
  269. color: #171826;
  270. font-family: PingFang SC;
  271. font-size: 18px;
  272. line-height: 26px;
  273. letter-spacing: 0px;
  274. text-align: left;
  275. span {
  276. display: inline-block;
  277. width: 3px;
  278. height: 16px;
  279. border-radius: 11px;
  280. background: #2ABED1;
  281. margin-right: 8px;
  282. }
  283. }
  284. }
  285. }
  286. </style>