RightBar.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482
  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="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="浏览记录">浏览记录</a></div>
  43. <div class="sidebar-menu" v-if="user.logged && listMe(history).length == 0"><a href="/user#/browsingHistory" title="浏览记录">浏览记录</a></div>
  44. <div class="foot-record sidebar-menu" v-if="user.logged && listMe(history).length > 0">
  45. <h3><a href="/user#/browsingHistory">浏览历史</a></h3>
  46. <dl>
  47. <dd v-for="item in listMe(history)">
  48. <a :href="'/store/' + item.storeid + '/' + item.batchCode" target="_blank" :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. a[disabled] {
  219. cursor: not-allowed;
  220. }
  221. em,i{
  222. font-style: inherit;
  223. }
  224. .right-bar ul li{
  225. position: relative;
  226. }
  227. .right-bar ul li .sidebar-menu {
  228. position: absolute;
  229. display: block;
  230. right: -100%;
  231. top: 0px;
  232. bottom: 0;
  233. width: 120px;
  234. line-height: 38px;
  235. height: 38px;
  236. color: #ffffff;
  237. background: #555;
  238. -webkit-transform: translateX(100%);
  239. -moz-transform: translateX(100%);
  240. -ms-transform: translateX(100%);
  241. -o-transform: translateX(100%);
  242. transform: translateX(100%);
  243. -webkit-transition: transform .5s;
  244. -moz-transition: transform .5s;
  245. -ms-transition: transform .5s;
  246. -o-transition: transform .5s;
  247. transition: transform .5s;
  248. z-index: 19;
  249. }
  250. .right-bar ul li .sidebar-menu a{
  251. background-color: #555555;
  252. }
  253. .right-bar ul li:hover a{
  254. background-color: #555555;
  255. }
  256. .right-bar ul li:hover .sidebar-menu {
  257. display: block;
  258. -webkit-transform: translateX(-72px);
  259. -moz-transform: translateX(-72px);
  260. -ms-transform: translateX(-72px);
  261. -o-transform: translateX(-72px);
  262. transform: translateX(-72px);
  263. }
  264. /*浏览记录*/
  265. .right-bar ul li .foot-record{
  266. /* display: none; */
  267. width: 210px !important;
  268. max-height: 230px;
  269. line-height: 30px;
  270. /* right: 200px;*/
  271. top: inherit;
  272. bottom: -100%;
  273. height: inherit;
  274. /*padding-bottom: 10px;*/
  275. }
  276. .right-bar ul li .foot-record h3{
  277. line-height: 39px;
  278. border-bottom: #767575 1px solid;
  279. text-align: left;
  280. padding-left: 10px;
  281. width: 96%;
  282. display: inline-block;
  283. margin: 0 auto;
  284. font-size: 12px;
  285. height: 39px;
  286. }
  287. .right-bar ul li .foot-record h3:hover a{
  288. color: #fbb029;
  289. }
  290. .right-bar ul li .foot-record h3 a{
  291. color: #fff;
  292. background-color: inherit;
  293. line-height: 39px;
  294. text-align: left;
  295. }
  296. .right-bar ul li .foot-record dl{
  297. padding-top: 5px;
  298. display: inline-block;
  299. background: #555;
  300. }
  301. .right-bar ul li .foot-record dl,.right-bar ul li .foot-record dl dd{
  302. width: 100%;
  303. margin: 0 auto;
  304. background: #555;
  305. }
  306. .right-bar ul li .foot-record dl dd{
  307. line-height: 22px;
  308. width: 100%;
  309. display: inline-block;
  310. float: left;
  311. height: 22px;
  312. position: relative;
  313. }
  314. .right-bar ul li .foot-record dl dd a{
  315. display: inline-block;
  316. height: 22px;
  317. padding: 0 10px;
  318. width: 91%;
  319. font-size: 12px;
  320. color: #fff;
  321. line-height: 22px;
  322. white-space: nowrap;
  323. overflow: hidden;
  324. text-overflow: ellipsis;
  325. background: none;
  326. text-align: left;
  327. padding-right: 44px;
  328. }
  329. .right-bar ul li a i{
  330. font-size: 20px;
  331. }
  332. .right-bar ul li li a:hover div.foot-record{
  333. display: inline-block !important;
  334. }
  335. .right-bar ul li .foot-record dl dd:hover{
  336. background: #fff;
  337. }
  338. .right-bar ul li .foot-record dl dd:hover a{
  339. color: #333;
  340. }
  341. .right-bar ul li .foot-record dl dd:hover div.hover-shows{
  342. display: inline-block;
  343. }
  344. .right-bar ul li .foot-record dl dd div.hover-shows{
  345. position: absolute;
  346. top: 0;
  347. right: 2px;
  348. max-width: 55px;
  349. line-height: 20px;
  350. padding-right: 0;
  351. z-index: 100;
  352. display: none;
  353. }
  354. .right-bar ul li .foot-record dl dd div.hover-shows span{
  355. display: inline-block;
  356. width: 30px;
  357. height: 20px;
  358. text-align: center;
  359. line-height: 20px;
  360. background: #e04b38;
  361. color: #fff;
  362. border-radius: 5px;
  363. opacity: 0;
  364. margin-top: 1px;
  365. }
  366. .right-bar ul li .foot-record dl dd:first-child{
  367. /* margin-top: 5px;*/
  368. }
  369. .right-bar ul li .foot-record dl dd:last-child{
  370. /* margin-bottom: 10px;*/
  371. }
  372. .right-bar ul li .foot-record dl dd div.hover-shows a{
  373. font-size: 23px;
  374. float: right;
  375. width: 20px;
  376. padding: 0;
  377. text-align: center;
  378. color: #999;
  379. top: -2px;
  380. }
  381. .right-bar ul li .foot-record dl dd div.hover-shows a:hover{
  382. color: #fbb029;
  383. }
  384. .right-bar ul li .foot-record dl dd div.hover-shows em{
  385. display: inline-block;
  386. position: absolute;
  387. width: 0;
  388. height: 0;
  389. border-top: 8px solid transparent;
  390. border-left: 7px solid #fbb029;
  391. border-bottom: 8px solid transparent;
  392. left: -158px;
  393. top: 4px;
  394. }
  395. .right-bar ul li .foot-record dl dd div.hover-shows em.off{
  396. border-left: 8px solid #b2b0b0;
  397. }
  398. .right-bar ul li .foot-record dl dd div.hover-shows span.off{
  399. opacity: 1;
  400. }
  401. /*浏览记录结束*/
  402. .right-bar ul li .contact-us{
  403. /*right: 200px;*/
  404. height: 180px;
  405. padding-top: 10px;
  406. width: 210px;
  407. top: -76px;
  408. }
  409. .right-bar ul li .contact-us p{
  410. line-height: 33px;
  411. text-align: left;
  412. padding-left: 10px;
  413. margin-bottom: 0;
  414. white-space: nowrap;
  415. font-size: 12px;
  416. }
  417. .right-bar ul li .contact-us .contact-btn{
  418. width: 62px;
  419. height: 18px;
  420. line-height: 18px;
  421. background: #ef7f03;
  422. display: inline-block;
  423. text-align: center;
  424. color: #fff;
  425. font-size: 12px;
  426. border-radius: 5px;
  427. padding: 0;
  428. }
  429. .right-bar-item{
  430. width: 36px;
  431. /* height: 38px;*/
  432. }
  433. .right-bar .right-bar-item a.title{
  434. display: inline-block;
  435. width: 36px;
  436. height: 38px;
  437. line-height: 38px;
  438. padding: 0;
  439. }
  440. .right-bar {
  441. position: fixed;
  442. z-index: 1000;
  443. right: 0;
  444. top: 0;
  445. width: 36px;
  446. height: 100%;
  447. .right-bar-center {
  448. position: absolute;
  449. top: 50%;
  450. transform: translateY(-50%);
  451. list-style: none;
  452. padding: 0;
  453. width: 100%;
  454. }
  455. .right-bar-bottom {
  456. position: absolute;
  457. right: 0;
  458. bottom: 0;
  459. width: 36px;
  460. }
  461. .right-bar-item {
  462. a {
  463. position: relative;
  464. display: block;
  465. width: 100%;
  466. color: #fff;
  467. background-color: #5078CB;
  468. text-align: center;
  469. -webkit-transition: background-color ease .5s;
  470. -moz-transition: background-color ease 0.5s;
  471. -ms-transition: background-color ease 0.5s;
  472. -o-transition: background-color ease 0.5s;
  473. transition: background-color ease 0.5s;
  474. z-index: 20;
  475. font-size: 12px;
  476. }
  477. }
  478. }
  479. </style>