person.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. <template>
  2. <view>
  3. <view class="backbb">
  4. <view @click="back" style="color: aliceblue;padding-top: 20rpx;padding-left: 20rpx;padding-bottom: 10rpx;">
  5. 返回
  6. </view>
  7. </view>
  8. <view class="person-head">
  9. <view class="cu-avatar xl round margin-left-sm" @tap="ChooseImage" :style="`background-image:url('${avatar}')`" ></view>
  10. <view class="person-head-box">
  11. <view class="person-head-nickname">{{userInfo.name}}</view>
  12. <view class="person-head-username">ID:{{userInfo.loginName}}</view>
  13. </view>
  14. </view>
  15. <view class="cu-list menu card-menu margin-top-20">
  16. <view class="cu-item">
  17. <view class="content">
  18. <Am-FontAwesome type=" fas fa-building" class="text-blue" ></Am-FontAwesome>
  19. <text class="text-grey">公司</text>
  20. </view>
  21. <view class="action">
  22. <text class="text-grey">{{userInfo.remarks || '无'}}</text>
  23. </view>
  24. </view>
  25. <view class="cu-item">
  26. <view class="content">
  27. <Am-FontAwesome type="fas fa-sitemap" class="text-blue" ></Am-FontAwesome>
  28. <text class="text-grey">部门</text>
  29. </view>
  30. <view class="action">
  31. <text class="text-grey">{{userInfo.officeDTO && userInfo.officeDTO.name || ''}}</text>
  32. </view>
  33. </view>
  34. <view class="cu-item">
  35. <view class="content">
  36. <Am-FontAwesome type="far fa-address-book" class="text-blue" ></Am-FontAwesome>
  37. <text class="text-grey">岗位</text>
  38. </view>
  39. <view class="action">
  40. <text class="text-grey">{{userInfo.post && userInfo.post.name || ''}}</text>
  41. </view>
  42. </view>
  43. <view class="cu-item">
  44. <view class="content">
  45. <Am-FontAwesome type="far fa-user" class="text-blue" ></Am-FontAwesome>
  46. <text class="text-grey">角色</text>
  47. </view>
  48. <view class="action">
  49. <text class="text-grey">{{userInfo.roleNames || ''}}</text>
  50. </view>
  51. </view>
  52. </view>
  53. <view class="cu-list menu card-menu">
  54. <view class="cu-item">
  55. <view class="content">
  56. <Am-FontAwesome type="fas fa-phone-square-alt" class="text-blue"></Am-FontAwesome>
  57. <text class="text-grey">联系电话</text>
  58. </view>
  59. <view class="action">
  60. <text class="text-grey">{{userInfo.phone || ''}}</text>
  61. </view>
  62. </view>
  63. <view class="cu-item">
  64. <view class="content">
  65. <Am-FontAwesome type="fas fa-envelope" class="text-blue"></Am-FontAwesome>
  66. <text class="text-grey">邮箱</text>
  67. </view>
  68. <view class="action">
  69. <text class="text-grey">{{userInfo.email || ''}}</text>
  70. </view>
  71. </view>
  72. <view class="cu-item arrow" @click="toPassword">
  73. <view class="content">
  74. <Am-FontAwesome type="fas fa-edit" class="text-red"></Am-FontAwesome>
  75. <text class="text-grey">修改密码</text>
  76. </view>
  77. <view class="action">
  78. <text class="text-grey"></text>
  79. </view>
  80. </view>
  81. </view>
  82. <view class="padding-xl">
  83. <button class="cu-btn block bg-blue margin-tb-sm lg" @click="outlogin">退出登录</button>
  84. <view class="cu-tabbar-height"></view>
  85. </view>
  86. </view>
  87. </template>
  88. <script>
  89. import {mapState, mapMutations, mapActions} from 'vuex'
  90. import userService from "@/api/sys/userService"
  91. import loginService from "@/api/auth/loginService"
  92. import fileService from "@/api/file/fileService.js"
  93. export default {
  94. name: "person",
  95. onShow() {
  96. this.$auth.checkLogin()
  97. },
  98. computed: mapState({
  99. userInfo: (state) => state.user.userInfo,
  100. avatar: (state) => state.user.avatar
  101. }),
  102. methods: {
  103. ...mapActions(['refreshUserInfo']),
  104. /**
  105. * 修改密码
  106. */
  107. toPassword() {
  108. uni.navigateTo({
  109. url: '/pages/user/setting/password/password'
  110. })
  111. },
  112. ChooseImage() {
  113. uni.chooseImage({
  114. count: 4, //默认9
  115. sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
  116. sourceType: ['album'], //从相册选择
  117. success: (res) => {
  118. this.upload(res.tempFilePaths[0])
  119. }
  120. });
  121. },
  122. upload(filePath) {
  123. fileService.upload(filePath).then(({data}) =>{
  124. userService.saveInfo({
  125. id: this.userInfo.id,
  126. photo: data
  127. }).then(()=>{
  128. this.refreshUserInfo()
  129. })
  130. })
  131. },
  132. outlogin() {
  133. uni.showLoading()
  134. loginService.logout().then(({data})=>{
  135. this.$store.commit('logout');
  136. uni.clearStorage();
  137. uni.reLaunch({
  138. url: '/pages/login/login'
  139. })
  140. })
  141. },
  142. back(){
  143. // 返回逻辑,比如跳转至上一页
  144. this.$router.go(-1);
  145. }
  146. }
  147. }
  148. </script>
  149. <style>
  150. .backbb{
  151. background: linear-gradient(to right, #365fff, #36bbff);
  152. }
  153. .person-head {
  154. display: flex;
  155. flex-direction: row;
  156. align-items: center;
  157. height: 140px;
  158. padding-left: 20px;
  159. background: linear-gradient(to right, #365fff, #36bbff);
  160. }
  161. .person-head-box {
  162. display: flex;
  163. flex-direction: column;
  164. justify-content: center;
  165. align-items: flex-start;
  166. margin-left: 10px;
  167. }
  168. .person-head-nickname {
  169. font-size: 18px;
  170. font-weight: 500;
  171. color: #fff;
  172. }
  173. .person-head-username {
  174. font-size: 14px;
  175. font-weight: 500;
  176. color: #fff;
  177. }
  178. .person-list {
  179. line-height: 0;
  180. }
  181. .cu-list.card-menu {
  182. overflow: hidden;
  183. margin-right: 5px;
  184. margin-left: 5px;
  185. border-radius: 7px;
  186. }
  187. .cu-list.card-menu.margin-top-20 {
  188. margin-top: -20px;
  189. }
  190. .cu-list.menu>.cu-item .content>uni-view:first-child {
  191. display: -webkit-box;
  192. display: -webkit-flex;
  193. display: flex;
  194. -webkit-box-align: center;
  195. /* -webkit-align-items: center; */
  196. /* align-items: center; */
  197. display: inline-block;
  198. margin-right: 5px;
  199. width: 1.6em;
  200. text-align: center;
  201. }
  202. </style>