person.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. <template>
  2. <view>
  3. <view class="person-head">
  4. <view class="cu-avatar xl round margin-left-sm" @tap="ChooseImage" :style="`background-image:url('${avatar}')`" ></view>
  5. <view class="person-head-box">
  6. <view class="person-head-nickname">{{userInfo.name}}</view>
  7. <view class="person-head-username">ID:{{userInfo.loginName}}</view>
  8. </view>
  9. </view>
  10. <u-cell-group :border="false" customStyle="padding: 5px">
  11. <u-cell
  12. title="公司"
  13. icon="home-fill"
  14. :iconStyle="{color: '#0081ff'}"
  15. :value="userInfo.companyDTO && userInfo.companyDTO.name"
  16. ></u-cell>
  17. <u-cell
  18. title="部门"
  19. icon="list-dot"
  20. :iconStyle="{color: '#0081ff'}"
  21. :value="userInfo.officeDTO && userInfo.officeDTO.name"
  22. ></u-cell>
  23. <u-cell
  24. title="岗位"
  25. icon="account-fill"
  26. :iconStyle="{color: '#0081ff'}"
  27. :value="userInfo.post && userInfo.post.name"
  28. ></u-cell>
  29. <u-cell
  30. title="角色"
  31. icon="man-add-fill"
  32. :iconStyle="{color: '#0081ff'}"
  33. :value="userInfo.roleNames"
  34. ></u-cell>
  35. <u-cell
  36. title="联系电话"
  37. icon="phone-fill"
  38. :iconStyle="{color: '#0081ff'}"
  39. :value="userInfo.phone"
  40. ></u-cell>
  41. <u-cell
  42. title="邮箱"
  43. icon="email-fill"
  44. :iconStyle="{color: '#0081ff'}"
  45. :value="userInfo.email"
  46. ></u-cell>
  47. <u-cell
  48. title="修改密码"
  49. icon="edit-pen"
  50. isLink
  51. :iconStyle="{color: '#e54d42'}"
  52. url="/pages/user/setting/password/password"
  53. ></u-cell>
  54. </u-cell-group>
  55. <view class="padding-xl">
  56. <u-button type="primary" text="退出登录" @click="outlogin"></u-button>
  57. <u-gap height="80" bgColor="#fff"></u-gap>
  58. </view>
  59. </view>
  60. </template>
  61. <script>
  62. import {mapState, mapMutations, mapActions} from 'vuex'
  63. import userService from "@/api/sys/userService"
  64. import loginService from "@/api/auth/loginService"
  65. import fileService from "@/api/file/fileService.js"
  66. export default {
  67. name: "person",
  68. computed: mapState({
  69. userInfo: (state) => state.user.userInfo,
  70. avatar: (state) => state.user.avatar
  71. }),
  72. methods: {
  73. ...mapActions(['refreshUserInfo']),
  74. /**
  75. * 修改密码
  76. */
  77. toPassword() {
  78. uni.navigateTo({
  79. url: '/pages/user/setting/password/password'
  80. })
  81. },
  82. ChooseImage() {
  83. uni.chooseImage({
  84. count: 4, //默认9
  85. sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
  86. sourceType: ['album'], //从相册选择
  87. success: (res) => {
  88. this.upload(res.tempFilePaths[0])
  89. }
  90. });
  91. },
  92. upload(filePath) {
  93. fileService.upload(filePath).then((data) =>{
  94. userService.saveInfo({
  95. id: this.userInfo.id,
  96. photo: data
  97. }).then(()=>{
  98. this.refreshUserInfo()
  99. })
  100. })
  101. },
  102. outlogin() {
  103. uni.showLoading()
  104. loginService.logout().then((data)=>{
  105. this.$store.commit('logout');
  106. uni.clearStorage();
  107. uni.reLaunch({
  108. url: '/pages/login/login'
  109. })
  110. })
  111. }
  112. }
  113. }
  114. </script>
  115. <style>
  116. .person-head {
  117. display: flex;
  118. flex-direction: row;
  119. align-items: center;
  120. height: 150px;
  121. padding-left: 20px;
  122. background: linear-gradient(to right, #365fff, #36bbff);
  123. }
  124. .person-head-box {
  125. display: flex;
  126. flex-direction: column;
  127. justify-content: center;
  128. align-items: flex-start;
  129. margin-left: 10px;
  130. }
  131. .person-head-nickname {
  132. font-size: 18px;
  133. font-weight: 500;
  134. color: #fff;
  135. }
  136. .person-head-username {
  137. font-size: 14px;
  138. font-weight: 500;
  139. color: #fff;
  140. }
  141. .person-list {
  142. line-height: 0;
  143. }
  144. .cu-list.card-menu {
  145. overflow: hidden;
  146. margin-right: 5px;
  147. margin-left: 5px;
  148. border-radius: 7px;
  149. }
  150. .cu-list.card-menu.margin-top-20 {
  151. margin-top: -20px;
  152. }
  153. .cu-list.menu>.cu-item .content>uni-view:first-child {
  154. display: -webkit-box;
  155. display: -webkit-flex;
  156. display: flex;
  157. -webkit-box-align: center;
  158. /* -webkit-align-items: center; */
  159. /* align-items: center; */
  160. display: inline-block;
  161. margin-right: 5px;
  162. width: 1.6em;
  163. text-align: center;
  164. }
  165. </style>