HeaderCat.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489
  1. <!-- 店铺头部数据(条幅和店铺分类) @zjf-2020-01-04 -->
  2. <template>
  3. <div class="sld_store_header">
  4. <NavTopBar></NavTopBar>
  5. <div class="container">
  6. <div class="ld left">
  7. <a href="javascript:void(0)" class="sld_img_center fl" @click="go_home">
  8. <img :src="filtersStore.getSiteLogo" :onerror="defaultImg" alt />
  9. </a>
  10. <!-- <span class="fl line"></span> -->
  11. <div class="sld_store_rate fl">
  12. <p class="name"><span>{{ storeData.info.storeName }} </span> <i class="sld_sjx"></i></p>
  13. <div class="sld_store_info_more">
  14. <div class="top clearfix">
  15. <div class="fl">
  16. <p>
  17. {{ L["服务承诺"] }}:<a href="JavaScript:;">{{ L["正品保障"] }}</a>
  18. </p>
  19. <p>{{ L["客服电话"] }}:{{ storeData.info.servicePhone }}</p>
  20. <p>
  21. {{ L["主营商品"] }}:{{
  22. storeData.info.mainBusiness
  23. ? storeData.info.mainBusiness
  24. .replace(/(.*),/, "$1。")
  25. .replace(/,/g, "、")
  26. : "--"
  27. }}
  28. </p>
  29. </div>
  30. <div class="fr flex_row_center_center">
  31. <img :src="storeData.info.storeLogoUrl" alt="" />
  32. </div>
  33. </div>
  34. <div class="bottom">
  35. <router-link :to="'/store/'+ calcProductName(storeData.info.storeName) +'_v-'+ vid"
  36. class="go_store_btn">
  37. {{ L["店铺首页"] }}
  38. </router-link>
  39. </div>
  40. </div>
  41. </div>
  42. <div class="sld_store_follow" @click="followStore" v-if="loginFlag">
  43. {{ storeData.info.isFollow == "true" ? L["取消关注"] : L["关注"] }}
  44. </div>
  45. </div>
  46. <div class="search_wrap clearfix">
  47. <div class="search_wrap-content">
  48. <form class="fl" action="javascript:void(0)" method="get">
  49. <el-select
  50. v-model="searchType"
  51. placeholder="Select"
  52. popper-class="select-search-type"
  53. >
  54. <el-option
  55. v-for="item in searchTypeOptions"
  56. :key="item.value"
  57. :label="item.label"
  58. :value="item.value"
  59. />
  60. </el-select>
  61. <input
  62. type="text"
  63. v-model="keyword"
  64. class="text"
  65. :placeholder="L['请输入关键词']"
  66. autocomplete="off"
  67. style="color: rgb(153, 153, 153)"
  68. ref="searchInput"
  69. @focus="inputFocus"
  70. @input="inputChange"
  71. @blur="inputBlur"
  72. />
  73. <input type="submit" :value="L['搜索']" class="button" @click="unifySearch" />
  74. </form>
  75. <!-- <input
  76. type="submit"
  77. :value="L['搜本店']"
  78. class="button fl"
  79. @click="searchStore('keyword')"
  80. style="background: #333"
  81. /> -->
  82. </div>
  83. </div>
  84. <div class="sld_cart_wrap">
  85. <dl class="">
  86. <dt
  87. class="ld cart_icon_text_wrap"
  88. >
  89. <span class="iconfont "><img src="/email.svg" /></span>
  90. <router-link target="_blank" :to="'/store/contact/'+ calcProductName(storeData.info.storeName) +'_v-'+ vid" >
  91. {{ L["询价"] }}
  92. </router-link>
  93. <!-- 没有商品显示0 -->
  94. </dt>
  95. </dl>
  96. </div>
  97. </div>
  98. <div class="sld_store_label_nav_wrap" v-if="showNav">
  99. <div class="sld_store_label_wrap">
  100. <img
  101. :src="storeData.info.storeBannerPcUrl ? storeData.info.storeBannerPcUrl : defaultStoreBanner"
  102. alt=""
  103. :onerror="defaultStoreBanner"
  104. />
  105. </div>
  106. <div class="logo_banner_left container" v-if="storeData.info.storeBannerPcSource == 'platform'">
  107. <img :src="storeData.info.storeLogoUrl ? storeData.info.storeLogoUrl : defaultStoreBanner" class="" />
  108. </div>
  109. <div class="sld_store_nav">
  110. <ul class="clearfix">
  111. <li class="sld_all_store_cat">
  112. <p class="all_type">
  113. <span>{{ L["本店全部分类"] }}</span> <i class="iconfont"></i>
  114. </p>
  115. <ul class="sld_store_first_cat">
  116. <li v-for="(item, index) in storeData.cat" :key="index">
  117. <nuxt-link
  118. target="_blank"
  119. :to="'/store/goods/'+ calcProductName(storeData.info.storeName) +'_v-'+ vid + '_c-' + item.innerLabelId"
  120. >
  121. <span :title="item.innerLabelName">{{ item.innerLabelName }}</span>
  122. <i v-if="item.children.length" class="iconfont fr"></i>
  123. </nuxt-link>
  124. <ul class="sld_store_second_cat" v-if="item.children.length">
  125. <li
  126. v-for="(item_child, index_child) in item.children"
  127. :key="index_child"
  128. >
  129. <nuxt-link
  130. target="_blank"
  131. :title="item_child.innerLabelName"
  132. :to="'/store/goods/'+ calcProductName(storeData.info.storeName) +'_v-'+ vid + '_c-' + item_child.innerLabelId"
  133. >
  134. {{ item_child.innerLabelName }}
  135. </nuxt-link>
  136. </li>
  137. </ul>
  138. </li>
  139. </ul>
  140. </li>
  141. <ul class="sld_store_cat_horizontal" v-if="storeData.info.storeName">
  142. <li :class="{ 'active': routePath === '/store/'+ calcProductName(storeData.info.storeName) +'_'+ vid }">
  143. <nuxt-link :to="'/store/'+ calcProductName(storeData.info.storeName) +'_'+ vid" >
  144. {{ L["首页"] }}
  145. </nuxt-link>
  146. </li>
  147. <li :class="{'active': routePath === '/store/goods/'+ calcProductName(storeData.info.storeName) +'_v-'+ vid}">
  148. <nuxt-link :to="'/store/goods/'+ calcProductName(storeData.info.storeName) +'_v-'+ vid" >{{
  149. L["所有商品"]
  150. }}</nuxt-link>
  151. </li>
  152. <li :class="{ 'active': routePath === '/store/about/'+ calcProductName(storeData.info.storeName) +'_v-'+ vid }">
  153. <nuxt-link :to="'/store/about/'+ calcProductName(storeData.info.storeName) +'_v-'+ vid" >{{
  154. L["关于我们"]
  155. }}</nuxt-link>
  156. </li>
  157. <li :class="{ 'active': routePath === '/store/contact/'+ calcProductName(storeData.info.storeName) +'_v-'+ vid }">
  158. <nuxt-link :to="'/store/contact/'+ calcProductName(storeData.info.storeName) +'_v-'+ vid" >{{
  159. L["联系我们"]
  160. }}</nuxt-link>
  161. </li>
  162. </ul>
  163. <!-- 分割线 -->
  164. <div class="search_line"></div>
  165. <!-- 搜索框 start -->
  166. <div class="search_modle flex_row_center_center">
  167. <input
  168. type="text"
  169. v-model="keywordStore"
  170. class="search_input"
  171. :placeholder="L['请输入关键词进行查询...']"
  172. @keyup.enter="searchStore('keywordStore')"
  173. />
  174. <span class="search_input_button" @click="searchStore('keywordStore')">{{
  175. L["搜索"]
  176. }}</span>
  177. </div>
  178. <!-- 搜索框 end -->
  179. </ul>
  180. </div>
  181. </div>
  182. </div>
  183. </template>
  184. <script setup>
  185. // import { lang_zn } from "@/assets/language/zh";
  186. import { getCurLanguage } from '@/composables/common.js';
  187. import {goodsInfo,useUserInfo} from '@/store/user.js'
  188. import { useFiltersStore } from "@/store/filter.js";
  189. const filtersStore = useFiltersStore();
  190. const goodsInfox = goodsInfo();
  191. const showNav = ref(false);
  192. // const L = lang_zn;
  193. const L = getCurLanguage();
  194. const emit = defineEmits(['updateFllow','sendGoodsName'])
  195. const defaultStoreBanner = ref("") ;
  196. const router = useRouter();
  197. const route = useRoute();
  198. const vid = ref("");
  199. const storeData = reactive({
  200. cat: [ ],
  201. info: {}
  202. }); //店铺数据,cat:店铺分类,info:店铺基本信息
  203. const searchType = ref('store');
  204. const searchTypeOptions = [
  205. {
  206. value: 'store',
  207. label: L['店铺内'],
  208. },
  209. {
  210. value: 'site',
  211. label: L['全平台'],
  212. },
  213. ]
  214. const otherMenuData = reactive({data:[]})
  215. const { proxy } = getCurrentInstance();
  216. const keyword = ref(
  217. route.query != undefined && route.query.keyword != undefined && route.query.keyword
  218. ? route.query.keyword
  219. : ""
  220. );
  221. const keywordStore = ref("");
  222. const loginFlag = ref(filtersStore.getLoginFlag);
  223. const defaultImg = ref("/assets/common_top_logo.png");
  224. const SAList = ref([]);
  225. const SAShow = ref(false);
  226. const routePath = computed(() => route.fullPath);
  227. console.log(routePath, 'routePath')
  228. const go_home = () => {
  229. window.location.href="/"
  230. };
  231. //只有列表页面通过nuxt3的路由获取vid
  232. const setVid = (v) => {
  233. vid.value = v
  234. getStoreInfoBaseInfo();
  235. getStoreCatData();
  236. }
  237. const setfollowStore = (v) => {
  238. storeData.info.isFollow = v
  239. }
  240. defineExpose({setVid,setfollowStore})
  241. //获取店铺基本信息
  242. const getStoreInfoBaseInfo = async () => {
  243. const {data:value} = await useFetchRaw(apiUrl + 'v3/seller/front/store/detail',{params:{storeId: vid.value}, headers:{Authorization:'Bearer ' + filtersStore.getToken}})
  244. const res = value._rawValue
  245. if (res.state == 200) {
  246. storeData.info = res.data;
  247. emit("sendGoodsName", storeData.info.storeName);
  248. storeData.info.storeAverageScore = (
  249. (res.data.deliverScore * 1 +
  250. res.data.descriptionScore * 1 +
  251. res.data.serviceScore * 1) /
  252. 3
  253. ).toFixed(1);
  254. showNav.value = true;
  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. white-space: nowrap;
  416. cursor: pointer;
  417. }
  418. input::placeholder {
  419. font-size: 12px;
  420. /*font-family: Microsoft YaHei;*/
  421. font-weight: 400;
  422. color: rgb(153, 153, 153);
  423. }
  424. ::-webkit-input-placeholder {
  425. margin-left: 20px;
  426. font-size: 12px;
  427. /*font-family: Microsoft YaHei;*/
  428. font-weight: 400;
  429. color: rgb(153, 153, 153);
  430. }
  431. /* 使用webkit内核的浏览器 */
  432. :-moz-placeholder {
  433. font-size: 12px;
  434. /*font-family: Microsoft YaHei;*/
  435. font-weight: 400;
  436. color: rgb(153, 153, 153);
  437. }
  438. /* Firefox版本19+ */
  439. :-ms-input-placeholder {
  440. font-size: 12px;
  441. /*font-family: Microsoft YaHei;*/
  442. font-weight: 400;
  443. color: rgb(153, 153, 153);
  444. }
  445. /* IE浏览器 */
  446. </style>