StoreHeader.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620
  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="goLink()" class="contact_btn">联系卖家</a>
  27. </span>
  28. <div class="share">
  29. <span @click="setShowShare(!showShare, $event)">生成手机版链接</span>
  30. <div v-show="showShare">
  31. <i class="icon-guanbi1 iconfont" @click="setShowShare(false, $event)"></i>
  32. <h1>分享链接</h1>
  33. <p>随时随地使用手机查看店铺现货</p>
  34. <canvas id="qrccode-canvas"></canvas>
  35. <input v-if="showShare" :value="url" readonly>
  36. <span v-if="showShare" id="copyLink" :data-clipboard-text="url">复制链接</span>
  37. </div>
  38. </div>
  39. </div>
  40. </div>
  41. <div class="clearfix"></div>
  42. </div>
  43. <div style="background: #FFFFFF;" v-if="isOpen">
  44. <ul class = "shop-contact list-unstyled" style="padding: 15px 0; margin-bottom: 0; border-top: #e8e8e8 1px solid; margin-top: 20px;">
  45. <li v-if="storeInfo.enterprise.enTel">
  46. <span class="public">电话:</span><span v-text="storeInfo.enterprise.enTel"></span>
  47. </li>
  48. <li v-if="storeInfo.enterprise.enFax">
  49. <span class="public">传真:</span><span v-text="storeInfo.enterprise.enFax"></span>
  50. </li>
  51. <li v-if="storeInfo.enterprise.address">
  52. <span class="public">地址:</span><span v-text="storeInfo.enterprise.address"></span>
  53. </li>
  54. <li v-if="storeInfo.enterprise.enPhone">
  55. <span class="public">手机:</span><span v-text="storeInfo.enterprise.enPhone"></span>
  56. </li>
  57. <li v-if="storeInfo.enterprise.enWeixin">
  58. <span class="public">微信:</span><span v-text="storeInfo.enterprise.enWeixin"></span>
  59. </li>
  60. <li v-if="storeInfo.enterprise.enQQ">
  61. <span class="public">Q&nbsp;Q:</span><span v-text="storeInfo.enterprise.enQQ"></span>
  62. </li>
  63. <li class="text-right">
  64. <nuxt-link :to="{ name: 'store-uuid-description', params: { uuid: storeInfo.uuid } }">了解更多&gt;</nuxt-link>
  65. </li>
  66. </ul>
  67. </div>
  68. </div>
  69. </div>
  70. <!-- 搜索框 -->
  71. <div id="search-group" style="margin-left: 450px;">
  72. <search-box/>
  73. </div>
  74. </div>
  75. </div>
  76. <!--关注-->
  77. <el-dialog
  78. :visible.sync="dialogVisible"
  79. size="tiny"
  80. >
  81. <h3 class="header-text">关注成功!</h3>
  82. <div class="focus modal-body">
  83. <button type="button" @click="dialogVisible = false" class="btn" style="margin-left:25px;">关&nbsp;&nbsp;闭</button>
  84. <button type="button" @click="dialogVisible = false" class="focus-btn btn btn btn-info" style="margin-left:35px;">
  85. <a href="/user#/storeFocus" target="_blank">查看我的店铺关注</a>
  86. </button>
  87. </div>
  88. </el-dialog>
  89. <link-saler-box
  90. :tel="tel"
  91. v-if="showLinkBox"
  92. @cancelAction="showLinkBox = false">
  93. </link-saler-box>
  94. </div>
  95. </template>
  96. <script>
  97. import Clipboard from 'clipboard'
  98. import SearchBox from '~components/main/Search.vue'
  99. import LinkSalerBox from '~components/common/LinkSalerBox.vue'
  100. import { goLinkUser } from '~utils/baseUtils'
  101. let QRCode = require('qrcode')
  102. export default {
  103. name: 'store-header',
  104. data () {
  105. return {
  106. isOpen: false,
  107. dialogVisible: false,
  108. clipboard: {},
  109. showShare: false,
  110. showLinkBox: false,
  111. tel: ''
  112. }
  113. },
  114. components: {
  115. SearchBox,
  116. LinkSalerBox
  117. },
  118. mounted () {
  119. let _this = this
  120. _this.url = window.location.href
  121. _this.clipboard = new Clipboard('#copyLink')
  122. _this.clipboard.on('success', e => {
  123. _this.clipboard.destroy()
  124. _this.$message.success('已复制到剪切板')
  125. })
  126. _this.clipboard.on('error', e => {
  127. _this.$message.error('浏览器不支持自动复制,请手动复制')
  128. _this.clipboard.destroy()
  129. })
  130. document.addEventListener('click', function () {
  131. _this.showShare = false
  132. })
  133. },
  134. computed: {
  135. storeInfo () {
  136. return this.$store.state.shop.storeInfo.store.data
  137. },
  138. user () {
  139. return this.$store.state.option.user
  140. },
  141. isFocus () {
  142. return this.$store.state.shop.storeInfo.focusList.data
  143. },
  144. tab () {
  145. return this.$store.state.chat.tab.tab.data
  146. },
  147. url: {
  148. get: function () {
  149. return window.location.protocol + '//' + window.location.host + '/mobile/share/storeShare/' + this.storeInfo.uuid
  150. },
  151. set: function () {
  152. }
  153. }
  154. },
  155. methods: {
  156. loadQRcode: function () {
  157. let canvas = document.getElementById('qrccode-canvas')
  158. QRCode.toCanvas(canvas, this.url, (error) => {
  159. console.log(error || 'QRcode success')
  160. })
  161. },
  162. closeDropDown () {
  163. this.isOpen = false
  164. },
  165. openDropDown () {
  166. this.isOpen = true
  167. },
  168. focus (id, name) {
  169. if (!this.user.logged) {
  170. this.$http.get('/login/page', {params: {returnUrl: window.location.href}}).then(response => {
  171. if (response.data) {
  172. window.location.href = response.data.content + '&baseUrl=' + encodeURIComponent(window.location.protocol + '//' + window.location.host + response.data.baseUrl)
  173. }
  174. })
  175. } else {
  176. this.dialogVisible = true
  177. this.$store.dispatch('shop/StoreFocus', {storeName: name, storeid: id})
  178. this.isFocus = true
  179. }
  180. },
  181. goLink: function () {
  182. goLinkUser(this, this.storeInfo.enUU)
  183. },
  184. // goWebChat: function () {
  185. // if (!this.user.logged) {
  186. // this.$http.get('/login/page').then(response => {
  187. // if (response.data) {
  188. // this.$router.push('/auth/login')
  189. // }
  190. // })
  191. // } else {
  192. // // 获得窗口的垂直位置
  193. // let iTop = (window.screen.availHeight - 30 - 780) / 2
  194. // // 获得窗口的水平位置
  195. // let iLeft = (window.screen.availWidth - 10 - 1030) / 2
  196. // if (this.tab.close) {
  197. // this.tab.close()
  198. // }
  199. // let newTab = window.open('', '即时对话框', 'height=750, width=1000, top=' + iTop + ', left=' + iLeft + ', toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, status=no')
  200. // newTab.close()
  201. // newTab = window.open('', '即时对话框', 'height=750, width=1000, top=' + iTop + ', left=' + iLeft + ', toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, status=no')
  202. // this.$store.dispatch('chat/setChatTab', {tab: newTab})
  203. // this.$http.get('/basic/enterprise/' + this.storeInfo.enUU + '/info')
  204. // .then(response => {
  205. // let obj = {}
  206. // obj.userPhone = this.user.data.userTel
  207. // obj.userType = 'ENTERPRISE'
  208. // this.user.data.enterprises.forEach(function (item, index) {
  209. // if (item.current) {
  210. // obj.enUU = item.uu
  211. // obj.enterprise = {enUU: item.uu, name: item.enName}
  212. // }
  213. // })
  214. // obj.otherEnUU = response.data.uu
  215. // obj.otherUserType = 'STORE'
  216. // obj.otherEnterprise = {enUU: response.data.uu, name: response.data.enName}
  217. // obj.type = 'CHAT'
  218. // if (!(/^1\d{10}$/).test(response.data.enTel)) {
  219. // this.$http.get('/basic/enterprise/' + response.data.uu + '/admin').then(response => {
  220. // console.log(response)
  221. // obj.toPhone = response.data.userTel
  222. // console.log(obj)
  223. // this.openWebChat(newTab, obj)
  224. // }, err => {
  225. // console.log(err)
  226. // this.$message.error('暂无卖家管理员手机号!')
  227. // })
  228. // } else {
  229. // obj.toPhone = response.data.enTel
  230. // console.log(obj)
  231. // this.openWebChat(newTab, obj)
  232. // }
  233. // }, err => {
  234. // console.log(err)
  235. // })
  236. // }
  237. // },
  238. // openWebChat: function (newTab, obj) {
  239. // this.$http.post('https://im.ubtob.com/api/chat/infos?condition=chat_info', obj)
  240. // .then(response => {
  241. // if (response.data.success) {
  242. // newTab.location.href = 'https://im.ubtob.com/chat/visit?gid=' + response.data.content
  243. // } else {
  244. // newTab.close()
  245. // this.$message.error(response.data.message)
  246. // }
  247. // })
  248. // },
  249. setShowShare: function (flag, event) {
  250. event.stopPropagation()
  251. this.loadQRcode()
  252. this.showShare = flag
  253. }
  254. }
  255. }
  256. </script>
  257. <style scoped>
  258. .header-text {
  259. text-align: center;
  260. font-size: 20px;
  261. color: #008B00;
  262. margin-top: 0;
  263. }
  264. .el-dialog__body{
  265. padding: 20px !important;
  266. }
  267. .focus button.focus-btn a{
  268. color: #fff;
  269. width: 100%;
  270. height: 100%;
  271. display: inline-block;
  272. }
  273. .focus button.focus-btn{
  274. width: 138px;
  275. height: 36px;
  276. line-height: 36px;
  277. padding: 0;
  278. }
  279. #nav_fragment {
  280. margin-bottom: 20px;
  281. }
  282. #nav_fragment .shop-name {
  283. font-size: 24px;
  284. color: RGB(50,50,50);
  285. }
  286. #nav_fragment div#shop {
  287. width: 440px;
  288. padding: 5px;
  289. }
  290. #nav_fragment .shop-info {
  291. font-size: 12px;
  292. color: rgb(50,50,50);
  293. }
  294. #nav_fragment .shop-data {
  295. font-size: 12px;
  296. line-height: 25px;
  297. font-weight: 600;
  298. color: RGB(255,0,0);
  299. }
  300. #nav_fragment .btn-nav{
  301. width: 40px;
  302. height: 20px;
  303. line-height: 14px;
  304. padding: 0;
  305. }
  306. #nav_fragment .btn-nav .watch {
  307. font-size: 12px;
  308. color: white;
  309. }
  310. #nav_fragment .btn-nav .message {
  311. font-size: 12px;
  312. color: rgb(50,50,50);
  313. }
  314. #nav_fragment div.dropdown {
  315. margin-top: -5px;
  316. padding: 5px;
  317. }
  318. #nav_fragment .shop-contact {
  319. font-size: 14px;
  320. color: rgb(120,120,120);
  321. line-height: 25px;
  322. }
  323. #nav_fragment .shop-contact a{
  324. color: rgb(33,71,151);
  325. }
  326. #nav_fragment .shop-contact li {
  327. height: 25px;
  328. }
  329. #nav_fragment .shop-contact span{
  330. display:inline-block;
  331. height: 100%
  332. }
  333. #nav_fragment .shop-contact .public {
  334. width:44px;
  335. display:inline-block;
  336. text-align: justify;
  337. vertical-align:top;
  338. }
  339. #nav_fragment .shop-contact .public::after{
  340. content:"";
  341. display: inline-block;
  342. width:100%;
  343. overflow:hidden;
  344. height:0;
  345. }
  346. #nav_fragment #search_input {
  347. height: 40px;
  348. font-size: 16px;
  349. border: 2px solid #5078cb;
  350. border-top-left-radius: 0px;
  351. border-bottom-left-radius: 0px;
  352. line-height: 40px;
  353. }
  354. #nav_fragment #search_input:focus {
  355. border-color: #5078cb;
  356. outline: 0;
  357. -webkit-box-shadow: none;
  358. box-shadow: none;
  359. }
  360. #nav_fragment #search_btn {
  361. background-color: #5078cb;
  362. color: rgb(255, 255, 255);
  363. font-size: 16px;
  364. width: 78px;
  365. height: 40px;
  366. border: 2px solid #5078cb;
  367. border-radius: 0;
  368. }
  369. #nav_fragment #search_btn_this {
  370. height: 36px;
  371. line-height: 36px;
  372. padding-top: 0px;
  373. padding-bottom: 0px;
  374. font-size: 16px;
  375. font-weight: 600;
  376. color: #5078cb;
  377. background: #fff;
  378. border-radius: 0;
  379. border: 1px #5078cb solid;
  380. }
  381. #nav_fragment .my-cart {
  382. margin-top: 20px;
  383. margin-left: 20px;
  384. }
  385. #nav_fragment .my-cart #my-cart{
  386. font-size: 14px;
  387. color: #5078cb;
  388. }
  389. #nav_fragment .my-cart .badge {
  390. background-color: #ff0000;
  391. position: absolute;
  392. top: -10px;
  393. }
  394. #nav_fragment .list-unstyled {
  395. list-style: none;
  396. }
  397. #nav_fragment a:hover,a:focus {
  398. text-decoration: none;
  399. }
  400. #nav_fragment .row>div {
  401. float: left;
  402. }
  403. #nav_fragment #shop {
  404. width: 100%;
  405. position: absolute;
  406. float: left;
  407. }
  408. #nav_fragment #search-group {
  409. padding-top: 20px;
  410. margin-left: 10px;
  411. padding-left: 20px;
  412. top: -12px;
  413. position: relative;
  414. }
  415. #nav_fragment #search-group .input-group {
  416. margin-right: 10px;
  417. float: left;
  418. width: 480px;
  419. }
  420. #nav_fragment .dropdown .dropdown-menu .dropdown-btn {
  421. float: left;
  422. margin-top: 30px;
  423. }
  424. #nav_fragment .dropdown .dropdown-score .description {
  425. padding-top: 10px;
  426. color: #323232;
  427. font-size: 12px;
  428. }
  429. #nav_fragment .dropdown .dropdown-score .score {
  430. display: inline-block;
  431. padding-top: 5px;
  432. color: #FF6868;
  433. font-size: 12px;
  434. }
  435. #nav_fragment .dropdown .dropdown-menu .dropdown-score>div>div {
  436. margin-top: 0px;
  437. width: 25px;
  438. margin-right: 10px;
  439. }
  440. #nav_fragment .shop-score {
  441. margin-top: 20px;
  442. margin-left: 70px;
  443. }
  444. #nav_fragment .shop-score>div>div {
  445. margin-right: 10px;
  446. width: 25px;
  447. }
  448. #nav_fragment .hot-search .active-search-item {
  449. color: #ff0101;
  450. font-size: 13px;
  451. display: inline-block;
  452. margin-right: 1em;
  453. }
  454. #nav_fragment .hot-search .resources {
  455. font-size: 12px;
  456. color: rgb(250,50,50);
  457. }
  458. #nav_fragment .hot-search .hot-word {
  459. font-size: 12px;
  460. color: rgb(50,50,50);
  461. margin-left: 20px;
  462. }
  463. #nav_fragment .drop-down-active {
  464. z-index: 20;
  465. -webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,.075),0 0 2px rgba(210,209,209,.9);
  466. box-shadow:inset 0 1px 1px rgba(0,0,0,.075),0 0 2px rgba(210,209,209,.9);
  467. border: #f5f5f5 1px solid;
  468. background-color: white;
  469. transition: dispaly .5s ease;
  470. }
  471. .hot-search{
  472. margin-top: 5px;
  473. }
  474. .hot-search .static{
  475. color: #f00;
  476. }
  477. .hot-search a{
  478. color: #838383;
  479. }
  480. .hot-search a:hover{
  481. color: #f00;
  482. }
  483. .my-cart .btn{
  484. top: -8px;
  485. position: relative;
  486. }
  487. #search-group .association {
  488. position: absolute;
  489. left: 0;
  490. top: 100%;
  491. right: 61px;
  492. list-style: none;
  493. -webkit-padding-start: 0;
  494. background: #ffffff;
  495. border: 1px solid #dddddd;
  496. z-index: 21;
  497. }
  498. #search-group .association li {
  499. padding: 0 15px;
  500. line-height: 30px;
  501. text-align: left;
  502. }
  503. #search-group .association li:hover {
  504. background: #EEEEEE;
  505. cursor: pointer;
  506. }
  507. .text-right{
  508. text-align: right;
  509. }
  510. .text-right a:hover{
  511. color: #d32526 !important;
  512. text-decoration: underline;
  513. }
  514. .icon-style img{
  515. vertical-align: top;
  516. position: relative;
  517. top: -9px;
  518. }
  519. .icon-style >span {
  520. margin-right: 5px;
  521. }
  522. .icon-style .link-seller {
  523. cursor: pointer;
  524. }
  525. .icon-style .link-seller img {
  526. top: -2px;
  527. }
  528. .icon-style .link-seller a {
  529. font-size: 12px;
  530. color: #fff;
  531. line-height: 20px;
  532. height: 20px;
  533. padding: 0 7px;
  534. background: #ef7f03;
  535. border-radius: 2px;
  536. }
  537. .icon-style .share {
  538. display: inline-block;
  539. margin-left: 5px;
  540. position: relative;
  541. }
  542. .icon-style .share > span {
  543. color: #4290f7;
  544. cursor: pointer;
  545. }
  546. .icon-style .share > div {
  547. position: absolute;
  548. top: 26px;
  549. left: -94px;
  550. width: 300px;
  551. height: 380px;
  552. background: #fff;
  553. box-shadow: 1px 1px 4px 0 #ccbebe;
  554. z-index: 1;
  555. text-align: center;
  556. }
  557. .icon-style .share > div input {
  558. display: inline-block;
  559. width: 140px;
  560. overflow: hidden;
  561. height: 35px;
  562. vertical-align: middle;
  563. }
  564. .icon-style .share > div span {
  565. display: inline-block;
  566. color: #fff;
  567. background: #4290f7;
  568. height: 36px;
  569. line-height: 36px;
  570. width: 70px;
  571. font-style: normal;
  572. vertical-align: middle;
  573. cursor: pointer;
  574. }
  575. .icon-style .share > div i {
  576. position: absolute;
  577. right: 10px;
  578. top: 5px;
  579. cursor: pointer;
  580. font-size: 14px;
  581. font-weight: bold;
  582. }
  583. </style>