<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'
const userStore = useUserStore()
// cons useMessage()
const { isLogined, userInfo } = storeToRefs(userStore)
const { data, run: setData } = useRequest(() =>
  getBroker({ brokerId: userInfo.value.userId.toString() }),
)
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">
    <div class="flex-1">
      <div class="flex justify-between items-center mb-[30px]">
        <div class="text-black/40 text-sm font-normal font-['PingFang_SC'] leading-none">头像</div>
        <wd-img width="28" height="28" round custom-class="" :src="data?.headImgUrl" />
      </div>
      <div class="flex justify-between items-center mb-[30px]">
        <div class="text-black/40 text-sm font-normal font-['PingFang_SC'] leading-none">名称</div>
        <div
          class="text-right text-[#999999] text-sm font-normal font-['PingFang_SC'] leading-none"
        >
          {{ data?.brokerName }}
        </div>
      </div>
      <div class="flex justify-between items-center mb-[30px]">
        <div class="text-black/40 text-sm font-normal font-['PingFang_SC'] leading-none">ID</div>
        <div
          class="text-right text-[#999999] text-sm font-normal font-['PingFang_SC'] leading-none"
        >
          {{ data?.id }}
        </div>
      </div>
      <div class="flex justify-between items-center mb-[30px]">
        <div class="text-black/40 text-sm font-normal font-['PingFang_SC'] leading-none">
          {{ messages.mine.setting.channelTypeTitleText }}
        </div>
        <div
          class="text-right text-[#999999] text-sm font-normal font-['PingFang_SC'] leading-none"
        >
          {{ data?.channelType }}
        </div>
      </div>
      <div class="flex justify-between items-center mb-[30px]">
        <div class="text-black/40 text-sm font-normal font-['PingFang_SC'] leading-none">
          {{ messages.mine.setting.mobileTitleText }}
        </div>
        <div
          class="text-right text-[#999999] text-sm font-normal font-['PingFang_SC'] leading-none"
        >
          {{ data?.mobile }}
        </div>
      </div>
      <SectionHeading title="修改密码" size="sm" end-arrow></SectionHeading>
    </div>
    <div class="w-full mt-[50px]">
      <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>
    </div>
  </view>
</template>

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