person.vue 4.2 KB

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