StoreBanner.vue 15 KB

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