article.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  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', 'authUserId']),
  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. const url = `/${this.authUserId}/app/database/article-detail`
  92. this.$router.push(url)
  93. },
  94. // tab切换
  95. onTabChange(item) {
  96. console.log(item)
  97. this.$router.push(`/ph${item.path}`)
  98. },
  99. // 搜索
  100. onSearch(keyword) {
  101. this.listQuery.articleTitle = keyword
  102. this.listQuery.pageNum = 1
  103. this.fetchList()
  104. },
  105. // 页码变化
  106. onPagiantionChange(index) {
  107. this.listQuery.pageNum = index
  108. this.fetchList()
  109. },
  110. },
  111. }
  112. </script>
  113. <style scoped lang="scss">
  114. /* scss中可以用mixin来扩展 */
  115. @mixin ellipsis($line: 1) {
  116. overflow: hidden;
  117. text-overflow: ellipsis;
  118. display: -webkit-box;
  119. -webkit-line-clamp: $line;
  120. -webkit-box-orient: vertical;
  121. }
  122. // pc 端
  123. @media screen and (min-width: 768px) {
  124. .page-top {
  125. height: 360px;
  126. background: url(https://static.caimei365.com/www/authentic/pc/bg-doc.png);
  127. background-size: auto 360px;
  128. .logo {
  129. display: block;
  130. width: 120px;
  131. height: 120px;
  132. border-radius: 50%;
  133. }
  134. .name {
  135. font-size: 30px;
  136. color: #fff;
  137. }
  138. }
  139. .page-content {
  140. width: 1200px;
  141. margin: 0 auto;
  142. background-color: #fff;
  143. .divider {
  144. height: 16px;
  145. background: #f7f7f7;
  146. }
  147. .search {
  148. display: none;
  149. }
  150. }
  151. .list {
  152. border-top: 16px solid #f7f7f7;
  153. border-bottom: 16px solid #f7f7f7;
  154. .section {
  155. padding: 32px 0;
  156. margin: 0 24px;
  157. background: #fff;
  158. border-bottom: 1px solid #d8d8d8;
  159. transition: all 0.4s;
  160. cursor: pointer;
  161. &:hover {
  162. .name {
  163. color: #bc1724 !important;
  164. }
  165. }
  166. &:last-child {
  167. border-bottom: 0;
  168. }
  169. .info {
  170. width: 1000px;
  171. height: 100%;
  172. .name {
  173. font-size: 18px;
  174. color: #404040;
  175. line-height: 1.6;
  176. margin-bottom: 18px;
  177. text-align: justify;
  178. @include ellipsis(2);
  179. }
  180. .date {
  181. font-size: 18px;
  182. color: #b2b2b2;
  183. line-height: 1.4;
  184. }
  185. }
  186. .cover {
  187. width: 106px;
  188. height: 106px;
  189. border-bottom: 1px solid #d8d8d8;
  190. }
  191. }
  192. }
  193. }
  194. // 移动 端
  195. @media screen and (max-width: 768px) {
  196. .page-top {
  197. height: 46vw;
  198. background: url(https://static.caimei365.com/www/authentic/h5/bg-club.png);
  199. background-size: auto 46vw;
  200. .logo {
  201. display: block;
  202. width: 14.8vw;
  203. height: 14.8vw;
  204. border-radius: 50%;
  205. }
  206. .name {
  207. font-size: 4vw;
  208. color: #fff;
  209. }
  210. }
  211. .page-content {
  212. position: relative;
  213. .divider {
  214. border-bottom: 3.2vw solid #f7f7f7;
  215. height: 12.4vw;
  216. }
  217. }
  218. .search {
  219. position: absolute;
  220. left: 50%;
  221. top: 0;
  222. transform: translate(-50%, -50%);
  223. }
  224. .list {
  225. .section {
  226. padding: 2.4vw 0;
  227. margin: 0 4vw;
  228. background: #fff;
  229. border-bottom: 0.1vw solid #d8d8d8;
  230. &:first-child {
  231. border-top: 0.1vw solid #d8d8d8;
  232. }
  233. .info {
  234. width: 67.3vw;
  235. height: 100%;
  236. .name {
  237. font-size: 3.6vw;
  238. color: #404040;
  239. line-height: 1.5;
  240. text-align: justify;
  241. margin-bottom: 2.4vw;
  242. @include ellipsis(2);
  243. }
  244. .date {
  245. font-size: 3.2vw;
  246. color: #b2b2b2;
  247. line-height: 1.4;
  248. }
  249. }
  250. .cover {
  251. width: 18vw;
  252. height: 18vw;
  253. border-bottom: 0.1vw solid #d8d8d8;
  254. }
  255. }
  256. }
  257. }
  258. </style>