person.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  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. <view class="cu-list menu card-menu margin-top-20">
  11. <view class="cu-item">
  12. <view class="content">
  13. <Am-FontAwesome type=" fas fa-building" class="text-blue" ></Am-FontAwesome>
  14. <text class="text-grey">公司</text>
  15. </view>
  16. <view class="action">
  17. <text class="text-grey">{{userInfo.companyDTO && userInfo.companyDTO.name || ''}}</text>
  18. </view>
  19. </view>
  20. <view class="cu-item">
  21. <view class="content">
  22. <Am-FontAwesome type="fas fa-sitemap" class="text-blue" ></Am-FontAwesome>
  23. <text class="text-grey">部门</text>
  24. </view>
  25. <view class="action">
  26. <text class="text-grey">{{userInfo.officeDTO && userInfo.officeDTO.name || ''}}</text>
  27. </view>
  28. </view>
  29. <view class="cu-item">
  30. <view class="content">
  31. <Am-FontAwesome type="far fa-address-book" class="text-blue" ></Am-FontAwesome>
  32. <text class="text-grey">岗位</text>
  33. </view>
  34. <view class="action">
  35. <text class="text-grey">{{userInfo.post && userInfo.post.name || ''}}</text>
  36. </view>
  37. </view>
  38. <view class="cu-item">
  39. <view class="content">
  40. <Am-FontAwesome type="far fa-user" class="text-blue" ></Am-FontAwesome>
  41. <text class="text-grey">角色</text>
  42. </view>
  43. <view class="action">
  44. <text class="text-grey">{{userInfo.roleNames || ''}}</text>
  45. </view>
  46. </view>
  47. </view>
  48. <view class="cu-list menu card-menu">
  49. <view class="cu-item">
  50. <view class="content">
  51. <Am-FontAwesome type="fas fa-phone-square-alt" class="text-blue"></Am-FontAwesome>
  52. <text class="text-grey">联系电话</text>
  53. </view>
  54. <view class="action">
  55. <text class="text-grey">{{userInfo.phone || ''}}</text>
  56. </view>
  57. </view>
  58. <view class="cu-item">
  59. <view class="content">
  60. <Am-FontAwesome type="fas fa-envelope" class="text-blue"></Am-FontAwesome>
  61. <text class="text-grey">邮箱</text>
  62. </view>
  63. <view class="action">
  64. <text class="text-grey">{{userInfo.email || ''}}</text>
  65. </view>
  66. </view>
  67. <view class="cu-item arrow" @click="toPassword">
  68. <view class="content">
  69. <Am-FontAwesome type="fas fa-edit" class="text-red"></Am-FontAwesome>
  70. <text class="text-grey">修改密码</text>
  71. </view>
  72. <view class="action">
  73. <text class="text-grey">{{userInfo.officeDTO.name || ''}}</text>
  74. </view>
  75. </view>
  76. </view>
  77. <view class="padding-xl">
  78. <button class="cu-btn block bg-blue margin-tb-sm lg" @click="outlogin">退出登录</button>
  79. <view class="cu-tabbar-height"></view>
  80. </view>
  81. </view>
  82. </template>
  83. <script>
  84. import {mapState, mapMutations, mapActions} from 'vuex'
  85. import UserService from "@/api/sys/UserService"
  86. import LoginService from "@/api/auth/LoginService"
  87. export default {
  88. name: "person",
  89. onShow() {
  90. this.$auth.checkLogin()
  91. },
  92. computed: mapState({
  93. userInfo: (state) => state.user.userInfo,
  94. avatar: (state) => state.user.avatar
  95. }),
  96. methods: {
  97. ...mapActions(['refreshUserInfo']),
  98. /**
  99. * 修改密码
  100. */
  101. toPassword() {
  102. uni.navigateTo({
  103. url: '/pages/user/setting/password/password'
  104. })
  105. },
  106. ChooseImage() {
  107. uni.chooseImage({
  108. count: 4, //默认9
  109. sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
  110. sourceType: ['album'], //从相册选择
  111. success: (res) => {
  112. this.upload(res.tempFilePaths[0])
  113. }
  114. });
  115. },
  116. upload(filePath) {
  117. new UserService().imageUpload(filePath).then((res)=>{
  118. this.refreshUserInfo()
  119. })
  120. },
  121. outlogin() {
  122. uni.showLoading()
  123. new LoginService().logout().then(({data})=>{
  124. this.$store.commit('logout');
  125. uni.clearStorage();
  126. uni.reLaunch({
  127. url: '/pages/login/login'
  128. })
  129. })
  130. }
  131. }
  132. }
  133. </script>
  134. <style>
  135. .person-head {
  136. display: flex;
  137. flex-direction: row;
  138. align-items: center;
  139. height: 150px;
  140. padding-left: 20px;
  141. background: linear-gradient(to right, #365fff, #36bbff);
  142. }
  143. .person-head-box {
  144. display: flex;
  145. flex-direction: column;
  146. justify-content: center;
  147. align-items: flex-start;
  148. margin-left: 10px;
  149. }
  150. .person-head-nickname {
  151. font-size: 18px;
  152. font-weight: 500;
  153. color: #fff;
  154. }
  155. .person-head-username {
  156. font-size: 14px;
  157. font-weight: 500;
  158. color: #fff;
  159. }
  160. .person-list {
  161. line-height: 0;
  162. }
  163. .cu-list.card-menu {
  164. overflow: hidden;
  165. margin-right: 5px;
  166. margin-left: 5px;
  167. border-radius: 7px;
  168. }
  169. .cu-list.card-menu.margin-top-20 {
  170. margin-top: -20px;
  171. }
  172. .cu-list.menu>.cu-item .content>uni-view:first-child {
  173. display: -webkit-box;
  174. display: -webkit-flex;
  175. display: flex;
  176. -webkit-box-align: center;
  177. /* -webkit-align-items: center; */
  178. /* align-items: center; */
  179. display: inline-block;
  180. margin-right: 5px;
  181. width: 1.6em;
  182. text-align: center;
  183. }
  184. </style>