StoreTitle.vue 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  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" v-if="storeInfo.type == 'AGENCY'">代理商</div>
  7. <div class="logo" v-if="storeInfo.type == 'DISTRIBUTION'">经销商</div>
  8. <div class="logo">代理商</div>
  9. <div class="shop-logo">
  10. <img :src="storeInfo.logoUrl || '/images/store/common/default.png'" />
  11. <!-- <p id="shop-title" v-if="storeInfo.storeShortName" v-text="storeInfo.storeShortName">店铺名称</p>-->
  12. <p id="shop-name" v-if="storeInfo.storeShortName">{{storeInfo.storeShortName | nameFilter}}</p>
  13. <div class="enter-store">
  14. <a @click="focus(storeInfo.id, storeInfo.storeName)">关注店铺</a>
  15. <a @click="goWebChat()">联系卖家</a>
  16. </div>
  17. </div>
  18. <!-- 店名展示 -->
  19. <div class="shop-banner">
  20. <img :src="storeInfo.bannerUrl || '/images/store/default/shop_banner.png'">
  21. <!-- <div id="shop-title" v-if="storeInfo.storeShortName" v-text="storeInfo.storeShortName">店铺名称</div>-->
  22. </div>
  23. </div>
  24. <el-dialog
  25. :visible.sync="dialogVisible"
  26. size="tiny"
  27. >
  28. <h3 class="header-text">关注成功!</h3>
  29. <div class="focus modal-body">
  30. <button type="button" @click="dialogVisible = false" class="btn" style="margin-left:25px;">关&nbsp;&nbsp;闭</button>
  31. <button type="button" @click="dialogVisible = false" class="focus-btn btn btn btn-info" style="margin-left:35px;">
  32. <a href="/user#/storeFocus" target="_blank">查看我的店铺关注</a>
  33. </button>
  34. </div>
  35. </el-dialog>
  36. </div>
  37. </div>
  38. </template>
  39. <script>
  40. export default {
  41. name: 'store-title',
  42. data () {
  43. return {
  44. dialogVisible: false
  45. }
  46. },
  47. methods: {
  48. focus (id, name) {
  49. if (!this.user.logged) {
  50. this.$http.get('/login/page', {params: {returnUrl: window.location.href}}).then(response => {
  51. if (response.data) {
  52. this.$router.push('/auth/login')
  53. }
  54. })
  55. } else {
  56. this.dialogVisible = true
  57. this.$store.dispatch('shop/StoreFocus', {storeName: name, storeid: id})
  58. }
  59. },
  60. goWebChat: function () {
  61. if (!this.user.logged) {
  62. this.$http.get('/login/page').then(response => {
  63. if (response.data) {
  64. this.$router.push('/auth/login')
  65. }
  66. })
  67. } else {
  68. // 获得窗口的垂直位置
  69. let iTop = (window.screen.availHeight - 30 - 780) / 2
  70. // 获得窗口的水平位置
  71. let iLeft = (window.screen.availWidth - 10 - 1030) / 2
  72. if (this.tab.close) {
  73. this.tab.close()
  74. }
  75. let newTab = window.open('', '即时对话框', 'height=750, width=1000, top=' + iTop + ', left=' + iLeft + ', toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, status=no')
  76. newTab.close()
  77. newTab = window.open('', '即时对话框', 'height=750, width=1000, top=' + iTop + ', left=' + iLeft + ', toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, status=no')
  78. this.$store.dispatch('chat/setChatTab', {tab: newTab})
  79. this.$http.get('/basic/enterprise/' + this.storeInfo.enUU + '/info')
  80. .then(response => {
  81. let obj = {}
  82. obj.userPhone = this.user.data.userTel
  83. obj.userType = 'ENTERPRISE'
  84. this.user.data.enterprises.forEach(function (item, index) {
  85. if (item.current) {
  86. obj.enUU = item.uu
  87. obj.enterprise = {enUU: item.uu, name: item.enName}
  88. }
  89. })
  90. obj.otherEnUU = response.data.uu
  91. obj.otherUserType = 'STORE'
  92. obj.otherEnterprise = {enUU: response.data.uu, name: response.data.enName}
  93. obj.type = 'CHAT'
  94. if (!(/^1\d{10}$/).test(response.data.enTel)) {
  95. this.$http.get('/basic/enterprise/' + response.data.uu + '/admin').then(response => {
  96. console.log(response)
  97. obj.toPhone = response.data.userTel
  98. console.log(obj)
  99. this.openWebChat(newTab, obj)
  100. }, err => {
  101. console.log(err)
  102. this.$message.error('暂无卖家管理员手机号!')
  103. })
  104. } else {
  105. obj.toPhone = response.data.enTel
  106. console.log(obj)
  107. this.openWebChat(newTab, obj)
  108. }
  109. }, err => {
  110. console.log(err)
  111. })
  112. }
  113. },
  114. openWebChat: function (newTab, obj) {
  115. this.$http.post('https://im.ubtob.com/api/chat/infos?condition=chat_info', obj)
  116. .then(response => {
  117. if (response.data.success) {
  118. newTab.location.href = 'https://im.ubtob.com/chat/visit?gid=' + response.data.content
  119. }
  120. })
  121. }
  122. },
  123. filters: {
  124. nameFilter: function (title) {
  125. if (title === '') {
  126. return title
  127. }
  128. let len = 0
  129. let index = 0
  130. for (let i = 0; i < title.length; i++) {
  131. if (index === 0 && title.charAt(i).charCodeAt(0) > 255) {
  132. len = len + 2
  133. } else {
  134. len++
  135. }
  136. if (len > 24) {
  137. index = i
  138. break
  139. }
  140. }
  141. if (index > 0) {
  142. return title.substring(0, index) + '...'
  143. } else {
  144. return title
  145. }
  146. },
  147. date: function (input) {
  148. const d = new Date(input)
  149. const year = d.getFullYear()
  150. const monthTemp = d.getMonth() + 1
  151. const month = monthTemp < 10 ? '0' + monthTemp : '' + monthTemp
  152. const hour = d.getHours() < 10 ? '0' + d.getHours() : '' + d.getHours() + ' '
  153. const minutes = d.getMinutes() < 10 ? '0' + d.getMinutes() : '' + d.getMinutes() + ' '
  154. const day = d.getDate() < 10 ? '0' + d.getDate() : '' + d.getDate() + ' '
  155. return year + '-' + month + '-' + day + ' ' + hour + ':' + minutes
  156. }
  157. },
  158. computed: {
  159. storeInfo () {
  160. return this.$store.state.shop.storeInfo.store.data
  161. },
  162. isConsignment () {
  163. return this.storeInfo.type === 'CONSIGNMENT'
  164. },
  165. tab () {
  166. return this.$store.state.chat.tab.tab.data
  167. },
  168. user () {
  169. return this.$store.state.option.user
  170. }
  171. }
  172. }
  173. </script>
  174. <style lang="scss">
  175. .header-text {
  176. text-align: center;
  177. font-size: 20px;
  178. color: #008B00;
  179. margin-top: 0;
  180. }
  181. .el-dialog__wrapper .el-dialog--tiny {
  182. width: 320px !important;
  183. }
  184. .el-dialog__body {
  185. padding: 14px !important;
  186. }
  187. .focus button.focus-btn a{
  188. color: #fff;
  189. width: 100%;
  190. height: 100%;
  191. display: inline-block;
  192. }
  193. .focus button.focus-btn{
  194. width: 138px;
  195. height: 36px;
  196. line-height: 36px;
  197. padding: 0;
  198. }
  199. #title-fragment {
  200. padding: 0;
  201. }
  202. #title-fragment .container {
  203. width: 1190px;
  204. padding-left: 0px;
  205. padding-right: 0px;
  206. }
  207. #title-fragment .container >.row {
  208. margin-left: 0px;
  209. margin-right: 0px;
  210. position: relative;
  211. background: #fff;
  212. }
  213. .logo{
  214. width: 28px;
  215. padding-right: 3px;
  216. height: 60px;
  217. text-align: center;
  218. line-height: 15px;
  219. position: absolute;
  220. top: 13px;
  221. left: 10px;
  222. color: #fff;
  223. margin-top: -20px;
  224. background: url('/images/store/home/logo-type.png') no-repeat;
  225. z-index: 100;
  226. padding-top: 3px;
  227. }
  228. #title-fragment .shop-logo {
  229. width: 220px;
  230. height: 220px;
  231. border: 1px solid #e8e8e8;
  232. float: left;
  233. text-align: center;
  234. line-height: 210px;
  235. overflow: hidden;
  236. position: relative;
  237. #shop-name{
  238. height: 40px;
  239. line-height: 40px;
  240. margin-top: -90px;
  241. width: 100%;
  242. }
  243. .enter-store {
  244. width: 100%;
  245. height: 30px;
  246. line-height: 30px;
  247. text-align: left;
  248. margin-top: -10px;
  249. padding-left: 20px;
  250. a {
  251. width: 70px;
  252. height: 24px;
  253. display: inline-block;
  254. line-height: 22px;
  255. text-align: center;
  256. font-size: 13px;
  257. margin-left: 12px;
  258. border-radius: 3px;
  259. &:first-child {
  260. background: #bd0505;
  261. border: 1px solid #bd0505;
  262. color: #fff;
  263. }
  264. &:last-child {
  265. background: #3c7cf7;
  266. border: 1px solid #3c7cf7;
  267. color: #fff;
  268. }
  269. }
  270. }
  271. }
  272. #title-fragment .shop-logo img {
  273. width: 80%;
  274. height: 60px;
  275. margin-top: -30px;
  276. }
  277. #title-fragment .shop-banner {
  278. float: left;
  279. position: relative;
  280. width: 970px;
  281. height: 220px;
  282. border: 1px solid #e8e8e8;
  283. border-left: none;
  284. overflow: hidden;
  285. }
  286. #title-fragment .shop-banner img {
  287. width: 970px;
  288. height: 220px;
  289. }
  290. #title-fragment .shop-banner #shop-title {
  291. position: absolute;
  292. top: 50px;
  293. left: 60px;
  294. font-size: 30px;
  295. color: rgb(255,255,255);
  296. }
  297. .container{
  298. width: 1190px;
  299. padding: 0;
  300. }
  301. </style>