RightBar.vue 16 KB

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