RightBar.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471
  1. <template>
  2. <div>
  3. <div class="right-bar">
  4. <ul class="right-bar-center">
  5. <li class="right-bar-item">
  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. <el-button type="text" @click="dialogVisible = true">
  13. <a @click="onLeaveMessageClick()" class="title">
  14. <i class="iconfont icon-liuyan icon-xlg"></i>
  15. </a>
  16. <div class="sidebar-menu"><a title="留言板" target="_blank">留言板</a></div>
  17. </el-button>
  18. </li>
  19. <li class="right-bar-item contact-menu">
  20. <a href="http://wpa.qq.com/msgrd?v=3&uin=3432892085&site=www.ubtoc.com&menu=yes" target="_blank" class="title">
  21. <i class="iconfont icon-kefu icon-xlg"></i>
  22. </a>
  23. <div class="contact-us sidebar-menu">
  24. <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>
  25. <p>服务电话:400-830-1818</p>
  26. <p>服务邮箱:yrsc@usoftchina.com</p>
  27. <p>工作时间:</p>
  28. <p>周一至周五 9:00-18:00</p>
  29. </div>
  30. </li>
  31. <li class="right-bar-item contact-menu">
  32. <a href="javascript:void(0)" class="title" @click="goWebChat" @mouseenter="getChatCount">
  33. <i class="fa fa-comments-o" aria-hidden="true" style="font-size: 18px;color: #FFFFFF;">
  34. </i>
  35. </a>
  36. <div class="sidebar-menu" title="优软互联"><a @click="goWebChat">优软互联<span v-if="user.logged">({{chatCount}})</span></a></div>
  37. </li>
  38. </ul>
  39. <ul class="right-bar-bottom">
  40. <li class="right-bar-item">
  41. <a href="http://www.usoftmall.com/user#/browsingHistory" class="title" target="_blank">
  42. <i class="iconfont icon-zuji icon-xlg"></i>
  43. </a>
  44. <div class="sidebar-menu" v-if="!user.logged"><a href="/user#/browsingHistory" title="浏览记录" target="_blank">浏览记录</a></div>
  45. <div class="sidebar-menu" v-if="user.logged && listMe(history).length == 0"><a href="/user#/browsingHistory" title="浏览记录" target="_blank">浏览记录</a></div>
  46. <div class="foot-record sidebar-menu" v-if="user.logged && listMe(history).length > 0">
  47. <h3><a href="">浏览历史</a></h3>
  48. <dl>
  49. <dd v-for="item in listMe(history)">
  50. <a :href="'/store/' + item.storeid + '/' + item.batchCode" :title="item.code" v-text="item.code" v-if="item.status== 1"></a>
  51. <a :title="item.code" v-text="item.code" v-if="item.status== 0" disabled="disabled"></a>
  52. <div class="hover-shows">
  53. <em :class="{ 'off' : item.status== 0}"></em>
  54. <span :class="{ 'off' : item.status== 0}">失效</span>
  55. <a @click="deleteHistory(item,item.id)">&times;</a>
  56. </div>
  57. </dd>
  58. </dl>
  59. </div>
  60. </li>
  61. <li class="right-bar-item">
  62. <a @click="toTop()" class="title">
  63. <i class="iconfont icon-arrow-up icon-xlg"></i>
  64. </a>
  65. <div class="sidebar-menu"><a @click="toTop()" title="返回顶部" target="_blank">返回顶部</a></div>
  66. </li>
  67. </ul>
  68. </div>
  69. <el-dialog class="dialog"
  70. :visible.sync="dialogVisible"
  71. size="tiny">
  72. <message-board @pageEvent="listenPage" @openBoardEvent="listenOpen"/>
  73. </el-dialog>
  74. </div>
  75. </template>
  76. <script>
  77. import axios from '~/plugins/axios'
  78. import { scrollTo } from '~utils/scroll'
  79. import MessageBoard from '~components/messageBoard/MessageBoard.vue'
  80. export default {
  81. name: 'right-bar',
  82. data () {
  83. return {
  84. historyLength: [],
  85. dialogVisible: false,
  86. dialogImageUrl: '',
  87. page: 1,
  88. count: 3,
  89. currentPage: 1,
  90. chatCount: -1
  91. }
  92. },
  93. created () {
  94. this.$store.dispatch('getMessageBoardInformation', {page: 1, count: 3})
  95. },
  96. components: {
  97. MessageBoard
  98. },
  99. computed: {
  100. user () {
  101. return this.$store.state.option.user
  102. },
  103. cartCount () {
  104. return this.$store.state.user.history.cartCount.data
  105. },
  106. history () {
  107. let arr = this.$store.state.user.history.historyList.data.slice(0, 8)
  108. return arr
  109. },
  110. enterprise () {
  111. let ens = this.user.data.enterprises
  112. if (ens && ens.length) {
  113. return ens.find(item => item.current) || ens[0]
  114. }
  115. return {}
  116. }
  117. },
  118. mounted () {
  119. this.$nextTick(() => {
  120. this.loadHistorys()
  121. this.loadCarCount()
  122. })
  123. },
  124. methods: {
  125. listenPage: function (p) {
  126. this.page = p
  127. this.$store.dispatch('getMessageBoardInformation', {page: this.page, count: 3})
  128. },
  129. listenOpen: function (flag) {
  130. this.dialogVisible = flag
  131. },
  132. listMe: function (list) {
  133. return list.filter(function (item) {
  134. return item.isDelete === 1
  135. })
  136. },
  137. loadHistorys () {
  138. this.$store.dispatch('user/loadHistory')
  139. },
  140. loadCarCount () {
  141. this.$store.dispatch('user/CarCount')
  142. },
  143. toTop () {
  144. scrollTo('body', 300)
  145. },
  146. toBottom () {
  147. scrollTo(window.scrollY + window.innerHeight, 300)
  148. },
  149. // 打开留言板
  150. onLeaveMessageClick () {
  151. },
  152. deleteHistory (item, id) {
  153. this.$store.dispatch('user/deleteHistory', {id: id})
  154. this.loadHistorys()
  155. },
  156. goCart: function () {
  157. if (!this.user.logged) {
  158. this.$http.get('/login/page').then(response => {
  159. if (response.data) {
  160. this.$router.push('/auth/login')
  161. }
  162. })
  163. } else {
  164. window.location.href = '/user#/cart'
  165. }
  166. },
  167. goWebChat: function () {
  168. if (!this.user.logged) {
  169. this.$http.get('/login/page').then(response => {
  170. if (response.data) {
  171. this.$router.push('/auth/login')
  172. }
  173. })
  174. } else {
  175. // 获得窗口的垂直位置
  176. let iTop = (window.screen.availHeight - 30 - 600) / 2
  177. // 获得窗口的水平位置
  178. let iLeft = (window.screen.availWidth - 10 - 1030) / 2
  179. let newTab = window.open('', '即时对话框', 'height=600, width=1030, top=' + iTop + ', left=' + iLeft + ', toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, status=no')
  180. axios.get('/basic/enterprise/' + this.enterprise.uu + '/info')
  181. .then(response => {
  182. let obj = {}
  183. obj.enUU = response.data.uu
  184. obj.enterprise = {enUU: response.data.uu, name: response.data.enName}
  185. obj.type = 'LIST'
  186. obj.userPhone = this.user.data.userTel
  187. axios.post('http://im.ubtob.com/api/chat/infos?condition=chat_info', obj)
  188. .then(response => {
  189. if (response.data.success) {
  190. newTab.location.href = 'http://im.ubtob.com/chat/visit?gid=' + response.data.content
  191. }
  192. })
  193. }, err => {
  194. console.log(err)
  195. })
  196. }
  197. },
  198. getChatCount: function () {
  199. if (this.user.logged) {
  200. axios.get('http://im.ubtob.com/api/chat/message', {params: {enUU: this.enterprise.uu, operate: 'count_unread', phone: this.user.data.userTel}})
  201. .then(response => {
  202. this.chatCount = response.data.count
  203. })
  204. }
  205. }
  206. }
  207. }
  208. </script>
  209. <style lang="scss" scoped>
  210. a[disabled] {
  211. cursor: not-allowed;
  212. }
  213. em,i{
  214. font-style: inherit;
  215. }
  216. .right-bar ul li{
  217. position: relative;
  218. }
  219. .right-bar ul li .sidebar-menu {
  220. position: absolute;
  221. display: block;
  222. right: -100%;
  223. top: 0px;
  224. bottom: 0;
  225. width: 120px;
  226. line-height: 38px;
  227. height: 38px;
  228. color: #ffffff;
  229. background: #555;
  230. -webkit-transform: translateX(100%);
  231. -moz-transform: translateX(100%);
  232. -ms-transform: translateX(100%);
  233. -o-transform: translateX(100%);
  234. transform: translateX(100%);
  235. -webkit-transition: transform .5s;
  236. -moz-transition: transform .5s;
  237. -ms-transition: transform .5s;
  238. -o-transition: transform .5s;
  239. transition: transform .5s;
  240. z-index: 19;
  241. }
  242. .right-bar ul li .sidebar-menu a{
  243. background-color: #555555;
  244. }
  245. .right-bar ul li:hover a{
  246. background-color: #555555;
  247. }
  248. .right-bar ul li:hover .sidebar-menu {
  249. display: block;
  250. -webkit-transform: translateX(-72px);
  251. -moz-transform: translateX(-72px);
  252. -ms-transform: translateX(-72px);
  253. -o-transform: translateX(-72px);
  254. transform: translateX(-72px);
  255. }
  256. /*浏览记录*/
  257. .right-bar ul li .foot-record{
  258. /* display: none; */
  259. width: 210px !important;
  260. max-height: 230px;
  261. line-height: 30px;
  262. /* right: 200px;*/
  263. top: inherit;
  264. bottom: -100%;
  265. height: inherit;
  266. /*padding-bottom: 10px;*/
  267. }
  268. .right-bar ul li .foot-record h3{
  269. line-height: 39px;
  270. border-bottom: #767575 1px solid;
  271. text-align: left;
  272. padding-left: 10px;
  273. width: 96%;
  274. display: inline-block;
  275. margin: 0 auto;
  276. font-size: 12px;
  277. height: 39px;
  278. }
  279. .right-bar ul li .foot-record h3:hover a{
  280. color: #fbb029;
  281. }
  282. .right-bar ul li .foot-record h3 a{
  283. color: #fff;
  284. background-color: inherit;
  285. line-height: 39px;
  286. text-align: left;
  287. }
  288. .right-bar ul li .foot-record dl{
  289. padding-top: 5px;
  290. display: inline-block;
  291. background: #555;
  292. }
  293. .right-bar ul li .foot-record dl,.right-bar ul li .foot-record dl dd{
  294. width: 100%;
  295. margin: 0 auto;
  296. background: #555;
  297. }
  298. .right-bar ul li .foot-record dl dd{
  299. line-height: 22px;
  300. width: 100%;
  301. display: inline-block;
  302. float: left;
  303. height: 22px;
  304. position: relative;
  305. }
  306. .right-bar ul li .foot-record dl dd a{
  307. display: inline-block;
  308. height: 22px;
  309. padding: 0 10px;
  310. width: 91%;
  311. font-size: 12px;
  312. color: #fff;
  313. line-height: 22px;
  314. white-space: nowrap;
  315. overflow: hidden;
  316. text-overflow: ellipsis;
  317. background: none;
  318. text-align: left;
  319. padding-right: 44px;
  320. }
  321. .right-bar ul li li a:hover div.foot-record{
  322. display: inline-block !important;
  323. }
  324. .right-bar ul li .foot-record dl dd:hover{
  325. background: #fff;
  326. }
  327. .right-bar ul li .foot-record dl dd:hover a{
  328. color: #333;
  329. }
  330. .right-bar ul li .foot-record dl dd:hover div.hover-shows{
  331. display: inline-block;
  332. }
  333. .right-bar ul li .foot-record dl dd div.hover-shows{
  334. position: absolute;
  335. top: 0;
  336. right: 2px;
  337. max-width: 55px;
  338. line-height: 20px;
  339. padding-right: 0;
  340. z-index: 100;
  341. display: none;
  342. }
  343. .right-bar ul li .foot-record dl dd div.hover-shows span{
  344. display: inline-block;
  345. width: 30px;
  346. height: 20px;
  347. text-align: center;
  348. line-height: 20px;
  349. background: #e04b38;
  350. color: #fff;
  351. border-radius: 5px;
  352. opacity: 0;
  353. margin-top: 1px;
  354. }
  355. .right-bar ul li .foot-record dl dd:first-child{
  356. /* margin-top: 5px;*/
  357. }
  358. .right-bar ul li .foot-record dl dd:last-child{
  359. /* margin-bottom: 10px;*/
  360. }
  361. .right-bar ul li .foot-record dl dd div.hover-shows a{
  362. font-size: 23px;
  363. float: right;
  364. width: 20px;
  365. padding: 0;
  366. text-align: center;
  367. color: #999;
  368. top: -2px;
  369. }
  370. .right-bar ul li .foot-record dl dd div.hover-shows a:hover{
  371. color: #fbb029;
  372. }
  373. .right-bar ul li .foot-record dl dd div.hover-shows em{
  374. display: inline-block;
  375. position: absolute;
  376. width: 0;
  377. height: 0;
  378. border-top: 8px solid transparent;
  379. border-left: 7px solid #fbb029;
  380. border-bottom: 8px solid transparent;
  381. left: -158px;
  382. top: 4px;
  383. }
  384. .right-bar ul li .foot-record dl dd div.hover-shows em.off{
  385. border-left: 8px solid #b2b0b0;
  386. }
  387. .right-bar ul li .foot-record dl dd div.hover-shows span.off{
  388. opacity: 1;
  389. }
  390. /*浏览记录结束*/
  391. .right-bar ul li .contact-us{
  392. /*right: 200px;*/
  393. height: 180px;
  394. padding-top: 10px;
  395. width: 210px;
  396. top: -76px;
  397. }
  398. .right-bar ul li .contact-us p{
  399. line-height: 33px;
  400. text-align: left;
  401. padding-left: 10px;
  402. margin-bottom: 0;
  403. white-space: nowrap;
  404. font-size: 12px;
  405. }
  406. .right-bar ul li .contact-us .contact-btn{
  407. width: 62px;
  408. height: 18px;
  409. line-height: 18px;
  410. background: #ef7f03;
  411. display: inline-block;
  412. text-align: center;
  413. color: #fff;
  414. font-size: 12px;
  415. border-radius: 5px;
  416. padding: 0;
  417. }
  418. .right-bar-item{
  419. width: 36px;
  420. /* height: 38px;*/
  421. }
  422. .right-bar .right-bar-item a.title{
  423. display: inline-block;
  424. width: 36px;
  425. height: 38px;
  426. line-height: 38px;
  427. padding: 0;
  428. }
  429. .right-bar {
  430. position: fixed;
  431. z-index: 1000;
  432. right: 0;
  433. top: 0;
  434. width: 36px;
  435. height: 100%;
  436. .right-bar-center {
  437. position: absolute;
  438. top: 50%;
  439. transform: translateY(-50%);
  440. list-style: none;
  441. padding: 0;
  442. width: 100%;
  443. }
  444. .right-bar-bottom {
  445. position: absolute;
  446. right: 0;
  447. bottom: 0;
  448. width: 36px;
  449. }
  450. .right-bar-item {
  451. a {
  452. position: relative;
  453. display: block;
  454. width: 100%;
  455. color: #fff;
  456. background-color: #5078CB;
  457. text-align: center;
  458. -webkit-transition: background-color ease .5s;
  459. -moz-transition: background-color ease 0.5s;
  460. -ms-transition: background-color ease 0.5s;
  461. -o-transition: background-color ease 0.5s;
  462. transition: background-color ease 0.5s;
  463. z-index: 20;
  464. font-size: 12px;
  465. }
  466. }
  467. }
  468. </style>