RecommendedPath.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. <template>
  2. <div class="recommended-path">
  3. <SearchBar class="search-bar" @search="onSearch"></SearchBar>
  4. <div class="keywords">
  5. <h2>推荐</h2>
  6. <button
  7. class="keyword"
  8. :class="{
  9. active: item.isActive,
  10. }"
  11. v-for="(item, index) in tagList"
  12. :key="index"
  13. @click="onClickTag(index)"
  14. >
  15. {{item.name}}
  16. </button>
  17. </div>
  18. <div class="card-list">
  19. <article
  20. v-for="(item, idx) in pathList"
  21. :key="item.id"
  22. @click="$router.push({
  23. name: 'RecommendedPathDetail', query: {id: item.id}
  24. })"
  25. >
  26. <div class="left">
  27. <img :src="require(`@/assets/img/service/path/${item.id}/1.jpg`)" alt="" draggable="false">
  28. </div>
  29. <div class="right">
  30. <h3>{{item.name}}</h3>
  31. <ul class="tags">
  32. <li
  33. class="tag"
  34. v-for="(item, index) in item.tagList"
  35. :key="index"
  36. >
  37. {{item}}
  38. </li>
  39. </ul>
  40. <div class="bottom">
  41. <div class="time">{{item.publicDate}}</div>
  42. <!-- <div class="view-count">
  43. <img class="icon" src="@/assets/img/service/eye.png" alt="" draggable="false">
  44. 666
  45. </div> -->
  46. </div>
  47. </div>
  48. </article>
  49. </div>
  50. </div>
  51. </template>
  52. <script>
  53. import SearchBar from "@/components/SearchRedBtn.vue";
  54. import serveData from "@/assets/data/serve/data.js";
  55. export default {
  56. components: {
  57. SearchBar,
  58. },
  59. data() {
  60. return {
  61. keyword: '',
  62. tagList: serveData.pathTagList.map((item) => {
  63. return {
  64. name: item,
  65. isActive: false,
  66. }
  67. }),
  68. }
  69. },
  70. computed: {
  71. pathList() {
  72. return serveData.pathList.filter((item) => {
  73. const activeTagList = this.tagList.filter((item) => {
  74. return item.isActive
  75. })
  76. if (!activeTagList.length) {
  77. return true
  78. } else {
  79. let ret = false
  80. for (const activeTag of activeTagList) {
  81. if (item.tagList.includes(activeTag.name)) {
  82. ret = true
  83. break
  84. }
  85. }
  86. return ret
  87. }
  88. }).filter((item) => {
  89. if (!this.keyword) {
  90. return true
  91. } else {
  92. return item.name.includes(this.keyword)
  93. }
  94. })
  95. }
  96. },
  97. methods: {
  98. onSearch(v) {
  99. this.keyword = v
  100. },
  101. onClickTag(idx) {
  102. this.tagList[idx].isActive = !this.tagList[idx].isActive
  103. }
  104. }
  105. }
  106. </script>
  107. <style lang="less" scoped>
  108. .recommended-path {
  109. background-color: #fff;
  110. height: calc(100% - 80px);
  111. overflow: auto;
  112. padding: 6.1vw 4.5vw 4.5vw 4.5vw;
  113. display: flex;
  114. flex-direction: column;
  115. .search-bar {
  116. flex: 0 0 auto;
  117. }
  118. .keywords {
  119. margin-top: 4.1vw;
  120. margin-right: -4.5vw;
  121. flex: 0 0 auto;
  122. > h2 {
  123. font-size: 3.5vw;
  124. font-weight: bold;
  125. color: #000000;
  126. margin-bottom: 3.2vw;
  127. }
  128. > button {
  129. &.active {
  130. background: #fe726b;
  131. color: #fff;
  132. }
  133. background: #F4F4F4;
  134. border-radius: 0.5vw;
  135. padding: 2.5vw 4vw;
  136. font-size: 2.7vw;
  137. color: #333333;
  138. margin-right: 4.5vw;
  139. margin-bottom: 3.2vw;
  140. }
  141. }
  142. .card-list {
  143. flex: 1 0 1px;
  144. overflow: auto;
  145. > article {
  146. height: 29.6vw;
  147. background: #F7F8FA;
  148. box-shadow: 0vw 0.5vw 1.1vw 0vw rgba(109,128,166,0.29);
  149. border-radius: 1.1vw;
  150. overflow: hidden;
  151. margin-right: 1.1vw;
  152. margin-bottom: 5.6vw;
  153. display: flex;
  154. > .left {
  155. height: 100%;
  156. width: 21.3vw;
  157. flex: 0 1 auto;
  158. > img {
  159. width: 100%;
  160. height: 100%;
  161. object-fit: cover;
  162. border-radius: 1.1vw;
  163. }
  164. }
  165. > .right {
  166. flex: 0 1 auto;
  167. width: 69.7vw;
  168. padding: 2.2vw 2vw 2.7vw 2vw;
  169. > h3 {
  170. font-size: 3.7vw;
  171. color: #333333;
  172. line-height: 6.4vw;
  173. display: -webkit-box;
  174. -webkit-box-orient: vertical;
  175. -webkit-line-clamp: 2;
  176. overflow: hidden;
  177. margin-bottom: 3vw;
  178. }
  179. > ul.tags {
  180. margin-bottom: 5vw;
  181. > li.tag {
  182. border: 0.3vw solid #FE6E69;
  183. border-radius: 0.5vw;
  184. margin-right: 2.9vw;
  185. padding: 0.8vw 2vw;
  186. font-size: 2.7vw;
  187. color: #FE6E69;
  188. letter-spacing: 0.2em;
  189. }
  190. }
  191. > .bottom {
  192. display: flex;
  193. justify-content: space-between;
  194. align-items: center;
  195. font-size: 2.7vw;
  196. color: #333333;
  197. > .time {
  198. }
  199. > .view-count {
  200. display: flex;
  201. align-items: center;
  202. > img {
  203. width: 3.3vw;
  204. height: 2.5vw;
  205. margin-right: 0.9vw;
  206. }
  207. }
  208. }
  209. }
  210. }
  211. }
  212. }
  213. </style>