HeaderCat.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491
  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" v-if="showNav">
  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 :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 showNav = ref(false);
  194. // const L = lang_zn;
  195. const L = getCurLanguage();
  196. const emit = defineEmits(['updateFllow','sendGoodsName'])
  197. const defaultStoreBanner = ref("") ;
  198. const router = useRouter();
  199. const route = useRoute();
  200. const vid = ref("");
  201. const storeData = reactive({
  202. cat: [ ],
  203. info: {}
  204. }); //店铺数据,cat:店铺分类,info:店铺基本信息
  205. const searchType = ref('store');
  206. const searchTypeOptions = [
  207. {
  208. value: 'store',
  209. label: L['店铺内'],
  210. },
  211. {
  212. value: 'site',
  213. label: L['全平台'],
  214. },
  215. ]
  216. const otherMenuData = reactive({data:[]})
  217. const { proxy } = getCurrentInstance();
  218. const keyword = ref(
  219. route.query != undefined && route.query.keyword != undefined && route.query.keyword
  220. ? route.query.keyword
  221. : ""
  222. );
  223. const keywordStore = ref("");
  224. const loginFlag = ref(filtersStore.getLoginFlag);
  225. const defaultImg = ref("/assets/common_top_logo.png");
  226. const SAList = ref([]);
  227. const SAShow = ref(false);
  228. const routePath = computed(() => route.fullPath);
  229. console.log(routePath, 'routePath')
  230. const go_home = () => {
  231. window.location.href="/"
  232. };
  233. //只有列表页面通过nuxt3的路由获取vid
  234. const setVid = (v) => {
  235. vid.value = v
  236. getStoreInfoBaseInfo();
  237. getStoreCatData();
  238. }
  239. const setfollowStore = (v) => {
  240. storeData.info.isFollow = v
  241. }
  242. defineExpose({setVid,setfollowStore})
  243. //获取店铺基本信息
  244. const getStoreInfoBaseInfo = async () => {
  245. const {data:value} = await useFetchRaw(apiUrl + 'v3/seller/front/store/detail',{params:{storeId: vid.value}, headers:{Authorization:'Bearer ' + filtersStore.getToken}})
  246. const res = value._rawValue
  247. if (res.state == 200) {
  248. storeData.info = res.data;
  249. emit("sendGoodsName", storeData.info.storeName);
  250. storeData.info.storeAverageScore = (
  251. (res.data.deliverScore * 1 +
  252. res.data.descriptionScore * 1 +
  253. res.data.serviceScore * 1) /
  254. 3
  255. ).toFixed(1);
  256. showNav.value = true;
  257. }
  258. };
  259. //获取店铺分类数据
  260. const getStoreCatData = async () => {
  261. const {data:value} = await useFetchRaw(apiUrl + 'v3/seller/front/store/storeCategory',{params:{storeId: vid.value}})
  262. const res = value._rawValue
  263. if (res.state == 200) {
  264. storeData.cat = res.data;
  265. }
  266. };
  267. const inputFocus = () => {
  268. proxy.$refs.searchInput.style.color = "#333";
  269. SAShow.value = true;
  270. if (keyword.value && SAList.value.length == 0) {
  271. searchAssociation(keyword.value);
  272. }
  273. };
  274. watchEffect(() => {
  275. let tmpRoute = router.currentRoute.value;
  276. if (tmpRoute.query.keyword != undefined) {
  277. keyword.value = tmpRoute.query.keyword;
  278. } else {
  279. keyword.value = "";
  280. }
  281. if (tmpRoute.fullPath.indexOf("/goods/detail") > -1) {
  282. get("v3/goods/front/goods/details", { productId: calcProductId(tmpRoute.path) })
  283. .then((res) => {
  284. if (res.state == 200) {
  285. vid.value = res.data.storeInf.storeId;
  286. getStoreInfoBaseInfo();
  287. getStoreCatData();
  288. }
  289. });
  290. }
  291. // -1代表没值 0有值
  292. if (
  293. (tmpRoute.fullPath.indexOf("/store") > -1 && tmpRoute.fullPath.indexOf("/store/goods") == -1)
  294. || tmpRoute.fullPath.indexOf("/store/about") > -1
  295. || tmpRoute.fullPath.indexOf("/store/contact") > -1
  296. ) {
  297. vid.value = calcUrlShopId(tmpRoute.path) || calcProductId(tmpRoute.path);
  298. getStoreInfoBaseInfo();
  299. getStoreCatData();
  300. }
  301. //老版的通过query传递vid的方法
  302. // if (tmpRoute.query != undefined && tmpRoute.query.vid != undefined && tmpRoute.query.vid) {
  303. // vid.value = tmpRoute.query.vid;
  304. // getStoreInfoBaseInfo();
  305. // getStoreCatData();
  306. // }
  307. });
  308. const unifySearch = () => {
  309. if (searchType.value === 'store') {
  310. searchStore('keyword')
  311. } else {
  312. search()
  313. }
  314. }
  315. //搜索事件(搜全站)
  316. const search = () => {
  317. if (keyword.value) {
  318. router.push({ path: `/goods/list/search_keyword-`+keyword.value});
  319. }
  320. keyword.value = "";
  321. };
  322. //搜索事件(搜本站)
  323. const searchStore = (type, arg) => {
  324. //return
  325. if (type == "keywordStore") {
  326. router.push({
  327. path: "/store/goods/"+ calcProductName(storeData.info.storeName)+"_v-"+ vid.value +"_k-" + keywordStore.value
  328. });
  329. // keywordStore.value = "";
  330. } else if (type == "keyword") {
  331. router.push({
  332. path: "/store/goods/"+ calcProductName(storeData.info.storeName)+"_v-"+ vid.value +"_k-" + keyword.value
  333. });
  334. // keyword.value = "";
  335. }
  336. };
  337. const followStore = () => {
  338. //关注店铺及取消关注
  339. if (filtersStore.getLoginFlag) {
  340. //已登录
  341. let params = {
  342. storeIds: storeData.info.storeId,
  343. isCollect: !eval(storeData.info.isFollow),
  344. };
  345. post("v3/member/front/followStore/edit", params).then((res) => {
  346. if (res.state == 200) {
  347. storeData.info.isFollow = !eval(storeData.info.isFollow) ? "true" : "false";
  348. emit("updateFllow", { state: storeData.info.isFollow });
  349. if (storeData.info.isFollow) {
  350. sldStatEvent({ behaviorType: "fol", storeId: storeData.info.storeId });
  351. }
  352. }
  353. });
  354. }
  355. };
  356. const searchAssociation = (input) => {
  357. get("v3/goods/front/goods/searchWords/list", {
  358. keyWord: input,
  359. }).then((res) => {
  360. if (res.state == 200) {
  361. SAList.value = res.data;
  362. }
  363. });
  364. };
  365. const inputChange = (e) => {
  366. let input = e.target.value;
  367. SAShow.value = true;
  368. if (input) {
  369. searchAssociation(input);
  370. } else {
  371. SAList.value = [];
  372. }
  373. };
  374. const inputBlur = () => {
  375. SAShow.value = false;
  376. };
  377. </script>
  378. <style lang="scss">
  379. .select-search-type {
  380. .el-select-dropdown__item {
  381. &.is-selected {
  382. color: #036EB8;
  383. }
  384. }
  385. }
  386. </style>
  387. <style lang="scss" scoped>
  388. @import "@/assets/style/store/storeHeader.scss";
  389. :deep(.el-select) {
  390. border-right: 1px solid $colorMain;
  391. }
  392. :deep(.el-select__wrapper) {
  393. position: relative;
  394. top: 2px;
  395. box-shadow: none;
  396. &:hover {
  397. box-shadow: none;
  398. }
  399. }
  400. .kefu {
  401. img {
  402. width: 16px;
  403. height: 16px;
  404. vertical-align: middle;
  405. }
  406. }
  407. .sld_store_follow {
  408. margin-left: 15px;
  409. padding: 7px 9px;
  410. border-radius: 15px;
  411. color: #fff;
  412. background-color: $colorMain;
  413. display: flex;
  414. justify-content: center;
  415. align-items: center;
  416. font-size: 12px;
  417. cursor: pointer;
  418. }
  419. input::placeholder {
  420. font-size: 12px;
  421. /*font-family: Microsoft YaHei;*/
  422. font-weight: 400;
  423. color: rgb(153, 153, 153);
  424. }
  425. ::-webkit-input-placeholder {
  426. margin-left: 20px;
  427. font-size: 12px;
  428. /*font-family: Microsoft YaHei;*/
  429. font-weight: 400;
  430. color: rgb(153, 153, 153);
  431. }
  432. /* 使用webkit内核的浏览器 */
  433. :-moz-placeholder {
  434. font-size: 12px;
  435. /*font-family: Microsoft YaHei;*/
  436. font-weight: 400;
  437. color: rgb(153, 153, 153);
  438. }
  439. /* Firefox版本19+ */
  440. :-ms-input-placeholder {
  441. font-size: 12px;
  442. /*font-family: Microsoft YaHei;*/
  443. font-weight: 400;
  444. color: rgb(153, 153, 153);
  445. }
  446. /* IE浏览器 */
  447. </style>