StoreBanner.vue 15 KB

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