RightBar.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605
  1. <template>
  2. <div>
  3. <div class="right-bar">
  4. <ul class="right-bar-center">
  5. <li class="right-bar-item" v-show="storeStatus && storeStatus.uuid">
  6. <a @click="goShop" class="title" target="_blank">
  7. <i class="iconfont icon-dianpu icon-xlg"></i>
  8. </a>
  9. <div class="sidebar-menu"><a @click="goShop" title="我的店铺" target="_blank">我的店铺</a></div>
  10. </li>
  11. <li class="right-bar-item" @mouseenter="loadCarCount()" id="shopCar">
  12. <a @click="goCart" class="title" target="_blank">
  13. <i class="iconfont icon-shopping-cart icon-xlg"></i>
  14. </a>
  15. <div class="sidebar-menu"><a @click="goCart" title="我的购物车" target="_blank">我的购物车<em><span>(<span v-text="cartCount.count || 0"></span>)</span></em></a></div>
  16. </li>
  17. <li class="right-bar-item">
  18. <a @click="dialogVisible = true" class="title">
  19. <i class="iconfont icon-liuyan icon-xlg"></i>
  20. <div class="sidebar-menu"><a title="留言板" target="_blank">留言板</a></div>
  21. </a>
  22. </li>
  23. <li class="right-bar-item contact-menu">
  24. <a href="http://wpa.qq.com/msgrd?v=3&uin=3432892085&site=www.ubtoc.com&menu=yes" target="_blank" class="title">
  25. <i class="iconfont icon-kefu icon-xlg"></i>
  26. </a>
  27. <div class="contact-us sidebar-menu">
  28. <p>在线客服:<img src="/images/all/songguo.png" /><a href="http://wpa.qq.com/msgrd?v=3&uin=3432892085&site=www.ubtoc.com&menu=yes" class="contact-btn" target="_blank">联系客服</a></p>
  29. <p>服务电话:400-830-1818</p>
  30. <p>服务邮箱:yrsc@usoftchina.com</p>
  31. <p>工作时间:</p>
  32. <p>周一至周五 9:00-18:00</p>
  33. </div>
  34. </li>
  35. <!-- <li class="right-bar-item contact-menu">
  36. <a href="javascript:void(0)" class="title" @click="goWebChat">
  37. <i class="fa fa-comments-o" aria-hidden="true" style="color: #FFFFFF;">
  38. </i>
  39. <i class="remind-point" v-if="user.logged && chatCount>0"></i>
  40. </a>
  41. <div class="sidebar-menu" title="优软互联"><a @click="goWebChat">优软互联<span v-if="user.logged">({{chatCount}})</span></a></div>
  42. </li>-->
  43. </ul>
  44. <ul class="right-bar-bottom">
  45. <li class="right-bar-item" @mouseenter="loadHistorys()">
  46. <a @click="goHistory" class="title" target="_blank">
  47. <i class="iconfont icon-zuji icon-xlg"></i>
  48. </a>
  49. <div class="sidebar-menu" v-if="!user.logged"><a @click="goHistory" title="浏览记录">浏览记录</a></div>
  50. <div class="sidebar-menu" v-if="user.logged && listMe(history).length == 0"><a href="/user#/browsingHistory" title="浏览记录">浏览记录</a></div>
  51. <div class="foot-record sidebar-menu" v-if="user.logged && listMe(history).length > 0">
  52. <h3><a href="/user#/browsingHistory">浏览历史</a></h3>
  53. <dl>
  54. <dd v-for="item in listMe(history)">
  55. <a :href="'/store/productDetail/' + item.batchCode" target="_blank" :title="item.code" v-text="item.code" v-if="item.status== 1"></a>
  56. <a :title="item.code" v-text="item.code" v-if="item.status== 0" disabled="disabled"></a>
  57. <div class="hover-shows">
  58. <em :class="{ 'off' : item.status== 0}"></em>
  59. <span :class="{ 'off' : item.status== 0}">失效</span>
  60. <a @click="deleteHistory(item,item.id)">&times;</a>
  61. </div>
  62. </dd>
  63. </dl>
  64. </div>
  65. </li>
  66. <li class="right-bar-item">
  67. <a @click="toTop()" class="title">
  68. <i class="iconfont icon-arrow-up icon-xlg"></i>
  69. </a>
  70. <div class="sidebar-menu"><a @click="toTop()" title="返回顶部" target="_blank">返回顶部</a></div>
  71. </li>
  72. </ul>
  73. </div>
  74. <el-dialog class="dialog"
  75. v-if="dialogVisible"
  76. :visible.sync="dialogVisible"
  77. size="tiny">
  78. <message-board @pageEvent="listenPage" @openBoardEvent="listenOpen"/>
  79. </el-dialog>
  80. <div v-for="(ball, index) in balls" v-bind:key="index">
  81. <transition name="drop" @before-enter="beforeEnter" @enter="enter" @after-enter="afterEnter">
  82. <div class="ball" v-show="ball.show">
  83. <div class="inner inner-hook"></div>
  84. </div>
  85. </transition>
  86. </div>
  87. </div>
  88. </template>
  89. <script>
  90. import { scrollTo } from '~utils/scroll'
  91. import MessageBoard from '~components/default/MessageBoard.vue'
  92. export default {
  93. name: 'right-bar',
  94. data () {
  95. return {
  96. historyLength: [],
  97. dialogVisible: false,
  98. page: 1,
  99. count: 3,
  100. currentPage: 1,
  101. chatCount: 0,
  102. showMyshop: false,
  103. // balls: [],
  104. dropBalls: []
  105. }
  106. },
  107. components: {
  108. MessageBoard
  109. },
  110. computed: {
  111. balls() {
  112. return this.$store.state.option.ballsList
  113. },
  114. user () {
  115. // console.log(this.$store.state.option)
  116. return this.$store.state.option.user
  117. },
  118. cartCount () {
  119. return this.$store.state.user.history.cartCount.data
  120. },
  121. history () {
  122. let arr = this.$store.state.user.history.historyList.data.slice(0, 8)
  123. return arr
  124. },
  125. enterprise () {
  126. let ens = this.user.data.enterprises
  127. if (ens && ens.length) {
  128. return ens.find(item => item.current) || {enName: this.user.data.userName + '(个人账户)'}
  129. } else {
  130. return {enName: this.user.data.userName + '(个人账户)'}
  131. }
  132. },
  133. tab () {
  134. return this.$store.state.chat.tab.tab.data
  135. },
  136. storeStatus () {
  137. return this.$store.state.option.storeStatus.data
  138. }
  139. },
  140. methods: {
  141. beforeEnter(el) {
  142. let count = this.balls.length
  143. while (count--) {
  144. let ball = this.balls[count]
  145. if (ball.show) {
  146. let rect = ball.el.getBoundingClientRect()
  147. let x = -(rect.right - rect.left + 56)
  148. let y = -(rect.top + window.innerHeight * 0.6)
  149. el.style.webkitTransform = `translate3d(0, ${y}px,0)`
  150. el.style.transform = `translate3d(0, ${y}px,0)`
  151. el.style.display = ''
  152. let inner = el.getElementsByClassName("inner-hook")[0]
  153. inner.style.webkitTransform = `translate3d(${x}px, 0, 0)`
  154. inner.style.transform = `translate3d(${x}px,0,0)`
  155. }
  156. }
  157. },
  158. enter(el, done) {
  159. let rf = el.offestHeight
  160. this.$nextTick(() => {
  161. el.style.webkitTransform = 'translate3d(0, 0, 0)'
  162. el.style.transform = 'translate3d(0, 0, 0)'
  163. let inner = el.getElementsByClassName('inner-hook')[0]
  164. inner.style.webkitTransform = 'translate3d(0, 0, 0)'
  165. inner.style.transform = 'translate3d(0, 0, 0)'
  166. el.addEventListener('transitionend', done)
  167. })
  168. },
  169. afterEnter(el) {
  170. this.$store.commit('option/SET_BALLSLIST_SUCCESS_DROP', el)
  171. },
  172. listenPage: function (p) {
  173. this.page = p
  174. this.$store.dispatch('getMessageBoardInformation', {page: this.page, count: 3})
  175. },
  176. listenOpen: function (flag) {
  177. this.dialogVisible = flag
  178. },
  179. listMe: function (list) {
  180. return list.filter(function (item) {
  181. return item.isDelete === 1
  182. })
  183. },
  184. loadHistorys () {
  185. if (this.user.logged) {
  186. if (!this.history.length) {
  187. this.$store.dispatch('user/loadHistory')
  188. }
  189. }
  190. },
  191. loadCarCount () {
  192. if (this.user.logged) {
  193. if (!this.cartCount.count) {
  194. this.$store.dispatch('user/CarCount')
  195. }
  196. }
  197. },
  198. toTop () {
  199. scrollTo('body', 300)
  200. },
  201. toBottom () {
  202. scrollTo(window.scrollY + window.innerHeight, 300)
  203. },
  204. deleteHistory (item, id) {
  205. this.$store.dispatch('user/deleteHistory', {id: id})
  206. this.$store.dispatch('user/loadHistory')
  207. },
  208. goLogin: function () {
  209. this.$http.get('/login/page', {params: {returnUrl: window.location.href}}).then(response => {
  210. if (response.data) {
  211. window.location.href = response.data.content + '&baseUrl=' + encodeURIComponent(window.location.protocol + '//' + window.location.host + response.data.baseUrl)
  212. }
  213. })
  214. },
  215. goHistory: function () {
  216. if (!this.user.logged) {
  217. this.goLogin()
  218. } else {
  219. window.location.href = '/user#/browsingHistory'
  220. }
  221. },
  222. goCart: function () {
  223. if (!this.user.logged) {
  224. this.goLogin()
  225. } else {
  226. window.open('/user#/cart')
  227. }
  228. },
  229. goShop: function () {
  230. window.location.href = `/store/${this.storeStatus.uuid}`
  231. },
  232. goWebChat: function () {
  233. if (!this.user.logged) {
  234. this.goLogin()
  235. } else {
  236. // 获得窗口的垂直位置
  237. let iTop = (window.screen.availHeight - 30 - 780) / 2
  238. // 获得窗口的水平位置
  239. let iLeft = (window.screen.availWidth - 10 - 1030) / 2
  240. if (this.tab.close) {
  241. this.tab.close()
  242. }
  243. let newTab = window.open('', '即时对话框', 'height=750, width=1000, top=' + iTop + ', left=' + iLeft + ', toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, status=no')
  244. newTab.close()
  245. newTab = window.open('', '即时对话框', 'height=750, width=1000, top=' + iTop + ', left=' + iLeft + ', toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, status=no')
  246. this.$store.dispatch('chat/setChatTab', {tab: newTab})
  247. this.$http.get('/basic/enterprise/' + this.enterprise.uu + '/info')
  248. .then(response => {
  249. let obj = {}
  250. obj.enUU = response.data.uu
  251. obj.enterprise = {enUU: response.data.uu, name: response.data.enName}
  252. obj.type = 'LIST'
  253. if (!(/^1\d{10}$/).test(this.user.data.userTel)) {
  254. this.$http.get('/basic/enterprise/' + obj.enUU + '/admin').then(response => {
  255. obj.userPhone = response.data.userTel
  256. this.openWebChat(newTab, obj)
  257. }, err => {
  258. console.log(err)
  259. this.$message.error('暂无卖家管理员手机号!')
  260. })
  261. } else {
  262. obj.userPhone = this.user.data.userTel
  263. this.openWebChat(newTab, obj)
  264. }
  265. }, err => {
  266. console.log(err)
  267. let obj = {}
  268. obj.type = 'LIST'
  269. if (!(/^1\d{10}$/).test(this.user.data.userTel)) {
  270. this.$http.get('/basic/enterprise/' + obj.enUU + '/admin').then(response => {
  271. obj.userPhone = response.data.userTel
  272. this.openWebChat(newTab, obj)
  273. }, err => {
  274. console.log(err)
  275. this.$message.error('暂无卖家管理员手机号!')
  276. })
  277. } else {
  278. obj.userPhone = this.user.data.userTel
  279. this.openWebChat(newTab, obj)
  280. }
  281. })
  282. }
  283. },
  284. openWebChat: function (newTab, obj) {
  285. this.$http.post('https://im.ubtob.com/api/chat/infos?condition=chat_info', obj)
  286. .then(response => {
  287. if (response.data.success) {
  288. newTab.location.href = 'https://im.ubtob.com/chat/visit?gid=' + response.data.content
  289. }
  290. })
  291. },
  292. getChatCount: function () {
  293. if (this.user.logged) {
  294. this.$http.get('https://im.ubtob.com/api/chat/message', {params: {enUU: this.enterprise.uu, operate: 'count_unread', phone: this.user.data.userTel}})
  295. .then(response => {
  296. this.chatCount = response.data.count
  297. })
  298. }
  299. }
  300. },
  301. mounted() {
  302. this.$nextTick(() => {
  303. let length = document.getElementsByClassName('ball')
  304. let _top = parseInt(window.innerHeight * 0.6) + 36
  305. for (let i = 0; i < length.length; i++) {
  306. length[i].style.top = _top + 'px'
  307. length[i].style.left = window.innerWidth + 'px'
  308. }
  309. })
  310. }
  311. }
  312. </script>
  313. <style lang="scss" scoped>
  314. a[disabled] {
  315. cursor: not-allowed;
  316. }
  317. em,
  318. i {
  319. font-style: inherit;
  320. }
  321. .right-bar ul li {
  322. position: relative;
  323. }
  324. .right-bar ul li .sidebar-menu {
  325. position: absolute;
  326. display: block;
  327. right: -100%;
  328. top: 0px;
  329. bottom: 0;
  330. width: 100px;
  331. line-height: 38px;
  332. height: 38px;
  333. color: #ffffff;
  334. background: #555;
  335. -webkit-transform: translateX(100%);
  336. -moz-transform: translateX(100%);
  337. -ms-transform: translateX(100%);
  338. -o-transform: translateX(100%);
  339. transform: translateX(100%);
  340. -webkit-transition: transform 0.5s;
  341. -moz-transition: transform 0.5s;
  342. -ms-transition: transform 0.5s;
  343. -o-transition: transform 0.5s;
  344. transition: transform 0.5s;
  345. z-index: 19;
  346. }
  347. .right-bar ul li .sidebar-menu a {
  348. background-color: #555555;
  349. }
  350. .right-bar ul li:hover a {
  351. background-color: #555555;
  352. }
  353. .right-bar ul li:hover .sidebar-menu {
  354. display: block;
  355. -webkit-transform: translateX(-72px);
  356. -moz-transform: translateX(-72px);
  357. -ms-transform: translateX(-72px);
  358. -o-transform: translateX(-72px);
  359. transform: translateX(-72px);
  360. }
  361. /*浏览记录*/
  362. .right-bar ul li .foot-record {
  363. /* display: none; */
  364. width: 210px !important;
  365. max-height: 230px;
  366. line-height: 30px;
  367. /* right: 200px;*/
  368. top: inherit;
  369. bottom: -100%;
  370. height: inherit;
  371. /*padding-bottom: 10px;*/
  372. }
  373. .right-bar ul li .foot-record h3 {
  374. line-height: 39px;
  375. border-bottom: #767575 1px solid;
  376. text-align: left;
  377. padding-left: 10px;
  378. width: 96%;
  379. display: inline-block;
  380. margin: 0 auto;
  381. font-size: 12px;
  382. height: 39px;
  383. }
  384. .right-bar ul li .foot-record h3:hover a {
  385. color: #fbb029;
  386. }
  387. .right-bar ul li .foot-record h3 a {
  388. color: #fff;
  389. background-color: inherit;
  390. line-height: 39px;
  391. text-align: left;
  392. }
  393. .right-bar ul li .foot-record dl {
  394. padding-top: 5px;
  395. display: inline-block;
  396. background: #555;
  397. }
  398. .right-bar ul li .foot-record dl,
  399. .right-bar ul li .foot-record dl dd {
  400. width: 100%;
  401. margin: 0 auto;
  402. background: #555;
  403. }
  404. .right-bar ul li .foot-record dl dd {
  405. line-height: 22px;
  406. width: 100%;
  407. display: inline-block;
  408. float: left;
  409. height: 22px;
  410. position: relative;
  411. }
  412. .right-bar ul li .foot-record dl dd a {
  413. display: inline-block;
  414. height: 22px;
  415. padding: 0 10px;
  416. width: 91%;
  417. font-size: 12px;
  418. color: #fff;
  419. line-height: 22px;
  420. white-space: nowrap;
  421. overflow: hidden;
  422. text-overflow: ellipsis;
  423. background: none;
  424. text-align: left;
  425. padding-right: 44px;
  426. }
  427. .right-bar ul li a i {
  428. font-size: 20px;
  429. }
  430. .right-bar .remind-point {
  431. width: 8px;
  432. height: 8px;
  433. display: block;
  434. border-radius: 100%;
  435. background: red;
  436. position: relative;
  437. top: -31px;
  438. right: -21px;
  439. }
  440. .right-bar ul li li a:hover div.foot-record {
  441. display: inline-block !important;
  442. }
  443. .right-bar ul li .foot-record dl dd:hover {
  444. background: #fff;
  445. }
  446. .right-bar ul li .foot-record dl dd:hover a {
  447. color: #333;
  448. }
  449. .right-bar ul li .foot-record dl dd:hover div.hover-shows {
  450. display: inline-block;
  451. }
  452. .right-bar ul li .foot-record dl dd div.hover-shows {
  453. position: absolute;
  454. top: 0;
  455. right: 2px;
  456. max-width: 55px;
  457. line-height: 20px;
  458. padding-right: 0;
  459. z-index: 100;
  460. display: none;
  461. }
  462. .right-bar ul li .foot-record dl dd div.hover-shows span {
  463. display: inline-block;
  464. width: 30px;
  465. height: 20px;
  466. text-align: center;
  467. line-height: 20px;
  468. background: #e04b38;
  469. color: #fff;
  470. border-radius: 5px;
  471. opacity: 0;
  472. margin-top: 1px;
  473. }
  474. .right-bar ul li .foot-record dl dd:first-child {
  475. /* margin-top: 5px;*/
  476. }
  477. .right-bar ul li .foot-record dl dd:last-child {
  478. /* margin-bottom: 10px;*/
  479. }
  480. .right-bar ul li .foot-record dl dd div.hover-shows a {
  481. font-size: 23px;
  482. float: right;
  483. width: 20px;
  484. padding: 0;
  485. text-align: center;
  486. color: #999;
  487. top: -2px;
  488. }
  489. .right-bar ul li .foot-record dl dd div.hover-shows a:hover {
  490. color: #fbb029;
  491. }
  492. .right-bar ul li .foot-record dl dd div.hover-shows em {
  493. display: inline-block;
  494. position: absolute;
  495. width: 0;
  496. height: 0;
  497. border-top: 8px solid transparent;
  498. border-left: 7px solid #fbb029;
  499. border-bottom: 8px solid transparent;
  500. left: -158px;
  501. top: 4px;
  502. }
  503. .right-bar ul li .foot-record dl dd div.hover-shows em.off {
  504. border-left: 8px solid #b2b0b0;
  505. }
  506. .right-bar ul li .foot-record dl dd div.hover-shows span.off {
  507. opacity: 1;
  508. }
  509. /*浏览记录结束*/
  510. .right-bar ul li .contact-us {
  511. /*right: 200px;*/
  512. height: 180px;
  513. padding-top: 10px;
  514. width: 210px;
  515. top: -76px;
  516. }
  517. .right-bar ul li .contact-us p {
  518. line-height: 33px;
  519. text-align: left;
  520. padding-left: 10px;
  521. margin-bottom: 0;
  522. white-space: nowrap;
  523. font-size: 12px;
  524. }
  525. .right-bar ul li .contact-us .contact-btn {
  526. width: 62px;
  527. height: 18px;
  528. line-height: 18px;
  529. background: #ef7f03;
  530. display: inline-block;
  531. text-align: center;
  532. color: #fff;
  533. font-size: 12px;
  534. border-radius: 5px;
  535. padding: 0;
  536. }
  537. .right-bar-item {
  538. width: 36px;
  539. /* height: 38px;*/
  540. }
  541. .right-bar .right-bar-item a.title {
  542. display: inline-block;
  543. width: 36px;
  544. height: 38px;
  545. line-height: 38px;
  546. padding: 0;
  547. }
  548. .right-bar {
  549. position: fixed;
  550. z-index: 1000;
  551. right: 0;
  552. top: 0;
  553. width: 36px;
  554. height: 100%;
  555. .right-bar-center {
  556. position: absolute;
  557. top: 60%;
  558. transform: translateY(-50%);
  559. list-style: none;
  560. padding: 0;
  561. width: 100%;
  562. }
  563. .right-bar-bottom {
  564. position: absolute;
  565. right: 0;
  566. bottom: 0;
  567. width: 36px;
  568. }
  569. .right-bar-item {
  570. a {
  571. position: relative;
  572. display: block;
  573. width: 100%;
  574. color: #fff;
  575. background-color: #5078cb;
  576. text-align: center;
  577. -webkit-transition: background-color ease 0.5s;
  578. -moz-transition: background-color ease 0.5s;
  579. -ms-transition: background-color ease 0.5s;
  580. -o-transition: background-color ease 0.5s;
  581. transition: background-color ease 0.5s;
  582. z-index: 20;
  583. font-size: 12px;
  584. }
  585. }
  586. }
  587. .ball {
  588. position: fixed;
  589. right: 0;
  590. z-index: 200;
  591. bottom: calc(100vh * 0.4);
  592. transition: all 0.4s cubic-bezier(0.49,-0.29,0.75, 0.14);
  593. }
  594. .ball .inner {
  595. width: 16px;
  596. height: 16px;
  597. border-radius: 50%;
  598. background: rgb(0, 160, 220);
  599. transition: all 0.4s linear
  600. }
  601. </style>