index.vue 3.78 KB
<template>
  <div class="home nafmii-head-bg1">
    <nafm-header :leftArrow="false" navClass="nafmii-head-bg1">
      <div class="head-custom-container">
        <SearchInput
          :placeholder="$t('home.searchPlaceholder')"
          :readonly="true"
          @click="handleSearch"
        />

        <div class="head-message-box">
          <img src="@/assets/icon/message.png" alt="" />
        </div>
      </div>
    </nafm-header>
    <main>
      <HomeBanner :data="HomeData" />
      <MenuModule :data="HomeData" />
      <DataModule
        v-for="(item, idx) in modules"
        :key="idx"
        v-bind="item"
        :datas="item.datas"
        @clickMore="handleMore(item)"
        @clickItem="handleItem"
        @clickTop="handleTop(item)"
      />
    </main>
  </div>
</template>
<script>
import { mapState } from "vuex";
import SearchInput from '@/components/SearchInput'
import HomeBanner from './components/HomeBanner'
import MenuModule from './components/MenuModule'
import DataModule from '@/components/HomeDataListModule'
export default {
  name: "Home",
  components: { HomeBanner, MenuModule, DataModule, SearchInput },
  data () {
    const datas = [
      {
        isRecommend: true,
        title: '创新推出碳中和债,助理实现30·60目标创新推出碳中和债,助理实现30·60目标创新推出碳中和债,助理实现30·60目标',
        date: '2020-02-02',
        dataType: '产品创新'
      },
      {
        isRecommend: false,
        title: '创新推出碳中和债,助理实现30·60目标创新推出碳中和60目标',
        date: '2020-02-02',
        dataType: '产品创新'
      },
      {
        isRecommend: false,
        title: '创新推出碳中和债,助理实现30·60目标出',
        date: '2020-02-02',
        dataType: '产品创新'
      }
    ]
    return {
      modules: [
        { type: '1', name: this.$t('home.disclosure'), dateText: this.$t('home.disclosureDate'), datas, showTop: false },
        { type: '2', name: this.$t('home.news'), dateText: this.$t('home.updateDate'), datas, showTop: true },
        { type: '3', name: this.$t('home.registered'), dateText: this.$t('home.updateDate'), datas, showTop: true }
      ]
    };
  },
  computed: {
    ...mapState('home', {
      HomeData: state => state.HomeData,
      // Banner: state => {
      //   const { carouseTime, carouseVOList } = state.HomeData || {}
      // }
    })
  },
  methods: {
    handleSearch () {
      this.$router.push({ name: 'GlobalSearch' })
    },

    handleTop (module) {
      const modules = []
      for (const item of this.modules) {
        const showTop = item.type != module.type
        !showTop ? modules.unshift(item) : modules.push(item)
        Object.assign(item, { showTop })
      }
      this.modules = modules
    },
    handleMore (module) {

    },

    handleItem (item) {

    }
  },
  mounted () {
    this.$store.dispatch('home/AGetHomeData')
  }
};
</script>


<style lang="less" scoped>
.home {
  @PaddingSize: 15px;

  main {
    padding: 0 @PaddingSize;
  }
}

@PaddingSize: 15px;
@HeadHeight: 50px;
.head-custom-container {
  width: 100%;
  height: @HeadHeight;
  display: flex;
  align-items: center;

  @InputHeight: 33px;
  .search-input-box {
    width: 100%;
    height: @InputHeight;
    border-radius: calc(@InputHeight / 2);
    background-color: rgba(255, 255, 255, 0.2);
    padding: 0 @PaddingSize;
    display: flex;
    align-items: center;

    @SearchIconSize: 12px;
    .search-icon {
      background: white;
      width: @SearchIconSize;
      height: @SearchIconSize;
    }
    .search-placeholder {
      color: white;
      font-size: 12px;
      padding-left: 22px;
    }
  }
  @MessageBoxSize: 23px;
  .head-message-box {
    width: @MessageBoxSize;
    height: @MessageBoxSize;
    margin-left: @PaddingSize;
  }
}
</style>