article.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  1. <template>
  2. <div class="page">
  3. <div class="page-top flex flex-col justify-center items-center">
  4. <img class="logo" :src="supplierInfo.logo" />
  5. <span class="name mt-2" v-text="supplierInfo.shopName + '资料库'"></span>
  6. </div>
  7. <div class="page-content">
  8. <!-- 搜索区域 -->
  9. <div class="search">
  10. <simple-search v-model="listQuery.articleTitle" @search="onSearch" />
  11. </div>
  12. <div class="divider"></div>
  13. <!-- tabbar -->
  14. <simple-tabs
  15. :tabs="tabs"
  16. :current="current"
  17. @change="onTabChange"
  18. @search="onSearch"
  19. ></simple-tabs>
  20. <div class="list">
  21. <div
  22. class="section flex justify-between items-center"
  23. v-for="item in list"
  24. :key="item.articleId"
  25. @click="toDetail(item)"
  26. >
  27. <div class="info">
  28. <div class="name" v-text="item.articleTitle"></div>
  29. <div class="date">{{ item.createTime | dateFormat }}</div>
  30. </div>
  31. <img class="cover" :src="item.articleImage" />
  32. </div>
  33. </div>
  34. <!-- 列表为空 -->
  35. <SimpleEmpty
  36. v-if="!total && !isRequest"
  37. description="敬请期待~"
  38. ></SimpleEmpty>
  39. <!-- 页码 -->
  40. <SimplePagination
  41. v-if="total > listQuery.pageSize"
  42. :total="total"
  43. :pageItems="listQuery.pageSize"
  44. @change="onPagiantionChange"
  45. ></SimplePagination>
  46. </div>
  47. </div>
  48. </template>
  49. <script>
  50. import { mapGetters } from 'vuex'
  51. import { tabs } from '@/configs/tabs'
  52. export default {
  53. layout: 'app',
  54. data() {
  55. return {
  56. isRequest: true,
  57. tabs: tabs(),
  58. current: 0,
  59. listQuery: {
  60. articleTitle: '',
  61. authUserId: '102',
  62. pageNum: 1,
  63. pageSize: 4,
  64. },
  65. list: [],
  66. total: 0,
  67. }
  68. },
  69. computed: {
  70. ...mapGetters(['userInfo', 'supplierInfo']),
  71. },
  72. mounted() {
  73. this.fetchList()
  74. },
  75. methods: {
  76. async fetchList() {
  77. try {
  78. this.listQuery.authUserId = this.userInfo.authUserId
  79. const res = await this.$http.api.getArticleList(this.listQuery)
  80. this.list = res.data.list
  81. this.total = res.data.total
  82. } catch (error) {
  83. console.log(error)
  84. } finally {
  85. this.isRequest = false
  86. }
  87. },
  88. // 详情
  89. toDetail(item) {
  90. localStorage.setItem('articleInfo', JSON.stringify(item))
  91. this.$router.push('/ph/database/article-detail')
  92. },
  93. // tab切换
  94. onTabChange(item) {
  95. console.log(item)
  96. this.$router.push(`/ph${item.path}`)
  97. },
  98. // 搜索
  99. onSearch(keyword) {
  100. this.listQuery.articleTitle = keyword
  101. this.listQuery.pageNum = 1
  102. this.fetchList()
  103. },
  104. // 页码变化
  105. onPagiantionChange(index) {
  106. this.listQuery.pageNum = index
  107. this.fetchList()
  108. },
  109. },
  110. }
  111. </script>
  112. <style scoped lang="scss">
  113. /* scss中可以用mixin来扩展 */
  114. @mixin ellipsis($line: 1) {
  115. overflow: hidden;
  116. text-overflow: ellipsis;
  117. display: -webkit-box;
  118. -webkit-line-clamp: $line;
  119. -webkit-box-orient: vertical;
  120. }
  121. // pc 端
  122. @media screen and (min-width: 768px) {
  123. .page-top {
  124. height: 360px;
  125. background: url(https://static.caimei365.com/www/authentic/pc/bg-doc.png);
  126. background-size: auto 360px;
  127. .logo {
  128. display: block;
  129. width: 120px;
  130. height: 120px;
  131. border-radius: 50%;
  132. }
  133. .name {
  134. font-size: 30px;
  135. color: #fff;
  136. }
  137. }
  138. .page-content {
  139. width: 1200px;
  140. margin: 0 auto;
  141. background-color: #fff;
  142. .divider {
  143. height: 16px;
  144. background: #f7f7f7;
  145. }
  146. .search {
  147. display: none;
  148. }
  149. }
  150. .list {
  151. border-top: 16px solid #f7f7f7;
  152. border-bottom: 16px solid #f7f7f7;
  153. .section {
  154. padding: 32px 0;
  155. margin: 0 24px;
  156. background: #fff;
  157. border-bottom: 1px solid #d8d8d8;
  158. transition: all 0.4s;
  159. cursor: pointer;
  160. &:hover {
  161. .name {
  162. color: #bc1724 !important;
  163. }
  164. }
  165. &:last-child {
  166. border-bottom: 0;
  167. }
  168. .info {
  169. width: 1000px;
  170. height: 100%;
  171. .name {
  172. font-size: 18px;
  173. color: #404040;
  174. line-height: 1.6;
  175. margin-bottom: 18px;
  176. text-align: justify;
  177. @include ellipsis(2);
  178. }
  179. .date {
  180. font-size: 18px;
  181. color: #b2b2b2;
  182. line-height: 1.4;
  183. }
  184. }
  185. .cover {
  186. width: 106px;
  187. height: 106px;
  188. border-bottom: 1px solid #d8d8d8;
  189. }
  190. }
  191. }
  192. }
  193. // 移动 端
  194. @media screen and (max-width: 768px) {
  195. .page-top {
  196. height: 46vw;
  197. background: url(https://static.caimei365.com/www/authentic/h5/bg-club.png);
  198. background-size: auto 46vw;
  199. .logo {
  200. display: block;
  201. width: 14.8vw;
  202. height: 14.8vw;
  203. border-radius: 50%;
  204. }
  205. .name {
  206. font-size: 4vw;
  207. color: #fff;
  208. }
  209. }
  210. .page-content {
  211. position: relative;
  212. .divider {
  213. border-bottom: 3.2vw solid #f7f7f7;
  214. height: 12.4vw;
  215. }
  216. }
  217. .search {
  218. position: absolute;
  219. left: 50%;
  220. top: 0;
  221. transform: translate(-50%, -50%);
  222. }
  223. .list {
  224. .section {
  225. padding: 2.4vw 0;
  226. margin: 0 4vw;
  227. background: #fff;
  228. border-bottom: 0.1vw solid #d8d8d8;
  229. &:first-child {
  230. border-top: 0.1vw solid #d8d8d8;
  231. }
  232. .info {
  233. width: 67.3vw;
  234. height: 100%;
  235. .name {
  236. font-size: 3.6vw;
  237. color: #404040;
  238. line-height: 1.5;
  239. text-align: justify;
  240. margin-bottom: 2.4vw;
  241. @include ellipsis(2);
  242. }
  243. .date {
  244. font-size: 3.2vw;
  245. color: #b2b2b2;
  246. line-height: 1.4;
  247. }
  248. }
  249. .cover {
  250. width: 18vw;
  251. height: 18vw;
  252. border-bottom: 0.1vw solid #d8d8d8;
  253. }
  254. }
  255. }
  256. }
  257. </style>