SldHomeTopSearch.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635
  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" style="margin-right: 90px">
  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: #fff;
  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: 1200px;
  208. margin: 0 auto;
  209. >div:last-child{
  210. width: 400px;
  211. }
  212. .fixed_sld_cart_wrap {
  213. margin-right: 120px;
  214. a {
  215. width: 100%;
  216. height: 100%;
  217. img {
  218. max-width: 100%;
  219. max-height: 100%;
  220. }
  221. }
  222. }
  223. }
  224. }
  225. .container_header {
  226. -webkit-animation: searchTop 0.5s ease-in-out;
  227. animation: searchTop 0.5s ease-in-out;
  228. }
  229. @-webkit-keyframes searchTop {
  230. 0% {
  231. top: -50px;
  232. }
  233. to {
  234. top: 0;
  235. }
  236. }
  237. @keyframes searchTop {
  238. 0% {
  239. top: -50px;
  240. }
  241. to {
  242. top: 0;
  243. }
  244. }
  245. &:before {
  246. display: table;
  247. content: " ";
  248. }
  249. .sld_home_top_search_left {
  250. height: 100%;
  251. // flex:0 0 200px;
  252. // position: absolute;
  253. // left: 240px;
  254. width: 200px;
  255. .sld_logo_wrap {
  256. height: 100%;
  257. img {
  258. width: 100%;
  259. height: 100%;
  260. object-fit: cover;
  261. }
  262. }
  263. }
  264. .sld_seach_wrap {
  265. // width: 536px;
  266. display: flex;
  267. justify-content: center;
  268. align-items: center;
  269. flex: 1;
  270. width: 100%;
  271. overflow: hidden;
  272. padding: 4px 20px;
  273. position: relative;
  274. .sld_seach_box {
  275. width: 536px;
  276. z-index: 11;
  277. height: 38px;
  278. border: 2px solid $colorMain;
  279. .form {
  280. background-color: $colorMain;
  281. height: 34px;
  282. overflow: hidden;
  283. .text {
  284. height: 36px;
  285. background-color: #fff;
  286. width: calc(100% - 103px);
  287. -webkit-appearance: none;
  288. -webkit-border-radius: 0;
  289. height: 34px;
  290. color: rgb(153, 153, 153);
  291. padding: 5px 5px 5px 10px;
  292. background-position: 0 -360px;
  293. background-color: #fff;
  294. background-repeat: repeat-x;
  295. line-height: 20px;
  296. font-family: arial, "\5b8b\4f53";
  297. font-size: 12px;
  298. outline: none;
  299. border: none;
  300. }
  301. input {
  302. margin: 0;
  303. padding: 0;
  304. height: 34px;
  305. border: 0;
  306. }
  307. input::placeholder {
  308. font-size: $fontE;
  309. /*font-family: Microsoft YaHei;*/
  310. font-weight: 400;
  311. color: rgba(40,46,48,0.6);
  312. }
  313. ::-webkit-input-placeholder {
  314. margin-left: 20px;
  315. font-size: $fontE;
  316. /*font-family: Microsoft YaHei;*/
  317. font-weight: 400;
  318. color: rgba(40,46,48,0.6);
  319. }
  320. /* 使用webkit内核的浏览器 */
  321. :-moz-placeholder {
  322. font-size: $fontE;
  323. /*font-family: Microsoft YaHei;*/
  324. font-weight: 400;
  325. color: rgba(40,46,48,0.6);
  326. }
  327. /* Firefox版本19+ */
  328. :-ms-input-placeholder {
  329. font-size: $fontE;
  330. /*font-family: Microsoft YaHei;*/
  331. font-weight: 400;
  332. color: rgba(40,46,48,0.6);
  333. }
  334. /* IE浏览器 */
  335. .button {
  336. width: 103px;
  337. background: $colorMain;
  338. font-size: $fontE;
  339. font-weight: 600;
  340. color: #fff;
  341. float: right;
  342. cursor: pointer;
  343. text-align: center;
  344. }
  345. }
  346. }
  347. .search_association {
  348. background: #fff;
  349. position: absolute;
  350. top: 43px;
  351. overflow: hidden;
  352. position: absolute;
  353. left: 0;
  354. width: 580px;
  355. border: 1px solid #ccc;
  356. background: #fff;
  357. z-index: 99;
  358. .s_a_item {
  359. display: flex;
  360. justify-content: space-between;
  361. overflow: hidden;
  362. padding: 1px 5px;
  363. line-height: 24px;
  364. cursor: pointer;
  365. font-size: 12px;
  366. -webkit-font-smoothing: antialiased;
  367. color: #666;
  368. div:first-child {
  369. width: 250px;
  370. white-space: nowrap;
  371. text-overflow: ellipsis;
  372. overflow: hidden;
  373. }
  374. div:last-child {
  375. overflow: hidden;
  376. color: #aaa;
  377. }
  378. &:hover {
  379. background-color: rgb(255, 233, 188);
  380. }
  381. }
  382. }
  383. }
  384. }
  385. .sld_cart_wrap {
  386. // position: absolute;
  387. // right: 240px;
  388. z-index: 99;
  389. height: 40px;
  390. width: 210px;
  391. text-align: center;
  392. dl {
  393. margin-bottom: 0px;
  394. .cart_goods_num {
  395. font: 11px/16px Verdana;
  396. color: #fff;
  397. background: $colorMain;
  398. text-align: center;
  399. display: inline-block;
  400. height: 16px;
  401. min-width: 16px;
  402. border: none 0;
  403. border-radius: 8px;
  404. margin-left: 10px;
  405. }
  406. dt {
  407. // position: absolute;
  408. z-index: 3;
  409. width: 100%;
  410. height: 38px;
  411. cursor: pointer;
  412. font-weight: 400;
  413. line-height: 38px;
  414. padding: 0;
  415. color: $colorMain;
  416. font-size: 15px;
  417. img {
  418. margin: -2px 11px 0 0px;
  419. vertical-align: middle;
  420. width: 20px;
  421. }
  422. &.cart_icon_text_wrap {
  423. background-color: #fff;
  424. a {
  425. color: #666666;
  426. font-size: 15px;
  427. line-height: 36px;
  428. }
  429. span {
  430. font-weight: bold;
  431. font-size: $fontE;
  432. color: $colorMain;
  433. }
  434. }
  435. }
  436. dd {
  437. .cart_goods {
  438. dl {
  439. padding-top: 8px;
  440. }
  441. dd {
  442. &.cart_goods_price {
  443. position: static;
  444. em {
  445. margin-right: 6px;
  446. width: auto;
  447. color: #666;
  448. &:nth-child(1) {
  449. display: block;
  450. font-weight: 600;
  451. }
  452. &:nth-child(2) {
  453. display: block;
  454. text-align: right;
  455. margin-top: 6px;
  456. }
  457. }
  458. }
  459. }
  460. }
  461. }
  462. }
  463. dd {
  464. position: absolute;
  465. top: 37px;
  466. right: 0;
  467. width: 355px;
  468. border: 1px solid #e3e3e3;
  469. background: #fff;
  470. z-index: 1;
  471. }
  472. }
  473. .ld {
  474. position: relative;
  475. zoom: 1;
  476. }
  477. .cart_data {
  478. height: 300px;
  479. display: flex;
  480. flex-direction: column;
  481. position: relative;
  482. .cart_data_title {
  483. font-weight: 600;
  484. float: left;
  485. padding: 7px;
  486. line-height: 32px;
  487. height: 32px;
  488. }
  489. .cart_list {
  490. padding: 20px;
  491. overflow-y: scroll;
  492. .cart_list_pre {
  493. margin-bottom: 20px;
  494. .cart_pre_left {
  495. .cart_pre_img {
  496. width: 48px;
  497. height: 48px;
  498. border: 1px solid #e3e3e3;
  499. cursor: pointer;
  500. img {
  501. width: 100%;
  502. height: 100%;
  503. }
  504. }
  505. .cart_pre_cen {
  506. width: 150px;
  507. margin-left: 20px;
  508. cursor: pointer;
  509. .cart_pre_name {
  510. word-break: break-all;
  511. text-overflow: ellipsis;
  512. display: -webkit-box;
  513. -webkit-box-orient: vertical;
  514. -webkit-line-clamp: 2;
  515. overflow: hidden;
  516. }
  517. .cart_pre_spec {
  518. overflow: hidden;
  519. text-overflow: ellipsis;
  520. white-space: nowrap;
  521. margin-top: 5px;
  522. }
  523. }
  524. }
  525. .cart_pre_right {
  526. .cart_pre_price {
  527. color: #666;
  528. }
  529. .cart_pre_del {
  530. color: #666;
  531. cursor: pointer;
  532. margin-top: 10px;
  533. &:hover {
  534. color: $colorMain;
  535. }
  536. }
  537. }
  538. }
  539. }
  540. .cart_bottom {
  541. width: 100%;
  542. height: 44px;
  543. border: 1px solid #e3e3e3;
  544. .cart_bottom_left {
  545. padding-left: 11px;
  546. height: 44px;
  547. span {
  548. color: #666;
  549. &:nth-child(2) {
  550. margin-left: 5px;
  551. }
  552. }
  553. }
  554. .cart_bottom_right {
  555. width: 110px;
  556. height: 44px;
  557. text-align: center;
  558. color: #fff;
  559. line-height: 44px;
  560. cursor: pointer;
  561. }
  562. }
  563. }
  564. </style>