RightBar.vue 14 KB

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