RightBar.vue 14 KB

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