<route lang="json">
{
  "style": {
    "navigationBarTitleText": "个人设置",
    "navigationBarBackgroundColor": "#fff"
  }
}
</route>
<script lang="ts" setup>
import { useUserStore } from '../../../../store'
import { storeToRefs } from 'pinia'

import { rightArrowIcon } from '@designer-hub/assets/src/svgs'
import { getBroker, getVendorAppInfo } from '../../../../core/libs/requests'
import SectionHeading from '@designer-hub/app/src/components/section-heading.vue'
import { messages } from '../../../../core/libs/messages'
import { useMessage } from 'wot-design-uni'
import BottomAppBar from '@/components/bottom-app-bar.vue'
import { useDictStore } from '@/store/dict'

const dictStore = useDictStore()
const { getOptionLabel } = dictStore
const userStore = useUserStore()
// cons useMessage()
const { isLogined, userInfo } = storeToRefs(userStore)
const { data, run: setData } = useRequest(() =>
  getBroker({ brokerId: String(userInfo.value.userId) }),
)
const logout = () => {
  uni.showModal({
    title: messages.mine.setting.logoutMessageText,
    success: function (res) {
      if (res.confirm) {
        userStore.clearUserInfo()
        uni.reLaunch({ url: '/pages/login/index' })
      }
    },
  })
}
onMounted(async () => {
  await setData()
})
</script>

<template>
  <view class="bg-white p-[16px] flex-grow flex flex-col gap-8.5">
    <SectionHeading size="sm" :title="'头像'">
      <template #append>
        <wd-img width="28" height="28" round custom-class="" :src="data?.headImgUrl" />
      </template>
    </SectionHeading>
    <SectionHeading size="sm" :title="'姓名'" :end-text="String(data?.brokerName)"></SectionHeading>
    <!--    <SectionHeading size="sm" :title="'ID'" :end-text="String(data?.id)"></SectionHeading>-->
    <SectionHeading
      size="sm"
      :title="messages.mine.setting.channelTypeTitleText"
      :end-text="getOptionLabel('member_channel_type', String(data?.channelType))"
    ></SectionHeading>
    <SectionHeading
      size="sm"
      :title="messages.mine.setting.mobileTitleText"
      :end-text="data?.mobile"
    ></SectionHeading>
    <SectionHeading
      title="修改密码"
      size="sm"
      path="/pages/common/auth/change-password/index"
      end-arrow
    ></SectionHeading>
    <BottomAppBar fixed placeholder>
      <wd-button block :round="false" @click="logout">
        <div
          class="text-center text-white text-base font-normal font-['PingFang_SC'] leading-normal"
        >
          退出登录
        </div>
      </wd-button>
    </BottomAppBar>
  </view>
</template>

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