StoreBanner.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561
  1. <template>
  2. <div class="container" id="title-fragment">
  3. <div class="container" v-if="$route.params.uuid === pcbId">
  4. <div class="shop-pcb">
  5. <ul class="pk-list">
  6. <li class="pk-item" v-for="kind in kinds">
  7. <nuxt-link :to="`/pcb/search/?w=${encodeURIComponent(kind.nameCn)}`">{{kind.nameCn}}<i class="icon-arrow-right iconfont"></i></nuxt-link>
  8. </li>
  9. </ul>
  10. </div>
  11. <div class="pcb-banner">
  12. <img :src="storeInfo.bannerUrl || '/images/store/default/shop_banner.png'">
  13. <div id="shop-title" v-if="storeInfo.storeShortName" v-text="storeInfo.storeShortName">店铺名称</div>
  14. </div>
  15. </div>
  16. <div class="container" v-else>
  17. <div class="row" style="margin-bottom: 20px;">
  18. <!-- 商标展示 -->
  19. <div class="logo two-word" v-if="storeInfo.type == 'ORIGINAL_FACTORY'">原厂</div>
  20. <div class="logo two-word" v-else-if="storeInfo.type == 'CONSIGNMENT'">寄售</div>
  21. <div class="logo" v-else-if="storeInfo.type == 'AGENCY'">代理商</div>
  22. <div class="logo" v-else-if="storeInfo.type == 'DISTRIBUTION'">经销商</div>
  23. <div class="shop-logo">
  24. <img class="logo-img" :src="storeInfo.logoUrl || '/images/store/common/default.png'" />
  25. <input type="text" readonly class="form-control shop-name" :value="storeInfo.storeName">
  26. <div class="enter-store">
  27. <a v-if="isFocus === 'false'" @click="focusStore(storeInfo, $event)">关注店铺</a>
  28. <a v-else class="focus" @click="focusStore(storeInfo, $event)">已关注</a>
  29. <a @click="goLink()">联系卖家</a>
  30. </div>
  31. <div class="share">
  32. <span @click="setShowShare(!showShare, $event)">手机版链接&nbsp;<img src="/images/store/home/qrccode-small.png">&nbsp;&nbsp;<img :class="{'active': showCate}" src="/images/store/home/arrow-down.png" alt=""></span>
  33. <div v-show="showShare">
  34. <i class="icon-guanbi1 iconfont" @click="setShowShare(false, $event)"></i>
  35. <h1>分享链接</h1>
  36. <p>随时随地使用手机查看店铺现货</p>
  37. <canvas id="qrccode-canvas"></canvas>
  38. <!--<input v-show="showShare" :value="url" readonly>-->
  39. <span v-if="showShare" id="copyLink" :data-clipboard-text="url">复制链接</span>
  40. </div>
  41. </div>
  42. </div>
  43. <!-- 店名展示 -->
  44. <div class="shop-banner">
  45. <img :src="storeInfo.bannerUrl || '/images/store/default/shop_banner.png'">
  46. <!-- <div id="shop-title" v-if="storeInfo.storeShortName" v-text="storeInfo.storeShortName">店铺名称</div>-->
  47. </div>
  48. </div>
  49. <el-dialog
  50. :visible.sync="dialogVisible"
  51. size="tiny"
  52. >
  53. <h3 class="header-text">关注成功!</h3>
  54. <div class="focus modal-body">
  55. <button type="button" @click="dialogVisible = false" class="btn" style="margin-left:25px;">关&nbsp;&nbsp;闭</button>
  56. <button type="button" @click="dialogVisible = false" class="focus-btn btn btn btn-info" style="margin-left:35px;">
  57. <a href="/user#/storeFocus" target="_blank">查看我的店铺关注</a>
  58. </button>
  59. </div>
  60. </el-dialog>
  61. <el-dialog
  62. :visible.sync="dialogInvisible"
  63. size="tiny"
  64. >
  65. <h3 class="header-text">关注取消!</h3>
  66. <div class="focus modal-body">
  67. <button type="button" @click="dialogInvisible = false" class="btn" style="margin-left:25px;">关&nbsp;&nbsp;闭</button>
  68. <button type="button" @click="dialogInvisible = false" class="focus-btn btn btn btn-info" style="margin-left:35px;">
  69. <a href="/user#/storeFocus" target="_blank">查看我的店铺关注</a>
  70. </button>
  71. </div>
  72. </el-dialog>
  73. <link-saler-box
  74. :tel="tel"
  75. v-if="showLinkBox"
  76. @cancelAction="showLinkBox = false">
  77. </link-saler-box>
  78. </div>
  79. </div>
  80. </template>
  81. <script>
  82. import Clipboard from 'clipboard'
  83. import LinkSalerBox from '~components/common/LinkSalerBox.vue'
  84. let QRCode = require('qrcode')
  85. export default {
  86. name: 'store-banner',
  87. data () {
  88. return {
  89. pcbId: process.env.pcbId,
  90. dialogVisible: false,
  91. dialogInvisible: false,
  92. showShare: false,
  93. clipboard: {},
  94. showLinkBox: false,
  95. showCate: false,
  96. tel: ''
  97. }
  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. // _this.showCate = false
  114. })
  115. },
  116. components: {
  117. LinkSalerBox
  118. },
  119. methods: {
  120. loadQRcode: function () {
  121. let canvas = document.getElementById('qrccode-canvas')
  122. QRCode.toCanvas(canvas, this.url, (error) => {
  123. console.log(error || 'QRcode success')
  124. })
  125. },
  126. setShowShare: function (flag, event) {
  127. event.stopPropagation()
  128. this.loadQRcode()
  129. this.showShare = flag
  130. this.showCate = flag
  131. },
  132. focusStore: function (item, $event) {
  133. $event.stopPropagation()
  134. if (this.user.logged) {
  135. if (this.isFocus === 'false') {
  136. this.dialogVisible = true
  137. this.$store.dispatch('shop/StoreFocus', {storeName: item.storeName, storeid: item.id})
  138. } else {
  139. this.$http.post('/trade/storeFocus/delete/storeId', [item.id])
  140. .then(response => {
  141. this.dialogInvisible = true
  142. this.$store.dispatch('shop/StoreFocusList', {id: item.id})
  143. })
  144. }
  145. } else {
  146. this.$http.get('/login/page', {params: {returnUrl: window.location.href}}).then(response => {
  147. if (response.data) {
  148. window.location.href = response.data.content + '&baseUrl=' + encodeURIComponent(window.location.protocol + '//' + window.location.host + response.data.baseUrl)
  149. }
  150. })
  151. }
  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. goLink: function () {
  167. this.baseUtils.goLinkUser(this, this.storeInfo.enUU)
  168. }
  169. // goWebChat: function () {
  170. // if (!this.user.logged) {
  171. // this.$http.get('/login/page').then(response => {
  172. // if (response.data) {
  173. // this.$router.push('/auth/login')
  174. // }
  175. // })
  176. // } else {
  177. // // 获得窗口的垂直位置
  178. // let iTop = (window.screen.availHeight - 30 - 780) / 2
  179. // // 获得窗口的水平位置
  180. // let iLeft = (window.screen.availWidth - 10 - 1030) / 2
  181. // if (this.tab.close) {
  182. // this.tab.close()
  183. // }
  184. // let newTab = window.open('', '即时对话框', 'height=750, width=1000, top=' + iTop + ', left=' + iLeft + ', toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, status=no')
  185. // newTab.close()
  186. // newTab = window.open('', '即时对话框', 'height=750, width=1000, top=' + iTop + ', left=' + iLeft + ', toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, status=no')
  187. // this.$store.dispatch('chat/setChatTab', {tab: newTab})
  188. // this.$http.get('/basic/enterprise/' + this.storeInfo.enUU + '/info')
  189. // .then(response => {
  190. // let obj = {}
  191. // obj.userPhone = this.user.data.userTel
  192. // obj.userType = 'ENTERPRISE'
  193. // this.user.data.enterprises.forEach(function (item, index) {
  194. // if (item.current) {
  195. // obj.enUU = item.uu
  196. // obj.enterprise = {enUU: item.uu, name: item.enName}
  197. // }
  198. // })
  199. // obj.otherEnUU = response.data.uu
  200. // obj.otherUserType = 'STORE'
  201. // obj.otherEnterprise = {enUU: response.data.uu, name: response.data.enName}
  202. // obj.type = 'CHAT'
  203. // if (!(/^1\d{10}$/).test(response.data.enTel)) {
  204. // this.$http.get('/basic/enterprise/' + response.data.uu + '/admin').then(response => {
  205. // console.log(response)
  206. // obj.toPhone = response.data.userTel
  207. // console.log(obj)
  208. // this.openWebChat(newTab, obj)
  209. // }, err => {
  210. // console.log(err)
  211. // this.$message.error('暂无卖家管理员手机号!')
  212. // })
  213. // } else {
  214. // obj.toPhone = response.data.enTel
  215. // console.log(obj)
  216. // this.openWebChat(newTab, obj)
  217. // }
  218. // }, err => {
  219. // console.log(err)
  220. // })
  221. // }
  222. // },
  223. // openWebChat: function (newTab, obj) {
  224. // this.$http.post('https://im.ubtob.com/api/chat/infos?condition=chat_info', obj)
  225. // .then(response => {
  226. // if (response.data.success) {
  227. // newTab.location.href = 'https://im.ubtob.com/chat/visit?gid=' + response.data.content
  228. // }
  229. // })
  230. // }
  231. },
  232. filters: {
  233. nameFilter: function (title) {
  234. if (title === '') {
  235. return title
  236. }
  237. let len = 0
  238. let index = 0
  239. for (let i = 0; i < title.length; i++) {
  240. if (index === 0 && title.charAt(i).charCodeAt(0) > 255) {
  241. len = len + 2
  242. } else {
  243. len++
  244. }
  245. if (len > 24) {
  246. index = i
  247. break
  248. }
  249. }
  250. if (index > 0) {
  251. return title.substring(0, index) + '...'
  252. } else {
  253. return title
  254. }
  255. },
  256. date: function (input) {
  257. const d = new Date(input)
  258. const year = d.getFullYear()
  259. const monthTemp = d.getMonth() + 1
  260. const month = monthTemp < 10 ? '0' + monthTemp : '' + monthTemp
  261. const hour = d.getHours() < 10 ? '0' + d.getHours() : '' + d.getHours() + ' '
  262. const minutes = d.getMinutes() < 10 ? '0' + d.getMinutes() : '' + d.getMinutes() + ' '
  263. const day = d.getDate() < 10 ? '0' + d.getDate() : '' + d.getDate() + ' '
  264. return year + '-' + month + '-' + day + ' ' + hour + ':' + minutes
  265. }
  266. },
  267. computed: {
  268. kinds () {
  269. return this.$store.state.pcb.kindsData.kinds.data
  270. },
  271. storeInfo () {
  272. return this.$store.state.shop.storeInfo.store.data
  273. },
  274. isConsignment () {
  275. return this.storeInfo.type === 'CONSIGNMENT'
  276. },
  277. tab () {
  278. return this.$store.state.chat.tab.tab.data
  279. },
  280. user () {
  281. return this.$store.state.option.user
  282. },
  283. isFocus () {
  284. return this.user.logged ? this.$store.state.shop.storeInfo.focusList.data : 'false'
  285. },
  286. url: {
  287. get: function () {
  288. return window.location.protocol + '//' + window.location.host + '/mobile/share/storeShare/' + this.storeInfo.uuid
  289. },
  290. set: function () {
  291. }
  292. }
  293. }
  294. }
  295. </script>
  296. <style lang="scss">
  297. .header-text {
  298. text-align: center;
  299. font-size: 20px;
  300. color: #008B00;
  301. margin-top: 0;
  302. }
  303. .el-dialog__wrapper .el-dialog--tiny {
  304. width: 320px !important;
  305. }
  306. .el-dialog__body {
  307. padding: 14px !important;
  308. }
  309. .focus button.focus-btn a{
  310. color: #fff;
  311. width: 100%;
  312. height: 100%;
  313. display: inline-block;
  314. }
  315. .focus button.focus-btn{
  316. width: 138px;
  317. height: 36px;
  318. line-height: 36px;
  319. padding: 0;
  320. }
  321. #title-fragment {
  322. padding: 0;
  323. }
  324. #title-fragment .container {
  325. width: 1190px;
  326. padding-left: 0px;
  327. padding-right: 0px;
  328. }
  329. #title-fragment .container >.row {
  330. margin-left: 0px;
  331. margin-right: 0px;
  332. position: relative;
  333. /*background: #fff;*/
  334. }
  335. #title-fragment .logo{
  336. width: 28px;
  337. padding-right: 3px;
  338. height: 60px;
  339. text-align: center;
  340. line-height: 15px;
  341. position: absolute;
  342. top: 13px;
  343. left: 0px;
  344. color: #fff;
  345. margin-top: -20px;
  346. background: url('/images/store/home/logo-type.png') no-repeat;
  347. z-index: 100;
  348. padding-top: 3px;
  349. }
  350. .two-word{
  351. padding-top: 10px;
  352. }
  353. #title-fragment .shop-pcb{
  354. margin-right: 10px;
  355. width: 220px;
  356. border: 1px solid #e8e8e8;
  357. float: left;
  358. text-align: center;
  359. line-height: 210px;
  360. position: relative;
  361. background: #fff;
  362. .pk-list {
  363. height:300px;
  364. .pk-item{
  365. height:50px;
  366. line-height: 50px;
  367. border-bottom:1px solid #e7e7e7;
  368. cursor:pointer;
  369. text-align: left;
  370. &:last-child{
  371. border:none;
  372. }
  373. a {
  374. color: #666;
  375. margin-left:20px;
  376. }
  377. .iconfont {
  378. float: right;
  379. margin-right: 18px;
  380. }
  381. }
  382. }
  383. }
  384. #title-fragment .shop-logo {
  385. margin-right: 10px;
  386. width: 220px;
  387. height: 260px;
  388. border: 1px solid #e8e8e8;
  389. float: left;
  390. text-align: center;
  391. line-height: 210px;
  392. position: relative;
  393. background: #fff;
  394. .shop-name{
  395. display:block;
  396. height: 40px;
  397. line-height: 40px;
  398. margin: 0 auto;
  399. margin-top: -105px;
  400. text-align: center;
  401. width: 95%;
  402. border: none;
  403. background: none;
  404. box-shadow: none;
  405. }
  406. .enter-store {
  407. width: 100%;
  408. height: 30px;
  409. line-height: 30px;
  410. text-align: left;
  411. margin: 10px 0;
  412. padding-left: 20px;
  413. a {
  414. width: 70px;
  415. height: 24px;
  416. display: inline-block;
  417. line-height: 22px;
  418. text-align: center;
  419. font-size: 13px;
  420. margin-left: 12px;
  421. border-radius: 3px;
  422. &:first-child {
  423. background: #2496f1;
  424. border: 1px solid #2496f1;
  425. color: #fff;
  426. }
  427. &.focus{
  428. background-color: #c1c1c1;
  429. border: 1px solid #c1c1c1;
  430. }
  431. &:last-child {
  432. background: #fff;
  433. border: 1px solid #2496f1;
  434. color: #2496f1;
  435. }
  436. }
  437. }
  438. .share {
  439. display: inline-block;
  440. position: relative;
  441. > span {
  442. position: relative;
  443. top: -81px;
  444. color: #2496f1;
  445. cursor: pointer;
  446. .active {
  447. transform:rotate(180deg);
  448. -ms-transform:rotate(180deg); /* Internet Explorer */
  449. -moz-transform:rotate(180deg); /* Firefox */
  450. -webkit-transform:rotate(180deg); /* Safari 和 Chrome */
  451. -o-transform:rotate(180deg); /* Opera */
  452. }
  453. }
  454. > div {
  455. position: absolute;
  456. top: 38px;
  457. left: -47px;
  458. width: 211px;
  459. height: 321px;
  460. background: #fff;
  461. box-shadow: 1px 1px 4px 0 #ccbebe;
  462. z-index: 1300000;
  463. text-align: center;
  464. h1, p{
  465. height: 30px;
  466. width: 100%;
  467. }
  468. h1{
  469. margin-top: -80px;
  470. }
  471. p{
  472. margin-top: -10px;
  473. }
  474. canvas{
  475. margin-top: 75px;
  476. }
  477. /*input {
  478. display: inline-block;
  479. width: 140px;
  480. overflow: hidden;
  481. height: 35px;
  482. vertical-align: middle;
  483. }*/
  484. span {
  485. display: inline-block;
  486. color: #fff;
  487. background: #4290f7;
  488. height: 36px;
  489. line-height: 36px;
  490. width: 70px;
  491. font-style: normal;
  492. vertical-align: middle;
  493. cursor: pointer;
  494. margin-top: -380px;
  495. }
  496. i {
  497. position: absolute;
  498. right: 10px;
  499. top: -89px;
  500. cursor: pointer;
  501. font-size: 14px;
  502. font-weight: bold;
  503. }
  504. }
  505. }
  506. }
  507. #title-fragment .shop-logo .logo-img {
  508. width: 173px;
  509. height: 86px;
  510. margin-top: -102px;
  511. }
  512. #title-fragment .pcb-banner {
  513. float: left;
  514. position: relative;
  515. width: 955px;
  516. height: 320px;
  517. border: 1px solid #e8e8e8;
  518. border-left: none;
  519. overflow: hidden;
  520. border-radius: 5px;
  521. img{
  522. width: 955px;
  523. height: 300px;
  524. }
  525. #shop-title{
  526. position: absolute;
  527. top: 50px;
  528. left: 60px;
  529. font-size: 30px;
  530. color: rgb(255,255,255);
  531. }
  532. }
  533. #title-fragment .shop-banner {
  534. float: left;
  535. position: relative;
  536. width: 955px;
  537. height: 280px;
  538. border: 1px solid #e8e8e8;
  539. border-left: none;
  540. overflow: hidden;
  541. border-radius: 5px;
  542. img{
  543. width: 955px;
  544. height: 280px;
  545. }
  546. #shop-title{
  547. position: absolute;
  548. top: 50px;
  549. left: 60px;
  550. font-size: 30px;
  551. color: rgb(255,255,255);
  552. }
  553. }
  554. .container{
  555. width: 1190px;
  556. padding: 0;
  557. }
  558. </style>