person.vue 4.2 KB

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