detail.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  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" @click="navPage(item)">
  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. navPage(item) {
  102. window.open(item.linkUrl);
  103. }
  104. }
  105. }
  106. </script>
  107. <style lang="scss" scoped>
  108. .cate-banner {
  109. width: 100%;
  110. background: #0D5CFA;
  111. font-size: 0;
  112. text-align: center;
  113. img {
  114. width: 1325px;
  115. height: 521px;
  116. }
  117. }
  118. .tabList {
  119. display: flex;
  120. justify-content: space-between;
  121. .tab-item {
  122. position: relative;
  123. margin: 21px 0 28px;
  124. font-size: 15px;
  125. font-family: PingFangSC-Regular, PingFang SC;
  126. font-weight: 400;
  127. color: #333333;
  128. &.active {
  129. font-size: 15px;
  130. font-family: PingFangSC-Semibold, PingFang SC;
  131. font-weight: 600;
  132. line-height: 21px;
  133. span {
  134. position: absolute;
  135. bottom: -6px;
  136. display: block;
  137. width: 39px;
  138. box-shadow: 0px 2px 4px 0px rgba(85, 141, 253, 0.4);
  139. }
  140. }
  141. &:hover {
  142. span {
  143. position: absolute;
  144. bottom: -6px;
  145. display: block;
  146. width: 39px;
  147. box-shadow: 0px 2px 4px 0px rgba(85, 141, 253, 0.4);
  148. }
  149. }
  150. span {
  151. width: 0px;
  152. height: 2px;
  153. background: #236AFA;
  154. border-radius: 20px;
  155. left: 0px;
  156. right: 0px;
  157. margin: 0 auto;
  158. transition: all .3s ease-in-out;
  159. }
  160. }
  161. }
  162. .cate-img {
  163. font-size: 0;
  164. img {
  165. width: 100%;
  166. }
  167. }
  168. .cate-main {
  169. margin: 80px 0;
  170. .cate-title {
  171. font-size: 34px;
  172. font-family: PingFangSC-Medium, PingFang SC;
  173. font-weight: 500;
  174. color: #333333;
  175. line-height: 48px;
  176. text-align: center;
  177. }
  178. .cate-des {
  179. margin-top: 14px;
  180. text-align: center;
  181. font-size: 16px;
  182. font-family: PingFangSC-Regular, PingFang SC;
  183. font-weight: 400;
  184. color: #646A7E;
  185. line-height: 24px;
  186. }
  187. .cate-product-list {
  188. margin-top: 40px;
  189. display: flex;
  190. flex-wrap: wrap;
  191. .product-item {
  192. margin: 0 22px 20px 0;
  193. width: 283px;
  194. height: 380px;
  195. background: #FFFFFF;
  196. box-shadow: 0px 2px 17px 0px rgba(208, 231, 253, 0.74);
  197. border-radius: 20px;
  198. text-align: center;
  199. transition: transform .3s ease-in-out;
  200. &:nth-child(4n) {
  201. margin-right: 0;
  202. }
  203. &:hover {
  204. transform: translate3d(0,-8px,0);
  205. }
  206. .title {
  207. margin-top: 36px;
  208. font-size: 16px;
  209. font-family: PingFangSC-Medium, PingFang SC;
  210. font-weight: 500;
  211. color: #333333;
  212. line-height: 22px;
  213. padding: 0 18px;
  214. overflow: hidden;
  215. text-overflow: ellipsis;
  216. white-space: nowrap;
  217. }
  218. }
  219. }
  220. .img-wrap {
  221. padding-top: 20px;
  222. font-size: 0;
  223. img {
  224. width: 240px;
  225. height: 263px;
  226. object-fit: cover;
  227. }
  228. }
  229. }
  230. </style>