userCenter.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  1. <template>
  2. <a-row :gutter="10">
  3. <a-col :xs="24" :sm="24" :md="7" :lg="7" :xl="7" class="mb-3">
  4. <a-card :bordered="false">
  5. <div class="account-center-avatarHolder">
  6. <div class="avatar">
  7. <a-spin size="small" :spinning="avatarLoading">
  8. <img :src="userInfo.avatar" />
  9. </a-spin>
  10. <!-- <a @click="uploadLogo">-->
  11. <!-- <div :class="userInfo.avatar ? 'mask' : 'mask-notImg'"><upload-outlined /></div>-->
  12. <!-- </a>-->
  13. </div>
  14. <div class="username">{{ userInfo.name }}</div>
  15. <div class="bio">{{ userInfo.nickname }}</div>
  16. </div>
  17. <div class="account-center-detail">
  18. <!-- <p><i class="title"></i>{{ userInfo.positionName }}</p>-->
  19. <p><i class="group"></i>{{ userInfo.orgName }}</p>
  20. <!-- <p>-->
  21. <!-- <i class="address"></i>-->
  22. <!-- <span>{{ userInfo.homeAddress ? userInfo.homeAddress : '暂无地址' }}</span>-->
  23. <!-- </p>-->
  24. </div>
  25. <!-- <a-divider />-->
  26. <!-- <div class="account-center-team">-->
  27. <!-- <div class="mb-2" v-if="userInfo.signature" style="width: 100%">-->
  28. <!-- <a-image :src="userInfo.signature" width="100%" style="height: 120px; border: 1px solid rgb(236 236 236)" />-->
  29. <!-- </div>-->
  30. <!-- <a-button @click="XnSignNameRef.show()">打开签名板</a-button>-->
  31. <!-- <XnSignName ref="XnSignNameRef" :image="userInfo.signature" @successful="signSuccess" />-->
  32. <!-- </div>-->
  33. </a-card>
  34. </a-col>
  35. <a-col :xs="24" :sm="24" :md="17" :lg="17" :xl="17">
  36. <a-card
  37. :bordered="false"
  38. style="width: 100%"
  39. :tab-list="tabList"
  40. :active-tab-key="noTitleKey"
  41. @tabChange="(key) => onTabChange(key, 'key')"
  42. >
  43. <p v-if="noTitleKey === 'accountBasic'">
  44. <accountBasic />
  45. </p>
  46. <p v-if="noTitleKey === 'organizationChart'">
  47. <organizationChart />
  48. </p>
  49. <p v-if="noTitleKey === 'accountBind'">
  50. <accountBind />
  51. </p>
  52. <p v-if="noTitleKey === 'shortcutSetting'">
  53. <shortcutSetting />
  54. </p>
  55. <p v-if="noTitleKey === 'userMessage'">
  56. <userMessage />
  57. </p>
  58. </a-card>
  59. </a-col>
  60. </a-row>
  61. <CropUpload ref="cropUpload" :img-src="userInfo.avatar" @successful="cropUploadSuccess" />
  62. </template>
  63. <script setup name="userCenter">
  64. import { onMounted } from 'vue'
  65. import { useRoute } from 'vue-router'
  66. import tool from '@/utils/tool'
  67. import { globalStore } from '@/store'
  68. import userCenterApi from '@/api/sys/userCenterApi'
  69. import accountBasic from './userTab/accountBasic.vue'
  70. import CropUpload from '@/components/CropUpload/index.vue'
  71. import organizationChart from './userTab/organizationChart.vue'
  72. import shortcutSetting from './userTab/shortcutSetting.vue'
  73. import accountBind from './userTab/accountBind.vue'
  74. import userMessage from './userTab/userMessage.vue'
  75. const global_store = globalStore()
  76. const userInfo = computed(() => {
  77. return global_store.userInfo
  78. })
  79. const cropUpload = ref()
  80. const avatarLoading = ref(false)
  81. const uploadLogo = () => {
  82. cropUpload.value.show()
  83. }
  84. const XnSignNameRef = ref()
  85. const tabList = [
  86. {
  87. key: 'accountBasic',
  88. tab: '基本信息'
  89. },
  90. // {
  91. // key: 'organizationChart',
  92. // tab: '组织架构'
  93. // },
  94. // {
  95. // key: 'accountBind',
  96. // tab: '账号相关'
  97. // },
  98. // {
  99. // key: 'shortcutSetting',
  100. // tab: '快捷方式'
  101. // },
  102. // {
  103. // key: 'userMessage',
  104. // tab: '我的消息'
  105. // }
  106. ]
  107. const noTitleKey = ref('accountBasic')
  108. const onTabChange = (key) => {
  109. console.log('key是什么呢', key)
  110. noTitleKey.value = key
  111. }
  112. const Route = useRoute()
  113. onMounted(() => {
  114. if (Route.query.tab) {
  115. noTitleKey.value = Route.query.tab
  116. }
  117. })
  118. // 头像裁剪图片回调
  119. const cropUploadSuccess = (data) => {
  120. // 转换为file类型
  121. const result = new File([data.blobData], data.fileName, { type: 'image/jpeg', lastModified: Date.now() })
  122. const fileData = new FormData()
  123. fileData.append('file', result)
  124. avatarLoading.value = true
  125. userCenterApi.userUpdateAvatar(fileData).then((data) => {
  126. avatarLoading.value = false
  127. userInfo.value.avatar = data
  128. // 更新缓存
  129. tool.data.set('USER_INFO', userInfo.value)
  130. global_store.setUserInfo(userInfo.value)
  131. })
  132. }
  133. // 签名板组件回调
  134. const signSuccess = (value) => {
  135. const param = {
  136. signature: value
  137. }
  138. userCenterApi.userUpdateSignature(param).then(() => {
  139. userInfo.value.signature = value
  140. // 更新缓存
  141. tool.data.set('USER_INFO', userInfo.value)
  142. global_store.setUserInfo(userInfo.value)
  143. })
  144. }
  145. </script>
  146. <style lang="less" scoped>
  147. .account-center-avatarHolder {
  148. text-align: center;
  149. margin-bottom: 24px;
  150. & > .avatar {
  151. margin: 0 auto;
  152. width: 104px;
  153. height: 104px;
  154. margin-bottom: 20px;
  155. border-radius: 50%;
  156. overflow: hidden;
  157. img {
  158. height: 100%;
  159. width: 100%;
  160. }
  161. }
  162. .mask {
  163. border-radius: 50%;
  164. position: absolute;
  165. margin-top: -104px;
  166. width: 104px;
  167. height: 104px;
  168. background: rgba(101, 101, 101, 0.6);
  169. color: #ffffff;
  170. opacity: 0;
  171. font-size: 25px;
  172. display: flex;
  173. justify-content: center;
  174. align-items: center;
  175. }
  176. .mask-notImg {
  177. border-radius: 50%;
  178. position: absolute;
  179. margin-top: -24px;
  180. width: 104px;
  181. height: 104px;
  182. background: rgba(101, 101, 101, 0.6);
  183. color: #ffffff;
  184. opacity: 0;
  185. font-size: 25px;
  186. display: flex;
  187. justify-content: center;
  188. align-items: center;
  189. }
  190. .avatar a:hover .mask {
  191. opacity: 1;
  192. }
  193. .avatar a:hover .mask-notImg {
  194. opacity: 1;
  195. }
  196. .username {
  197. font-size: 20px;
  198. line-height: 28px;
  199. font-weight: 500;
  200. margin-bottom: 4px;
  201. }
  202. }
  203. .account-center-detail {
  204. p {
  205. margin-bottom: 8px;
  206. padding-left: 26px;
  207. position: relative;
  208. }
  209. i {
  210. position: absolute;
  211. height: 14px;
  212. width: 14px;
  213. left: 0;
  214. top: 4px;
  215. background: url(https://gw.alipayobjects.com/zos/rmsportal/pBjWzVAHnOOtAUvZmZfy.svg);
  216. }
  217. .title {
  218. background-position: 0 0;
  219. }
  220. .group {
  221. background-position: 0 -22px;
  222. }
  223. .address {
  224. background-position: 0 -44px;
  225. }
  226. }
  227. .teamTitle {
  228. font-weight: 500;
  229. margin-bottom: 12px;
  230. }
  231. .account-center-team {
  232. .members {
  233. a {
  234. display: block;
  235. margin: 12px 0;
  236. line-height: 24px;
  237. height: 24px;
  238. .member {
  239. font-size: 14px;
  240. line-height: 24px;
  241. max-width: 100px;
  242. vertical-align: top;
  243. margin-left: 12px;
  244. transition: all 0.3s;
  245. display: inline-block;
  246. }
  247. }
  248. }
  249. }
  250. </style>