<template>
  <view>
    <m-tabbar fixed fill :current="current" safeBottom :tabbar="tabbar" native openType="switchTab" @click="tabClick">
      <!--      <template v-slot:tabbar_index_2>-->
      <!--        <view class="custom_style">-->
      <!--          <view class="custom_style_icon">-->
      <!--            <u-image v-if="!isAuditing" src="https://oss.wsdns.cn/20250627/b6ea18396b074f8db2f649c7db385419.png" width="160rpx"-->
      <!--                     height="160rpx"/>-->
      <!--            <u-image v-else src="https://img.ggsxiangan.com/62c543af60204ff8868df41a31f79ec0.png" width="160rpx"-->
      <!--                     height="160rpx"/>-->
      <!--          </view>-->
      <!--        </view>-->
      <!--      </template>-->
    </m-tabbar>
  </view>
</template>

<script>
import {dictDataInfoReq} from "@/api/common";

export default {
  name: "customTabbar",
  props: {
    current: {
      default: 0,
      type: Number
    }
  },
  data() {
    return {
      tabbar: {
        color: "#333",
        selectedColor: "#98C147",
        borderStyle: "F0F0F0",
        backgroundColor: "#FFFFFF",
        list: [
          {
            "pagePath": "pages/index/index",
            "iconPath": "static/tabbar/home.png",
            "selectedIconPath": "static/tabbar/home-active.png",
            "text": "首页"
          },
          {
            "pagePath": "pages/index/index",
            "iconPath": "static/tabbar/service.png",
            "selectedIconPath": "static/tabbar/service-active.png",
            "text": "服务"
          },
		  {
		    "pagePath": "pages/community/index",
		    "iconPath": "static/tabbar/xiaoqu.png",
		    "selectedIconPath": "static/tabbar/xiaoqu-active.png",
		    "text": "小区"
		  },
          {
            "pagePath": "pages/index/index",
            "iconPath": "static/tabbar/store.png",
            "selectedIconPath": "static/tabbar/store-active.png",
            "text": "商城"
          },
          {
            "pagePath": "pages/user/index",
            "iconPath": "static/tabbar/user.png",
            "selectedIconPath": "static/tabbar/user-active.png",
            "text": "我的"
          }
        ]
      },
      isAuditing: true
    }
  },
  methods: {
    tabClick(val) {
      console.log('val', val)
      if (val === 0 && this.current === 0) this.$jump('/pages/index/index')
      if (val === 3) {
        uni.navigateToMiniProgram({
          appId: 'wxad2376fd45fb7eca',
          complete() {
            uni.switchTab({url: '/pages/index/index'})
          },
        })
      }
    },
    async checkAudit() {
      const {data} = await dictDataInfoReq(3678)
      this.isAuditing = data.dictDataCode === '1'
    }
  },
  mounted() {
    this.checkAudit()
  },
}
</script>

<style lang="scss">
.custom_style {
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 24rpx;
  width: 100rpx;
  height: 100rpx;
  margin-top: -40rpx;

  &_icon {
    //background-color: #2ACF8D;
    font-size: 80rpx;
    width: 100rpx;
    height: 100rpx;
    border-radius: 100%;
    display: flex;
    justify-content: center;
    align-items: center;

  }
}
</style>