<template xmlns="">
  <view class="">
    <view class="p-f back-box" @click="clickHandle">
      <ly-icon :size="60" color="" name="icon-fanhui"/>
    </view>
    <view class="p-f bottom-right"></view>
    <view class="p-f mac-info" @click="toSetting">
      mac:{{ userStore.mac || '未登录' }}
    </view>
  </view>
</template>

<script setup>
import {reactive} from "vue";
import {navigateBack, navTo, showToast} from "@/utils/app";
import {useUserStore} from "@/store/useUserStore";
import {useConfigStore} from "@/store/useConfigStore";
import debounce from "@/utils/debounce";

const configStore = useConfigStore()
const userStore = useUserStore()

const pd = reactive({})
const props = defineProps({
  showBack: {
    type: Boolean,
    default: true,
  },
  autoBack: {
    type: Boolean,
    default: true
  },
  color: {
    type: String,
    default: '#FFF'
  },
  backClick: {
    type: Function,
  },
})

const clickHandle = () => {
  if (this.autoBack) {
    navigateBack()
  } else {
    this.$emit('backClick')
  }
}

const toSetting = () => {
  debounce.secondCountDown('toSetting', {
    time: 5000,
    limit: 10,
    repetition_time: 0,
    run: (num, count, statue) => {
      if (count > 5) showToast(`再点击${10 - count}次`)
    },
    success: () => {
      console.log('success')
      navTo('pages/setting/index')
    },
    fail: () => {
      console.log('fail')
    },
  })
}
</script>

<style lang="scss" scoped>
.mac-info {
  bottom: 10rpx;
  right: 20rpx;
  font-size: 35rpx;
  color: #cccccc;
}
</style>
