person.vue 4.3 KB

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