detail.vue 5.6 KB

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