StoreBanner.vue 13 KB

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