ProfileView.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. <template>
  2. <view class="app-container pb-40">
  3. <!-- 顶部个人信息 -->
  4. <view class="px-4 pb-6 rounded-b-3xl" style="background: linear-gradient(135deg, #1e3a8a, #1e40af);">
  5. <StatusBar />
  6. <view class="flex items-center pt-3">
  7. <view class="w-16 h-16 rounded-full flex items-center justify-center mr-4" style="background-color: rgba(255, 255, 255, 0.2);">
  8. <text class="uni-icons uniui-person-filled text-white text-2xl"></text>
  9. </view>
  10. <view class="flex-1 min-w-0">
  11. <text class="text-white text-lg font-semibold block truncate">{{ displayName }}</text>
  12. <view class="flex items-center flex-wrap mt-1">
  13. <text v-if="primaryMeta" class="text-white text-sm mr-3" style="opacity: 0.8;">{{ primaryMeta }}</text>
  14. <text v-if="secondaryMeta" class="text-white text-sm" style="opacity: 0.8;">{{ secondaryMeta }}</text>
  15. </view>
  16. </view>
  17. </view>
  18. </view>
  19. <!-- 功能列表 -->
  20. <view class="px-4 py-4 gap-y-4">
  21. <!-- 账号信息 -->
  22. <view class="bg-white rounded-xl shadow-sm p-4">
  23. <text class="text-base font-semibold text-gray-800 block mb-3">账号信息</text>
  24. <uni-list :border="false">
  25. <uni-list-item title="姓名" :note="userInfo?.name || '-'" />
  26. <template v-if="role === 'construction'">
  27. <uni-list-item title="班组" :note="userInfo?.team || '-'" />
  28. <uni-list-item title="职位" :note="userInfo?.position || '-'" />
  29. <uni-list-item title="工号" :note="userInfo?.employeeNo || '-'" />
  30. <uni-list-item title="联系电话" :note="userInfo?.phone || '-'" />
  31. </template>
  32. <template v-else>
  33. <uni-list-item title="部门" :note="userInfo?.department || '-'" />
  34. <uni-list-item title="职位" :note="userInfo?.position || '-'" />
  35. <uni-list-item title="工号" :note="userInfo?.employeeNo || '-'" />
  36. <uni-list-item title="电话" :note="userInfo?.phone || '-'" />
  37. <uni-list-item title="邮箱" :note="userInfo?.email || '-'" />
  38. <uni-list-item title="入职日期" :note="userInfo?.hireDate || '-'" />
  39. </template>
  40. </uni-list>
  41. </view>
  42. <!-- 功能菜单 -->
  43. <view class="bg-white rounded-xl shadow-sm p-4">
  44. <text class="text-base font-semibold text-gray-800 block mb-3">功能菜单</text>
  45. <uni-list :border="false">
  46. <view hover-class="scale-down" :hover-start-time="0" :hover-stay-time="150" @click="goToChangePassword">
  47. <uni-list-item
  48. title="修改密码"
  49. icon="uniui-locked-filled"
  50. show-arrow
  51. />
  52. </view>
  53. <view hover-class="scale-down" :hover-start-time="0" :hover-stay-time="150" @click="goToNotices">
  54. <uni-list-item
  55. title="通知公告"
  56. icon="uniui-notification-filled"
  57. show-arrow
  58. />
  59. </view>
  60. <view hover-class="scale-down" :hover-start-time="0" :hover-stay-time="150" @click="goToHelp">
  61. <uni-list-item
  62. title="帮助中心"
  63. icon="uniui-help-filled"
  64. show-arrow
  65. />
  66. </view>
  67. </uni-list>
  68. </view>
  69. <!-- 退出登录 -->
  70. <view class="mt-4">
  71. <button class="w-full py-3 bg-red-500 text-white rounded-xl font-medium transition-colors logout-btn" @click="handleLogout">
  72. 退出登录
  73. </button>
  74. </view>
  75. </view>
  76. </view>
  77. </template>
  78. <script setup lang="ts">
  79. import { computed } from 'vue'
  80. import { useAuthStore } from '@/stores/auth'
  81. import StatusBar from '@/components/common/StatusBar.vue'
  82. import UniList from '@/components/uni-list/uni-list.vue'
  83. import UniListItem from '@/components/uni-list/uni-list-item.vue'
  84. const authStore = useAuthStore()
  85. const userInfo = computed(() => authStore.user)
  86. const role = computed(() => userInfo.value?.role || 'sales')
  87. const displayName = computed(() => {
  88. return userInfo.value?.name || '用户'
  89. })
  90. const primaryMeta = computed(() => {
  91. if (role.value === 'construction') {
  92. return userInfo.value?.team ? `${userInfo.value.team}` : ''
  93. }
  94. return userInfo.value?.department || ''
  95. })
  96. const secondaryMeta = computed(() => {
  97. if (role.value === 'construction') {
  98. return userInfo.value?.position ? `/${userInfo.value.position}` : ''
  99. }
  100. return userInfo.value?.position || ''
  101. })
  102. function goToChangePassword() {
  103. uni.navigateTo({ url: '/subPackages/pages-common/changePassword' })
  104. }
  105. function goToNotices() {
  106. const paths: Record<string, string> = {
  107. sales: '/subPackages/pages-common/noticeList',
  108. dispatch: '/subPackages/pages-dispatch/noticeList',
  109. construction: '/subPackages/pages-construction/noticeList',
  110. }
  111. uni.navigateTo({ url: paths[role.value] || paths.sales })
  112. }
  113. function goToHelp() {
  114. uni.navigateTo({ url: '/subPackages/pages-common/helpCenter' })
  115. }
  116. async function handleLogout() {
  117. const res = await uni.showModal({
  118. title: '确认退出',
  119. content: '确定要退出登录吗?',
  120. })
  121. if (res.confirm) {
  122. uni.reLaunch({
  123. url: '/pages/login/login',
  124. complete: () => {
  125. authStore.doLogout()
  126. },
  127. })
  128. }
  129. }
  130. </script>
  131. <style scoped>
  132. .scale-down {
  133. transition: transform 0.15s ease;
  134. }
  135. .scale-down:hover,
  136. .scale-down:active {
  137. transform: scale(0.95);
  138. }
  139. .logout-btn:active {
  140. background-color: #dc2626;
  141. }
  142. </style>