RightBar.vue 15 KB

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