<template>
  <view class="index_main" :style="{ minHeight: screenH + 'px' }">
    <view class="back-top"></view>
    <!-- 轮播图 -->
    <view class="swiper_nav">
      <swiper autoplay :duration="1000">
        <swiper-item v-for="(item, index) in swiperImg" :key="index">
          <image :src="item" style="width: 100%; height: 100%"></image>
        </swiper-item>
      </swiper>
    </view>
    <!-- 皖送e餐 志愿者服务 -->
    <view class="main_menu">
      <view class="main_menu_item" v-for="(item, index) in firstMenus" :key="index" @click="handleItem(index)">
        <image :src="item.icon"></image>
        <view class="main_menu_name">{{ item.name }}</view>
      </view>
    </view>
  </view>
</template>

<script>
export default {
  data() {
    return {
      screenH: '',
      swiperImg: [require('../static/images/system/top.png')],
      firstMenus: [
        {
          name: '就餐服务',
          icon: require('../static/images/system/1.png')
        },
        {
          name: '志愿者服务',
          icon: require('../static/images/system/2.png')
        },
        {
          name: '驿站服务',
          icon: require('../static/images/system/3.png')
        }
      ]
    }
  },
  mounted() {
    uni.getSystemInfo({
      success: res => {
        this.screenH = res.windowHeight
      }
    })
  },
  methods: {
    handleItem(index) {
      if (index === 0) {
        this.$tab.reLaunch('/pages/index')
      } else if (index === 1) {

      } else if (index === 2) {
        uni.navigateTo(
          {
            url : '/pages/post/index'
          }
        )
      }
    }
  }
}
</script>

<style lang="scss">
page {
  min-height: 100vh;
  background-image: url('../static/images/system/bg.png');
}

.index_main {
  /* background: #f2f6fa; */
  overflow: auto;
  padding: 24rpx 0;
  box-sizing: border-box;
}

.back-top {
  position: fixed;
  width: 100%;
  height: 578rpx;
  /* background: linear-gradient(180deg, #d2eaff 0%, rgba(208, 233, 254, 0) 100%); */
  top: 0;
  left: 0;
}

.swiper_nav {
  width: 100%;
  height: 300rpx;
  /* background: #ffffff; */
  border-radius: 20rpx;
  padding: 0 24rpx;
  box-sizing: border-box;
}

.main_menu {
  display: flex;
  justify-content: space-between;
  margin-top: 24px;
  padding: 0 12rpx;
  box-sizing: border-box;
}

.main_menu_item {
  z-index: 99;
  margin: 0 12rpx;
  padding: 28rpx 0;
  flex: 1;
  height: 208rpx;
  background: #ffffff;
  border-radius: 20rpx;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;

  .main_menu_name {
    font-family: PingFang SC, PingFang SC;
    font-weight: bold;
    font-size: 30rpx;
    color: #0e1a24;
    font-style: normal;
    text-transform: none;
  }

  image {
    display: flex;
    width: 88rpx;
    height: 88rpx;
    border-radius: 34rpx;
  }
}

.yiz_menu {
  width: calc(100% - 48rpx);
  min-height: 480rpx;
  background: #ffffff;
  border-radius: 20rpx;
  margin-top: 24rpx;
  margin-left: 24rpx;
}

.yiz_menu_tle {
  font-family: PingFang SC, PingFang SC;
  font-weight: bold;
  font-size: 32rpx;
  color: #0e1a24;
  font-style: normal;
  text-transform: none;
  padding: 28rpx 28rpx 0 28rpx;
}

.yiz_menu_nav {
  display: flex;
  align-items: center;
  flex-wrap: wrap;

  .yiz_menu_nav_item {
    width: calc(100% / 4);
    margin-top: 48rpx;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;

    image {
      display: block;
      width: 88rpx;
      height: 88rpx;
      border-radius: 34rpx;
    }

    .yiz_menu_name {
      font-family: PingFang SC, PingFang SC;
      font-weight: 400;
      font-size: 28rpx;
      color: #0e1a24;
      font-style: normal;
      text-transform: none;
      margin-top: 20rpx;
    }
  }
}
</style>
