detail.vue 5.3 KB

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