SldHomeTopSearch.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641
  1. <template>
  2. <div class="sld_home_top">
  3. <div class="sld_home_top_search container">
  4. <div class="ld sld_home_top_search_left">
  5. <a href="javascript:void(0)" class="sld_logo_wrap flex_row_start_center" @click="go_home">
  6. <img :src="filtersStore.getSiteLogo" />
  7. </a>
  8. </div>
  9. <div class="sld_seach_wrap">
  10. <div class="sld_seach_box ld">
  11. <div class="form" @submit.prevent>
  12. <el-popover
  13. class="box-item"
  14. placement="bottom-start"
  15. width="536px"
  16. :visible="visible"
  17. :show-arrow="false"
  18. :offset="2"
  19. >
  20. <HotList></HotList>
  21. <template #reference>
  22. <input
  23. v-model="keyword"
  24. type="text"
  25. class="text"
  26. autocomplete="off"
  27. :placeholder="L['请输入关键词']"
  28. @keyup.enter="search"
  29. ref="searchInput"
  30. @focus="visible = true"
  31. @input="inputChange"
  32. @blur="visible = false"
  33. />
  34. </template>
  35. </el-popover>
  36. <input type="submit" :value="L['搜索']" class="button" @click="search" />
  37. </div>
  38. </div>
  39. <!-- <div class="search_association">
  40. <div
  41. class="s_a_item"
  42. v-for="(item, index) in SAList"
  43. @mousedown="quickSearch(item.wordsContent, 'associ')"
  44. >
  45. <div>{{ item.wordsContent }}</div>
  46. <div>{{ item.searchGoodsNum }} {{L['个商品']}}</div>
  47. </div>
  48. </div> -->
  49. </div>
  50. <div v-if="searchBarFixed" class="container_header">
  51. <div class="container_header_box flex_row_start_center">
  52. <div class="sld_cart_wrap fixed_sld_cart_wrap">
  53. <nuxt-link tag="a" class="sld_logo_wrap flex_row_start_center" :to="`/`">
  54. <img :src="filtersStore.getSiteLogo" />
  55. </nuxt-link>
  56. </div>
  57. <div class="sld_seach_wrap">
  58. <div class="sld_seach_box ld">
  59. <div class="form">
  60. <input
  61. v-model="keyword"
  62. type="text"
  63. class="text"
  64. autocomplete="off"
  65. style="color: rgb(153, 153, 153)"
  66. :placeholder="L['请输入关键词']"
  67. ref="searchInput"
  68. @focus="inputFocus"
  69. />
  70. <input type=" submit" :value="L['搜索']" class="button" @click="search" />
  71. </div>
  72. </div>
  73. </div>
  74. <div class="sld_cart_wrap">
  75. <dl class>
  76. <dt
  77. class="ld cart_icon_text_wrap"
  78. >
  79. <img src="/email.svg" />
  80. <nuxt-link target="_self" :to="`/home/contact`">{{
  81. L["询价"]
  82. }}</nuxt-link>
  83. </dt>
  84. </dl>
  85. </div>
  86. </div>
  87. </div>
  88. <div class="sld_cart_wrap">
  89. <dl class>
  90. <nuxt-link target="_self" :to="`/home/contact`">
  91. <dt
  92. class="ld cart_icon_text_wrap"
  93. >
  94. <img src="/email.svg" />
  95. <span>{{ L["询价"] }}</span>
  96. </dt>
  97. </nuxt-link>
  98. </dl>
  99. </div>
  100. </div>
  101. </div>
  102. </template>
  103. <script setup>
  104. // import { lang_zn } from "@/assets/language/zh.js";
  105. import { getCurLanguage } from '@/composables/common.js';
  106. import { useFiltersStore } from '@/store/filter.js'
  107. import {ref} from "vue";
  108. const filtersStore = useFiltersStore()
  109. // const L = lang_zn;
  110. const L = getCurLanguage();
  111. const { proxy } = getCurrentInstance();
  112. const searchBarFixed = ref(false);
  113. const SAList = ref([]);
  114. const SAShow = ref(false);
  115. const router = useRouter();
  116. const route = useRoute();
  117. const visible = ref(false)
  118. const keyword = ref(calcMallUrlKeyword(route.path))
  119. const go_home = () => {
  120. window.location.href="/"
  121. };
  122. //搜索事件
  123. const search = () => {
  124. // searchInput.value.style.color = "rgb(153,153,153)";
  125. if (keyword.value) {
  126. router.push({
  127. path: `/goods/list/search_keyword-`+keyword.value,
  128. });
  129. }
  130. };
  131. const searchAssociation = (input) => {
  132. get("v3/goods/front/goods/searchWords/list", {
  133. keyWord: input,
  134. }).then((res) => {
  135. if (res.state == 200) {
  136. SAList.value = res.data;
  137. }
  138. });
  139. };
  140. const inputChange = (e) => {
  141. let input = e.target.value.trim();
  142. // SAShow.value = true;
  143. // if (input) {
  144. // searchAssociation(input);
  145. // } else {
  146. // SAList.value = [];
  147. // }
  148. };
  149. const inputFocus = () => {
  150. // searchInput.value.style.color = "#333";
  151. // SAShow.value = true;
  152. // if (keyword.value && SAList.value.length == 0) {
  153. // searchAssociation(keyword.value);
  154. // }
  155. };
  156. const inputBlur = () => {
  157. SAShow.value = false;
  158. };
  159. //滚动事件
  160. if (process.client) {
  161. const handleScroll = () => {
  162. var height = 600;
  163. var scrollTop =
  164. window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop;
  165. if (scrollTop > height) {
  166. searchBarFixed.value = true;
  167. } else {
  168. searchBarFixed.value = false;
  169. }
  170. };
  171. window.addEventListener("scroll", handleScroll);
  172. }
  173. </script>
  174. <style lang="scss" scoped>
  175. a:active,
  176. a:visited {
  177. color: #333;
  178. }
  179. .sld_home_top {
  180. width: 100%;
  181. background: #F6F8FA;
  182. // border-bottom: 1px solid #dbdbdb;
  183. }
  184. .sld_home_top_search {
  185. height: 80px;
  186. position: relative;
  187. z-index: 12;
  188. width: 1440px;
  189. margin: 0 auto;
  190. display: flex;
  191. align-items: center;
  192. .container_header {
  193. width: 100%;
  194. position: fixed;
  195. background-color: #F6F8FA;
  196. left: 0;
  197. right: 0;
  198. top: 0;
  199. z-index: 999;
  200. border-bottom: 2px solid $colorMain;
  201. .sld_seach_wrap,
  202. .sld_cart_wrap {
  203. margin: 5px;
  204. position: relative;
  205. }
  206. .container_header_box {
  207. width: 1440px;
  208. margin: 0 auto;
  209. display: flex;
  210. align-items: center;
  211. >div:last-child{
  212. width: 210px;
  213. }
  214. .fixed_sld_cart_wrap {
  215. // margin-right: 120px;
  216. a {
  217. width: 100%;
  218. height: 100%;
  219. img {
  220. width: 100%;
  221. height: 100%;
  222. object-fit: cover;
  223. }
  224. }
  225. }
  226. }
  227. }
  228. .container_header {
  229. -webkit-animation: searchTop 0.5s ease-in-out;
  230. animation: searchTop 0.5s ease-in-out;
  231. }
  232. @-webkit-keyframes searchTop {
  233. 0% {
  234. top: -50px;
  235. }
  236. to {
  237. top: 0;
  238. }
  239. }
  240. @keyframes searchTop {
  241. 0% {
  242. top: -50px;
  243. }
  244. to {
  245. top: 0;
  246. }
  247. }
  248. &:before {
  249. display: table;
  250. content: " ";
  251. }
  252. .sld_home_top_search_left {
  253. height: 100%;
  254. // flex:0 0 200px;
  255. // position: absolute;
  256. // left: 240px;
  257. width: 200px;
  258. .sld_logo_wrap {
  259. height: 100%;
  260. img {
  261. width: 100%;
  262. height: 100%;
  263. object-fit: cover;
  264. }
  265. }
  266. }
  267. .sld_seach_wrap {
  268. // width: 536px;
  269. display: flex;
  270. justify-content: center;
  271. align-items: center;
  272. flex: 1;
  273. width: 100%;
  274. overflow: hidden;
  275. padding: 4px 20px;
  276. position: relative;
  277. .sld_seach_box {
  278. width: 536px;
  279. z-index: 11;
  280. height: 38px;
  281. border: 2px solid $colorMain;
  282. .form {
  283. // background-color: $colorMain;
  284. // height: 34px;
  285. height: 100%;
  286. overflow: hidden;
  287. .text {
  288. height: 36px;
  289. background-color: #fff;
  290. width: calc(100% - 103px);
  291. -webkit-appearance: none;
  292. -webkit-border-radius: 0;
  293. height: 34px;
  294. color: rgb(153, 153, 153);
  295. padding: 5px 5px 5px 10px;
  296. background-position: 0 -360px;
  297. background-color: #fff;
  298. background-repeat: repeat-x;
  299. line-height: 20px;
  300. font-family: arial, "\5b8b\4f53";
  301. font-size: 12px;
  302. outline: none;
  303. border: none;
  304. }
  305. input {
  306. margin: 0;
  307. padding: 0;
  308. height: 34px;
  309. border: 0;
  310. }
  311. input::placeholder {
  312. font-size: $fontE;
  313. /*font-family: Microsoft YaHei;*/
  314. font-weight: 400;
  315. color: rgba(40,46,48,0.6);
  316. }
  317. ::-webkit-input-placeholder {
  318. margin-left: 20px;
  319. font-size: $fontE;
  320. /*font-family: Microsoft YaHei;*/
  321. font-weight: 400;
  322. color: rgba(40,46,48,0.6);
  323. }
  324. /* 使用webkit内核的浏览器 */
  325. :-moz-placeholder {
  326. font-size: $fontE;
  327. /*font-family: Microsoft YaHei;*/
  328. font-weight: 400;
  329. color: rgba(40,46,48,0.6);
  330. }
  331. /* Firefox版本19+ */
  332. :-ms-input-placeholder {
  333. font-size: $fontE;
  334. /*font-family: Microsoft YaHei;*/
  335. font-weight: 400;
  336. color: rgba(40,46,48,0.6);
  337. }
  338. /* IE浏览器 */
  339. .button {
  340. width: 103px;
  341. background: $colorMain;
  342. font-size: $fontE;
  343. font-weight: 600;
  344. height: 100%;
  345. color: #fff;
  346. float: right;
  347. cursor: pointer;
  348. text-align: center;
  349. }
  350. }
  351. }
  352. .search_association {
  353. background: #fff;
  354. position: absolute;
  355. top: 43px;
  356. overflow: hidden;
  357. position: absolute;
  358. left: 0;
  359. width: 580px;
  360. border: 1px solid #ccc;
  361. background: #fff;
  362. z-index: 99;
  363. .s_a_item {
  364. display: flex;
  365. justify-content: space-between;
  366. overflow: hidden;
  367. padding: 1px 5px;
  368. line-height: 24px;
  369. cursor: pointer;
  370. font-size: 12px;
  371. -webkit-font-smoothing: antialiased;
  372. color: #666;
  373. div:first-child {
  374. width: 250px;
  375. white-space: nowrap;
  376. text-overflow: ellipsis;
  377. overflow: hidden;
  378. }
  379. div:last-child {
  380. overflow: hidden;
  381. color: #aaa;
  382. }
  383. &:hover {
  384. background-color: rgb(255, 233, 188);
  385. }
  386. }
  387. }
  388. }
  389. }
  390. .sld_cart_wrap {
  391. // position: absolute;
  392. // right: 240px;
  393. z-index: 99;
  394. height: 40px;
  395. width: 210px;
  396. text-align: center;
  397. dl {
  398. margin-bottom: 0px;
  399. .cart_goods_num {
  400. font: 11px/16px Verdana;
  401. color: #fff;
  402. background: $colorMain;
  403. text-align: center;
  404. display: inline-block;
  405. height: 16px;
  406. min-width: 16px;
  407. border: none 0;
  408. border-radius: 8px;
  409. margin-left: 10px;
  410. }
  411. dt {
  412. // position: absolute;
  413. z-index: 3;
  414. width: 100%;
  415. height: 38px;
  416. cursor: pointer;
  417. font-weight: 400;
  418. line-height: 38px;
  419. padding: 0;
  420. color: $colorMain;
  421. font-size: 15px;
  422. img {
  423. margin: -2px 11px 0 0px;
  424. vertical-align: middle;
  425. width: 20px;
  426. }
  427. &.cart_icon_text_wrap {
  428. background-color: #fff;
  429. a {
  430. color: $colorMain;
  431. font-weight: bold;
  432. font-size: 15px;
  433. line-height: 36px;
  434. }
  435. span {
  436. font-weight: bold;
  437. font-size: $fontE;
  438. color: $colorMain;
  439. }
  440. }
  441. }
  442. dd {
  443. .cart_goods {
  444. dl {
  445. padding-top: 8px;
  446. }
  447. dd {
  448. &.cart_goods_price {
  449. position: static;
  450. em {
  451. margin-right: 6px;
  452. width: auto;
  453. color: #666;
  454. &:nth-child(1) {
  455. display: block;
  456. font-weight: 600;
  457. }
  458. &:nth-child(2) {
  459. display: block;
  460. text-align: right;
  461. margin-top: 6px;
  462. }
  463. }
  464. }
  465. }
  466. }
  467. }
  468. }
  469. dd {
  470. position: absolute;
  471. top: 37px;
  472. right: 0;
  473. width: 355px;
  474. border: 1px solid #e3e3e3;
  475. background: #fff;
  476. z-index: 1;
  477. }
  478. }
  479. .ld {
  480. position: relative;
  481. zoom: 1;
  482. }
  483. .cart_data {
  484. height: 300px;
  485. display: flex;
  486. flex-direction: column;
  487. position: relative;
  488. .cart_data_title {
  489. font-weight: 600;
  490. float: left;
  491. padding: 7px;
  492. line-height: 32px;
  493. height: 32px;
  494. }
  495. .cart_list {
  496. padding: 20px;
  497. overflow-y: scroll;
  498. .cart_list_pre {
  499. margin-bottom: 20px;
  500. .cart_pre_left {
  501. .cart_pre_img {
  502. width: 48px;
  503. height: 48px;
  504. border: 1px solid #e3e3e3;
  505. cursor: pointer;
  506. img {
  507. width: 100%;
  508. height: 100%;
  509. }
  510. }
  511. .cart_pre_cen {
  512. width: 150px;
  513. margin-left: 20px;
  514. cursor: pointer;
  515. .cart_pre_name {
  516. word-break: break-all;
  517. text-overflow: ellipsis;
  518. display: -webkit-box;
  519. -webkit-box-orient: vertical;
  520. -webkit-line-clamp: 2;
  521. overflow: hidden;
  522. }
  523. .cart_pre_spec {
  524. overflow: hidden;
  525. text-overflow: ellipsis;
  526. white-space: nowrap;
  527. margin-top: 5px;
  528. }
  529. }
  530. }
  531. .cart_pre_right {
  532. .cart_pre_price {
  533. color: #666;
  534. }
  535. .cart_pre_del {
  536. color: #666;
  537. cursor: pointer;
  538. margin-top: 10px;
  539. &:hover {
  540. color: $colorMain;
  541. }
  542. }
  543. }
  544. }
  545. }
  546. .cart_bottom {
  547. width: 100%;
  548. height: 44px;
  549. border: 1px solid #e3e3e3;
  550. .cart_bottom_left {
  551. padding-left: 11px;
  552. height: 44px;
  553. span {
  554. color: #666;
  555. &:nth-child(2) {
  556. margin-left: 5px;
  557. }
  558. }
  559. }
  560. .cart_bottom_right {
  561. width: 110px;
  562. height: 44px;
  563. text-align: center;
  564. color: #fff;
  565. line-height: 44px;
  566. cursor: pointer;
  567. }
  568. }
  569. }
  570. </style>