StoreHeader.vue 16 KB

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