<template>
  <ie-page bg-color="#f8fcff">
    <ie-navbar title="关于" />
    <view class="flex items-center justify-center py-80">
      <ie-image src="/static/logo.png" custom-class="w-160 h-160" mode="widthFix" />
    </view>
    <uv-cell-group class="bg-white !flex-none">
      <uv-cell v-for="item in settings" :icon="item.icon" :is-link="item.isLink" :title="item.title" :value="item.value"
        icon-style="font-size: 20px;" @click="item.handler()" />
    </uv-cell-group>
  </ie-page>
</template>

<script lang="ts" setup>
import { useTransferPage } from '@/hooks/useTransferPage';
import { useAppStore } from '@/store/appStore';
import { useUserStore } from '@/store/userStore';
import config from '@/config';

const appStore = useAppStore();
const userStore = useUserStore();
const { transferTo, routes } = useTransferPage();
const contactPhone = computed(() => userStore.orgInfo.contactPhone);

const settings = computed(() => [
  {
    title: '服务协议',
    icon: 'empty-order',
    isLink: true,
    handler: () => {
      transferTo(routes.pageWebview, {
        data: {
          url: config.userProtocolUrl,
          title: '服务协议'
        }
      });
    }
  },
  {
    title: '隐私政策',
    icon: 'lock',
    isLink: true,
    handler: () => {
      transferTo(routes.pageWebview, {
        data: {
          url: config.privacyPolicyUrl,
          title: '隐私政策'
        }
      });
    }
  },
  {
    title: '当前版本',
    icon: 'tags',
    value: appStore.systemInfo?.appVersion,
    handler: () => {
    }
  },
  {
    title: '注销账号',
    icon: 'trash',
    isLink: true,
    handler: async () => {
      uni.$ie.showModal({
        title: '注销账号',
        content: '是否注销账号，注销后卡号将不能再注册使用系统且永久失效。请谨慎操作！'
      }).then(confirm => {
        if (confirm) {
          userStore.deleteAccount();
        }
      });
    }
  },
  {
    title: 'APP备案号',
    icon: 'empty-permission',
    value: '湘ICP备18012964号-8A',
    handler: () => {
    }
  },
  {
    title: '客服电话',
    icon: 'server-man',
    value: contactPhone.value,
    handler: () => {
      userStore.callContactPhone();
    }
  }
]);
</script>

<style lang="scss"></style>