StoreHeader.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478
  1. <template>
  2. <div id="nav_fragment">
  3. <div class="container">
  4. <div class="row" style="height: 120px; padding-top: 30px; margin: 0;">
  5. <!-- 店铺信息以及下拉菜单 -->
  6. <div id = "shop" :class="{ 'drop-down-active' : isOpen }" @mouseleave="closeDropDown()">
  7. <div class="dropdown">
  8. <div style="width: 440px;">
  9. <div class="dropdown-btn" style="margin-top: 0;">
  10. <div style="margin-bottom: 15px;">
  11. <a role="button" class="dropdown-toggle" @mouseover="openDropDown()">
  12. <span class="shop-name" v-text="storeInfo.storeName || '店铺名称'"></span>
  13. <span><i class="fa fa-angle-down fa-fw" style="font-size: 20px;"></i></span>
  14. </a>
  15. </div>
  16. <div class="icon-style">
  17. <button class="btn btn-xs btn-danger btn-nav" v-if="!isFocus"><span class="watch">关注</span></button>
  18. <span v-if="isFocus == 'false' || typeof isFocus == 'object'"><button type="text" @click="focus(storeInfo.id, storeInfo.storeName)" class="btn btn-xs btn-danger btn-nav"><span class="watch">关注</span></button></span>
  19. <span v-if="isFocus == 'true'" ><button class="btn btn-xs btn-default btn-nav" style="width:50px"><span>已关注</span></button></span>
  20. <span v-if="storeInfo.type == 'ORIGINAL_FACTORY'">&nbsp;<img src="/images/store/icon/icon-factory.png"/></span>
  21. <span v-else-if="storeInfo.type == 'AGENCY'">&nbsp;<img src="/images/store/icon/icon-agent.png"/></span>
  22. <span v-else-if="storeInfo.type == 'DISTRIBUTION'">&nbsp;<img src="/images/store/icon/icon-distribution.png"/></span>
  23. <span v-else-if="storeInfo.type == 'CONSIGNMENT'">&nbsp;<img src="/images/store/icon/consignment.png"/></span>
  24. <span class="link-seller">
  25. <img src="/images/all/songguo.png">
  26. <a @click="goWebChat()" class="contact_btn">联系卖家</a>
  27. </span>
  28. </div>
  29. </div>
  30. <div class="clearfix"></div>
  31. </div>
  32. <div style="background: #FFFFFF;" v-if="isOpen">
  33. <ul class = "shop-contact list-unstyled" style="padding: 15px 0; margin-bottom: 0; border-top: #e8e8e8 1px solid; margin-top: 20px;">
  34. <li v-if="storeInfo.enterprise.enTel">
  35. <span>电话:</span><span v-text="storeInfo.enterprise.enTel"></span>
  36. </li>
  37. <li v-if="storeInfo.enterprise.enFax">
  38. <span>传真:</span><span v-text="storeInfo.enterprise.enFax"></span>
  39. </li>
  40. <li v-if="storeInfo.enterprise.address || storeInfo.enterprise.enAddress">
  41. <span>地址:</span><span v-text="storeInfo.enterprise.address || storeInfo.enterprise.enAddress"></span>
  42. </li>
  43. <li class="text-right">
  44. <nuxt-link :to="{ name: 'store-uuid-description', params: { uuid: storeInfo.uuid } }">了解更多&gt;</nuxt-link>
  45. </li>
  46. </ul>
  47. </div>
  48. </div>
  49. </div>
  50. <!-- 搜索框 -->
  51. <div id="search-group" style="margin-left: 450px;">
  52. <search-box/>
  53. </div>
  54. </div>
  55. </div>
  56. <!--关注-->
  57. <el-dialog
  58. :visible.sync="dialogVisible"
  59. size="tiny"
  60. >
  61. <h3 class="header-text">关注成功!</h3>
  62. <div class="focus modal-body">
  63. <button type="button" @click="dialogVisible = false" class="btn" style="margin-left:25px;">关&nbsp;&nbsp;闭</button>
  64. <button type="button" @click="dialogVisible = false" class="focus-btn btn btn btn-info" style="margin-left:35px;">
  65. <a href="/user#/storeFocus" target="_blank">查看我的店铺关注</a>
  66. </button>
  67. </div>
  68. </el-dialog>
  69. </div>
  70. </template>
  71. <script>
  72. import SearchBox from '~components/main/Search.vue'
  73. export default {
  74. name: 'store-header',
  75. data () {
  76. return {
  77. isOpen: false,
  78. dialogVisible: false
  79. }
  80. },
  81. components: {
  82. SearchBox
  83. },
  84. computed: {
  85. storeInfo () {
  86. return this.$store.state.shop.storeInfo.store.data
  87. },
  88. user () {
  89. return this.$store.state.option.user
  90. },
  91. isFocus () {
  92. return this.$store.state.shop.storeInfo.focusList.data
  93. },
  94. tab () {
  95. return this.$store.state.chat.tab.tab.data
  96. }
  97. },
  98. methods: {
  99. closeDropDown () {
  100. this.isOpen = false
  101. },
  102. openDropDown () {
  103. this.isOpen = true
  104. },
  105. focus (id, name) {
  106. if (!this.user.logged) {
  107. this.$http.get('/login/page', {params: {returnUrl: window.location.href}}).then(response => {
  108. if (response.data) {
  109. window.location.href = response.data.content + '&baseUrl=' + encodeURIComponent(window.location.protocol + '//' + window.location.host + response.data.baseUrl)
  110. }
  111. })
  112. } else {
  113. this.dialogVisible = true
  114. this.$store.dispatch('shop/StoreFocus', {storeName: name, storeid: id})
  115. this.isFocus = true
  116. }
  117. },
  118. goWebChat: function () {
  119. if (!this.user.logged) {
  120. this.$http.get('/login/page').then(response => {
  121. if (response.data) {
  122. this.$router.push('/auth/login')
  123. }
  124. })
  125. } else {
  126. // 获得窗口的垂直位置
  127. let iTop = (window.screen.availHeight - 30 - 780) / 2
  128. // 获得窗口的水平位置
  129. let iLeft = (window.screen.availWidth - 10 - 1030) / 2
  130. if (this.tab.close) {
  131. this.tab.close()
  132. }
  133. let newTab = window.open('', '即时对话框', 'height=750, width=1000, top=' + iTop + ', left=' + iLeft + ', toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, status=no')
  134. newTab.close()
  135. newTab = window.open('', '即时对话框', 'height=750, width=1000, top=' + iTop + ', left=' + iLeft + ', toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, status=no')
  136. this.$store.dispatch('chat/setChatTab', {tab: newTab})
  137. this.$http.get('/basic/enterprise/' + this.storeInfo.enUU + '/info')
  138. .then(response => {
  139. let obj = {}
  140. obj.userPhone = this.user.data.userTel
  141. obj.userType = 'ENTERPRISE'
  142. this.user.data.enterprises.forEach(function (item, index) {
  143. if (item.current) {
  144. obj.enUU = item.uu
  145. obj.enterprise = {enUU: item.uu, name: item.enName}
  146. }
  147. })
  148. obj.otherEnUU = response.data.uu
  149. obj.otherUserType = 'STORE'
  150. obj.otherEnterprise = {enUU: response.data.uu, name: response.data.enName}
  151. obj.type = 'CHAT'
  152. if (!(/^1\d{10}$/).test(response.data.enTel)) {
  153. this.$http.get('/basic/enterprise/' + response.data.uu + '/admin').then(response => {
  154. console.log(response)
  155. obj.toPhone = response.data.userTel
  156. console.log(obj)
  157. this.openWebChat(newTab, obj)
  158. }, err => {
  159. console.log(err)
  160. this.$message.error('暂无卖家管理员手机号!')
  161. })
  162. } else {
  163. obj.toPhone = response.data.enTel
  164. console.log(obj)
  165. this.openWebChat(newTab, obj)
  166. }
  167. }, err => {
  168. console.log(err)
  169. })
  170. }
  171. },
  172. openWebChat: function (newTab, obj) {
  173. this.$http.post('https://im.ubtob.com/api/chat/infos?condition=chat_info', obj)
  174. .then(response => {
  175. if (response.data.success) {
  176. newTab.location.href = 'https://im.ubtob.com/chat/visit?gid=' + response.data.content
  177. }
  178. })
  179. }
  180. }
  181. }
  182. </script>
  183. <style scoped>
  184. .header-text {
  185. text-align: center;
  186. font-size: 20px;
  187. color: #008B00;
  188. margin-top: 0;
  189. }
  190. .el-dialog__body{
  191. padding: 20px !important;
  192. }
  193. .focus button.focus-btn a{
  194. color: #fff;
  195. width: 100%;
  196. height: 100%;
  197. display: inline-block;
  198. }
  199. .focus button.focus-btn{
  200. width: 138px;
  201. height: 36px;
  202. line-height: 36px;
  203. padding: 0;
  204. }
  205. #nav_fragment {
  206. margin-bottom: 20px;
  207. }
  208. #nav_fragment .shop-name {
  209. font-size: 24px;
  210. color: RGB(50,50,50);
  211. }
  212. #nav_fragment div#shop {
  213. width: 440px;
  214. padding: 5px;
  215. }
  216. #nav_fragment .shop-info {
  217. font-size: 12px;
  218. color: rgb(50,50,50);
  219. }
  220. #nav_fragment .shop-data {
  221. font-size: 12px;
  222. line-height: 25px;
  223. font-weight: 600;
  224. color: RGB(255,0,0);
  225. }
  226. #nav_fragment .btn-nav{
  227. width: 40px;
  228. height: 20px;
  229. line-height: 14px;
  230. padding: 0;
  231. }
  232. #nav_fragment .btn-nav .watch {
  233. font-size: 12px;
  234. color: white;
  235. }
  236. #nav_fragment .btn-nav .message {
  237. font-size: 12px;
  238. color: rgb(50,50,50);
  239. }
  240. #nav_fragment div.dropdown {
  241. margin-top: -5px;
  242. padding: 5px;
  243. }
  244. #nav_fragment .shop-contact {
  245. font-size: 14px;
  246. color: rgb(120,120,120);
  247. line-height: 25px;
  248. }
  249. #nav_fragment .shop-contact a{
  250. color: rgb(33,71,151);
  251. }
  252. #nav_fragment #search_input {
  253. height: 40px;
  254. font-size: 16px;
  255. border: 2px solid #5078cb;
  256. border-top-left-radius: 0px;
  257. border-bottom-left-radius: 0px;
  258. line-height: 40px;
  259. }
  260. #nav_fragment #search_input:focus {
  261. border-color: #5078cb;
  262. outline: 0;
  263. -webkit-box-shadow: none;
  264. box-shadow: none;
  265. }
  266. #nav_fragment #search_btn {
  267. background-color: #5078cb;
  268. color: rgb(255, 255, 255);
  269. font-size: 16px;
  270. width: 78px;
  271. height: 40px;
  272. border: 2px solid #5078cb;
  273. border-radius: 0;
  274. }
  275. #nav_fragment #search_btn_this {
  276. height: 36px;
  277. line-height: 36px;
  278. padding-top: 0px;
  279. padding-bottom: 0px;
  280. font-size: 16px;
  281. font-weight: 600;
  282. color: #5078cb;
  283. background: #fff;
  284. border-radius: 0;
  285. border: 1px #5078cb solid;
  286. }
  287. #nav_fragment .my-cart {
  288. margin-top: 20px;
  289. margin-left: 20px;
  290. }
  291. #nav_fragment .my-cart #my-cart{
  292. font-size: 14px;
  293. color: #5078cb;
  294. }
  295. #nav_fragment .my-cart .badge {
  296. background-color: #ff0000;
  297. position: absolute;
  298. top: -10px;
  299. }
  300. #nav_fragment .list-unstyled {
  301. list-style: none;
  302. }
  303. #nav_fragment a:hover,a:focus {
  304. text-decoration: none;
  305. }
  306. #nav_fragment .row>div {
  307. float: left;
  308. }
  309. #nav_fragment #shop {
  310. width: 100%;
  311. position: absolute;
  312. float: left;
  313. }
  314. #nav_fragment #search-group {
  315. padding-top: 20px;
  316. margin-left: 10px;
  317. padding-left: 20px;
  318. top: -12px;
  319. position: relative;
  320. }
  321. #nav_fragment #search-group .input-group {
  322. margin-right: 10px;
  323. float: left;
  324. width: 480px;
  325. }
  326. #nav_fragment .dropdown .dropdown-menu .dropdown-btn {
  327. float: left;
  328. margin-top: 30px;
  329. }
  330. #nav_fragment .dropdown .dropdown-score .description {
  331. padding-top: 10px;
  332. color: #323232;
  333. font-size: 12px;
  334. }
  335. #nav_fragment .dropdown .dropdown-score .score {
  336. display: inline-block;
  337. padding-top: 5px;
  338. color: #FF6868;
  339. font-size: 12px;
  340. }
  341. #nav_fragment .dropdown .dropdown-menu .dropdown-score>div>div {
  342. margin-top: 0px;
  343. width: 25px;
  344. margin-right: 10px;
  345. }
  346. #nav_fragment .shop-score {
  347. margin-top: 20px;
  348. margin-left: 70px;
  349. }
  350. #nav_fragment .shop-score>div>div {
  351. margin-right: 10px;
  352. width: 25px;
  353. }
  354. #nav_fragment .hot-search .active-search-item {
  355. color: #ff0101;
  356. font-size: 13px;
  357. display: inline-block;
  358. margin-right: 1em;
  359. }
  360. #nav_fragment .hot-search .resources {
  361. font-size: 12px;
  362. color: rgb(250,50,50);
  363. }
  364. #nav_fragment .hot-search .hot-word {
  365. font-size: 12px;
  366. color: rgb(50,50,50);
  367. margin-left: 20px;
  368. }
  369. #nav_fragment .drop-down-active {
  370. z-index: 20;
  371. -webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,.075),0 0 2px rgba(210,209,209,.9);
  372. box-shadow:inset 0 1px 1px rgba(0,0,0,.075),0 0 2px rgba(210,209,209,.9);
  373. border: #f5f5f5 1px solid;
  374. background-color: white;
  375. transition: dispaly .5s ease;
  376. }
  377. .hot-search{
  378. margin-top: 5px;
  379. }
  380. .hot-search .static{
  381. color: #f00;
  382. }
  383. .hot-search a{
  384. color: #838383;
  385. }
  386. .hot-search a:hover{
  387. color: #f00;
  388. }
  389. .my-cart .btn{
  390. top: -8px;
  391. position: relative;
  392. }
  393. #search-group .association {
  394. position: absolute;
  395. left: 0;
  396. top: 100%;
  397. right: 61px;
  398. list-style: none;
  399. -webkit-padding-start: 0;
  400. background: #ffffff;
  401. border: 1px solid #dddddd;
  402. z-index: 21;
  403. }
  404. #search-group .association li {
  405. padding: 0 15px;
  406. line-height: 30px;
  407. text-align: left;
  408. }
  409. #search-group .association li:hover {
  410. background: #EEEEEE;
  411. cursor: pointer;
  412. }
  413. .text-right{
  414. text-align: right;
  415. }
  416. .text-right a:hover{
  417. color: #d32526 !important;
  418. text-decoration: underline;
  419. }
  420. .icon-style img{
  421. vertical-align: top;
  422. position: relative;
  423. top: -9px;
  424. }
  425. .icon-style >span {
  426. margin-right: 5px;
  427. }
  428. .icon-style .link-seller {
  429. cursor: pointer;
  430. }
  431. .icon-style .link-seller img {
  432. top: -2px;
  433. }
  434. .icon-style .link-seller a {
  435. font-size: 12px;
  436. color: #fff;
  437. line-height: 20px;
  438. height: 20px;
  439. padding: 0 7px;
  440. background: #ef7f03;
  441. border-radius: 2px;
  442. }
  443. </style>