RightBar.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523
  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 href="http://www.usoftmall.com/user#/browsingHistory" 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 href="/user#/browsingHistory" 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 href="">浏览历史</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. goCart: 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#/cart'
  162. }
  163. },
  164. goWebChat: 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. // 获得窗口的垂直位置
  173. let iTop = (window.screen.availHeight - 30 - 600) / 2
  174. // 获得窗口的水平位置
  175. let iLeft = (window.screen.availWidth - 10 - 1030) / 2
  176. let newTab = window.open('', '即时对话框', 'height=600, width=1030, top=' + iTop + ', left=' + iLeft + ', toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, status=no')
  177. axios.get('/basic/enterprise/' + this.enterprise.uu + '/info')
  178. .then(response => {
  179. let obj = {}
  180. obj.enUU = response.data.uu
  181. obj.enterprise = {enUU: response.data.uu, name: response.data.enName}
  182. obj.type = 'LIST'
  183. obj.userPhone = this.user.data.userTel
  184. axios.post('http://im.ubtob.com/api/chat/infos?condition=chat_info', obj)
  185. .then(response => {
  186. if (response.data.success) {
  187. newTab.location.href = 'http://im.ubtob.com/chat/visit?gid=' + response.data.content
  188. }
  189. })
  190. }, err => {
  191. console.log(err)
  192. })
  193. }
  194. },
  195. getChatCount: function () {
  196. if (this.user.logged) {
  197. axios.get('http://im.ubtob.com/api/chat/message', {params: {enUU: this.enterprise.uu, operate: 'count_unread', phone: this.user.data.userTel}})
  198. .then(response => {
  199. this.chatCount = response.data.count
  200. })
  201. }
  202. }
  203. }
  204. }
  205. </script>
  206. <style lang="scss" scoped>
  207. /*查看*/
  208. #image-box .x-floating-wrap {
  209. position: fixed;
  210. z-index: 99998;
  211. background: #000;
  212. top: 0;
  213. left: 0;
  214. width: 100%;
  215. height: 100%;
  216. opacity: 0.5;
  217. }
  218. #image-box .x-floating {
  219. position: fixed;
  220. z-index: 99999;
  221. top: 60px;
  222. left: 0;
  223. width: 100%;
  224. height: 100%;
  225. text-align: center;
  226. vertical-align: middle;
  227. }
  228. #image-box .x-floating img {
  229. margin: auto auto;
  230. max-width: 100%;
  231. max-height: 80%;
  232. -webkit-user-select: none;
  233. -moz-user-select: none;
  234. -ms-user-select: none;
  235. user-select: none
  236. }
  237. #image-box .x-close-wrap {
  238. position: fixed;
  239. top: 0;
  240. right: 0;
  241. z-index: 100000;
  242. width: 120px;
  243. height: 120px;
  244. margin: -60px -60px 0 0;
  245. border-radius: 100%;
  246. background: #000;
  247. opacity: .3
  248. }
  249. #image-box .x-close-wrap a {
  250. position: absolute;
  251. left: 25px;
  252. bottom: 25px;
  253. font-size: 42px;
  254. color: #fff
  255. }
  256. #image-box .x-close-wrap:hover {
  257. opacity: .7
  258. }
  259. a[disabled] {
  260. cursor: not-allowed;
  261. }
  262. em,i{
  263. font-style: inherit;
  264. }
  265. .right-bar ul li{
  266. position: relative;
  267. }
  268. .right-bar ul li .sidebar-menu {
  269. position: absolute;
  270. display: block;
  271. right: -100%;
  272. top: 0px;
  273. bottom: 0;
  274. width: 120px;
  275. line-height: 38px;
  276. height: 38px;
  277. color: #ffffff;
  278. background: #555;
  279. -webkit-transform: translateX(100%);
  280. -moz-transform: translateX(100%);
  281. -ms-transform: translateX(100%);
  282. -o-transform: translateX(100%);
  283. transform: translateX(100%);
  284. -webkit-transition: transform .5s;
  285. -moz-transition: transform .5s;
  286. -ms-transition: transform .5s;
  287. -o-transition: transform .5s;
  288. transition: transform .5s;
  289. z-index: 19;
  290. }
  291. .right-bar ul li .sidebar-menu a{
  292. background-color: #555555;
  293. }
  294. .right-bar ul li:hover a{
  295. background-color: #555555;
  296. }
  297. .right-bar ul li:hover .sidebar-menu {
  298. display: block;
  299. -webkit-transform: translateX(-72px);
  300. -moz-transform: translateX(-72px);
  301. -ms-transform: translateX(-72px);
  302. -o-transform: translateX(-72px);
  303. transform: translateX(-72px);
  304. }
  305. /*浏览记录*/
  306. .right-bar ul li .foot-record{
  307. /* display: none; */
  308. width: 210px !important;
  309. max-height: 230px;
  310. line-height: 30px;
  311. /* right: 200px;*/
  312. top: inherit;
  313. bottom: -100%;
  314. height: inherit;
  315. /*padding-bottom: 10px;*/
  316. }
  317. .right-bar ul li .foot-record h3{
  318. line-height: 39px;
  319. border-bottom: #767575 1px solid;
  320. text-align: left;
  321. padding-left: 10px;
  322. width: 96%;
  323. display: inline-block;
  324. margin: 0 auto;
  325. font-size: 12px;
  326. height: 39px;
  327. }
  328. .right-bar ul li .foot-record h3:hover a{
  329. color: #fbb029;
  330. }
  331. .right-bar ul li .foot-record h3 a{
  332. color: #fff;
  333. background-color: inherit;
  334. line-height: 39px;
  335. text-align: left;
  336. }
  337. .right-bar ul li .foot-record dl{
  338. padding-top: 5px;
  339. display: inline-block;
  340. background: #555;
  341. }
  342. .right-bar ul li .foot-record dl,.right-bar ul li .foot-record dl dd{
  343. width: 100%;
  344. margin: 0 auto;
  345. background: #555;
  346. }
  347. .right-bar ul li .foot-record dl dd{
  348. line-height: 22px;
  349. width: 100%;
  350. display: inline-block;
  351. float: left;
  352. height: 22px;
  353. position: relative;
  354. }
  355. .right-bar ul li .foot-record dl dd a{
  356. display: inline-block;
  357. height: 22px;
  358. padding: 0 10px;
  359. width: 91%;
  360. font-size: 12px;
  361. color: #fff;
  362. line-height: 22px;
  363. white-space: nowrap;
  364. overflow: hidden;
  365. text-overflow: ellipsis;
  366. background: none;
  367. text-align: left;
  368. padding-right: 44px;
  369. }
  370. .right-bar ul li li a:hover div.foot-record{
  371. display: inline-block !important;
  372. }
  373. .right-bar ul li .foot-record dl dd:hover{
  374. background: #fff;
  375. }
  376. .right-bar ul li .foot-record dl dd:hover a{
  377. color: #333;
  378. }
  379. .right-bar ul li .foot-record dl dd:hover div.hover-shows{
  380. display: inline-block;
  381. }
  382. .right-bar ul li .foot-record dl dd div.hover-shows{
  383. position: absolute;
  384. top: 0;
  385. right: 2px;
  386. max-width: 55px;
  387. line-height: 20px;
  388. padding-right: 0;
  389. z-index: 100;
  390. display: none;
  391. }
  392. .right-bar ul li .foot-record dl dd div.hover-shows span{
  393. display: inline-block;
  394. width: 30px;
  395. height: 20px;
  396. text-align: center;
  397. line-height: 20px;
  398. background: #e04b38;
  399. color: #fff;
  400. border-radius: 5px;
  401. opacity: 0;
  402. margin-top: 1px;
  403. }
  404. .right-bar ul li .foot-record dl dd:first-child{
  405. /* margin-top: 5px;*/
  406. }
  407. .right-bar ul li .foot-record dl dd:last-child{
  408. /* margin-bottom: 10px;*/
  409. }
  410. .right-bar ul li .foot-record dl dd div.hover-shows a{
  411. font-size: 23px;
  412. float: right;
  413. width: 20px;
  414. padding: 0;
  415. text-align: center;
  416. color: #999;
  417. top: -2px;
  418. }
  419. .right-bar ul li .foot-record dl dd div.hover-shows a:hover{
  420. color: #fbb029;
  421. }
  422. .right-bar ul li .foot-record dl dd div.hover-shows em{
  423. display: inline-block;
  424. position: absolute;
  425. width: 0;
  426. height: 0;
  427. border-top: 8px solid transparent;
  428. border-left: 7px solid #fbb029;
  429. border-bottom: 8px solid transparent;
  430. left: -158px;
  431. top: 4px;
  432. }
  433. .right-bar ul li .foot-record dl dd div.hover-shows em.off{
  434. border-left: 8px solid #b2b0b0;
  435. }
  436. .right-bar ul li .foot-record dl dd div.hover-shows span.off{
  437. opacity: 1;
  438. }
  439. /*浏览记录结束*/
  440. .right-bar ul li .contact-us{
  441. /*right: 200px;*/
  442. height: 180px;
  443. padding-top: 10px;
  444. width: 210px;
  445. top: -76px;
  446. }
  447. .right-bar ul li .contact-us p{
  448. line-height: 33px;
  449. text-align: left;
  450. padding-left: 10px;
  451. margin-bottom: 0;
  452. white-space: nowrap;
  453. font-size: 12px;
  454. }
  455. .right-bar ul li .contact-us .contact-btn{
  456. width: 62px;
  457. height: 18px;
  458. line-height: 18px;
  459. background: #ef7f03;
  460. display: inline-block;
  461. text-align: center;
  462. color: #fff;
  463. font-size: 12px;
  464. border-radius: 5px;
  465. padding: 0;
  466. }
  467. .right-bar-item{
  468. width: 36px;
  469. /* height: 38px;*/
  470. }
  471. .right-bar .right-bar-item a.title{
  472. display: inline-block;
  473. width: 36px;
  474. height: 38px;
  475. line-height: 38px;
  476. padding: 0;
  477. }
  478. .right-bar {
  479. position: fixed;
  480. z-index: 1000;
  481. right: 0;
  482. top: 0;
  483. width: 36px;
  484. height: 100%;
  485. .right-bar-center {
  486. position: absolute;
  487. top: 50%;
  488. transform: translateY(-50%);
  489. list-style: none;
  490. padding: 0;
  491. width: 100%;
  492. }
  493. .right-bar-bottom {
  494. position: absolute;
  495. right: 0;
  496. bottom: 0;
  497. width: 36px;
  498. }
  499. .right-bar-item {
  500. a {
  501. position: relative;
  502. display: block;
  503. width: 100%;
  504. color: #fff;
  505. background-color: #5078CB;
  506. text-align: center;
  507. -webkit-transition: background-color ease .5s;
  508. -moz-transition: background-color ease 0.5s;
  509. -ms-transition: background-color ease 0.5s;
  510. -o-transition: background-color ease 0.5s;
  511. transition: background-color ease 0.5s;
  512. z-index: 20;
  513. font-size: 12px;
  514. }
  515. }
  516. }
  517. </style>