<template>
  <div>

    <div class="home_body_com" v-if="page_show">

      <scroller>

        <div v-for="(item,index) in list" :key="index">
          <goods_list v-if="item.type=='goods_list'" :data="item.data"></goods_list>
          <swiper v-if="item.type=='swiper'" :data="item.data"></swiper>
          <nav_menu v-if="item.type=='nav_menu'" :data="item.data"></nav_menu>


          <div v-if="item.type=='diy'" v-html="item.data"></div>


          <van-search v-if="item.type == 'search'"

            placeholder="请输入搜索关键词"
            show-action

          >
            <div slot="action" @click="onSearch">搜索</div>
          </van-search>

        </div>


      </scroller>

    </div>


    <common_footer :active_index="0"></common_footer>

  </div>
</template>

<script>
  import common_footer from '@/components/common/footer'
  import goods_list from '@/components/modules/goods_list'
  import swiper from '@/components/modules/swiper'
  import nav_menu from '@/components/modules/nav_menu'
  import request from '@/utils/request'
  export default {
    name: 'home',
    components: {common_footer,goods_list,swiper,nav_menu},
    created(){
      this.$toast.loading({
        mask: true,
        message: '加载中...'
      })
      this.get_data()
    },
    data(){
      return {
        page_show:false,
        list:[]
      }
    },
    methods: {
      get_data () {
        let self = this
        request('get','/shop/ajax/get_index_data').then((ret) => {
          this.list = ret.data.data
          self.$nextTick(() => {
            self.$toast.clear()
            self.page_show = true
          })
        }).catch((e) => {})
      }
    }
  }
</script>
<style rel="stylesheet/scss" lang="scss">
  .home_body_com {
    height: calc(100% - 1rem);
    position: relative;
  }
</style>

