HeaderCat.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489
  1. <!-- 店铺头部数据(条幅和店铺分类) @zjf-2020-01-04 -->
  2. <template>
  3. <div class="sld_store_header">
  4. <div class="container">
  5. <div class="ld left">
  6. <a href="javascript:void(0)" class="sld_img_center fl" @click="go_home">
  7. <img :src="filtersStore.getSiteLogo" :onerror="defaultImg" alt />
  8. </a>
  9. <!-- <span class="fl line"></span> -->
  10. <div class="sld_store_rate fl">
  11. <p class="name"><span>{{ storeData.info.storeName }} </span> <i class="sld_sjx"></i></p>
  12. <div class="sld_store_info_more">
  13. <div class="top clearfix">
  14. <div class="fl">
  15. <p>
  16. {{ L["服务承诺"] }}:<a href="JavaScript:;">{{ L["正品保障"] }}</a>
  17. </p>
  18. <p>{{ L["客服电话"] }}:{{ storeData.info.servicePhone }}</p>
  19. <p>
  20. {{ L["主营商品"] }}:{{
  21. storeData.info.mainBusiness
  22. ? storeData.info.mainBusiness
  23. .replace(/(.*),/, "$1。")
  24. .replace(/,/g, "、")
  25. : "--"
  26. }}
  27. </p>
  28. </div>
  29. <div class="fr flex_row_center_center">
  30. <img :src="storeData.info.storeLogoUrl" alt="" />
  31. </div>
  32. </div>
  33. <div class="bottom">
  34. <router-link :to="'/store/'+ calcProductName(storeData.info.storeName) +'_v-'+ vid"
  35. class="go_store_btn">
  36. {{ L["店铺首页"] }}
  37. </router-link>
  38. </div>
  39. </div>
  40. </div>
  41. <div class="sld_store_follow" @click="followStore" v-if="loginFlag">
  42. {{ storeData.info.isFollow == "true" ? L["取消关注"] : L["关注"] }}
  43. </div>
  44. </div>
  45. <div class="search_wrap clearfix">
  46. <div class="search_wrap-content">
  47. <form class="fl" action="javascript:void(0)" method="get">
  48. <el-select
  49. v-model="searchType"
  50. placeholder="Select"
  51. popper-class="select-search-type"
  52. style="width: 140px;
  53. height: 100%"
  54. >
  55. <el-option
  56. v-for="item in searchTypeOptions"
  57. :key="item.value"
  58. :label="item.label"
  59. :value="item.value"
  60. />
  61. </el-select>
  62. <input
  63. type="text"
  64. v-model="keyword"
  65. class="text"
  66. :placeholder="L['请输入关键词']"
  67. autocomplete="off"
  68. style="color: rgb(153, 153, 153)"
  69. ref="searchInput"
  70. @focus="inputFocus"
  71. @input="inputChange"
  72. @blur="inputBlur"
  73. />
  74. <input type="submit" :value="L['搜索']" class="button" @click="unifySearch" />
  75. </form>
  76. <!-- <input
  77. type="submit"
  78. :value="L['搜本店']"
  79. class="button fl"
  80. @click="searchStore('keyword')"
  81. style="background: #333"
  82. /> -->
  83. </div>
  84. </div>
  85. <div class="sld_cart_wrap">
  86. <dl class="">
  87. <dt
  88. class="ld cart_icon_text_wrap"
  89. >
  90. <span class="iconfont "><img src="/email.svg" /></span>
  91. <router-link target="_blank" :to="'/store/contact/'+ calcProductName(storeData.info.storeName) +'_v-'+ vid" >
  92. {{ L["发布需求"] }}
  93. </router-link>
  94. <!-- 没有商品显示0 -->
  95. </dt>
  96. </dl>
  97. </div>
  98. </div>
  99. <NavTopBar></NavTopBar>
  100. <div class="sld_store_label_nav_wrap">
  101. <div class="sld_store_label_wrap">
  102. <img
  103. :src="storeData.info.storeBannerPcUrl ? storeData.info.storeBannerPcUrl : defaultStoreBanner"
  104. alt=""
  105. :onerror="defaultStoreBanner"
  106. />
  107. </div>
  108. <div class="logo_banner_left container" v-if="storeData.info.storeBannerPcSource == 'platform'">
  109. <img :src="storeData.info.storeLogoUrl ? storeData.info.storeLogoUrl : defaultStoreBanner" class="" />
  110. </div>
  111. <div class="sld_store_nav">
  112. <ul class="clearfix">
  113. <li class="sld_all_store_cat">
  114. <p class="all_type">
  115. <span>{{ L["本店全部分类"] }}</span> <i class="iconfont"></i>
  116. </p>
  117. <ul class="sld_store_first_cat">
  118. <li v-for="(item, index) in storeData.cat" :key="index">
  119. <nuxt-link
  120. target="_blank"
  121. :to="'/store/goods/'+ calcProductName(storeData.info.storeName) +'_v-'+ vid + '_c-' + item.innerLabelId"
  122. >
  123. <span :title="item.innerLabelName">{{ item.innerLabelName }}</span>
  124. <i v-if="item.children.length" class="iconfont fr"></i>
  125. </nuxt-link>
  126. <ul class="sld_store_second_cat" v-if="item.children.length">
  127. <li
  128. v-for="(item_child, index_child) in item.children"
  129. :key="index_child"
  130. >
  131. <nuxt-link
  132. target="_blank"
  133. :title="item_child.innerLabelName"
  134. :to="'/store/goods/'+ calcProductName(storeData.info.storeName) +'_v-'+ vid + '_c-' + item_child.innerLabelId"
  135. >
  136. {{ item_child.innerLabelName }}
  137. </nuxt-link>
  138. </li>
  139. </ul>
  140. </li>
  141. </ul>
  142. </li>
  143. <ul class="sld_store_cat_horizontal" v-if="storeData.info.storeName">
  144. <!-- <li :class="{ 'active': routePath === '/store/'+ calcProductName(storeData.info.storeName) +'_'+ vid }">
  145. <nuxt-link target="_blank" :to="'/store/'+ calcProductName(storeData.info.storeName) +'_'+ vid" >
  146. {{ L["首页"] }}
  147. </nuxt-link>
  148. </li> -->
  149. <li :class="{'active': routePath === '/store/goods/'+ calcProductName(storeData.info.storeName) +'_v-'+ vid}">
  150. <nuxt-link :to="'/store/goods/'+ calcProductName(storeData.info.storeName) +'_v-'+ vid" >{{
  151. L["所有商品"]
  152. }}</nuxt-link>
  153. </li>
  154. <li :class="{ 'active': routePath === '/store/about/'+ calcProductName(storeData.info.storeName) +'_v-'+ vid }">
  155. <nuxt-link :to="'/store/about/'+ calcProductName(storeData.info.storeName) +'_v-'+ vid" >{{
  156. L["关于我们"]
  157. }}</nuxt-link>
  158. </li>
  159. <li :class="{ 'active': routePath === '/store/contact/'+ calcProductName(storeData.info.storeName) +'_v-'+ vid }">
  160. <nuxt-link :to="'/store/contact/'+ calcProductName(storeData.info.storeName) +'_v-'+ vid" >{{
  161. L["联系我们"]
  162. }}</nuxt-link>
  163. </li>
  164. </ul>
  165. <!-- 分割线 -->
  166. <div class="search_line"></div>
  167. <!-- 搜索框 start -->
  168. <div class="search_modle flex_row_center_center">
  169. <input
  170. type="text"
  171. v-model="keywordStore"
  172. class="search_input"
  173. :placeholder="L['请输入关键词进行查询...']"
  174. @keyup.enter="searchStore('keywordStore')"
  175. />
  176. <span class="search_input_button" @click="searchStore('keywordStore')">{{
  177. L["搜索"]
  178. }}</span>
  179. </div>
  180. <!-- 搜索框 end -->
  181. </ul>
  182. </div>
  183. </div>
  184. </div>
  185. </template>
  186. <script setup>
  187. // import { lang_zn } from "@/assets/language/zh";
  188. import { getCurLanguage } from '@/composables/common.js';
  189. import {goodsInfo,useUserInfo} from '@/store/user.js'
  190. import { useFiltersStore } from "@/store/filter.js";
  191. const filtersStore = useFiltersStore();
  192. const goodsInfox = goodsInfo();
  193. // const L = lang_zn;
  194. const L = getCurLanguage();
  195. const emit = defineEmits(['updateFllow','sendGoodsName'])
  196. const defaultStoreBanner = ref("") ;
  197. const router = useRouter();
  198. const route = useRoute();
  199. const vid = ref("");
  200. const storeData = reactive({
  201. cat: [ ],
  202. info: {}
  203. }); //店铺数据,cat:店铺分类,info:店铺基本信息
  204. const searchType = ref('store');
  205. const searchTypeOptions = [
  206. {
  207. value: 'store',
  208. label: 'In This Store',
  209. },
  210. {
  211. value: 'site',
  212. label: 'Full Site',
  213. },
  214. ]
  215. const otherMenuData = reactive({data:[]})
  216. const { proxy } = getCurrentInstance();
  217. const keyword = ref(
  218. route.query != undefined && route.query.keyword != undefined && route.query.keyword
  219. ? route.query.keyword
  220. : ""
  221. );
  222. const keywordStore = ref("");
  223. const loginFlag = ref(filtersStore.getLoginFlag);
  224. const defaultImg = ref("/assets/common_top_logo.png");
  225. const SAList = ref([]);
  226. const SAShow = ref(false);
  227. const routePath = computed(() => route.fullPath);
  228. console.log(routePath, 'routePath')
  229. const go_home = () => {
  230. window.location.href="/"
  231. };
  232. //只有列表页面通过nuxt3的路由获取vid
  233. const setVid = (v) => {
  234. vid.value = v
  235. getStoreInfoBaseInfo();
  236. getStoreCatData();
  237. }
  238. const setfollowStore = (v) => {
  239. storeData.info.isFollow = v
  240. }
  241. defineExpose({setVid,setfollowStore})
  242. //获取店铺基本信息
  243. const getStoreInfoBaseInfo = async () => {
  244. const {data:value} = await useFetchRaw(apiUrl + 'v3/seller/front/store/detail',{params:{storeId: vid.value}, headers:{Authorization:'Bearer ' + filtersStore.getToken}})
  245. const res = value._rawValue
  246. if (res.state == 200) {
  247. storeData.info = res.data;
  248. emit("sendGoodsName", storeData.info.storeName);
  249. storeData.info.storeAverageScore = (
  250. (res.data.deliverScore * 1 +
  251. res.data.descriptionScore * 1 +
  252. res.data.serviceScore * 1) /
  253. 3
  254. ).toFixed(1);
  255. }
  256. };
  257. //获取店铺分类数据
  258. const getStoreCatData = async () => {
  259. const {data:value} = await useFetchRaw(apiUrl + 'v3/seller/front/store/storeCategory',{params:{storeId: vid.value}})
  260. const res = value._rawValue
  261. if (res.state == 200) {
  262. storeData.cat = res.data;
  263. }
  264. };
  265. const inputFocus = () => {
  266. proxy.$refs.searchInput.style.color = "#333";
  267. SAShow.value = true;
  268. if (keyword.value && SAList.value.length == 0) {
  269. searchAssociation(keyword.value);
  270. }
  271. };
  272. watchEffect(() => {
  273. let tmpRoute = router.currentRoute.value;
  274. if (tmpRoute.query.keyword != undefined) {
  275. keyword.value = tmpRoute.query.keyword;
  276. } else {
  277. keyword.value = "";
  278. }
  279. if (tmpRoute.fullPath.indexOf("/goods/detail") > -1) {
  280. get("v3/goods/front/goods/details", { productId: calcProductId(tmpRoute.path) })
  281. .then((res) => {
  282. if (res.state == 200) {
  283. vid.value = res.data.storeInf.storeId;
  284. getStoreInfoBaseInfo();
  285. getStoreCatData();
  286. }
  287. });
  288. }
  289. // -1代表没值 0有值
  290. if (
  291. (tmpRoute.fullPath.indexOf("/store") > -1 && tmpRoute.fullPath.indexOf("/store/goods") == -1)
  292. || tmpRoute.fullPath.indexOf("/store/about") > -1
  293. || tmpRoute.fullPath.indexOf("/store/contact") > -1
  294. ) {
  295. vid.value = calcUrlShopId(tmpRoute.path) || calcProductId(tmpRoute.path);
  296. getStoreInfoBaseInfo();
  297. getStoreCatData();
  298. }
  299. //老版的通过query传递vid的方法
  300. // if (tmpRoute.query != undefined && tmpRoute.query.vid != undefined && tmpRoute.query.vid) {
  301. // vid.value = tmpRoute.query.vid;
  302. // getStoreInfoBaseInfo();
  303. // getStoreCatData();
  304. // }
  305. });
  306. const unifySearch = () => {
  307. if (searchType.value === 'store') {
  308. searchStore('keyword')
  309. } else {
  310. search()
  311. }
  312. }
  313. //搜索事件(搜全站)
  314. const search = () => {
  315. if (keyword.value) {
  316. router.push({ path: `/goods/list/search_keyword-`+keyword.value});
  317. }
  318. keyword.value = "";
  319. };
  320. //搜索事件(搜本站)
  321. const searchStore = (type, arg) => {
  322. //return
  323. if (type == "keywordStore") {
  324. router.push({
  325. path: "/store/goods/"+ calcProductName(storeData.info.storeName)+"_v-"+ vid.value +"_k-" + keywordStore.value
  326. });
  327. // keywordStore.value = "";
  328. } else if (type == "keyword") {
  329. router.push({
  330. path: "/store/goods/"+ calcProductName(storeData.info.storeName)+"_v-"+ vid.value +"_k-" + keyword.value
  331. });
  332. // keyword.value = "";
  333. }
  334. };
  335. const followStore = () => {
  336. //关注店铺及取消关注
  337. if (filtersStore.getLoginFlag) {
  338. //已登录
  339. let params = {
  340. storeIds: storeData.info.storeId,
  341. isCollect: !eval(storeData.info.isFollow),
  342. };
  343. post("v3/member/front/followStore/edit", params).then((res) => {
  344. if (res.state == 200) {
  345. storeData.info.isFollow = !eval(storeData.info.isFollow) ? "true" : "false";
  346. emit("updateFllow", { state: storeData.info.isFollow });
  347. if (storeData.info.isFollow) {
  348. sldStatEvent({ behaviorType: "fol", storeId: storeData.info.storeId });
  349. }
  350. }
  351. });
  352. }
  353. };
  354. const searchAssociation = (input) => {
  355. get("v3/goods/front/goods/searchWords/list", {
  356. keyWord: input,
  357. }).then((res) => {
  358. if (res.state == 200) {
  359. SAList.value = res.data;
  360. }
  361. });
  362. };
  363. const inputChange = (e) => {
  364. let input = e.target.value;
  365. SAShow.value = true;
  366. if (input) {
  367. searchAssociation(input);
  368. } else {
  369. SAList.value = [];
  370. }
  371. };
  372. const inputBlur = () => {
  373. SAShow.value = false;
  374. };
  375. </script>
  376. <style lang="scss">
  377. .select-search-type {
  378. .el-select-dropdown__item {
  379. &.is-selected {
  380. color: #036EB8;
  381. }
  382. }
  383. }
  384. </style>
  385. <style lang="scss" scoped>
  386. @import "@/assets/style/store/storeHeader.scss";
  387. :deep(.el-select) {
  388. border-right: 1px solid $colorMain;
  389. }
  390. :deep(.el-select__wrapper) {
  391. position: relative;
  392. top: 2px;
  393. box-shadow: none;
  394. &:hover {
  395. box-shadow: none;
  396. }
  397. }
  398. .kefu {
  399. img {
  400. width: 16px;
  401. height: 16px;
  402. vertical-align: middle;
  403. }
  404. }
  405. .sld_store_follow {
  406. margin-left: 15px;
  407. padding: 7px 9px;
  408. border-radius: 15px;
  409. color: #fff;
  410. background-color: $colorMain;
  411. display: flex;
  412. justify-content: center;
  413. align-items: center;
  414. font-size: 12px;
  415. cursor: pointer;
  416. }
  417. input::placeholder {
  418. font-size: 12px;
  419. /*font-family: Microsoft YaHei;*/
  420. font-weight: 400;
  421. color: rgb(153, 153, 153);
  422. }
  423. ::-webkit-input-placeholder {
  424. margin-left: 20px;
  425. font-size: 12px;
  426. /*font-family: Microsoft YaHei;*/
  427. font-weight: 400;
  428. color: rgb(153, 153, 153);
  429. }
  430. /* 使用webkit内核的浏览器 */
  431. :-moz-placeholder {
  432. font-size: 12px;
  433. /*font-family: Microsoft YaHei;*/
  434. font-weight: 400;
  435. color: rgb(153, 153, 153);
  436. }
  437. /* Firefox版本19+ */
  438. :-ms-input-placeholder {
  439. font-size: 12px;
  440. /*font-family: Microsoft YaHei;*/
  441. font-weight: 400;
  442. color: rgb(153, 153, 153);
  443. }
  444. /* IE浏览器 */
  445. </style>