detail.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  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. const id = item.id;
  91. this.currentTab = id;
  92. const data = cateData.find(item => item.id == id) || cateData[0];
  93. this.currenCate = data;
  94. console.log(this.cateData);
  95. }
  96. }
  97. }
  98. </script>
  99. <style lang="scss" scoped>
  100. .tabList {
  101. display: flex;
  102. justify-content: space-between;
  103. .tab-item {
  104. position: relative;
  105. margin: 21px 0 28px;
  106. font-size: 15px;
  107. font-family: PingFangSC-Regular, PingFang SC;
  108. font-weight: 400;
  109. color: #333333;
  110. &.active {
  111. font-size: 15px;
  112. font-family: PingFangSC-Semibold, PingFang SC;
  113. font-weight: 600;
  114. line-height: 21px;
  115. span {
  116. position: absolute;
  117. bottom: -6px;
  118. display: block;
  119. width: 39px;
  120. box-shadow: 0px 2px 4px 0px rgba(85, 141, 253, 0.4);
  121. }
  122. }
  123. &:hover {
  124. span {
  125. position: absolute;
  126. bottom: -6px;
  127. display: block;
  128. width: 39px;
  129. box-shadow: 0px 2px 4px 0px rgba(85, 141, 253, 0.4);
  130. }
  131. }
  132. span {
  133. width: 0px;
  134. height: 2px;
  135. background: #236AFA;
  136. border-radius: 20px;
  137. left: 0px;
  138. right: 0px;
  139. margin: 0 auto;
  140. transition: all .3s ease-in-out;
  141. }
  142. }
  143. }
  144. .cate-img {
  145. font-size: 0;
  146. img {
  147. width: 100%;
  148. }
  149. }
  150. .cate-main {
  151. margin: 80px 0;
  152. .cate-title {
  153. font-size: 34px;
  154. font-family: PingFangSC-Medium, PingFang SC;
  155. font-weight: 500;
  156. color: #333333;
  157. line-height: 48px;
  158. text-align: center;
  159. }
  160. .cate-des {
  161. margin-top: 14px;
  162. text-align: center;
  163. font-size: 16px;
  164. font-family: PingFangSC-Regular, PingFang SC;
  165. font-weight: 400;
  166. color: #646A7E;
  167. line-height: 24px;
  168. }
  169. .cate-product-list {
  170. margin-top: 40px;
  171. display: flex;
  172. flex-wrap: wrap;
  173. .product-item {
  174. margin: 0 22px 20px 0;
  175. width: 283px;
  176. height: 380px;
  177. background: #FFFFFF;
  178. box-shadow: 0px 2px 17px 0px rgba(208, 231, 253, 0.74);
  179. border-radius: 20px;
  180. text-align: center;
  181. transition: transform .3s ease-in-out;
  182. &:nth-child(4n) {
  183. margin-right: 0;
  184. }
  185. &:hover {
  186. transform: translate3d(0,-8px,0);
  187. }
  188. .title {
  189. margin-top: 36px;
  190. font-size: 16px;
  191. font-family: PingFangSC-Medium, PingFang SC;
  192. font-weight: 500;
  193. color: #333333;
  194. line-height: 22px;
  195. }
  196. }
  197. }
  198. .img-wrap {
  199. padding-top: 20px;
  200. font-size: 0;
  201. img {
  202. width: 240px;
  203. height: 263px;
  204. object-fit: cover;
  205. }
  206. }
  207. }
  208. </style>