StoreHeader.vue 17 KB

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