person.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. <template>
  2. <view>
  3. <view class="person-head">
  4. <view class="cu-avatar xl round margin-left-sm" @tap="ChooseImage" :style="backgroundStyle" ></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. backgroundStyle() {
  73. return {
  74. 'background-image': `url(${this.avatar})`,
  75. };
  76. }
  77. },
  78. methods: {
  79. ...mapActions(['refreshUserInfo']),
  80. /**
  81. * 修改密码
  82. */
  83. toPassword() {
  84. uni.navigateTo({
  85. url: '/pages/user/setting/password/password'
  86. })
  87. },
  88. ChooseImage() {
  89. uni.chooseImage({
  90. count: 4, //默认9
  91. sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
  92. sourceType: ['album'], //从相册选择
  93. success: (res) => {
  94. this.upload(res.tempFilePaths[0])
  95. }
  96. });
  97. },
  98. upload(filePath) {
  99. fileService.upload(filePath).then((data) =>{
  100. userService.saveInfo({
  101. id: this.userInfo.id,
  102. photo: data
  103. }).then(()=>{
  104. this.refreshUserInfo()
  105. })
  106. })
  107. },
  108. outlogin() {
  109. uni.showLoading()
  110. loginService.logout().then((data)=>{
  111. this.$store.commit('logout');
  112. uni.clearStorage();
  113. uni.reLaunch({
  114. url: '/pages/login/login'
  115. })
  116. })
  117. }
  118. }
  119. }
  120. </script>
  121. <style>
  122. .person-head {
  123. display: flex;
  124. flex-direction: row;
  125. align-items: center;
  126. height: 150px;
  127. padding-left: 20px;
  128. background: linear-gradient(to right, #365fff, #36bbff);
  129. }
  130. .person-head-box {
  131. display: flex;
  132. flex-direction: column;
  133. justify-content: center;
  134. align-items: flex-start;
  135. margin-left: 10px;
  136. }
  137. .person-head-nickname {
  138. font-size: 18px;
  139. font-weight: 500;
  140. color: #fff;
  141. }
  142. .person-head-username {
  143. font-size: 14px;
  144. font-weight: 500;
  145. color: #fff;
  146. }
  147. .person-list {
  148. line-height: 0;
  149. }
  150. .cu-list.card-menu {
  151. overflow: hidden;
  152. margin-right: 5px;
  153. margin-left: 5px;
  154. border-radius: 7px;
  155. }
  156. .cu-list.card-menu.margin-top-20 {
  157. margin-top: -20px;
  158. }
  159. .cu-list.menu>.cu-item .content>uni-view:first-child {
  160. display: -webkit-box;
  161. display: -webkit-flex;
  162. display: flex;
  163. -webkit-box-align: center;
  164. /* -webkit-align-items: center; */
  165. /* align-items: center; */
  166. display: inline-block;
  167. margin-right: 5px;
  168. width: 1.6em;
  169. text-align: center;
  170. }
  171. </style>