RightBar.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520
  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">
  31. <i class="fa fa-comments-o" aria-hidden="true" style="color: #FFFFFF;">
  32. </i>
  33. <i class="remind-point" v-if="user.logged && chatCount>0"></i>
  34. </a>
  35. <div class="sidebar-menu" title="优软互联"><a @click="goWebChat">优软互联<span v-if="user.logged">({{chatCount}})</span></a></div>
  36. </li>
  37. </ul>
  38. <ul class="right-bar-bottom">
  39. <li class="right-bar-item" @mouseenter="loadHistorys()">
  40. <a @click="goHistory" class="title" target="_blank">
  41. <i class="iconfont icon-zuji icon-xlg"></i>
  42. </a>
  43. <div class="sidebar-menu" v-if="!user.logged"><a @click="goHistory" title="浏览记录">浏览记录</a></div>
  44. <div class="sidebar-menu" v-if="user.logged && listMe(history).length == 0"><a href="/user#/browsingHistory" title="浏览记录">浏览记录</a></div>
  45. <div class="foot-record sidebar-menu" v-if="user.logged && listMe(history).length > 0">
  46. <h3><a href="/user#/browsingHistory">浏览历史</a></h3>
  47. <dl>
  48. <dd v-for="item in listMe(history)">
  49. <a :href="'/store/' + item.storeid + '/' + item.batchCode" target="_blank" :title="item.code" v-text="item.code" v-if="item.status== 1"></a>
  50. <a :title="item.code" v-text="item.code" v-if="item.status== 0" disabled="disabled"></a>
  51. <div class="hover-shows">
  52. <em :class="{ 'off' : item.status== 0}"></em>
  53. <span :class="{ 'off' : item.status== 0}">失效</span>
  54. <a @click="deleteHistory(item,item.id)">&times;</a>
  55. </div>
  56. </dd>
  57. </dl>
  58. </div>
  59. </li>
  60. <li class="right-bar-item">
  61. <a @click="toTop()" class="title">
  62. <i class="iconfont icon-arrow-up icon-xlg"></i>
  63. </a>
  64. <div class="sidebar-menu"><a @click="toTop()" title="返回顶部" target="_blank">返回顶部</a></div>
  65. </li>
  66. </ul>
  67. </div>
  68. <el-dialog class="dialog"
  69. :visible.sync="dialogVisible"
  70. size="tiny">
  71. <message-board @pageEvent="listenPage" @openBoardEvent="listenOpen"/>
  72. </el-dialog>
  73. </div>
  74. </template>
  75. <script>
  76. import { scrollTo } from '~utils/scroll'
  77. import MessageBoard from '~components/default/MessageBoard.vue'
  78. export default {
  79. name: 'right-bar',
  80. data () {
  81. return {
  82. historyLength: [],
  83. dialogVisible: false,
  84. page: 1,
  85. count: 3,
  86. currentPage: 1,
  87. chatCount: 0
  88. }
  89. },
  90. components: {
  91. MessageBoard
  92. },
  93. computed: {
  94. user () {
  95. return this.$store.state.option.user
  96. },
  97. cartCount () {
  98. return this.$store.state.user.history.cartCount.data
  99. },
  100. history () {
  101. let arr = this.$store.state.user.history.historyList.data.slice(0, 8)
  102. return arr
  103. },
  104. enterprise () {
  105. let ens = this.user.data.enterprises
  106. if (ens && ens.length) {
  107. return ens.find(item => item.current) || {enName: this.user.data.userName + '(个人账户)'}
  108. } else {
  109. return {enName: this.user.data.userName + '(个人账户)'}
  110. }
  111. }
  112. },
  113. mounted () {
  114. this.$nextTick(() => {
  115. this.getChatCount()
  116. // 刷新统计信息
  117. setInterval(() => {
  118. this.getChatCount()
  119. }, 10000)
  120. })
  121. },
  122. methods: {
  123. listenPage: function (p) {
  124. this.page = p
  125. this.$store.dispatch('getMessageBoardInformation', {page: this.page, count: 3})
  126. },
  127. listenOpen: function (flag) {
  128. this.dialogVisible = flag
  129. },
  130. listMe: function (list) {
  131. return list.filter(function (item) {
  132. return item.isDelete === 1
  133. })
  134. },
  135. loadHistorys () {
  136. if (this.user.logged) {
  137. if (!this.history.length) {
  138. this.$store.dispatch('user/loadHistory')
  139. }
  140. }
  141. },
  142. loadCarCount () {
  143. if (this.user.logged) {
  144. if (!this.cartCount.count) {
  145. this.$store.dispatch('user/CarCount')
  146. }
  147. }
  148. },
  149. toTop () {
  150. scrollTo('body', 300)
  151. },
  152. toBottom () {
  153. scrollTo(window.scrollY + window.innerHeight, 300)
  154. },
  155. deleteHistory (item, id) {
  156. this.$store.dispatch('user/deleteHistory', {id: id})
  157. this.$store.dispatch('user/loadHistory')
  158. },
  159. goLogin: function () {
  160. this.$http.get('/login/page', {params: {returnUrl: window.location.href}}).then(response => {
  161. if (response.data) {
  162. window.location.href = response.data.content + '&baseUrl=' + encodeURIComponent(window.location.protocol + '//' + window.location.host + response.data.baseUrl)
  163. }
  164. })
  165. },
  166. goHistory: function () {
  167. if (!this.user.logged) {
  168. this.goLogin()
  169. } else {
  170. window.location.href = '/user#/browsingHistory'
  171. }
  172. },
  173. goCart: function () {
  174. if (!this.user.logged) {
  175. this.goLogin()
  176. } else {
  177. window.location.href = '/user#/cart'
  178. }
  179. },
  180. goWebChat: function () {
  181. if (!this.user.logged) {
  182. this.goLogin()
  183. } else {
  184. // 获得窗口的垂直位置
  185. let iTop = (window.screen.availHeight - 30 - 780) / 2
  186. // 获得窗口的水平位置
  187. let iLeft = (window.screen.availWidth - 10 - 1030) / 2
  188. let newTab = window.open('', '即时对话框', 'height=750, width=1000, top=' + iTop + ', left=' + iLeft + ', toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, status=no')
  189. this.$http.get('/basic/enterprise/' + this.enterprise.uu + '/info')
  190. .then(response => {
  191. let obj = {}
  192. obj.enUU = response.data.uu
  193. obj.enterprise = {enUU: response.data.uu, name: response.data.enName}
  194. obj.type = 'LIST'
  195. if (!(/^1\d{10}$/).test(this.user.data.userTel)) {
  196. this.$http.get('/basic/enterprise/' + obj.enUU + '/admin').then(response => {
  197. obj.userPhone = response.userTel
  198. this.openWebChat(newTab, obj)
  199. }, err => {
  200. console.log(err)
  201. this.$message.error('暂无卖家管理员手机号!')
  202. })
  203. } else {
  204. obj.userPhone = this.user.data.userTel
  205. this.openWebChat(newTab, obj)
  206. }
  207. }, err => {
  208. console.log(err)
  209. let obj = {}
  210. obj.type = 'LIST'
  211. if (!(/^1\d{10}$/).test(this.user.data.userTel)) {
  212. this.$http.get('/basic/enterprise/' + obj.enUU + '/admin').then(response => {
  213. obj.userPhone = response.userTel
  214. this.openWebChat(newTab, obj)
  215. }, err => {
  216. console.log(err)
  217. this.$message.error('暂无卖家管理员手机号!')
  218. })
  219. } else {
  220. obj.userPhone = this.user.data.userTel
  221. this.openWebChat(newTab, obj)
  222. }
  223. })
  224. }
  225. },
  226. openWebChat: function (newTab, obj) {
  227. this.$http.post('http://im.ubtob.com/api/chat/infos?condition=chat_info', obj)
  228. .then(response => {
  229. if (response.data.success) {
  230. newTab.location.href = 'http://im.ubtob.com/chat/visit?gid=' + response.data.content
  231. }
  232. })
  233. },
  234. getChatCount: function () {
  235. if (this.user.logged) {
  236. this.$http.get('http://im.ubtob.com/api/chat/message', {params: {enUU: this.enterprise.uu, operate: 'count_unread', phone: this.user.data.userTel}})
  237. .then(response => {
  238. this.chatCount = response.data.count
  239. })
  240. }
  241. }
  242. }
  243. }
  244. </script>
  245. <style lang="scss" scoped>
  246. a[disabled] {
  247. cursor: not-allowed;
  248. }
  249. em,i{
  250. font-style: inherit;
  251. }
  252. .right-bar ul li{
  253. position: relative;
  254. }
  255. .right-bar ul li .sidebar-menu {
  256. position: absolute;
  257. display: block;
  258. right: -100%;
  259. top: 0px;
  260. bottom: 0;
  261. width: 100px;
  262. line-height: 38px;
  263. height: 38px;
  264. color: #ffffff;
  265. background: #555;
  266. -webkit-transform: translateX(100%);
  267. -moz-transform: translateX(100%);
  268. -ms-transform: translateX(100%);
  269. -o-transform: translateX(100%);
  270. transform: translateX(100%);
  271. -webkit-transition: transform .5s;
  272. -moz-transition: transform .5s;
  273. -ms-transition: transform .5s;
  274. -o-transition: transform .5s;
  275. transition: transform .5s;
  276. z-index: 19;
  277. }
  278. .right-bar ul li .sidebar-menu a{
  279. background-color: #555555;
  280. }
  281. .right-bar ul li:hover a{
  282. background-color: #555555;
  283. }
  284. .right-bar ul li:hover .sidebar-menu {
  285. display: block;
  286. -webkit-transform: translateX(-72px);
  287. -moz-transform: translateX(-72px);
  288. -ms-transform: translateX(-72px);
  289. -o-transform: translateX(-72px);
  290. transform: translateX(-72px);
  291. }
  292. /*浏览记录*/
  293. .right-bar ul li .foot-record{
  294. /* display: none; */
  295. width: 210px !important;
  296. max-height: 230px;
  297. line-height: 30px;
  298. /* right: 200px;*/
  299. top: inherit;
  300. bottom: -100%;
  301. height: inherit;
  302. /*padding-bottom: 10px;*/
  303. }
  304. .right-bar ul li .foot-record h3{
  305. line-height: 39px;
  306. border-bottom: #767575 1px solid;
  307. text-align: left;
  308. padding-left: 10px;
  309. width: 96%;
  310. display: inline-block;
  311. margin: 0 auto;
  312. font-size: 12px;
  313. height: 39px;
  314. }
  315. .right-bar ul li .foot-record h3:hover a{
  316. color: #fbb029;
  317. }
  318. .right-bar ul li .foot-record h3 a{
  319. color: #fff;
  320. background-color: inherit;
  321. line-height: 39px;
  322. text-align: left;
  323. }
  324. .right-bar ul li .foot-record dl{
  325. padding-top: 5px;
  326. display: inline-block;
  327. background: #555;
  328. }
  329. .right-bar ul li .foot-record dl,.right-bar ul li .foot-record dl dd{
  330. width: 100%;
  331. margin: 0 auto;
  332. background: #555;
  333. }
  334. .right-bar ul li .foot-record dl dd{
  335. line-height: 22px;
  336. width: 100%;
  337. display: inline-block;
  338. float: left;
  339. height: 22px;
  340. position: relative;
  341. }
  342. .right-bar ul li .foot-record dl dd a{
  343. display: inline-block;
  344. height: 22px;
  345. padding: 0 10px;
  346. width: 91%;
  347. font-size: 12px;
  348. color: #fff;
  349. line-height: 22px;
  350. white-space: nowrap;
  351. overflow: hidden;
  352. text-overflow: ellipsis;
  353. background: none;
  354. text-align: left;
  355. padding-right: 44px;
  356. }
  357. .right-bar ul li a i{
  358. font-size: 20px;
  359. }
  360. .right-bar .remind-point {
  361. width: 8px;
  362. height: 8px;
  363. display: block;
  364. border-radius: 100%;
  365. background: red;
  366. position: relative;
  367. top: -31px;
  368. right: -21px;
  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: 60%;
  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>