123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154 |
- <template>
- <view class="contacts">
- <view class="contacts-container">
- <view class="user-list" v-if="groups && groups.length !==0">
- <view class="user-list-item" v-for="(group, id) in groups" :key="id" @click="groupChat(group)">
- <view class="user-item-avatar">
- <image :src="group.avatar"/>
- </view>
- <view class="user-item-info">
- <span class="user-item-info__name">{{ group.name }}</span>
- </view>
- </view>
- </view>
- <view class="contacts-title" v-if="friends && friends.length !==0">联系人</view>
- <view class="user-list">
- <view class="user-list-item" v-for="(friend, id) in friends" :key="id"
- @click="privateChat(friend)">
- <view class="user-item-avatar">
- <image :src="friend.avatar"></image>
- </view>
- <view class="user-item-info">
- <span class="user-item-info__name">{{ friend.Name }}</span>
- </view>
- </view>
- </view>
- </view>
- </view>
- </template>
- <script>
- import restApi from '../lib/restapi';
- export default {
- name: 'contacts',
- data() {
- return {
- friends: [],
- groups: []
- }
- },
- onShow() {
- const currentUser = uni.$currentUser;
- /* this.$http('imSys/listUsers', {
- userCode:this.form.phone,
- userPwd:this.form.password,
-
- },'GET').then(res => {
- console.log(res)
-
- }) */
- this.friends=res.data.Items
- var fobj={
- ID:'2C3E3A5C-D449-4439-842F-8E1C5C9EF91E',
- Name:'杨'
- }
- this.friends.push(fobj)
- // this.friends=this.friends.concat(fobj)
- //this.friends = restApi.findFriends(currentUser);
- console.log(this.friends)
- //this.groups = restApi.findGroups(currentUser);
- },
- methods: {
- privateChat (friend) {
- uni.setStorage({
- key: 'friend',
- data: friend,
- success: function () {
- uni.navigateTo({
- url: './privateChat?to=' + friend.ID
- });
- }
- });
-
-
- },
- groupChat (group) {
- uni.navigateTo({
- url: './groupChat?to=' + group.ID
- });
- }
- }
- }
- </script>
- <style>
- .contacts {
- width: 100%;
- height: 100%;
- display: flex;
- flex-direction: column;
- }
- .contacts .contacts-container {
- width: 100%;
- height: 100%;
- overflow: auto;
- }
- .contacts .user-list-item {
- height: 132rpx;
- padding-left: 32rpx;
- display: flex;
- align-items: center;
- }
- .contacts .contacts-title {
- height: 80rpx;
- line-height: 100rpx;
- font-size: 34rpx;
- color: #666666;
- background: #F3F4F7;
- text-indent: 44rpx;
- }
- .contacts .user-list {
- flex-grow: 1;
- background: #ffffff;
- display: flex;
- flex-direction: column;
- }
- .contacts .user-item-avatar {
- width: 96rpx;
- height: 96rpx;
- margin-right: 32rpx;
- overflow: hidden;
- position: relative;
- }
- .contacts .user-item-avatar image {
- width: 100%;
- height: 100%;
- display: block;
- }
- .contacts .user-item-info {
- height: 130rpx;
- padding-right: 32rpx;
- line-height: 88rpx;
- flex-grow: 1;
- border-bottom: 1px solid #EFEFEF;
- display: flex;
- justify-content: space-between;
- align-items: center;
- }
- .contacts .user-item-info__name {
- font-size: 34rpx;
- font-style: normal;
- font-weight: bold;
- color: #262628;
- }
- </style>
|