HomeSlot.vue 5.05 KB
<template>
  <view :class="['app-content-box right-content', { 'show-content-box': tabIndex == 0 }]">
    <view class="start" @click="$emit('start')">
      <view class="sprite-icon icon-start-text"></view>
    </view>
    <view class="right-content-box flex">
      <view class="content-left">
        <view class="module-box box-class">
          <view class="common-title">
            <text class="title-text">
              <text class="highlight-type" @click="changeType">{{ currentType.typeName }}</text>
              产品介绍
            </text>
            <view class="switch-btn flex" @click="changeType">
              <view class="icon-box flex">
                 <uni-icons type="loop" size="14" color="#2c66f7"></uni-icons>
              </view>
              <text>切换产品</text>
            </view>
          </view>
          <view class="content-box">
            <template>
              <Material ref="materialRef" :moduleList="moduleList"></Material>
            </template>
          </view>
        </view>
      </view>
    </view>
    <!-- 业务类型选择器 -->
    <business-type-selector ref="bizTypeSelector" @choose="chooseBusinessType" />
  </view>
</template>

<script>
import Material from '@/components/MaterialIndex.vue'
import BusinessTypeSelector from './BusinessTypeSelector.vue'

export default {
  name: 'HomeSlot',
  components: { Material, BusinessTypeSelector },
  props: {
    tabIndex: {
      type: Number,
      default: 0
    },
    moduleList: {
      type: Array,
      default: () => []
    }
  },
  data() {
    return {
      currentType: {}
    }
  },
  mounted() {
    this.currentType = uni.$storage.get('typeItem') || {}
  },
  methods: {
    changeType() {
      this.$refs.bizTypeSelector.open()
    },
    chooseBusinessType(item) {
      this.currentType = item
      uni.$storage.set('typeItem', item)
      this.$emit('changeType', item)
    }
  }
}
</script>

<style scoped lang="scss">
.right-content {
  height: 100vh;
  box-sizing: border-box;
  position: relative;
  animation: show-box 0.15s forwards;
  overflow: hidden;
}

@keyframes show-box {
  0% {
    left: 100%;
  }

  100% {
    left: 0;
  }
}

.start {
  height: toRpx(232);
  box-sizing: border-box;
  margin-right: toRpx(64);
  position: relative;
  background: url('@/assets/images/home/start-btn.png') no-repeat;
  background-size: 100% 100%;
  padding-top: toRpx(60);
  display: flex;
  justify-content: center;

  .sprite-icon {
    zoom: 2;
  }
}

.right-content-box {
  width: 100%;
  // height: calc(100% - #{toRpx(232)});
  height: 100%;
  gap: toRpx(48);
  box-sizing: border-box;
  padding: toRpx(32) 0 toRpx(80);

  .box-class {
    background: #ffffff59;
    backdrop-filter: blur(toRpx(16));
    box-shadow: inset 0 0 toRpx(16) 0 #ffffff;
    border-radius: toRpx(48);
    overflow: hidden;
  }

  .content-box {
    position: relative;
    width: 100%;
    height: calc(100% - #{toRpx(160)});

    .message-box {
      height: 100%;
    }
  }

  .content-left,
  .content-right {
    height: 100%;
    flex-shrink: 0;
  }

  .content-left {
    width: calc(100% - #{toRpx(48)});

    .common-title {
      display: flex;
      align-items: center;
      /* justify-content: space-between; 不需要space-between,左对齐自然排列 */
      padding-right: toRpx(48); /* 保持右侧边距 */
      
      .title-text {
        flex: 1; /* 标题占据剩余空间 */
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;

        .highlight-type {
          color: #2c66f7;
          font-weight: bold;
          margin-right: toRpx(8);
          font-size: 1.1em;
          text-shadow: 0 toRpx(4) toRpx(8) rgba(44, 102, 247, 0.15);
        }
      }

      .switch-btn {
        padding: toRpx(8) toRpx(20) toRpx(8) toRpx(12);
        background: rgba(44, 102, 247, 0.08);
        border-radius: toRpx(32);
        border: 1px solid rgba(44, 102, 247, 0.15);
        transition: all 0.3s ease;
        margin-left: toRpx(24);
        
        .icon-box {
          width: toRpx(36);
          height: toRpx(36);
          background: #FFFFFF;
          border-radius: 50%;
          justify-content: center;
          align-items: center;
          margin-right: toRpx(12);
          box-shadow: 0 toRpx(4) toRpx(8) rgba(44, 102, 247, 0.15);
        }
        
        text {
          font-size: toRpx(24);
          color: #2c66f7;
          font-weight: 500;
          line-height: 1;
        }
        
        &:active {
          transform: scale(0.96);
          background: rgba(44, 102, 247, 0.15);
        }
      }
    }

    .module-box {
      height: calc(100% - #{toRpx(235)});
      margin-bottom: toRpx(48);
    }
    
    .tool-box {
      height: calc(100% - #{toRpx(712)});

      .content-box {
        width: calc(100% - #{toRpx(96)});
        margin: 0 toRpx(48);
      }
    }
  }

  .content-right {
    width: calc(100% - #{toRpx(1322)});
    // width: toRpx(800);
  }
}

.app-content-box {
  width: 100%;
  position: absolute;
  left: 0;
  top: 0;
  opacity: 0;
  z-index: -999;
}

.show-content-box {
  opacity: 1;
  z-index: 1;
}
</style>