HeaderCat.vue 13 KB

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