<template>
  <view class="content" :style="{ backgroundPositionY: -44 + safeAreaInsets.top + 'px' }">
    <view class="top" :style="{ paddingTop: safeAreaInsets.top + 'px' }">
      <uni-search-bar class="search" bgColor="#EEEEEE" radius="100" placeholder="搜索" clearButton="none" cancelButton="none" @confirm="search" />
      <uni-icons type="email-filled" size="30" color="#fff"></uni-icons>
    </view>
    <view class="card">
      <view class="card-content">
        <view class="card-content-top">
          <image class="image" src="../../static/car.png" />
          <text style="margin-left: 30rpx">机动车</text>
        </view>
        <view class="card-content-bottom">
          <text style="font-size: 26rpx">未查询到备案的机动车</text>
        </view>
      </view>
      <view class="card-content" @click="drivingLicence">
        <view class="card-content-top">
          <image class="image" src="../../static/jiashizheng.png" />
          <text style="margin-left: 30rpx">驾驶证</text>
        </view>
        <view class="card-content-bottom">
          <text style="font-size: 26rpx">未查询到备案的驾驶证</text>
        </view>
      </view>
    </view>
    <view class="business">
      <view v-for="(item, index) in businessList" :key="index" class="grid-item">
        <view class="business-content" @click="closedclick(item.id)">
          <image class="image" style="margin-bottom: 20rpx" :src="item.img" />
          <text style="font-size: 12px">{{ item.text }}</text>
        </view>
      </view>
    </view>
    <view class="information">
      <view class="information-top">
        <view style="margin-left: 20rpx">
          <text style="font-weight: 600; font-size: 34rpx">资讯中心</text>
          <text style="font-size: 24rpx; font-weight: 400; color: #9b9b9b; margin-left: 50rpx">最新实时地方交通资讯</text>
        </view>
        <uni-icons type="right" size="20" color="#acacac" style="margin-right: 20rpx"></uni-icons>
      </view>
      <view class="information-content">
        <uni-swiper-dot :info="info" :current="current" field="content" mode="default">
          <swiper class="swiper-box" @change="change">
            <swiper-item v-for="(item, index) in info" :key="index">
              <view class="swiper-item" style="margin-right: 20rpx">
                <image src="../../static/index-bgd.png" style="width: 200rpx; height: 200rpx; margin-left: 20rpx"></image>
                <view class="swiper-text">
                  <text>{{ '测试数据' }}</text>
                  <view style="width: 100%; display: flex; justify-content: flex-end; color: #cecdd3; font-size: 28rpx">
                    {{ '2024-06-14' }}
                  </view>
                </view>
              </view>
            </swiper-item>
          </swiper>
        </uni-swiper-dot>
      </view>
      <view class="bottom">
        <view class="bottom-top">
          <view style="border-bottom: 1rpx solid #adc1d8; width: 60rpx" />
          <text style="color: #adc1d8; margin: 0 10rpx">\\\\</text>
          <view style="border-bottom: 1px solid #adc1d8; width: 360rpx" />
        </view>
        <view class="bottom-center">
          <view class="center-content">
            <view class="icon">
              <uni-icons type="undo" size="20" color="#8ca9cd"></uni-icons>
            </view>
            <view class="text">
              <text style="color: #8ca9cd; font-size: 24rpx; display: inline-block; text-align: center">未来会有更过服务,更好的体验现在快把我分享给帮你的好友吧</text>
            </view>
          </view>
        </view>
        <view class="bottom-bottom">
          <view style="border-bottom: 1rpx solid #e5e5e8; width: 25%" />
          <text style="color: #727272; margin: 0 10rpx; font-size: 24rpx">交管12123版本v3.1.1 B603</text>
          <view style="border-bottom: 1px solid #e5e5e8; width: 25%" />
        </view>
      </view>
    </view>
  </view>
</template>

<script setup>
import { ref } from 'vue';
const { safeAreaInsets } = uni.getSystemInfoSync();
const businessList = ref([
  {
    img: '../../static/rili.png',
    text: '考试预约\n\n',
    id: '1'
  },
  {
    img: '../../static/xinche.png',
    text: '新车选号\n\n',
    id: '2'
  },
  {
    img: '../../static/beian.png',
    text: '备案非本\n人机动车',
    id: '3'
  },
  {
    img: '../../static/xinche.png',
    text: '申请新车\n临时号牌',
    id: '4'
  },
  {
    img: '../../static/renling.png',
    text: '业务委托\n申请',
    id: '5'
  },
  {
    img: '../../static/laoren.png',
    text: '老年人业\n务代办',
    id: '6'
  },
  {
    img: '../../static/gongbu.png',
    text: '号牌号段\n公布',
    id: '7'
  },
  {
    img: '../../static/kaoshi.png',
    text: '考试信息\n公布',
    id: '8'
  },
  {
    img: '../../static/nuoche.png',
    text: '一键挪车\n\n',
    id: '9'
  },
  {
    img: '../../static/gengduo.png',
    text: '更多\n\n',
    id: '10'
  }
]);
const info = [
  {
    content: '内容 A'
  },
  {
    content: '内容 B'
  },
  {
    content: '内容 C'
  }
];
const current = ref(0);
const change = (e) => {
  current.value = e.detail.current;
};
const drivingLicence = () => {
  uni.navigateTo({
    url: './components/drivingLicence'
  });
};
const closedclick = (id) => {
  if (id == 10) {
    uni.navigateTo({
      url: './components/businessCenter'
    });
  }
};
</script>

<style lang="scss">
.content {
  width: 710rpx;
  background-image: url(@/static/index-bgd.png);
  background-size: contain;
  background-repeat: no-repeat;
  border-radius: 0 0 40rpx 40rpx;
  padding: 0 20rpx;

  .top {
    width: 100%;
    height: 100rpx;
    display: flex;
    align-items: center;
    padding: 10rpx 0;

    .search {
      width: 84%;
    }
  }

  .card {
    width: 100%;
    height: 200rpx;
    display: flex;
    justify-content: space-between;

    .card-content {
      width: 39%;
      height: 90%;
      border: 1px solid #fffff8;
      border-radius: 20rpx;
      color: #fffff8;
      padding: 0 30rpx;
      display: flex;
      flex-direction: column;
      justify-content: space-between;

      .card-content-top {
        height: 40%;
        width: 100%;
        display: flex;
        align-items: center;
      }

      .card-content-bottom {
        height: 50%;
        width: 100%;
        display: flex;
        align-items: center;
        justify-content: center;
      }
    }
  }

  .business {
    margin: 5% 0;
    height: 350rpx;
    width: 100%;
    background-color: #fff;
    border: 1px solid #ebeef0;
    border-radius: 20rpx;
    box-shadow: 0px 0px 30px 5px rgba(0, 0, 0, 0.1);
    display: grid;
    grid-template-columns: repeat(5, 1fr);

    /* 列间隔 */
    .grid-item {
      padding: 5%;
      border-radius: 5px;
    }

    .business-content {
      width: 100%;
      height: 100%;
      padding: 4rpx;
      display: flex;
      flex-direction: column;
      justify-content: center;
      align-items: center;
      /* 新增样式 */
      white-space: pre-wrap;
      /* 或者使用 'normal' */
      word-break: normal;
      /* 或者使用 'break-word' */
      text-align: center;
      /* 文字居中对齐 */
    }
  }

  .information {
    width: 100%;
    height: 350rpx;
    background-color: #fff;
    border: 1px solid #ebebeb;
    border-radius: 20rpx;
    box-shadow: 0px 0px 30px 5px rgba(0, 0, 0, 0.1);

    .information-top {
      width: 100%;
      height: 30%;
      border-bottom: 1px solid #f4f3f5;
      display: flex;
      align-items: center;
      justify-content: space-between;
    }

    .information-content {
      width: 100%;
      height: 70%;
      display: flex;
      margin-bottom: 20rpx;

      .swiper-item {
        display: flex;
        padding: 20rpx 0;
      }

      .swiper-text {
        width: 70%;
        display: flex;
        flex-direction: column;
        justify-content: space-between;
      }
    }
  }

  .bottom {
    width: 100%;
    height: 300rpx;

    .bottom-top {
      width: 100%;
      display: flex;
      align-items: center;
      justify-content: center;
    }

    .bottom-center {
      width: 100%;
      height: 80rpx;
      display: flex;
      justify-content: center;

      .center-content {
        width: 430rpx;
        display: flex;

        .icon {
          width: 30%;
          height: 100%;
          display: flex;
          align-items: center;
          justify-content: center;
        }
      }
    }

    .bottom-bottom {
      width: 100%;
      margin-top: 30rpx;
      display: flex;
      align-items: center;
      justify-content: center;
    }
  }
}

.image {
  width: 50rpx;
  height: 50rpx;
}
</style>
