<template>
  <view class="px-base">
    <CuNavbar title="设置"></CuNavbar>
    <view class="space-y-base mt-base">
      <view class="card-shadow bg-white rounded-19rpx">
        <Cell
          title="修改密码"
          :shadow="false"
          @onClick="goPath('/pages/setting/password')"
        ></Cell>
        <uv-line color="#f5f5f5"></uv-line>
        <Cell
          title="举报投诉"
          :shadow="false"
          @click="goPath('/pages/setting/complain')"
        ></Cell>
        <uv-line color="#f5f5f5"></uv-line>
        <Cell
          title="意见箱"
          :shadow="false"
          @click="goPath('/pages/setting/suggestion')"
        ></Cell>
        <uv-line color="#f5f5f5"></uv-line>
      </view>
      <view>
        <Cell title="当前版本" :isLink="false">
          <view class="flex justify-end text-hex-999999 text-24rpx px-base">
            v{{ varsion }}
          </view>
        </Cell>
      </view>
    </view>
    <view class="mt-100rpx">
      <uv-button @click="confirmLogout" block type="primary"
        >退出登录</uv-button
      >
    </view>

    <uv-modal
      ref="modalRef"
      title="提示"
      content="确定退出?"
      @confirm="logout"
    ></uv-modal>
  </view>
</template>
<script setup>
import { ref } from 'vue'
import CuNavbar from '@/components/cu-navbar/index'
import Cell from '@/components/cell/index'
import { sys } from '@climblee/uv-ui/libs/function'
import { computed } from 'vue'
import { useUserStore } from '@/store/modules/user'
const modalRef = ref(null)
const userStore = useUserStore()

const sysInfo = sys()
const varsion = computed(() => sysInfo.appVersion)
const goPath = (url) => {
  uni.navigateTo({
    url,
  })
}

const confirmLogout = () => {
  modalRef.value.open()
}

const logout = () => {
  userStore.logout()
  uni.reLaunch({
    url: '/pages/login/index',
  })
}
</script>
