LeftSide.vue 7.08 KB
<template>
  <view class="left-side">
    <view class="user-box">
      <view class="user-info flex">
        <view :class="['user-avatar', 'sprite-icon', 'icon-avatar', tabIndex == 99 ? 'user-active' : '']"></view>
        <view class="user-name">
          <view class="user-name-text">{{ userInfo.name }}</view>
        </view>
      </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, i)"
          v-if="!i.hidden"
        >
          <view class="icon-box">
            <view :class="['sprite-icon', `icon-${i.icon}${tabIndex == index ? '-active' : ''}`]"></view>
          </view>
          {{ i.label }}
        </view>
      </template>
    </view>
    <view class="left-footer">
      <view
        class="btn"
        @click="handleSetting"
      >
        <view class="sprite-icon icon-setting"></view>
      </view>
    </view>
    <!-- 设置弹框 -->
    <setting-box
      ref="settingRef"
      @stopAudio="$emit('stopAudio')"
    />
  </view>
</template>

<script type="text/ecmascript-6">
import SettingBox from "./SettingBox";
export default {
  components: {  SettingBox },
  props: {
    tabIndex: Number,
    userInfo: Object
  },
  name: '',
  data () {
    return {
    }
  },
  watch: {
    userInfo (n) {
    },

  },
  computed: {
    perRecordNumber () {
      return this.$store.state.audio.perRecordNumber
    },
    tabs () {
      const tabs = [
        {
          label: "首页",
          icon: "home",
          name: 'HomeSlot'
        },
        {
          label: "订单",
          icon: "scene",
          name: 'Order'
        }
      ]
      return tabs
    }
  },
  created () {
  },
  inject: ['showPage'],
  methods: {
    // addTrack () {
    //   const { merchantId, merchantName } = uni.$storage.get("userInfo")
    //   const params = {
    //     goodsType: 1,
    //     merchantId,
    //     merchantName
    //   }
    //   uni.$api.commonApi.dynamicrecordAdd(params).then(res => {
    //     this.trackId = res
    //   })
    // },
    // leaveTrack () {
    //   if (!this.trackId) return
    //   uni.$api.commonApi.dynamicrecordLeave({ id: this.trackId }).then(res => {
    //   })
    // },
    // startTrack () {
    //   if (this.trackInterval) clearInterval(this.trackInterval)
    //   this.trackInterval = setInterval(() => {
    //     this.leaveTrack()
    //   }, 5000)
    // },
    clickHome () {
      if (this.tabs[this.tabIndex].isTrack)
        this.changeIndex(0, this.tabs[0])
    },
    handleSetting () {
      this.$refs.settingRef.open()
      this.clickHome()
    },
    async changeIndex (index, item) {
      if (item.eventCode) uni.$track.add({
        eventCode: item.eventCode
      })
      this.$emit('update:tabIndex', index)
      this.$emit("changeTab", {
        item,
        index
      })
    },
  },
  beforeCreate () {
    // clearInterval(this.trackInterval)
    // this.trackInterval = null
  },
  beforeDestroy () {
    // clearInterval(this.trackInterval)
    // this.trackInterval = null
  },
}
</script>

<style scoped lang="scss">
.left-side {
  display: flex;
  flex-direction: column;
  position: relative;
  width: toRpx(240);
  flex-shrink: 0;
  background-image: url('@/assets/images/home/left-bg.png');
  background-size: 100% 100%;
  .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(104);
      font-size: toRpx(26);
      color: #8a98b5;
      text-align: center;
      padding-bottom: toRpx(25);
      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(104);
        height: toRpx(104);
        display: flex;
        justify-content: center;
        align-items: center;
        border-radius: 100%;
      }
      .tip-box {
        position: absolute;
        left: toRpx(90);
        top: toRpx(20);
        color: #ffffff;
        font-size: toRpx(28);
        width: toRpx(310);
        height: toRpx(90);
        line-height: toRpx(64);
        background-image: url('@/assets/images/home/daliog.png');
        background-size: 100% 100%;
        z-index: 99999;
        padding-left: toRpx(60);
        text-align: left;
        opacity: 0;
      }
    }

    .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-box {
    padding-top: toRpx(92);
  }
  .user-info {
    width: toRpx(184);
    box-sizing: border-box;
    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-active {
      border: toRpx(2) solid rgb(55, 115, 248);
    }
  }

  .user-name {
    display: inline-flex;
    align-items: center;
    font-weight: 500;
    font-size: toRpx(28);
    color: #292d33;
    margin-top: toRpx(16);
    padding: 0 toRpx(12);
    &-text {
      width: toRpx(112);
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }
  }

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

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

  .btn {
    position: relative;
    display: flex;
    align-items: center;
    margin: toRpx(48) auto 0;
    box-sizing: border-box;
    padding-left: toRpx(60);
    .icon-scene-change {
      zoom: 2;
    }
    .message-number {
      position: absolute;
      display: flex;
      align-items: center;
      justify-content: center;
      width: toRpx(16);
      height: toRpx(16);
      background-color: #f24724;
      right: 50%;
      top: 0;
      color: #fff;
      border-radius: 50%;
      font-size: toRpx(20);
    }
  }
}
</style>