123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459 |
- <template>
- <div class="work-layout">
- <top-nav></top-nav>
- <div :class="isCollapse ? 'small-main work-layout-main':'work-layout-main'">
- <div class="app-main-box">
- <el-menu router :default-active="key" :collapse="isCollapse" :collapse-transition="false">
- <sub-menu :menuData="menuList" :menuIndex="1"></sub-menu>
- </el-menu>
- </div>
- <div class="app-main-button" @click="isCollapse = !isCollapse">
- <i :class="isCollapse?'el-icon-s-unfold':'el-icon-s-fold'"></i>
- <div class="app-main-icon">收起导航</div>
- </div>
- </div>
- <bread-crumb :class="isCollapse ? 'small-crumb':''"></bread-crumb>
- <div :class="isCollapse ? 'small-content work-layout-content':'work-layout-content'">
- <transition name="slide-fade">
- <router-view :key="key" />
- </transition>
- </div>
- <div class="chat-box">
- <el-badge :value="badge" :hidden="!badge" class="item">
- <div class="chat" @click="openChat(1)">
- <i class="el-icon-s-comment"></i>
- </div>
- </el-badge>
- </div>
- <div class="chat-box customer-serve" v-if="isCustomer">
- <el-badge :value="badges" :hidden="!badges" class="item">
- <div class="chat" @click="openChat(2)">
- <i class="iconfont huifont-kefu"></i>
- </div>
- </el-badge>
- </div>
- <el-dialog :close-on-click-modal="true" title="优惠券" :visible.sync="hasCoupon" width="600px"
- :append-to-body="true">
- <div class="hui-flex hui-dialog">
- <div class="hui-flex-box hui-dialog-content" style="background: #f7f9fc;">
- <div class="coupon-card-wrap" v-for="(item,index) in coupon" :key="index">
- <div class="price">
- <div v-if="item.type === 1">
- <span class="symbol">¥</span>
- <span>{{item.couponAmount}}</span>
- </div>
- <div v-else>
- <span>{{item.discount*100}}</span>
- <span class="symbol">折</span>
- </div>
- </div>
- <div class="center-describe">
- <div class="product">{{item.title}}</div>
- <div class="sub-title">
- <span>{{item.type === 1?`满${item.threshold}减${item.couponAmount}`:`满${item.threshold}可用,最高抵扣${item.mostConstraint}`}}</span>
- </div>
- </div>
- <el-button type="primary" size="small" @click="reviceCoupon(item)">立即领取</el-button>
- </div>
- </div>
- </div>
- </el-dialog>
- <el-dialog :close-on-click-modal="false" title="聊天列表" :visible.sync="visible" width="900px"
- :append-to-body="true">
- <chat v-if="visible && chatType === 1"></chat>
- <chats v-if="visible && chatType === 2"></chats>
- </el-dialog>
- </div>
- </template>
- <script>
- import {
- mapGetters
- } from 'vuex';
- import {
- getCouponListByUser,
- receiveCouponByUser
- } from '@/api/discount'
- import {
- getCustomerServeListByQuery
- } from '@/api/organization'
- const topNav = () => import('./components/topNav');
- const subMenu = () => import('./components/subMenu');
- const breadCrumb = () => import('./components/breadCrumb');
- const chat = () => import('./components/chat/customer/chat');
- const chats = () => import('./components/chat/customerServe/chat');
- export default {
- data() {
- return {
- menuList: [],
- isCollapse: false,
- coupon: [],
- hasCoupon: false,
- visible: false,
- badge: 0,
- badges: 0,
- isCustomer: false,
- chatType: 1
- }
- },
- mounted() {
- this.init();
- this.initCoupon();
- this.initCustomerServe();
- },
- methods: {
- init() {
- this.menuList = this.$store.getters.menuData;
- this.$chat.getConversationList(data => {
- this.countNumber('badge', data.data)
- });
- },
- initCustomerServe() {
- getCustomerServeListByQuery({
- organizationId: this.$store.getters.organization.id,
- userId: this.$store.getters.user.userId
- }).then(res => {
- if (res.state && res.data && res.data.length > 0) {
- let data = res.data[0];
- this.isCustomer = true;
- this.$store.dispatch('app/changeCustomerId', data.customerId);
- this.$chats.connect();
- }
- })
- },
- openChat(type) {
- this.chatType = type;
- this.visible = true;
- },
- countNumber(type, data) {
- let badge = 0;
- let list = data.filter(node => node.conversationId !== 'system');
- for (let i = 0; i < list.length; i++) {
- badge += list[i].unread
- }
- this[type] = badge;
- },
- initCoupon() {
- getCouponListByUser(this.$store.getters.user.userId).then(res => {
- if (res.state) {
- this.coupon = res.data;
- this.hasCoupon = this.coupon.length > 0;
- }
- })
- },
- reviceCoupon(item) {
- receiveCouponByUser(this.$store.getters.user.userId, item.id).then(res => {
- if (res.state) {
- this.$message.success('领取成功');
- this.initCoupon();
- }
- })
- }
- },
- components: {
- topNav,
- subMenu,
- breadCrumb,
- chat,
- chats
- },
- computed: {
- key() {
- return this.$route.path;
- },
- ...mapGetters(['menuData', 'chatList', 'chatLists'])
- },
- watch: {
- menuData() {
- this.init();
- },
- chatList() {
- this.countNumber('badge', this.$store.getters.chatList || [])
- },
- chatLists() {
- this.countNumber('badges', this.$store.getters.chatLists || [])
- }
- }
- }
- </script>
- <style lang="scss">
- .coupon-card-wrap {
- align-items: center;
- background: url('@/assets/img/coupon.png') 50% / 100% 100% no-repeat;
- display: -webkit-flex;
- display: flex;
- margin-bottom: 9px;
- height: 110px;
- padding-right: 20px;
- .price {
- color: $--color-danger;
- font-size: 24px;
- font-weight: 500;
- line-height: 24px;
- text-align: center;
- width: 120px;
- .symbol {
- margin: 0 3px;
- font-size: $--font-size-base;
- }
- }
- .center-describe {
- display: inline-block;
- margin-right: auto;
- padding-left: 20px;
- text-align: left;
- .product {
- color: $--color-text-primary;
- font-size: $--font-size-large;
- font-weight: 550;
- line-height: 14px;
- padding-bottom: 12px;
- }
- }
- }
- .work-layout {
- width: 100%;
- height: 100%;
- background: $--background-color-base;
- .chat-box {
- position: fixed;
- bottom: 60px;
- right: 20px;
- font-size: 26px;
- cursor: pointer;
- z-index: 999;
- .chat {
- width: 50px;
- height: 50px;
- background: $--color-primary;
- color: #fff;
- border-radius: 50px;
- display: flex;
- align-items: center;
- justify-content: center;
- }
- &.customer-serve {
- bottom: 120px;
- .huifont-kefu {
- font-size: 26px;
- }
- }
- }
- .work-layout-main {
- position: fixed;
- left: 0;
- top: 52px;
- width: 164px;
- bottom: 0;
- background: $--color-white;
- padding: 8px 8px 0px 8px;
- box-sizing: border-box;
- display: flex;
- flex-direction: column;
- transition: all 0.4s;
- z-index: 99;
- border-right: 1px solid $--border-color-lighter;
- &.small-main {
- width: 64px;
- padding: 8px 8px 0px 8px;
- }
- .app-main-box {
- flex: 1;
- height: 0;
- overflow-y: auto;
- overflow-x: hidden;
- -ms-overflow-style: none;
- /* 隐藏 IE 中的滚动条 */
- scrollbar-width: none;
- /* 隐藏 Firefox 中的滚动条 */
- }
- .app-main-box::-webkit-scrollbar {
- width: 0;
- /* 隐藏滚动条 */
- }
- .el-menu {
- width: 100%;
- height: 100%;
- border-right: none;
- .el-icon-arrow-down {
- font-family: "iconfont" !important;
- font-size: 16px;
- }
- .el-icon-arrow-down::before {
- content: "\e72d";
- }
- .el-menu-item,
- .el-submenu__title {
- border-radius: 5px;
- height: 48px;
- line-height: 46px;
- font-size: 14px;
- min-width: auto;
- margin: 3px 0;
- padding-right: 10px;
- background-color: $--color-white;
- i.icon {
- font-size: 24px;
- margin-right: 8px;
- color: $--color-text-primary;
- }
- &:hover,
- &.is-active,
- &:focus {
- background-color: $--color-primary;
- color: $--color-white;
- i,
- span {
- color: $--color-white;
- }
- }
- }
- .el-submenu__title {
- .el-submenu__icon-arrow {
- right: 10px;
- }
- }
- .menu-index-1 {
- .el-menu-item,
- .el-submenu__title {
- padding-left: 12px !important;
- }
- }
- .menu-index-2 {
- .el-menu-item,
- .el-submenu__title {
- padding-left: 40px !important;
- }
- }
- .menu-index-3 {
- .el-menu-item,
- .el-submenu__title {
- padding-left: 45px !important;
- }
- }
- .menu-index-3 {
- .el-menu-item,
- .el-submenu__title {
- padding-left: 50px !important;
- }
- }
- .menu-index-4 {
- .el-menu-item,
- .el-submenu__title {
- padding-left: 55px !important;
- }
- }
- .menu-index-5 {
- .el-menu-item,
- .el-submenu__title {
- padding-left: 60px !important;
- }
- }
- }
- .app-main-button {
- border-top: 1px solid $--border-color-light;
- padding: 16px 13px;
- display: flex;
- cursor: pointer;
- margin-top: 12px;
- align-items: center;
- i {
- font-size: 24px;
- margin-right: 7px;
- color: $--color-text-secondary;
- }
- .app-main-icon {
- flex: 1;
- width: 0;
- overflow: hidden;
- font-weight: 400;
- word-spacing: break-all;
- height: 20px;
- }
- }
- }
- .el-menu--collapse {
- .el-submenu.is-active .el-submenu__title {
- background-color: $--color-primary;
- color: $--color-white;
- i,
- span {
- color: $--color-white;
- }
- }
- .el-submenu__icon-arrow,
- .menu-title {
- display: none;
- }
- }
- .work-layout-content {
- position: absolute;
- top: 89px;
- left: 176px;
- right: 12px;
- bottom: 12px;
- transition: left 0.4s;
- .slide-fade-enter-active {
- transition: all 0.1s ease;
- }
- .slide-fade-leave-active {
- transition: all 0.2s cubic-bezier(1, 0.5, 0.8, 1);
- }
- .slide-fade-enter,
- .slide-fade-leave-to {
- transform: translateX(10px);
- opacity: 0;
- }
- &.small-content {
- left: 76px;
- }
- }
- }
- </style>
|