RightBar.vue 15 KB

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