好友申请流程优化,群创建简化

This commit is contained in:
2022-02-14 14:23:28 +08:00
parent d8c1ab7090
commit b61d90de4e
10 changed files with 113 additions and 114 deletions

View File

@@ -429,9 +429,7 @@
"path": "pages/im/friends/mine", "path": "pages/im/friends/mine",
"name": "imFriendsMine", "name": "imFriendsMine",
"style": { "style": {
"navigationBarTitleText": "我的二维码", "navigationBarTitleText": "我的资料"
"navigationBarBackgroundColor": "#34CE98",
"navigationBarTextStyle": "white"
} }
}, },
{ {
@@ -477,13 +475,6 @@
"navigationBarTitleText": "群信息" "navigationBarTitleText": "群信息"
} }
}, },
{
"path": "pages/im/group/create",
"name": "imGroupCreate",
"style": {
"navigationBarTitleText": "创建群聊"
}
},
{ {
"path": "pages/im/group/users", "path": "pages/im/group/users",
"name": "imGroupUsers", "name": "imGroupUsers",

View File

@@ -17,13 +17,13 @@
<view class="text" v-if="infoObj.gender === 2"></view> <view class="text" v-if="infoObj.gender === 2"></view>
</view> </view>
<view class="item"> <view class="item">
<label>HASH</label> <label>地址</label>
<view class="text">{{infoObj.hash}}</view> <view class="text">{{infoObj.address}}</view>
</view> </view>
</view> </view>
<!-- 二维码 --> <!-- 二维码 -->
<view class="info-code"> <view class="info-code">
<uqrcode class="info-code-src" :size="198" ref="uQRCode" :text="qrContent" /> <uqrcode class="info-code-src" :size="198" :text="qrContent" />
<view class="info-code-text"> <view class="info-code-text">
<view>ZH-HEALTH扫一扫上面的二维码</view> <view>ZH-HEALTH扫一扫上面的二维码</view>
<view>添加我的好友</view> <view>添加我的好友</view>
@@ -51,11 +51,10 @@
qrContent: 'ADDFRIEND|' qrContent: 'ADDFRIEND|'
} }
}, },
onLoad(e) {}, onLoad(e) {
mounted() { this.qrContent += e.targetId
getUserInfo(this.$Route.query.targetId).then(res => { getUserInfo(e.targetId).then(res => {
this.infoObj = res this.infoObj = res
this.qrContent += res.userId
}) })
}, },
methods: { methods: {

View File

@@ -13,8 +13,8 @@
</template> </template>
<script> <script>
import * as RongIMLib from '@/uni_modules/RongCloud-IMWrapper/js_sdk/index'
import applyCell from '../components/friendApplyCell' import applyCell from '../components/friendApplyCell'
import im from '@/utils/im/index.js'
export default { export default {
components: { components: {
@@ -34,13 +34,8 @@
}, },
methods: { methods: {
getPendingList() { getPendingList() {
// 获取系统中的好友关系会话列表 im.getPendingList((pendings) => {
RongIMLib.getConversationList([RongIMLib.ConversationType.SYSTEM], 1000, 0, (res) => { this.pendings = pendings
if (res.code === 0) {
this.pendings = res.conversations.filter((item) => {
return item.objectName == RongIMLib.ObjectName.ContactNotification
})
}
}) })
} }
} }

View File

@@ -75,10 +75,18 @@
}, },
methods: { methods: {
toUser(item) { toUser(item) {
console.log(item); if (item.senderUserId == '__system__') {
uni.navigateTo({ return
url: '/pages/im/friends/info?targetId=' + item.senderUserId }
}) if (item.messageDirection == 1) {
uni.navigateTo({
url: '/pages/im/friends/mine?targetId=' + item.senderUserId
})
} else{
uni.navigateTo({
url: '/pages/im/friends/info?targetId=' + item.senderUserId
})
}
}, },
// 获取消息列表 // 获取消息列表
getMessageList() { getMessageList() {

View File

@@ -1,48 +0,0 @@
<template>
<view>
<u--input placeholder="请输入内容" border="surround" v-model="group_name"></u--input>
<u-button type="primary" text="确定" @click="onCreate"></u-button>
</view>
</template>
<script>
import {
createGroup
} from '@/apis/interfaces/im.js'
export default {
data() {
return {
group_name: '',
}
},
onLoad() {
},
methods: {
onCreate() {
console.log('阿斯利康');
createGroup({
name: this.group_name
}).then(res => {
console.log(res);
uni.showToast({
title: '创建成功'
})
uni.navigateBack()
}).catch(err => {
console.log(err);
uni.showToast({
icon: 'none',
title: err
})
})
}
}
}
</script>
<style>
</style>

View File

@@ -7,18 +7,27 @@
<view class="name">{{ item.name }}</view> <view class="name">{{ item.name }}</view>
</view> </view>
</view> </view>
<u-modal negativeTop="300" :show="createModal" title="创建群聊" showCancelButton @cancel="onHideModal"
@confirm="onCreateGroup">
<view class="slot-content">
<u--input placeholder="群名称" border="surround" focus v-model="groupName"></u--input>
</view>
</u-modal>
</view> </view>
</template> </template>
<script> <script>
import { import {
getMyGroups getMyGroups,
createGroup
} from '@/apis/interfaces/im.js' } from '@/apis/interfaces/im.js'
export default { export default {
data() { data() {
return { return {
groups: [] groups: [],
createModal: false,
groupName: ''
} }
}, },
computed: { computed: {
@@ -29,19 +38,40 @@
} }
}, },
onNavigationBarButtonTap() { onNavigationBarButtonTap() {
uni.navigateTo({ this.createModal = true
url: 'pages/im/group/create'
})
}, },
onLoad() { onLoad() {
getMyGroups().then((res) => { this.initData()
this.groups = res
res.map(item => {
this.$store.dispatch('updateContact', item)
})
})
}, },
methods: { methods: {
initData() {
getMyGroups().then((res) => {
this.groups = res
res.map(item => {
this.$store.dispatch('updateContact', item)
})
})
},
onHideModal() {
this.createModal = false
this.groupName = ''
},
onCreateGroup() {
createGroup({
name: this.groupName
}).then(res => {
uni.showToast({
title: '创建成功'
})
this.initData()
this.onHideModal()
}).catch(err => {
uni.showToast({
icon: 'none',
title: err
})
})
},
toGroup(targetId) { toGroup(targetId) {
uni.navigateTo({ uni.navigateTo({
url: '/pages/im/group/chat?targetId=' + targetId url: '/pages/im/group/chat?targetId=' + targetId

View File

@@ -9,7 +9,7 @@
<view class="user"> <view class="user">
<u-avatar @click="inviteUser" size="44" shape="square" icon="plus" bg-color="#eeeeee" <u-avatar @click="inviteUser" size="44" shape="square" icon="plus" bg-color="#eeeeee"
color="#999999"></u-avatar> color="#999999"></u-avatar>
<view class="name">邀请用户</view> <view class="name">邀请好友</view>
</view> </view>
</view> </view>
@@ -18,6 +18,7 @@
<u-cell-group class="cells"> <u-cell-group class="cells">
<u-cell isLink title="群公告" :label="announcement" @click="toAnnouncement"></u-cell> <u-cell isLink title="群公告" :label="announcement" @click="toAnnouncement"></u-cell>
<u-cell isLink title="二维码" @click="showGroupQrCode"></u-cell>
<u-cell title="聊天置顶"> <u-cell title="聊天置顶">
<u-switch slot="value" size="20" v-model="isTop" activeColor="#34CE98" @change="setTop"></u-switch> <u-switch slot="value" size="20" v-model="isTop" activeColor="#34CE98" @change="setTop"></u-switch>
</u-cell> </u-cell>
@@ -45,6 +46,12 @@
<u--input placeholder="群名称" border="surround" focus v-model="groupName"></u--input> <u--input placeholder="群名称" border="surround" focus v-model="groupName"></u--input>
</view> </view>
</u-modal> </u-modal>
<u-modal :show="qrCodeShow" :title="group.name" @confirm="qrCodeShow = false">
<view class="slot-content">
<uqrcode class="info-code-src" :size="198" :text="qrContent" />
</view>
</u-modal>
</view> </view>
</template> </template>
@@ -72,11 +79,14 @@
isTop: false, isTop: false,
loaded: false, loaded: false,
modalShow: false, modalShow: false,
groupName: '' groupName: '',
qrCodeShow: false,
qrContent: 'JOINGROUP|'
} }
}, },
onLoad(e) { onLoad(e) {
this.targetId = e.targetId this.targetId = e.targetId
this.qrContent += e.targetId
RongIMLib.getConversationNotificationStatus(this.conversationType, this.targetId, ({ RongIMLib.getConversationNotificationStatus(this.conversationType, this.targetId, ({
status status
}) => { }) => {
@@ -146,6 +156,9 @@
url: '/pages/im/group/announcement?targetId=' + this.targetId url: '/pages/im/group/announcement?targetId=' + this.targetId
}) })
}, },
showGroupQrCode() {
this.qrCodeShow = true
},
onGroupName() { onGroupName() {
this.modalShow = true this.modalShow = true
console.log(this.$refs.groupNameRef); console.log(this.$refs.groupNameRef);

View File

@@ -4,7 +4,7 @@
<view class="user" v-if="isAdmin"> <view class="user" v-if="isAdmin">
<u-avatar @click="inviteUser" size="44" shape="square" icon="plus" bg-color="#eeeeee" color="#999999"> <u-avatar @click="inviteUser" size="44" shape="square" icon="plus" bg-color="#eeeeee" color="#999999">
</u-avatar> </u-avatar>
<view class="name">邀请用户</view> <view class="name">邀请好友</view>
</view> </view>
<view :class="['user', {'active': item.targetId == currentUser.targetId}]" @longpress="showAction(item)" <view :class="['user', {'active': item.targetId == currentUser.targetId}]" @longpress="showAction(item)"
v-for="(item, index) in members" :key="index" @click="toUser(item)"> v-for="(item, index) in members" :key="index" @click="toUser(item)">

View File

@@ -73,13 +73,8 @@
}, },
methods: { methods: {
checkNewFriendPending() { checkNewFriendPending() {
// 获取是否有新的好友申请 im.getPendingList((pendings) => {
RongIMLib.getConversationList([RongIMLib.ConversationType.SYSTEM], 1000, 0, (res) => { this.hasNewFriends = pendings.length
if (res.code === 0) {
this.hasNewFriends = res.conversations.filter((item) => {
return item.objectName == RongIMLib.ObjectName.ContactNotification
}).length
}
}) })
}, },
// 检查登录 // 检查登录

View File

@@ -41,6 +41,21 @@ const getMessageList = (conversationType, targetId, timeStamp, count, isForward,
) )
} }
// 获取好友申请列表
const getPendingList = (callback, total) => {
total = total || 100
RongIMLib.getConversationList([RongIMLib.ConversationType.SYSTEM], total, 0, (res) => {
if (res.code === 0) {
const pendings = res.conversations.filter((item) => {
return item.objectName == RongIMLib.ObjectName.ContactNotification &&
item.latestMessage.operation === 'Request'
})
callback(pendings)
}
})
}
/** /**
* 发送文本消息 * 发送文本消息
* @param {number} conversationType 消息类型 * @param {number} conversationType 消息类型
@@ -190,6 +205,7 @@ const sendFile = (conversationType, targetId, fileUrl, time, callback) => {
export default { export default {
getMessageList, getMessageList,
getPendingList,
sentText, sentText,
sentVoice, sentVoice,
sentImage, sentImage,