LeftSide.vue 5.48 KB
<template>
  <view class="left-side">
    <view class="user-info flex">
      <view class="user-avatar sprite-icon icon-avatar"></view>
      <view class="user-name">{{ userInfo.name }}</view>
    </view>
    <view :class="['left-tabs', { three: tabs.length == 3 }]">
      <template v-for="(i, index) in tabs">
        <view :class="['tab-item', { tabActive: tabIndex == index }]" :key="index" @click="changeIndex(index)">
          <view class="icon-box">
            <view :class="['sprite-icon', `icon-${i.icon}${tabIndex == index ? '-active' : ''}`]"></view>
          </view>
          {{ i.label }}
          <view class="dot" v-if="i.icon == 'record' && perRecordNumber"></view>
        </view>
      </template>
    </view>
    <view class="left-footer">
      <view class="btn" @click="$refs.kfRef.open()">
        <view class="sprite-icon icon-feedback"></view>
      </view>
      <view class="btn" @click="$refs.settingRef.open()">
        <view class="sprite-icon icon-setting"></view>
      </view>
    </view>
    <!-- 客服弹框 -->
    <kf-box ref="kfRef" />
    <!-- 设置弹框 -->
    <setting-box ref="settingRef" @stopAudio="$emit('stopAudio')" />
  </view>
</template>

<script type="text/ecmascript-6">
import KfBox from "./KfBox";
import SettingBox from "./SettingBox";
import { STORAGE_OBJECTkEY } from '@/utils/cache/constantData'
export default {
  components: { KfBox, SettingBox },
  props: {
    tabIndex: Number,
    userInfo: Object
  },
  name: '',
  data() {
    return {
      tabs: [
        {
          label: "首页",
          icon: "home",
          name: 'HomeSlot'
        },
        {
          label: "接待记录",
          icon: "record",
          name: 'RecordList'
        },
      ],
    }
  },
  watch: {
    userInfo(n) {
      if (n.shopMerchantId) this.haveCustomerAccess(n)
    }
  },
  computed: {
    perRecordNumber() {
      return this.$store.state.audio.perRecordNumber
    }
  },
  mounted() {
  },
  methods: {
    changeIndex(index) {
      if (this.tabIndex == index) return;
      this.$emit('update:tabIndex', index)
      this.$emit("changeTab", index)
    },
    async haveCustomerAccess(val) {
      const {shopMerchantId, sceneType:scene} = val
      const res = await uni.$api.customerApi.haveCustomerAccess({
        merchantId:shopMerchantId
      })
      if (res) this.tabs.push( {
        label: "客户档案",
        icon: "customer-file",
        name: 'CustomerFile'
      })
      this.$store.state.user.haveCustomerAccess = res
       uni.$api.customerApi.saleOpen({
        merchantId:shopMerchantId,
        scene
      }).then(result=>{
        if(result) {
          this.tabs.push({
          label: "个人中心",
          icon: "point",
          name: 'Point'
        })
        }
      })
    }
  }
}
</script>

<style scoped lang="scss">
.left-side {
  display: flex;
  flex-direction: column;
  position: relative;
  width: toRpx(240);
  flex-shrink: 0;

  .left-tabs {
    width: 100%;
    height: toRpx(1080);
    display: flex;
    flex-direction: column;
    justify-content: center;
    // align-items: center;
    box-sizing: border-box;
    padding: toRpx(16) 0;
    position: absolute;
    top: 50%;
    left: 0;
    transform: translateY(-50%);
    margin: auto;
    box-sizing: border-box;
    padding-left: toRpx(32);

    &::after {
      position: absolute;
      left: 0;
      top: 0;
      width: 100%;
      height: 100%;
      background-image: url('@/assets/images/home/left.webp');
      background-size: 100% 100%;
      content: '';
      z-index: -1;
    }

    .tab-item {
      width: toRpx(112);
      font-size: toRpx(28);
      color: #8a98b5;
      text-align: center;
      padding-bottom: toRpx(46);
      position: relative;

      .dot {
        width: toRpx(16);
        height: toRpx(16);
        background: #f24724;
        border-radius: 50%;
        position: absolute;
        right: toRpx(20);
        top: toRpx(20);
      }

      .icon-box {
        width: toRpx(112);
        height: toRpx(112);
        display: flex;
        justify-content: center;
        align-items: center;
        border-radius: 100%;
      }
    }

    .tabActive {
      color: #3773f8;

      .icon-box {
        animation: arc-move 0.15s forwards;
      }
    }

    @keyframes arc-move {
      from {
        transform: scale(0.1) rotate(0);
      }

      to {
        transform: scale(1) rotate(360deg);
      }
    }
  }

  .three {
    .tab-item {
      padding-bottom: toRpx(64);
    }
  }

  .user-info {
    width: toRpx(184);
    box-sizing: border-box;
    padding-top: toRpx(92);
    flex-direction: column;
    position: relative;
    z-index: 2;
    text-align: center;

    .account-change {
      width: toRpx(136);
      height: toRpx(32);
      background: #ffffff66;
      border-radius: toRpx(16);
      font-size: toRpx(20);
      color: #9e9e9e;
      justify-content: center;
      margin-top: toRpx(10);
    }
  }

  .user-avatar {
    width: toRpx(100);
    height: toRpx(100);
    border: toRpx(2) solid #ffffff;
    box-shadow: 0 toRpx(4) toRpx(8) 0 #0000001a;
    border-radius: 100%;
  }

  .user-name {
    font-weight: 500;
    font-size: toRpx(28);
    color: #292d33;
    margin-top: toRpx(16);
    padding: 0 toRpx(24);
  }

  .user-position {
    font-size: toRpx(20);
    color: #9b9b9e;
    margin-top: toRpx(8);
  }

  .left-footer {
    margin-top: auto;
    padding: 0 0 toRpx(80) 0;
  }

  .btn {
    display: flex;
    align-items: center;
    margin: toRpx(48) auto 0;
    box-sizing: border-box;
    padding-left: toRpx(60);
  }
}
</style>