person.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  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.mobile}}</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.roleNames && userInfo.roleNames"
  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. url="/pages/user/setting/password/password"
  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. import notifyService from "@/api/notify/notifyService";
  67. import { EventBus } from '@/store/eventBus.js';
  68. export default {
  69. name: "person",
  70. computed: mapState({
  71. userInfo: (state) => state.user.userInfo,
  72. avatar: (state) => state.user.avatar
  73. }),
  74. created() {
  75. this.getUnreadCountByIsSelf()
  76. console.log(this.userInfo)
  77. },
  78. methods: {
  79. ...mapActions(['refreshUserInfo']),
  80. /**
  81. * 修改密码
  82. */
  83. toPassword() {
  84. uni.navigateTo({
  85. url: '/pages/user/setting/password/password'
  86. })
  87. },
  88. getUnreadCountByIsSelf() {
  89. notifyService.getUnreadCountByIsSelf({
  90. isSelf: true,
  91. ...this.searchForm
  92. }).then((data)=>{
  93. EventBus.$emit('dataFromMessage', data); // 触发事件,传递参数
  94. })
  95. },
  96. ChooseImage() {
  97. uni.chooseImage({
  98. count: 4, //默认9
  99. sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
  100. sourceType: ['album'], //从相册选择
  101. success: (res) => {
  102. this.upload(res.tempFilePaths[0])
  103. }
  104. });
  105. },
  106. upload(filePath) {
  107. fileService.upload(filePath).then((data) =>{
  108. userService.saveInfo({
  109. id: this.userInfo.id,
  110. photo: data
  111. }).then(()=>{
  112. this.refreshUserInfo()
  113. })
  114. })
  115. },
  116. outlogin() {
  117. uni.showLoading()
  118. loginService.logout().then((data)=>{
  119. this.$store.commit('logout');
  120. uni.clearStorage();
  121. uni.reLaunch({
  122. url: '/pages/login/login'
  123. })
  124. })
  125. }
  126. }
  127. }
  128. </script>
  129. <style>
  130. .person-head {
  131. display: flex;
  132. flex-direction: row;
  133. align-items: center;
  134. height: 150px;
  135. padding-left: 20px;
  136. background: linear-gradient(to right, #365fff, #36bbff);
  137. }
  138. .person-head-box {
  139. display: flex;
  140. flex-direction: column;
  141. justify-content: center;
  142. align-items: flex-start;
  143. margin-left: 10px;
  144. }
  145. .person-head-nickname {
  146. font-size: 18px;
  147. font-weight: 500;
  148. color: #fff;
  149. }
  150. .person-head-username {
  151. font-size: 14px;
  152. font-weight: 500;
  153. color: #fff;
  154. }
  155. .person-list {
  156. line-height: 0;
  157. }
  158. .cu-list.card-menu {
  159. overflow: hidden;
  160. margin-right: 5px;
  161. margin-left: 5px;
  162. border-radius: 7px;
  163. }
  164. .cu-list.card-menu.margin-top-20 {
  165. margin-top: -20px;
  166. }
  167. .cu-list.menu>.cu-item .content>uni-view:first-child {
  168. display: -webkit-box;
  169. display: -webkit-flex;
  170. display: flex;
  171. -webkit-box-align: center;
  172. /* -webkit-align-items: center; */
  173. /* align-items: center; */
  174. display: inline-block;
  175. margin-right: 5px;
  176. width: 1.6em;
  177. text-align: center;
  178. }
  179. </style>