GoodsListCate3.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536
  1. <template>
  2. <div>
  3. <div class="goods_list_cate3 clearfix">
  4. <template v-if="categoryid">
  5. <div
  6. class="sld_goods_recommend"
  7. v-if="recomData.data != undefined && recomData.data.length"
  8. >
  9. <h3 class="fl">{{ L["热门推荐"] }}</h3>
  10. <ul class="fl">
  11. <li
  12. class="fl"
  13. v-for="(
  14. { goodsName, goodsImage, goodsPrice, defaultProductId,goodsMoney }, index
  15. ) in recomData.data"
  16. :key="index"
  17. >
  18. <nuxt-link
  19. target="_blank"
  20. :to="'/goods/detail/'+ calcProductName(goodsName) +'_'+ defaultProductId"
  21. class="sld_img"
  22. >
  23. <CoverImage :src="goodsImage" width="100" height="100"></CoverImage>
  24. </nuxt-link>
  25. <div class="sld_hot_goods">
  26. <div class="sld_h32_hide">
  27. <router-link
  28. target="_blank"
  29. :to="'/goods/detail/'+ calcProductName(goodsName) +'_'+ defaultProductId"
  30. class="sld_goods_name"
  31. >
  32. {{ goodsName }}
  33. </router-link>
  34. </div>
  35. <p class="sld_goods_price">
  36. <em>{{ goodsMoney == null ? '面议' : goodsMoney}}</em>
  37. </p>
  38. <router-link
  39. target="_blank"
  40. :to="'/goods/detail/'+ calcProductName(goodsName) +'_'+ defaultProductId"
  41. class="btn"
  42. >
  43. {{L['了解更多']}}
  44. </router-link>
  45. </div>
  46. </li>
  47. </ul>
  48. </div>
  49. <div
  50. class="sld_brand sld_show clearfix"
  51. v-if="
  52. brandData.data.brandList != undefined &&
  53. brandData.data.brandList.length &&
  54. brandFlag
  55. "
  56. >
  57. <p class="sld_gleft">{{L['品牌']}}</p>
  58. <ul class="sld_gright">
  59. <li
  60. class="sld_brand_item"
  61. v-for="(item, index) in brandData.data.brandList"
  62. :key="index"
  63. :title="item.brandName"
  64. >
  65. <a @click="brandOption(item.brandId, item.brandName)">
  66. <span :style="`background-image:url('` + item.image + `');`"></span>
  67. </a>
  68. </li>
  69. </ul>
  70. </div>
  71. <ul
  72. class="sld_cat sld_show"
  73. v-if="
  74. brandData.data.categoryList != undefined && brandData.data.categoryList.length
  75. "
  76. >
  77. <div class="clearfix sld_cat_item">
  78. <p class="sld_gleft">{{L['分类']}}</p>
  79. <ul class="sld_gright">
  80. <li v-for="(item, index) in brandData.data.categoryList" :key="index">
  81. <Nuxt-link :to="'/goods/list/'+ calcProductName(item.categoryName) +'_v-'+ item.categoryId + '_gid-3_pid-' + pid" >
  82. {{ item.categoryName }}
  83. </Nuxt-link>
  84. </li>
  85. </ul>
  86. </div>
  87. </ul>
  88. <ul
  89. class="sld_cat sld_show"
  90. v-if="
  91. brandData.data.attributeList != undefined &&
  92. brandData.data.attributeList.length
  93. "
  94. >
  95. <template
  96. :key="index"
  97. v-for="(
  98. { attributeName, attributeValueList, attributeId, isShow }, index
  99. ) in brandData.data.attributeList"
  100. >
  101. <div
  102. v-if="isShow"
  103. :class="{
  104. clearfix: true,
  105. sld_cat_item: true,
  106. sld_cat_item_open: isOpen,
  107. sld_cat_item_hide: !isOpen,
  108. }"
  109. >
  110. <div>
  111. <p class="sld_gleft">{{ attributeName }}</p>
  112. <ul class="sld_gright">
  113. <li v-for="(item, aindex) in attributeValueList" :key="aindex">
  114. <a
  115. @click="
  116. attri(
  117. attributeName,
  118. item.attributeValue,
  119. attributeId,
  120. item.valueId
  121. )
  122. "
  123. >
  124. {{ item.attributeValue }}
  125. </a>
  126. </li>
  127. </ul>
  128. </div>
  129. </div>
  130. </template>
  131. </ul>
  132. <a
  133. :class="{ sld_more_bo: true, on: showFlag }"
  134. @click="showMore"
  135. v-if="
  136. brandData.data.attributeList != undefined &&
  137. brandData.data.attributeList.length > 1 &&
  138. brandData.unshowNum
  139. "
  140. >
  141. <span style="cursor: pointer">{{ showFlag ? L["收起"] : L["更多选项"] }}</span>
  142. <i class="iconfont"></i>
  143. </a>
  144. </template>
  145. </div>
  146. </div>
  147. </template>
  148. <script setup>
  149. // import { lang_zn } from "@/assets/language/zh";
  150. import { getCurLanguage } from '@/composables/common.js';
  151. // const L = lang_zn;
  152. const L = getCurLanguage();
  153. const props = defineProps(["categoryid","pid"]);
  154. const emit = defineEmits(["attriOption","brandOption"])
  155. const { proxy } = getCurrentInstance();
  156. const brandData = reactive({ data: [], unshowNum: 0 });
  157. const showFlag = ref(false);
  158. const recomData = reactive({ data: [] });
  159. const isOpen = ref(false);
  160. const route = useRoute();
  161. const pid = ref(props.pid);
  162. const params = reactive({
  163. categoryId: props.categoryid,
  164. });
  165. const brandFlag = ref(true);
  166. watch(
  167. () => props.categoryid,
  168. (nv, ov) => {
  169. if (nv != ov) {
  170. params.categoryId = nv;
  171. getInitData(params);
  172. }
  173. }
  174. );
  175. const getInitData = async (params) => {
  176. get("v3/goods/front/goods/category/screenList", params).then((res) => {
  177. if (res.state == 200) {
  178. brandData.data = res.data;
  179. brandData.unshowNum =
  180. res.data.attributeList.length > 2 ? res.data.attributeList.length - 2 : 0;
  181. brandData.data.attributeList.map((item) => {
  182. item.isShow = true;
  183. });
  184. }
  185. });
  186. let recomm = {
  187. queryType: "hot",
  188. categoryId3: props.categoryid,
  189. };
  190. // const {data:value} = await useFetch(apiUrl + 'v3/goods/front/goods/recommendList',{params:recomm,key: props.categoryid})
  191. // const res = value._rawValue
  192. // if (res.state === 200) {
  193. // recomData.data = res.data.list;
  194. // }
  195. get("v3/goods/front/goods/recommendList", recomm).then((res) => {
  196. if (res.state === 200) {
  197. recomData.data = res.data.list;
  198. }
  199. });
  200. };
  201. const attri = (attributeName, attributeValue, attributeId, attributeValueId) => {
  202. attrSorH(attributeId);
  203. emit("attriOption", attributeName, attributeValue, attributeId, attributeValueId);
  204. };
  205. const brandOption = (brandId, brandName) => {
  206. brandSorH();
  207. emit("brandOption", brandId, brandName);
  208. };
  209. const showMore = () => {
  210. isOpen.value = !isOpen.value;
  211. showFlag.value = !showFlag.value;
  212. };
  213. const brandSorH = () => {
  214. brandFlag.value = !brandFlag.value;
  215. };
  216. const attrSorH = (attributeId) => {
  217. let item = brandData.data.attributeList.find((item) => item.attributeId == attributeId);
  218. item.isShow = !item.isShow;
  219. let num = 0;
  220. brandData.data.attributeList.forEach((item) => {
  221. if (item.isShow) {
  222. num++;
  223. }
  224. });
  225. brandData.unshowNum = num > 2 ? num - 2 : 0;
  226. };
  227. defineExpose({attrSorH,brandSorH})
  228. getInitData(params);
  229. </script>
  230. <style lang="scss">
  231. @import "@/assets/style/theme.scss";
  232. .clearfix {
  233. display: block;
  234. zoom: 1;
  235. &:after {
  236. content: "";
  237. display: block;
  238. height: 0;
  239. clear: both;
  240. visibility: hidden;
  241. }
  242. }
  243. ul,
  244. ol,
  245. li {
  246. list-style: none;
  247. }
  248. .fr {
  249. float: right;
  250. }
  251. .fl {
  252. float: left;
  253. }
  254. a,
  255. a:visited {
  256. color: #333333;
  257. }
  258. .sld_goods_recommend {
  259. width: 100%;
  260. height: 150px;
  261. margin-bottom: 30px;
  262. background-color: #f1f1f1;
  263. overflow: hidden;
  264. display: flex;
  265. h3 {
  266. width: 40px;
  267. height: 170px;
  268. background-color: $colorMain;
  269. font-size: 16px;
  270. font-weight: 600;
  271. color: #fff;
  272. line-height: 40px;
  273. writing-mode: vertical-lr;
  274. text-align: center;
  275. letter-spacing: 10px;
  276. /*font-family: MicrosoftYaHei-Bold;*/
  277. }
  278. ul {
  279. display: flex;
  280. padding: 14px 0 20px 11px;
  281. }
  282. li {
  283. width: 276px;
  284. height: 120px;
  285. background-color: #fff;
  286. margin-right: 12px;
  287. a.btn {
  288. margin-top: 7px;
  289. font: 12px/150% , Arial, Verdana, "\5b8b\4f53";
  290. color: #333333;
  291. display: block;
  292. width: 72px;
  293. height: 25px;
  294. border-radius: 2px;
  295. text-align: center;
  296. line-height: 25px;
  297. font-size: 12px;
  298. color: #fff;
  299. cursor: pointer;
  300. background-color: $colorMain;
  301. }
  302. }
  303. .sld_img {
  304. float: left;
  305. height: 100px;
  306. margin-top: 11px;
  307. margin-left: 11px;
  308. width: 100px;
  309. img {
  310. width: 100px;
  311. height: 100px;
  312. }
  313. }
  314. .sld_hot_goods {
  315. float: left;
  316. width: 144px;
  317. box-sizing: border-box;
  318. padding: 12px;
  319. }
  320. .sld_h32_hide {
  321. height: 40px;
  322. overflow: hidden;
  323. text-overflow: ellipsis;
  324. }
  325. .sld_goods_price {
  326. color: $colorMain2;
  327. font-size: 15px;
  328. font-weight: bold;
  329. margin-top: 6px;
  330. overflow: hidden;
  331. white-space: nowrap;
  332. text-overflow: ellipsis;
  333. em {
  334. font-style: normal;
  335. }
  336. }
  337. .sld_goods_name {
  338. font-size: 12px;
  339. color: #666;
  340. line-height: 20px;
  341. overflow: hidden;
  342. text-overflow: ellipsis;
  343. display: -webkit-box;
  344. -webkit-line-clamp: 2;
  345. line-clamp: 2;
  346. -webkit-box-orient: vertical;
  347. &:hover{
  348. color: #00985e;
  349. }
  350. }
  351. }
  352. .goods_list_cate3 {
  353. position: relative;
  354. margin-bottom: 43px;
  355. color: #606060;
  356. font-size: 12px;
  357. /*font-family: MicrosoftYaHei !important;*/
  358. .sld_brand {
  359. position: relative;
  360. border: 1px solid #d7d7d7;
  361. .sld_gleft {
  362. position: absolute;
  363. top: 0;
  364. left: 0;
  365. bottom: 0;
  366. width: 120px;
  367. padding: 12px 0 0 17px;
  368. background-color: #f9f9f9;
  369. }
  370. .sld_gright {
  371. overflow: hidden;
  372. width: 850px;
  373. /* border: 1px solid #E1E1E1; */
  374. border-bottom: none;
  375. border-right: none;
  376. float: left;
  377. margin: 10px 0 10px 144px;
  378. background-color: #fff;
  379. }
  380. .sld_brand_item {
  381. margin-right: 10px;
  382. margin-bottom: 5px;
  383. padding: 5px;
  384. cursor: pointer;
  385. span {
  386. display: inline-block;
  387. width: 102px;
  388. height: 36px;
  389. background-position: center;
  390. background-size: contain;
  391. background-repeat: no-repeat;
  392. }
  393. }
  394. ul li {
  395. float: left;
  396. width: 112px;
  397. height: 48px;
  398. border: 1px solid #e1e1e1;
  399. }
  400. li:hover {
  401. border: 1px solid $colorMain;
  402. }
  403. li img {
  404. width: 100%;
  405. height: 100%;
  406. border: 0;
  407. }
  408. }
  409. .sld_cat {
  410. border: 1px solid #cbcbcb;
  411. border-bottom: none;
  412. margin-top: -1px;
  413. .sld_cat_item {
  414. position: relative;
  415. border-bottom: 1px solid #cbcbcb;
  416. padding-right: 150px;
  417. .sld_gleft {
  418. position: absolute;
  419. top: 0;
  420. left: 0;
  421. bottom: 0;
  422. width: 120px;
  423. padding: 14px 0 0 17px;
  424. background-color: #f9f9f9;
  425. }
  426. .sld_gright {
  427. float: left;
  428. margin: 10px 0 10px 144px;
  429. background-color: #fff;
  430. }
  431. li a {
  432. color: #666;
  433. cursor: pointer;
  434. &:hover {
  435. color: $colorMain;
  436. }
  437. }
  438. li {
  439. float: left;
  440. margin-right: 40px;
  441. line-height: 23px;
  442. }
  443. }
  444. .sld_cat_item_open:not(:nth-child(1)):not(:nth-child(2)) {
  445. display: block;
  446. }
  447. .sld_cat_item_hide:not(:nth-child(1)):not(:nth-child(2)) {
  448. display: none;
  449. }
  450. }
  451. .sld_more_bo {
  452. position: absolute;
  453. bottom: -23px;
  454. left: 50%;
  455. width: 120px;
  456. height: 24px;
  457. line-height: 24px;
  458. color: #666;
  459. -webkit-transform: translateX(-50%);
  460. -moz-transform: translateX(-50%);
  461. -ms-transform: translateX(-50%);
  462. -o-transform: translateX(-50%);
  463. transform: translateX(-50%);
  464. text-align: center;
  465. background-color: #fff;
  466. border: 1px solid #d7d7d7;
  467. border-top: none;
  468. i {
  469. display: inline-block;
  470. vertical-align: middle;
  471. font-size: 12px;
  472. transition: all 0.3s;
  473. }
  474. &:hover {
  475. color: $colorMain;
  476. text-decoration: none;
  477. }
  478. }
  479. .sld_more_bo.on {
  480. i {
  481. -webkit-transform: rotate(-180deg);
  482. -moz-transform: rotate(-180deg);
  483. -ms-transform: rotate(-180deg);
  484. -o-transform: rotate(-180deg);
  485. transform: rotate(-180deg);
  486. }
  487. }
  488. }
  489. </style>