HeaderCat.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428
  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" style="font-weight: bold">
  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>
  130. <nuxt-link target="_blank" :to="'/store/'+ calcProductName(storeData.info.storeName) +'_'+ vid" >
  131. {{ L["首页"] }}
  132. </nuxt-link>
  133. </li>
  134. <li>
  135. <nuxt-link target="_blank" :to="'/store/goods/'+ calcProductName(storeData.info.storeName) +'_v-'+ vid" >{{
  136. L["所有商品"]
  137. }}</nuxt-link>
  138. </li>
  139. <li >
  140. <nuxt-link :to="'/store/about/'+ calcProductName(storeData.info.storeName) +'_v-'+ vid" >{{
  141. L["关于我们"]
  142. }}</nuxt-link>
  143. </li>
  144. <li>
  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 go_home = () => {
  202. window.location.href="/"
  203. };
  204. //只有列表页面通过nuxt3的路由获取vid
  205. const setVid = (v) => {
  206. vid.value = v
  207. getStoreInfoBaseInfo();
  208. getStoreCatData();
  209. }
  210. const setfollowStore = (v) => {
  211. storeData.info.isFollow = v
  212. }
  213. defineExpose({setVid,setfollowStore})
  214. //获取店铺基本信息
  215. const getStoreInfoBaseInfo = async () => {
  216. const {data:value} = await useFetchRaw(apiUrl + 'v3/seller/front/store/detail',{params:{storeId: vid.value}, headers:{Authorization:'Bearer ' + filtersStore.getToken}})
  217. const res = value._rawValue
  218. if (res.state == 200) {
  219. storeData.info = res.data;
  220. emit("sendGoodsName", storeData.info.storeName);
  221. storeData.info.storeAverageScore = (
  222. (res.data.deliverScore * 1 +
  223. res.data.descriptionScore * 1 +
  224. res.data.serviceScore * 1) /
  225. 3
  226. ).toFixed(1);
  227. }
  228. };
  229. //获取店铺分类数据
  230. const getStoreCatData = async () => {
  231. const {data:value} = await useFetchRaw(apiUrl + 'v3/seller/front/store/storeCategory',{params:{storeId: vid.value}})
  232. const res = value._rawValue
  233. if (res.state == 200) {
  234. storeData.cat = res.data;
  235. }
  236. };
  237. const inputFocus = () => {
  238. proxy.$refs.searchInput.style.color = "#333";
  239. SAShow.value = true;
  240. if (keyword.value && SAList.value.length == 0) {
  241. searchAssociation(keyword.value);
  242. }
  243. };
  244. watchEffect(() => {
  245. let tmpRoute = router.currentRoute.value;
  246. if (tmpRoute.query.keyword != undefined) {
  247. keyword.value = tmpRoute.query.keyword;
  248. } else {
  249. keyword.value = "";
  250. }
  251. if (tmpRoute.fullPath.indexOf("/goods/detail") > -1) {
  252. get("v3/goods/front/goods/details", { productId: calcProductId(tmpRoute.path) })
  253. .then((res) => {
  254. if (res.state == 200) {
  255. vid.value = res.data.storeInf.storeId;
  256. getStoreInfoBaseInfo();
  257. getStoreCatData();
  258. }
  259. });
  260. }
  261. // -1代表没值 0有值
  262. if (
  263. (tmpRoute.fullPath.indexOf("/store") > -1 && tmpRoute.fullPath.indexOf("/store/goods") == -1)
  264. || tmpRoute.fullPath.indexOf("/store/about") > -1
  265. || tmpRoute.fullPath.indexOf("/store/contact") > -1
  266. ) {
  267. vid.value = calcUrlShopId(tmpRoute.path) || calcProductId(tmpRoute.path);
  268. getStoreInfoBaseInfo();
  269. getStoreCatData();
  270. }
  271. //老版的通过query传递vid的方法
  272. // if (tmpRoute.query != undefined && tmpRoute.query.vid != undefined && tmpRoute.query.vid) {
  273. // vid.value = tmpRoute.query.vid;
  274. // getStoreInfoBaseInfo();
  275. // getStoreCatData();
  276. // }
  277. });
  278. //搜索事件(搜全站)
  279. const search = () => {
  280. if (keyword.value) {
  281. router.push({ path: `/goods/list/search_keyword-`+keyword.value});
  282. }
  283. keyword.value = "";
  284. };
  285. //搜索事件(搜本站)
  286. const searchStore = (type, arg) => {
  287. //return
  288. if (type == "keywordStore") {
  289. router.push({
  290. path: "/store/goods/"+ calcProductName(storeData.info.storeName)+"_v-"+ vid.value +"_k-" + keywordStore.value
  291. });
  292. // keywordStore.value = "";
  293. } else if (type == "keyword") {
  294. router.push({
  295. path: "/store/goods/"+ calcProductName(storeData.info.storeName)+"_v-"+ vid.value +"_k-" + keyword.value
  296. });
  297. // keyword.value = "";
  298. }
  299. };
  300. const followStore = () => {
  301. //关注店铺及取消关注
  302. if (filtersStore.getLoginFlag) {
  303. //已登录
  304. let params = {
  305. storeIds: storeData.info.storeId,
  306. isCollect: !eval(storeData.info.isFollow),
  307. };
  308. post("v3/member/front/followStore/edit", params).then((res) => {
  309. if (res.state == 200) {
  310. storeData.info.isFollow = !eval(storeData.info.isFollow) ? "true" : "false";
  311. emit("updateFllow", { state: storeData.info.isFollow });
  312. if (storeData.info.isFollow) {
  313. sldStatEvent({ behaviorType: "fol", storeId: storeData.info.storeId });
  314. }
  315. }
  316. });
  317. }
  318. };
  319. const searchAssociation = (input) => {
  320. get("v3/goods/front/goods/searchWords/list", {
  321. keyWord: input,
  322. }).then((res) => {
  323. if (res.state == 200) {
  324. SAList.value = res.data;
  325. }
  326. });
  327. };
  328. const inputChange = (e) => {
  329. let input = e.target.value;
  330. SAShow.value = true;
  331. if (input) {
  332. searchAssociation(input);
  333. } else {
  334. SAList.value = [];
  335. }
  336. };
  337. const inputBlur = () => {
  338. SAShow.value = false;
  339. };
  340. </script>
  341. <style lang="scss" scoped>
  342. @import "@/assets/style/store/storeHeader.scss";
  343. .kefu {
  344. img {
  345. width: 16px;
  346. height: 16px;
  347. vertical-align: middle;
  348. }
  349. }
  350. .sld_store_follow {
  351. margin-left: 15px;
  352. padding: 7px 9px;
  353. border-radius: 15px;
  354. color: #fff;
  355. background-color: $colorMain;
  356. display: flex;
  357. justify-content: center;
  358. align-items: center;
  359. font-size: 12px;
  360. cursor: pointer;
  361. }
  362. input::placeholder {
  363. font-size: 12px;
  364. /*font-family: Microsoft YaHei;*/
  365. font-weight: 400;
  366. color: rgb(153, 153, 153);
  367. }
  368. ::-webkit-input-placeholder {
  369. margin-left: 20px;
  370. font-size: 12px;
  371. /*font-family: Microsoft YaHei;*/
  372. font-weight: 400;
  373. color: rgb(153, 153, 153);
  374. }
  375. /* 使用webkit内核的浏览器 */
  376. :-moz-placeholder {
  377. font-size: 12px;
  378. /*font-family: Microsoft YaHei;*/
  379. font-weight: 400;
  380. color: rgb(153, 153, 153);
  381. }
  382. /* Firefox版本19+ */
  383. :-ms-input-placeholder {
  384. font-size: 12px;
  385. /*font-family: Microsoft YaHei;*/
  386. font-weight: 400;
  387. color: rgb(153, 153, 153);
  388. }
  389. /* IE浏览器 */
  390. </style>