StoreBanner.vue 17 KB

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