detail.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. <template>
  2. <div class="detail">
  3. <common-banner :img="bannerImg"></common-banner>
  4. <!-- 分类 -->
  5. <div class="tabList w1200">
  6. <div :class="['tab-item', currentTab == item.id ? 'active' : '' ]" v-for="(item, index) in tabList" :key="index" @click="handleClick(item)">
  7. {{item.title}}
  8. <span></span>
  9. </div>
  10. </div>
  11. <!-- 分类图 -->
  12. <div class="cate-img w1200">
  13. <img v-if="currenCate" :src="currenCate.cateImg" alt="" srcset="">
  14. </div>
  15. <!-- 分类信息 -->
  16. <div class="cate-main">
  17. <div class="cate-content w1200">
  18. <div class="cate-title">{{ currenCate.title }}</div>
  19. <div class="cate-des">{{ currenCate.desc }}</div>
  20. <div class="cate-product-list">
  21. <div class="product-item" v-for="(item, index) in currenCate.productList" :key="index">
  22. <div class="img-wrap"><img :src="item.productImg" alt="" srcset=""></div>
  23. <div class="title">{{ item.title }}</div>
  24. </div>
  25. </div>
  26. </div>
  27. </div>
  28. </div>
  29. </template>
  30. <script>
  31. import CommonBanner from '@/components/common/banner';
  32. import cateData from './data.js';
  33. export default {
  34. data() {
  35. return {
  36. currentTab: 1,
  37. currenCate: {},
  38. bannerImg: require('~/assets/images/products/product_banner.png'),
  39. cateImg: require('~/assets/images/products/cate_banner_01.png'),
  40. productImg: require('~/assets/images/goods/product_jc_01.jpg'),
  41. tabList: [
  42. {
  43. id: 1,
  44. title: '逻辑狗系列',
  45. },
  46. {
  47. id: 2,
  48. title: '春夏秋冬系列',
  49. },
  50. {
  51. id: 3,
  52. title: '聪明书系列',
  53. },
  54. {
  55. id: 4,
  56. title: '逻辑狗-入学准备系列',
  57. },
  58. {
  59. id: 5,
  60. title: '思维魔法我的pad-lvk系列',
  61. },
  62. {
  63. id: 6,
  64. title: '与克鲁德一起听说读系列',
  65. },
  66. {
  67. id: 7,
  68. title: '蚂蚁沙丘系列',
  69. },
  70. {
  71. id: 8,
  72. title: '中华小熊猫系列'
  73. }
  74. ]
  75. }
  76. },
  77. asyncData({isDev, route, store, env, params, query, req, res, redirect, error}) {
  78. const id = query.id;
  79. const data = cateData.find(item => item.id == id) || cateData[0];
  80. return {
  81. currentTab: id,
  82. currenCate: data,
  83. }
  84. },
  85. components: {
  86. CommonBanner
  87. },
  88. methods: {
  89. handleClick(item) {
  90. this.currentTab = item.id;
  91. }
  92. }
  93. }
  94. </script>
  95. <style lang="scss" scoped>
  96. .tabList {
  97. display: flex;
  98. justify-content: space-between;
  99. .tab-item {
  100. position: relative;
  101. margin: 21px 0 28px;
  102. font-size: 15px;
  103. font-family: PingFangSC-Regular, PingFang SC;
  104. font-weight: 400;
  105. color: #333333;
  106. &.active {
  107. font-size: 15px;
  108. font-family: PingFangSC-Semibold, PingFang SC;
  109. font-weight: 600;
  110. line-height: 21px;
  111. span {
  112. position: absolute;
  113. bottom: -6px;
  114. display: block;
  115. width: 39px;
  116. box-shadow: 0px 2px 4px 0px rgba(85, 141, 253, 0.4);
  117. }
  118. }
  119. &:hover {
  120. span {
  121. position: absolute;
  122. bottom: -6px;
  123. display: block;
  124. width: 39px;
  125. box-shadow: 0px 2px 4px 0px rgba(85, 141, 253, 0.4);
  126. }
  127. }
  128. span {
  129. width: 0px;
  130. height: 2px;
  131. background: #236AFA;
  132. border-radius: 20px;
  133. left: 0px;
  134. right: 0px;
  135. margin: 0 auto;
  136. transition: all .3s ease-in-out;
  137. }
  138. }
  139. }
  140. .cate-img {
  141. font-size: 0;
  142. img {
  143. width: 100%;
  144. }
  145. }
  146. .cate-main {
  147. margin-top: 80px;
  148. .cate-title {
  149. font-size: 34px;
  150. font-family: PingFangSC-Medium, PingFang SC;
  151. font-weight: 500;
  152. color: #333333;
  153. line-height: 48px;
  154. text-align: center;
  155. }
  156. .cate-des {
  157. margin-top: 14px;
  158. text-align: center;
  159. font-size: 16px;
  160. font-family: PingFangSC-Regular, PingFang SC;
  161. font-weight: 400;
  162. color: #646A7E;
  163. line-height: 24px;
  164. }
  165. .cate-product-list {
  166. margin-top: 40px;
  167. display: flex;
  168. flex-wrap: wrap;
  169. .product-item {
  170. margin: 0 22px 20px 0;
  171. width: 283px;
  172. height: 380px;
  173. background: #FFFFFF;
  174. box-shadow: 0px 2px 17px 0px rgba(208, 231, 253, 0.74);
  175. border-radius: 20px;
  176. text-align: center;
  177. transition: transform .3s ease-in-out;
  178. &:nth-child(4n) {
  179. margin-right: 0;
  180. }
  181. &:hover {
  182. transform: translate3d(0,-8px,0);
  183. }
  184. .title {
  185. margin-top: 36px;
  186. font-size: 16px;
  187. font-family: PingFangSC-Medium, PingFang SC;
  188. font-weight: 500;
  189. color: #333333;
  190. line-height: 22px;
  191. }
  192. }
  193. }
  194. .img-wrap {
  195. padding-top: 20px;
  196. font-size: 0;
  197. img {
  198. width: 240px;
  199. height: 263px;
  200. object-fit: cover;
  201. }
  202. }
  203. }
  204. </style>