RightBar.vue 16 KB

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