HeaderCat.vue 13 KB

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