RightBar.vue 15 KB

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