contacts.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. <template>
  2. <view class="contacts">
  3. <view class="contacts-container">
  4. <view class="user-list" v-if="groups && groups.length !==0">
  5. <view class="user-list-item" v-for="(group, id) in groups" :key="id" @click="groupChat(group)">
  6. <view class="user-item-avatar">
  7. <image :src="group.avatar"/>
  8. </view>
  9. <view class="user-item-info">
  10. <span class="user-item-info__name">{{ group.name }}</span>
  11. </view>
  12. </view>
  13. </view>
  14. <view class="contacts-title" v-if="friends && friends.length !==0">联系人</view>
  15. <view class="user-list">
  16. <view class="user-list-item" v-for="(friend, id) in friends" :key="id"
  17. @click="privateChat(friend)">
  18. <view class="user-item-avatar">
  19. <image :src="friend.avatar"></image>
  20. </view>
  21. <view class="user-item-info">
  22. <span class="user-item-info__name">{{ friend.Name }}</span>
  23. </view>
  24. </view>
  25. </view>
  26. </view>
  27. </view>
  28. </template>
  29. <script>
  30. import restApi from '../lib/restapi';
  31. export default {
  32. name: 'contacts',
  33. data() {
  34. return {
  35. friends: [],
  36. groups: []
  37. }
  38. },
  39. onShow() {
  40. const currentUser = uni.$currentUser;
  41. /* this.$http('imSys/listUsers', {
  42. userCode:this.form.phone,
  43. userPwd:this.form.password,
  44. },'GET').then(res => {
  45. console.log(res)
  46. }) */
  47. this.friends=res.data.Items
  48. var fobj={
  49. ID:'2C3E3A5C-D449-4439-842F-8E1C5C9EF91E',
  50. Name:'杨'
  51. }
  52. this.friends.push(fobj)
  53. // this.friends=this.friends.concat(fobj)
  54. //this.friends = restApi.findFriends(currentUser);
  55. console.log(this.friends)
  56. //this.groups = restApi.findGroups(currentUser);
  57. },
  58. methods: {
  59. privateChat (friend) {
  60. uni.setStorage({
  61. key: 'friend',
  62. data: friend,
  63. success: function () {
  64. uni.navigateTo({
  65. url: './privateChat?to=' + friend.ID
  66. });
  67. }
  68. });
  69. },
  70. groupChat (group) {
  71. uni.navigateTo({
  72. url: './groupChat?to=' + group.ID
  73. });
  74. }
  75. }
  76. }
  77. </script>
  78. <style>
  79. .contacts {
  80. width: 100%;
  81. height: 100%;
  82. display: flex;
  83. flex-direction: column;
  84. }
  85. .contacts .contacts-container {
  86. width: 100%;
  87. height: 100%;
  88. overflow: auto;
  89. }
  90. .contacts .user-list-item {
  91. height: 132rpx;
  92. padding-left: 32rpx;
  93. display: flex;
  94. align-items: center;
  95. }
  96. .contacts .contacts-title {
  97. height: 80rpx;
  98. line-height: 100rpx;
  99. font-size: 34rpx;
  100. color: #666666;
  101. background: #F3F4F7;
  102. text-indent: 44rpx;
  103. }
  104. .contacts .user-list {
  105. flex-grow: 1;
  106. background: #ffffff;
  107. display: flex;
  108. flex-direction: column;
  109. }
  110. .contacts .user-item-avatar {
  111. width: 96rpx;
  112. height: 96rpx;
  113. margin-right: 32rpx;
  114. overflow: hidden;
  115. position: relative;
  116. }
  117. .contacts .user-item-avatar image {
  118. width: 100%;
  119. height: 100%;
  120. display: block;
  121. }
  122. .contacts .user-item-info {
  123. height: 130rpx;
  124. padding-right: 32rpx;
  125. line-height: 88rpx;
  126. flex-grow: 1;
  127. border-bottom: 1px solid #EFEFEF;
  128. display: flex;
  129. justify-content: space-between;
  130. align-items: center;
  131. }
  132. .contacts .user-item-info__name {
  133. font-size: 34rpx;
  134. font-style: normal;
  135. font-weight: bold;
  136. color: #262628;
  137. }
  138. </style>