<template>
  <view class="center">
    <view
      @click="goPath(item)"
      class="center-item"
      v-for="(item, index) in centerList"
      :key="index"
    >
      <image class="center-img" :src="item.img"></image>
      <text v-if="index == 0"  class="center-text">{{ item.text+'\n500题'}}</text>
      <text v-if="index == 1" class="center-text">{{ item.text }}</text>
    </view>
  </view>
</template>

<script>
import utils from "@/utils/index";
export default {
  data() {
    //exercise
    return {};
  },
  methods: {
    goPath(item) {
      let query = Object.assign({}, this.query);
      query.title = item.text;
      if (item.path) {
        let str = utils.mapToUrlQuery(query);
        console.log(item.path + "?" + str, "str");
        uni.navigateTo({
          url: item.path + "?" + str,
        });
      }
    },
  },
  props: {
    query: {
      type: Object,
      default: () => {
        return {};
      },
    },
    centerList: {
      type: Array,
      default: () => {
        return [];
      },
    },
  },
};
</script>

<style lang="scss" scoped>
.center {
  display: flex;
  flex-direction: column;
  width: 300rpx;

  .center-item {
    position: relative;
    margin-bottom: 30rpx;
    color: #fff;
    text-align: center;
  }
  .center-img {
    width: 300rpx;
    height: 300rpx;
  }
  .center-text {
    position: absolute;
    width: 100%;
    height: 100%;
    display: flex;
    align-content: center;
    justify-content: center;
    align-items: center;
    left: 0;
    top: 0;
  }
}
</style>