<template>
  <view class="center">
    <view
      @click="goPath(item, index)"
      class="center-item"
      v-for="(item, index) in centerList"
      :key="index"
    >
      <image class="center-img" :src="item.img"></image>
   
    
    </view>
  </view>
</template>

<script>
import utils from "@/utils/index";
export default {
  data() {
    //exercise
    return {};
  },
  computed: {
    isVip() {
      return this.$store.getters.isVip;
    },
  },
  methods: {
    goPath(item, index) {
      let query = Object.assign({}, this.query);
      query.title = item.text;
      if (this.needVipList.includes(index) && !this.isVip) {
        uni.showModal({
          title: "提示",
          content: "需要vip才能使用这个功能",
          confirmText: "购买vip",
          cancelText: "取消",
          success(res) {
            console.log(res);
            if (res.confirm) {
              uni.navigateTo({
                url: "/otherPages/buyVip/index",
              });
            }
          },
        });

        return;
      }
      if (item.path) {
        let str = utils.mapToUrlQuery(query);
        console.log(item.path + "?" + str, "str");
        uni.navigateTo({
          url: item.path + "?" + str,
        });
      }
    },
  },
  props: {
    needVipList: {
      type: Array,
      default: () => {
        return [];
      },
    },
    query: {
      type: Object,
      default: () => {
        return {};
      },
    },
    centerList: {
      type: Array,
      default: () => {
        return [];
      },
    },
  },
};
</script>

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

  .center-item {
    position: relative;
    margin-bottom: 100rpx;
    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;
    font-size: $uni-app-fontsize-paragraph;
  }
}
</style>