RightBar.vue 16 KB

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