person.vue 4.7 KB

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