RightBar.vue 16 KB

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