person.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  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. import fileService from "@/api/file/fileService.js"
  88. export default {
  89. name: "person",
  90. onShow() {
  91. this.$auth.checkLogin()
  92. },
  93. computed: mapState({
  94. userInfo: (state) => state.user.userInfo,
  95. avatar: (state) => state.user.avatar
  96. }),
  97. methods: {
  98. ...mapActions(['refreshUserInfo']),
  99. /**
  100. * 修改密码
  101. */
  102. toPassword() {
  103. uni.navigateTo({
  104. url: '/pages/user/setting/password/password'
  105. })
  106. },
  107. ChooseImage() {
  108. uni.chooseImage({
  109. count: 4, //默认9
  110. sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
  111. sourceType: ['album'], //从相册选择
  112. success: (res) => {
  113. this.upload(res.tempFilePaths[0])
  114. }
  115. });
  116. },
  117. upload(filePath) {
  118. fileService.upload(filePath).then(({data}) =>{
  119. userService.saveInfo({
  120. id: this.userInfo.id,
  121. photo: data
  122. }).then(()=>{
  123. this.refreshUserInfo()
  124. })
  125. })
  126. },
  127. outlogin() {
  128. uni.showLoading()
  129. loginService.logout().then(({data})=>{
  130. this.$store.commit('logout');
  131. uni.clearStorage();
  132. uni.reLaunch({
  133. url: '/pages/login/login'
  134. })
  135. })
  136. }
  137. }
  138. }
  139. </script>
  140. <style>
  141. .person-head {
  142. display: flex;
  143. flex-direction: row;
  144. align-items: center;
  145. height: 150px;
  146. padding-left: 20px;
  147. background: linear-gradient(to right, #365fff, #36bbff);
  148. }
  149. .person-head-box {
  150. display: flex;
  151. flex-direction: column;
  152. justify-content: center;
  153. align-items: flex-start;
  154. margin-left: 10px;
  155. }
  156. .person-head-nickname {
  157. font-size: 18px;
  158. font-weight: 500;
  159. color: #fff;
  160. }
  161. .person-head-username {
  162. font-size: 14px;
  163. font-weight: 500;
  164. color: #fff;
  165. }
  166. .person-list {
  167. line-height: 0;
  168. }
  169. .cu-list.card-menu {
  170. overflow: hidden;
  171. margin-right: 5px;
  172. margin-left: 5px;
  173. border-radius: 7px;
  174. }
  175. .cu-list.card-menu.margin-top-20 {
  176. margin-top: -20px;
  177. }
  178. .cu-list.menu>.cu-item .content>uni-view:first-child {
  179. display: -webkit-box;
  180. display: -webkit-flex;
  181. display: flex;
  182. -webkit-box-align: center;
  183. /* -webkit-align-items: center; */
  184. /* align-items: center; */
  185. display: inline-block;
  186. margin-right: 5px;
  187. width: 1.6em;
  188. text-align: center;
  189. }
  190. </style>