userInfo.vue 4.5 KB

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