person.vue 4.1 KB

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