ProfileView.vue 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362
  1. <template>
  2. <view class="app-container pb-24">
  3. <!-- 顶部个人信息 -->
  4. <view class="header-gradient">
  5. <StatusBar />
  6. <view class="px-4 pt-4 pb-8">
  7. <view class="flex items-center">
  8. <view class="profile-avatar mr-4">
  9. <text class="uni-icons uniui-person-filled text-primary text-3xl"></text>
  10. </view>
  11. <view class="flex-1 min-w-0">
  12. <view class="flex items-center flex-wrap">
  13. <text class="text-white text-xl font-bold truncate">{{ displayName }}</text>
  14. <text class="role-chip">{{ roleLabel }}</text>
  15. </view>
  16. <view v-if="primaryMeta || secondaryMeta" class="flex items-center flex-wrap mt-2">
  17. <text v-if="primaryMeta" class="profile-meta">{{ primaryMeta }}</text>
  18. <text v-if="primaryMeta && secondaryMeta" class="profile-meta-dot">·</text>
  19. <text v-if="secondaryMeta" class="profile-meta">{{ secondaryMeta }}</text>
  20. </view>
  21. <view v-if="userInfo?.employeeNo" class="mt-2">
  22. <text class="emp-chip">工号 {{ userInfo.employeeNo }}</text>
  23. </view>
  24. </view>
  25. </view>
  26. </view>
  27. </view>
  28. <!-- 内容区 -->
  29. <view class="px-4 -mt-4">
  30. <!-- 账号信息 -->
  31. <view class="card">
  32. <view class="flex items-center px-4 pt-4 pb-3">
  33. <view class="section-bar mr-2"></view>
  34. <text class="text-base font-bold text-gray-800">账号信息</text>
  35. </view>
  36. <view class="px-4 pb-2">
  37. <view class="info-row">
  38. <text class="info-label">姓名</text>
  39. <text class="info-value">{{ userInfo?.name || '-' }}</text>
  40. </view>
  41. <template v-if="role === 'construction'">
  42. <view class="info-row">
  43. <text class="info-label">班组</text>
  44. <text class="info-value">{{ userInfo?.team || '-' }}</text>
  45. </view>
  46. <view class="info-row">
  47. <text class="info-label">职位</text>
  48. <text class="info-value">{{ userInfo?.position || '-' }}</text>
  49. </view>
  50. <view class="info-row">
  51. <text class="info-label">工号</text>
  52. <text class="info-value">{{ userInfo?.employeeNo || '-' }}</text>
  53. </view>
  54. <view class="info-row">
  55. <text class="info-label">联系电话</text>
  56. <text class="info-value">{{ userInfo?.phone || '-' }}</text>
  57. </view>
  58. </template>
  59. <template v-else>
  60. <view class="info-row">
  61. <text class="info-label">部门</text>
  62. <text class="info-value">{{ userInfo?.department || '-' }}</text>
  63. </view>
  64. <view class="info-row">
  65. <text class="info-label">职位</text>
  66. <text class="info-value">{{ userInfo?.position || '-' }}</text>
  67. </view>
  68. <view class="info-row">
  69. <text class="info-label">工号</text>
  70. <text class="info-value">{{ userInfo?.employeeNo || '-' }}</text>
  71. </view>
  72. <view class="info-row">
  73. <text class="info-label">电话</text>
  74. <text class="info-value">{{ userInfo?.phone || '-' }}</text>
  75. </view>
  76. <view class="info-row">
  77. <text class="info-label">邮箱</text>
  78. <text class="info-value break-all">{{ userInfo?.email || '-' }}</text>
  79. </view>
  80. <view class="info-row">
  81. <text class="info-label">入职日期</text>
  82. <text class="info-value">{{ userInfo?.hireDate || '-' }}</text>
  83. </view>
  84. </template>
  85. </view>
  86. </view>
  87. <!-- 功能菜单 -->
  88. <view class="card p-2">
  89. <view
  90. class="menu-item"
  91. hover-class="menu-hover"
  92. :hover-start-time="0"
  93. :hover-stay-time="120"
  94. @click="goToChangePassword"
  95. >
  96. <view class="menu-icon bg-blue-50">
  97. <text class="uni-icons uniui-locked-filled text-blue-600"></text>
  98. </view>
  99. <view class="flex-1 min-w-0">
  100. <text class="menu-title">修改密码</text>
  101. <text class="menu-desc">定期更换,保障账号安全</text>
  102. </view>
  103. <text class="uni-icons uniui-arrowright text-gray-400"></text>
  104. </view>
  105. <view
  106. class="menu-item"
  107. hover-class="menu-hover"
  108. :hover-start-time="0"
  109. :hover-stay-time="120"
  110. @click="goToNotices"
  111. >
  112. <view class="menu-icon bg-orange-50">
  113. <text class="uni-icons uniui-notification-filled text-orange-600"></text>
  114. </view>
  115. <view class="flex-1 min-w-0">
  116. <text class="menu-title">通知公告</text>
  117. <text class="menu-desc">查看公司最新通知与公告</text>
  118. </view>
  119. <text class="uni-icons uniui-arrowright text-gray-400"></text>
  120. </view>
  121. <view
  122. class="menu-item"
  123. hover-class="menu-hover"
  124. :hover-start-time="0"
  125. :hover-stay-time="120"
  126. @click="goToHelp"
  127. >
  128. <view class="menu-icon bg-green-50">
  129. <text class="uni-icons uniui-help-filled text-green-600"></text>
  130. </view>
  131. <view class="flex-1 min-w-0">
  132. <text class="menu-title">帮助中心</text>
  133. <text class="menu-desc">常见问题与使用指南</text>
  134. </view>
  135. <text class="uni-icons uniui-arrowright text-gray-400"></text>
  136. </view>
  137. </view>
  138. <!-- 退出登录 -->
  139. <view
  140. class="card logout-row"
  141. hover-class="logout-hover"
  142. :hover-start-time="0"
  143. :hover-stay-time="120"
  144. @click="handleLogout"
  145. >
  146. <view class="menu-icon bg-red-50 mr-3">
  147. <text class="uni-icons uniui-loop text-red-600"></text>
  148. </view>
  149. <text class="flex-1 text-base font-medium text-red-600">退出登录</text>
  150. <text class="uni-icons uniui-arrowright text-red-300"></text>
  151. </view>
  152. </view>
  153. </view>
  154. </template>
  155. <script setup lang="ts">
  156. import { computed } from 'vue'
  157. import { useAuthStore } from '@/stores/auth'
  158. import StatusBar from '@/components/common/StatusBar.vue'
  159. const authStore = useAuthStore()
  160. const userInfo = computed(() => authStore.user)
  161. const role = computed(() => userInfo.value?.role || 'sales')
  162. const roleLabel = computed(() => {
  163. const map: Record<string, string> = {
  164. sales: '销售',
  165. dispatch: '调度',
  166. construction: '施工',
  167. }
  168. return map[role.value] || '员工'
  169. })
  170. const displayName = computed(() => {
  171. return userInfo.value?.name || '用户'
  172. })
  173. const primaryMeta = computed(() => {
  174. if (role.value === 'construction') {
  175. return userInfo.value?.team ? `${userInfo.value.team}` : ''
  176. }
  177. return userInfo.value?.department || ''
  178. })
  179. const secondaryMeta = computed(() => {
  180. return userInfo.value?.position || ''
  181. })
  182. function goToChangePassword() {
  183. uni.navigateTo({ url: '/subPackages/pages-common/changePassword' })
  184. }
  185. function goToNotices() {
  186. const paths: Record<string, string> = {
  187. sales: '/subPackages/pages-common/noticeList',
  188. dispatch: '/subPackages/pages-dispatch/noticeList',
  189. construction: '/subPackages/pages-construction/noticeList',
  190. }
  191. uni.navigateTo({ url: paths[role.value] || paths.sales })
  192. }
  193. function goToHelp() {
  194. uni.navigateTo({ url: '/subPackages/pages-common/helpCenter' })
  195. }
  196. async function handleLogout() {
  197. const res = await uni.showModal({
  198. title: '确认退出',
  199. content: '确定要退出登录吗?',
  200. })
  201. if (res.confirm) {
  202. uni.reLaunch({
  203. url: '/pages/login/login',
  204. complete: () => {
  205. authStore.doLogout()
  206. },
  207. })
  208. }
  209. }
  210. </script>
  211. <style scoped>
  212. /* 头像 */
  213. .profile-avatar {
  214. width: 72px;
  215. height: 72px;
  216. border-radius: 50%;
  217. background-color: #ffffff;
  218. display: flex;
  219. align-items: center;
  220. justify-content: center;
  221. box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
  222. flex-shrink: 0;
  223. }
  224. /* 角色徽标 */
  225. .role-chip {
  226. margin-left: 8px;
  227. padding: 2px 10px;
  228. border-radius: 20px;
  229. font-size: 12px;
  230. font-weight: 500;
  231. color: #ffffff;
  232. background-color: rgba(255, 255, 255, 0.22);
  233. border: 1px solid rgba(255, 255, 255, 0.35);
  234. }
  235. /* 头部 meta 文字 */
  236. .profile-meta {
  237. color: rgba(255, 255, 255, 0.9);
  238. font-size: 13px;
  239. }
  240. .profile-meta-dot {
  241. color: rgba(255, 255, 255, 0.5);
  242. font-size: 13px;
  243. margin: 0 6px;
  244. }
  245. /* 工号 chip */
  246. .emp-chip {
  247. display: inline-block;
  248. padding: 2px 10px;
  249. border-radius: 20px;
  250. font-size: 12px;
  251. color: rgba(255, 255, 255, 0.92);
  252. background-color: rgba(0, 0, 0, 0.16);
  253. }
  254. /* 区块标题装饰条 */
  255. .section-bar {
  256. width: 4px;
  257. height: 16px;
  258. border-radius: 2px;
  259. background: linear-gradient(180deg, #3b82f6 0%, #2563eb 100%);
  260. }
  261. /* 信息行 */
  262. .info-row {
  263. display: flex;
  264. align-items: flex-start;
  265. justify-content: space-between;
  266. padding: 12px 0;
  267. border-bottom: 1px solid #f3f4f6;
  268. }
  269. .info-row:last-child {
  270. border-bottom: none;
  271. }
  272. .info-label {
  273. font-size: 14px;
  274. color: #6b7280;
  275. flex-shrink: 0;
  276. margin-right: 16px;
  277. }
  278. .info-value {
  279. flex: 1;
  280. font-size: 14px;
  281. font-weight: 500;
  282. color: #1f2937;
  283. text-align: right;
  284. }
  285. /* 菜单项 */
  286. .menu-item {
  287. display: flex;
  288. align-items: center;
  289. padding: 12px;
  290. border-radius: 12px;
  291. }
  292. .menu-icon {
  293. width: 40px;
  294. height: 40px;
  295. border-radius: 10px;
  296. display: flex;
  297. align-items: center;
  298. justify-content: center;
  299. flex-shrink: 0;
  300. margin-right: 12px;
  301. font-size: 20px;
  302. }
  303. .menu-title {
  304. display: block;
  305. font-size: 15px;
  306. font-weight: 500;
  307. color: #1f2937;
  308. }
  309. .menu-desc {
  310. display: block;
  311. margin-top: 2px;
  312. font-size: 12px;
  313. color: #9ca3af;
  314. }
  315. .menu-hover {
  316. background-color: #f9fafb;
  317. }
  318. /* 退出登录 */
  319. .logout-row {
  320. display: flex;
  321. align-items: center;
  322. padding: 14px 16px;
  323. }
  324. .logout-hover {
  325. background-color: #fef2f2;
  326. }
  327. .text-red-300 {
  328. color: #fca5a5;
  329. }
  330. </style>