StoreBanner.vue 17 KB

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