RightBar.vue 16 KB

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