workLayout.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459
  1. <template>
  2. <div class="work-layout">
  3. <top-nav></top-nav>
  4. <div :class="isCollapse ? 'small-main work-layout-main':'work-layout-main'">
  5. <div class="app-main-box">
  6. <el-menu router :default-active="key" :collapse="isCollapse" :collapse-transition="false">
  7. <sub-menu :menuData="menuList" :menuIndex="1"></sub-menu>
  8. </el-menu>
  9. </div>
  10. <div class="app-main-button" @click="isCollapse = !isCollapse">
  11. <i :class="isCollapse?'el-icon-s-unfold':'el-icon-s-fold'"></i>
  12. <div class="app-main-icon">收起导航</div>
  13. </div>
  14. </div>
  15. <bread-crumb :class="isCollapse ? 'small-crumb':''"></bread-crumb>
  16. <div :class="isCollapse ? 'small-content work-layout-content':'work-layout-content'">
  17. <transition name="slide-fade">
  18. <router-view :key="key" />
  19. </transition>
  20. </div>
  21. <div class="chat-box">
  22. <el-badge :value="badge" :hidden="!badge" class="item">
  23. <div class="chat" @click="openChat(1)">
  24. <i class="el-icon-s-comment"></i>
  25. </div>
  26. </el-badge>
  27. </div>
  28. <div class="chat-box customer-serve" v-if="isCustomer">
  29. <el-badge :value="badges" :hidden="!badges" class="item">
  30. <div class="chat" @click="openChat(2)">
  31. <i class="iconfont huifont-kefu"></i>
  32. </div>
  33. </el-badge>
  34. </div>
  35. <el-dialog :close-on-click-modal="true" title="优惠券" :visible.sync="hasCoupon" width="600px"
  36. :append-to-body="true">
  37. <div class="hui-flex hui-dialog">
  38. <div class="hui-flex-box hui-dialog-content" style="background: #f7f9fc;">
  39. <div class="coupon-card-wrap" v-for="(item,index) in coupon" :key="index">
  40. <div class="price">
  41. <div v-if="item.type === 1">
  42. <span class="symbol">¥</span>
  43. <span>{{item.couponAmount}}</span>
  44. </div>
  45. <div v-else>
  46. <span>{{item.discount*100}}</span>
  47. <span class="symbol">折</span>
  48. </div>
  49. </div>
  50. <div class="center-describe">
  51. <div class="product">{{item.title}}</div>
  52. <div class="sub-title">
  53. <span>{{item.type === 1?`满${item.threshold}减${item.couponAmount}`:`满${item.threshold}可用,最高抵扣${item.mostConstraint}`}}</span>
  54. </div>
  55. </div>
  56. <el-button type="primary" size="small" @click="reviceCoupon(item)">立即领取</el-button>
  57. </div>
  58. </div>
  59. </div>
  60. </el-dialog>
  61. <el-dialog :close-on-click-modal="false" title="聊天列表" :visible.sync="visible" width="900px"
  62. :append-to-body="true">
  63. <chat v-if="visible && chatType === 1"></chat>
  64. <chats v-if="visible && chatType === 2"></chats>
  65. </el-dialog>
  66. </div>
  67. </template>
  68. <script>
  69. import {
  70. mapGetters
  71. } from 'vuex';
  72. import {
  73. getCouponListByUser,
  74. receiveCouponByUser
  75. } from '@/api/discount'
  76. import {
  77. getCustomerServeListByQuery
  78. } from '@/api/organization'
  79. const topNav = () => import('./components/topNav');
  80. const subMenu = () => import('./components/subMenu');
  81. const breadCrumb = () => import('./components/breadCrumb');
  82. const chat = () => import('./components/chat/customer/chat');
  83. const chats = () => import('./components/chat/customerServe/chat');
  84. export default {
  85. data() {
  86. return {
  87. menuList: [],
  88. isCollapse: false,
  89. coupon: [],
  90. hasCoupon: false,
  91. visible: false,
  92. badge: 0,
  93. badges: 0,
  94. isCustomer: false,
  95. chatType: 1
  96. }
  97. },
  98. mounted() {
  99. this.init();
  100. this.initCoupon();
  101. this.initCustomerServe();
  102. },
  103. methods: {
  104. init() {
  105. this.menuList = this.$store.getters.menuData;
  106. this.$chat.getConversationList(data => {
  107. this.countNumber('badge', data.data)
  108. });
  109. },
  110. initCustomerServe() {
  111. getCustomerServeListByQuery({
  112. organizationId: this.$store.getters.organization.id,
  113. userId: this.$store.getters.user.userId
  114. }).then(res => {
  115. if (res.state && res.data && res.data.length > 0) {
  116. let data = res.data[0];
  117. this.isCustomer = true;
  118. this.$store.dispatch('app/changeCustomerId', data.customerId);
  119. this.$chats.connect();
  120. }
  121. })
  122. },
  123. openChat(type) {
  124. this.chatType = type;
  125. this.visible = true;
  126. },
  127. countNumber(type, data) {
  128. let badge = 0;
  129. let list = data.filter(node => node.conversationId !== 'system');
  130. for (let i = 0; i < list.length; i++) {
  131. badge += list[i].unread
  132. }
  133. this[type] = badge;
  134. },
  135. initCoupon() {
  136. getCouponListByUser(this.$store.getters.user.userId).then(res => {
  137. if (res.state) {
  138. this.coupon = res.data;
  139. this.hasCoupon = this.coupon.length > 0;
  140. }
  141. })
  142. },
  143. reviceCoupon(item) {
  144. receiveCouponByUser(this.$store.getters.user.userId, item.id).then(res => {
  145. if (res.state) {
  146. this.$message.success('领取成功');
  147. this.initCoupon();
  148. }
  149. })
  150. }
  151. },
  152. components: {
  153. topNav,
  154. subMenu,
  155. breadCrumb,
  156. chat,
  157. chats
  158. },
  159. computed: {
  160. key() {
  161. return this.$route.path;
  162. },
  163. ...mapGetters(['menuData', 'chatList', 'chatLists'])
  164. },
  165. watch: {
  166. menuData() {
  167. this.init();
  168. },
  169. chatList() {
  170. this.countNumber('badge', this.$store.getters.chatList || [])
  171. },
  172. chatLists() {
  173. this.countNumber('badges', this.$store.getters.chatLists || [])
  174. }
  175. }
  176. }
  177. </script>
  178. <style lang="scss">
  179. .coupon-card-wrap {
  180. align-items: center;
  181. background: url('@/assets/img/coupon.png') 50% / 100% 100% no-repeat;
  182. display: -webkit-flex;
  183. display: flex;
  184. margin-bottom: 9px;
  185. height: 110px;
  186. padding-right: 20px;
  187. .price {
  188. color: $--color-danger;
  189. font-size: 24px;
  190. font-weight: 500;
  191. line-height: 24px;
  192. text-align: center;
  193. width: 120px;
  194. .symbol {
  195. margin: 0 3px;
  196. font-size: $--font-size-base;
  197. }
  198. }
  199. .center-describe {
  200. display: inline-block;
  201. margin-right: auto;
  202. padding-left: 20px;
  203. text-align: left;
  204. .product {
  205. color: $--color-text-primary;
  206. font-size: $--font-size-large;
  207. font-weight: 550;
  208. line-height: 14px;
  209. padding-bottom: 12px;
  210. }
  211. }
  212. }
  213. .work-layout {
  214. width: 100%;
  215. height: 100%;
  216. background: $--background-color-base;
  217. .chat-box {
  218. position: fixed;
  219. bottom: 60px;
  220. right: 20px;
  221. font-size: 26px;
  222. cursor: pointer;
  223. z-index: 999;
  224. .chat {
  225. width: 50px;
  226. height: 50px;
  227. background: $--color-primary;
  228. color: #fff;
  229. border-radius: 50px;
  230. display: flex;
  231. align-items: center;
  232. justify-content: center;
  233. }
  234. &.customer-serve {
  235. bottom: 120px;
  236. .huifont-kefu {
  237. font-size: 26px;
  238. }
  239. }
  240. }
  241. .work-layout-main {
  242. position: fixed;
  243. left: 0;
  244. top: 52px;
  245. width: 164px;
  246. bottom: 0;
  247. background: $--color-white;
  248. padding: 8px 8px 0px 8px;
  249. box-sizing: border-box;
  250. display: flex;
  251. flex-direction: column;
  252. transition: all 0.4s;
  253. z-index: 99;
  254. border-right: 1px solid $--border-color-lighter;
  255. &.small-main {
  256. width: 64px;
  257. padding: 8px 8px 0px 8px;
  258. }
  259. .app-main-box {
  260. flex: 1;
  261. height: 0;
  262. overflow-y: auto;
  263. overflow-x: hidden;
  264. -ms-overflow-style: none;
  265. /* 隐藏 IE 中的滚动条 */
  266. scrollbar-width: none;
  267. /* 隐藏 Firefox 中的滚动条 */
  268. }
  269. .app-main-box::-webkit-scrollbar {
  270. width: 0;
  271. /* 隐藏滚动条 */
  272. }
  273. .el-menu {
  274. width: 100%;
  275. height: 100%;
  276. border-right: none;
  277. .el-icon-arrow-down {
  278. font-family: "iconfont" !important;
  279. font-size: 16px;
  280. }
  281. .el-icon-arrow-down::before {
  282. content: "\e72d";
  283. }
  284. .el-menu-item,
  285. .el-submenu__title {
  286. border-radius: 5px;
  287. height: 48px;
  288. line-height: 46px;
  289. font-size: 14px;
  290. min-width: auto;
  291. margin: 3px 0;
  292. padding-right: 10px;
  293. background-color: $--color-white;
  294. i.icon {
  295. font-size: 24px;
  296. margin-right: 8px;
  297. color: $--color-text-primary;
  298. }
  299. &:hover,
  300. &.is-active,
  301. &:focus {
  302. background-color: $--color-primary;
  303. color: $--color-white;
  304. i,
  305. span {
  306. color: $--color-white;
  307. }
  308. }
  309. }
  310. .el-submenu__title {
  311. .el-submenu__icon-arrow {
  312. right: 10px;
  313. }
  314. }
  315. .menu-index-1 {
  316. .el-menu-item,
  317. .el-submenu__title {
  318. padding-left: 12px !important;
  319. }
  320. }
  321. .menu-index-2 {
  322. .el-menu-item,
  323. .el-submenu__title {
  324. padding-left: 40px !important;
  325. }
  326. }
  327. .menu-index-3 {
  328. .el-menu-item,
  329. .el-submenu__title {
  330. padding-left: 45px !important;
  331. }
  332. }
  333. .menu-index-3 {
  334. .el-menu-item,
  335. .el-submenu__title {
  336. padding-left: 50px !important;
  337. }
  338. }
  339. .menu-index-4 {
  340. .el-menu-item,
  341. .el-submenu__title {
  342. padding-left: 55px !important;
  343. }
  344. }
  345. .menu-index-5 {
  346. .el-menu-item,
  347. .el-submenu__title {
  348. padding-left: 60px !important;
  349. }
  350. }
  351. }
  352. .app-main-button {
  353. border-top: 1px solid $--border-color-light;
  354. padding: 16px 13px;
  355. display: flex;
  356. cursor: pointer;
  357. margin-top: 12px;
  358. align-items: center;
  359. i {
  360. font-size: 24px;
  361. margin-right: 7px;
  362. color: $--color-text-secondary;
  363. }
  364. .app-main-icon {
  365. flex: 1;
  366. width: 0;
  367. overflow: hidden;
  368. font-weight: 400;
  369. word-spacing: break-all;
  370. height: 20px;
  371. }
  372. }
  373. }
  374. .el-menu--collapse {
  375. .el-submenu.is-active .el-submenu__title {
  376. background-color: $--color-primary;
  377. color: $--color-white;
  378. i,
  379. span {
  380. color: $--color-white;
  381. }
  382. }
  383. .el-submenu__icon-arrow,
  384. .menu-title {
  385. display: none;
  386. }
  387. }
  388. .work-layout-content {
  389. position: absolute;
  390. top: 89px;
  391. left: 176px;
  392. right: 12px;
  393. bottom: 12px;
  394. transition: left 0.4s;
  395. .slide-fade-enter-active {
  396. transition: all 0.1s ease;
  397. }
  398. .slide-fade-leave-active {
  399. transition: all 0.2s cubic-bezier(1, 0.5, 0.8, 1);
  400. }
  401. .slide-fade-enter,
  402. .slide-fade-leave-to {
  403. transform: translateX(10px);
  404. opacity: 0;
  405. }
  406. &.small-content {
  407. left: 76px;
  408. }
  409. }
  410. }
  411. </style>