userInfo.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  1. <template>
  2. <view class="content">
  3. <!-- 个人信息 -->
  4. <view class="user-info">
  5. <view class="info-box">
  6. <view class="left">
  7. <view class="head-box">
  8. <image class="img" :src="avatar" mode="aspectFill"></image>
  9. </view>
  10. <view class="info">
  11. <text class="name">{{nickName}}</text>
  12. <text class="title">{{postNames}}</text>
  13. </view>
  14. </view>
  15. <image v-if="!isShow" class="right" src="/static/images/icon_edit.png" mode="aspectFill" @click="editInfo"></image>
  16. </view>
  17. <!-- 公司 -->
  18. <view class="comp-info">
  19. <image class="img" src="/static/images/icon_comp_white.png" mode="aspectFill"></image>
  20. <text class="text">{{deptName}}</text>
  21. </view>
  22. </view>
  23. <!-- 详细信息 -->
  24. <view class="info-detail">
  25. <view class="item">
  26. <text class="label">姓名</text>
  27. <text class="text">{{nickName}}</text>
  28. </view>
  29. <view class="item">
  30. <text class="label">性别</text>
  31. <text class="text">{{sex}}</text>
  32. </view>
  33. <view class="item column" @click="callPhone(phonenumber)">
  34. <view class="left">
  35. <text class="label">手机</text>
  36. <text class="text">{{phonenumber}}</text>
  37. </view>
  38. <image class="img" src="/static/images/icon_phone_left.png" mode="aspectFill" ></image>
  39. </view>
  40. <view class="item">
  41. <text class="label">邮箱</text>
  42. <text class="text">{{email}}</text>
  43. </view>
  44. <view class="item">
  45. <text class="label">部门</text>
  46. <text class="text">{{deptName}}</text>
  47. </view>
  48. <view class="item">
  49. <text class="label">岗位</text>
  50. <text class="text">{{postNames}}</text>
  51. </view>
  52. </view>
  53. </view>
  54. </template>
  55. <script>
  56. import {getUserInfoByUserId,getUserInfo} from '@/api/user.js';
  57. export default {
  58. data() {
  59. return {
  60. avatar:"/static/images/default.png",
  61. nickName:"",
  62. deptName:"",
  63. postNames:"",
  64. phonenumber:"",
  65. email:"",
  66. sex:"",
  67. isShow:false,
  68. userId:undefined,
  69. }
  70. },
  71. onLoad(option) {
  72. // 修改顶部导航背景色
  73. // uni.setNavigationBarColor({
  74. // frontColor: '#ffffff',
  75. // backgroundColor: '#4BC9B1',
  76. // animation: {
  77. // duration: 400,
  78. // timingFunc: 'easeIn'
  79. // }
  80. // })
  81. if(!this.utils.isEmpty(option.userId)){
  82. this.userId = option.userId;
  83. this.isShow=true;
  84. }
  85. },
  86. onShow() {
  87. if(this.isShow){
  88. this.getUserInfoByUserId(this.userId);
  89. }
  90. else{
  91. this.getUserInfo();
  92. }
  93. },
  94. methods: {
  95. bindUser(data){
  96. var that=this;
  97. that.nickName=data.user.nickName;
  98. that.deptName=data.user.dept.deptName;
  99. that.posts=data.post;
  100. that.phonenumber=data.user.phonenumber;
  101. that.email=data.user.email;
  102. if(data.user.sex==0){
  103. that.sex="男";
  104. }
  105. else if(data.user.sex==1){
  106. that.sex="女";
  107. }
  108. else if(data.user.sex==2){
  109. that.sex="未知";
  110. }
  111. if(data.post!=null&&data.post.length>0){
  112. var posts=[];
  113. data.post.forEach( (v,i) => {
  114. posts.push(v);
  115. },this);
  116. that.postNames=posts.toString()
  117. }
  118. if(!that.utils.isEmpty(data.user.avatar)){
  119. that.avatar=uni.getStorageSync('requestPath')+data.user.avatar;
  120. }
  121. },
  122. getUserInfoByUserId(userId){
  123. var data = {userId:userId};
  124. var that=this;
  125. getUserInfoByUserId(data).then(
  126. res => {
  127. that.bindUser(res);
  128. },
  129. rej => {}
  130. );
  131. },
  132. getUserInfo(){
  133. var data = {};
  134. var that=this;
  135. getUserInfo(data).then(
  136. res => {
  137. that.bindUser(res);
  138. },
  139. rej => {}
  140. );
  141. },
  142. // 拨打电话
  143. callPhone(tel){
  144. uni.makePhoneCall({
  145. phoneNumber: tel
  146. })
  147. },
  148. // 个人信息编辑
  149. editInfo() {
  150. uni.navigateTo({
  151. url: '../editUser'
  152. })
  153. }
  154. }
  155. }
  156. </script>
  157. <style lang="scss">
  158. page{
  159. background: #fff;
  160. }
  161. </style>
  162. <style scoped lang="scss">
  163. .content{
  164. // 个人信息
  165. .user-info{
  166. background: #115296;
  167. padding: 0 30upx;
  168. .info-box{
  169. display: flex;
  170. align-items: center;
  171. justify-content: space-between;
  172. .left{
  173. display: flex;
  174. align-items: center;
  175. justify-content: center;
  176. padding: 20upx 0;
  177. .head-box{
  178. width: 120upx;
  179. height: 120upx;
  180. line-height: 100upx;
  181. font-size: 30upx;
  182. color: #fff;
  183. text-align: center;
  184. margin-right: 20upx;
  185. .img{
  186. border-radius: 50%;
  187. width: 100%;
  188. height: 100%;
  189. }
  190. }
  191. .info{
  192. height: 80upx;
  193. display: flex;
  194. flex-direction: column;
  195. justify-content: space-between;
  196. .name{
  197. font-size: 30upx;
  198. color: #fff;
  199. }
  200. .title{
  201. font-size: 28upx;
  202. color: #fff;
  203. }
  204. }
  205. }
  206. .right{
  207. width: 40upx;
  208. height: 40upx;
  209. }
  210. }
  211. .comp-info{
  212. padding: 20upx 0 40upx;
  213. display: flex;
  214. align-items: center;
  215. .img{
  216. width: 30upx;
  217. height: 30upx;
  218. margin-right: 20upx;
  219. }
  220. .text{
  221. font-size: 30upx;
  222. color: #fff;
  223. }
  224. }
  225. }
  226. // 详细信息
  227. .info-detail{
  228. padding: 0 24upx;
  229. .item{
  230. padding: 20upx 0;
  231. border-bottom: 1px solid #f7f7f7;
  232. .label{
  233. font-size: 30upx;
  234. color: #999;
  235. margin-right: 20upx;
  236. }
  237. .text{
  238. font-size: 30upx;
  239. color: #333;
  240. }
  241. &.column{
  242. display: flex;
  243. align-items: center;
  244. justify-content: space-between;
  245. .img{
  246. width: 50upx;
  247. height: 50upx;
  248. }
  249. }
  250. }
  251. }
  252. }
  253. </style>