HeaderCat.vue 13 KB

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