RightBar.vue 15 KB

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