RightBar.vue 14 KB

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