RightBar.vue 14 KB

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