StoreHeader.vue 17 KB

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