好友申请流程优化,群创建简化
This commit is contained in:
11
pages.json
11
pages.json
@@ -429,9 +429,7 @@
|
||||
"path": "pages/im/friends/mine",
|
||||
"name": "imFriendsMine",
|
||||
"style": {
|
||||
"navigationBarTitleText": "我的二维码",
|
||||
"navigationBarBackgroundColor": "#34CE98",
|
||||
"navigationBarTextStyle": "white"
|
||||
"navigationBarTitleText": "我的资料"
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -477,13 +475,6 @@
|
||||
"navigationBarTitleText": "群信息"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/im/group/create",
|
||||
"name": "imGroupCreate",
|
||||
"style": {
|
||||
"navigationBarTitleText": "创建群聊"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/im/group/users",
|
||||
"name": "imGroupUsers",
|
||||
|
||||
@@ -17,13 +17,13 @@
|
||||
<view class="text" v-if="infoObj.gender === 2">女</view>
|
||||
</view>
|
||||
<view class="item">
|
||||
<label>HASH</label>
|
||||
<view class="text">{{infoObj.hash}}</view>
|
||||
<label>地址</label>
|
||||
<view class="text">{{infoObj.address}}</view>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 二维码 -->
|
||||
<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>ZH-HEALTH扫一扫上面的二维码</view>
|
||||
<view>添加我的好友</view>
|
||||
@@ -51,12 +51,11 @@
|
||||
qrContent: 'ADDFRIEND|'
|
||||
}
|
||||
},
|
||||
onLoad(e) {},
|
||||
mounted() {
|
||||
getUserInfo(this.$Route.query.targetId).then(res => {
|
||||
this.infoObj = res
|
||||
this.qrContent += res.userId
|
||||
})
|
||||
onLoad(e) {
|
||||
this.qrContent += e.targetId
|
||||
getUserInfo(e.targetId).then(res => {
|
||||
this.infoObj = res
|
||||
})
|
||||
},
|
||||
methods: {
|
||||
|
||||
|
||||
@@ -13,8 +13,8 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import * as RongIMLib from '@/uni_modules/RongCloud-IMWrapper/js_sdk/index'
|
||||
import applyCell from '../components/friendApplyCell'
|
||||
import im from '@/utils/im/index.js'
|
||||
|
||||
export default {
|
||||
components: {
|
||||
@@ -34,13 +34,8 @@
|
||||
},
|
||||
methods: {
|
||||
getPendingList() {
|
||||
// 获取系统中的好友关系会话列表
|
||||
RongIMLib.getConversationList([RongIMLib.ConversationType.SYSTEM], 1000, 0, (res) => {
|
||||
if (res.code === 0) {
|
||||
this.pendings = res.conversations.filter((item) => {
|
||||
return item.objectName == RongIMLib.ObjectName.ContactNotification
|
||||
})
|
||||
}
|
||||
im.getPendingList((pendings) => {
|
||||
this.pendings = pendings
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,10 +75,18 @@
|
||||
},
|
||||
methods: {
|
||||
toUser(item) {
|
||||
console.log(item);
|
||||
uni.navigateTo({
|
||||
url: '/pages/im/friends/info?targetId=' + item.senderUserId
|
||||
})
|
||||
if (item.senderUserId == '__system__') {
|
||||
return
|
||||
}
|
||||
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() {
|
||||
|
||||
@@ -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>
|
||||
@@ -7,18 +7,27 @@
|
||||
<view class="name">{{ item.name }}</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>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {
|
||||
getMyGroups
|
||||
getMyGroups,
|
||||
createGroup
|
||||
} from '@/apis/interfaces/im.js'
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
groups: []
|
||||
groups: [],
|
||||
createModal: false,
|
||||
groupName: ''
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
@@ -29,19 +38,40 @@
|
||||
}
|
||||
},
|
||||
onNavigationBarButtonTap() {
|
||||
uni.navigateTo({
|
||||
url: 'pages/im/group/create'
|
||||
})
|
||||
this.createModal = true
|
||||
},
|
||||
onLoad() {
|
||||
getMyGroups().then((res) => {
|
||||
this.groups = res
|
||||
res.map(item => {
|
||||
this.$store.dispatch('updateContact', item)
|
||||
})
|
||||
})
|
||||
this.initData()
|
||||
},
|
||||
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) {
|
||||
uni.navigateTo({
|
||||
url: '/pages/im/group/chat?targetId=' + targetId
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
<view class="user">
|
||||
<u-avatar @click="inviteUser" size="44" shape="square" icon="plus" bg-color="#eeeeee"
|
||||
color="#999999"></u-avatar>
|
||||
<view class="name">邀请用户</view>
|
||||
<view class="name">邀请好友</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
<u-cell-group class="cells">
|
||||
<u-cell isLink title="群公告" :label="announcement" @click="toAnnouncement"></u-cell>
|
||||
<u-cell isLink title="二维码" @click="showGroupQrCode"></u-cell>
|
||||
<u-cell title="聊天置顶">
|
||||
<u-switch slot="value" size="20" v-model="isTop" activeColor="#34CE98" @change="setTop"></u-switch>
|
||||
</u-cell>
|
||||
@@ -45,6 +46,12 @@
|
||||
<u--input placeholder="群名称" border="surround" focus v-model="groupName"></u--input>
|
||||
</view>
|
||||
</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>
|
||||
</template>
|
||||
|
||||
@@ -72,11 +79,14 @@
|
||||
isTop: false,
|
||||
loaded: false,
|
||||
modalShow: false,
|
||||
groupName: ''
|
||||
groupName: '',
|
||||
qrCodeShow: false,
|
||||
qrContent: 'JOINGROUP|'
|
||||
}
|
||||
},
|
||||
onLoad(e) {
|
||||
this.targetId = e.targetId
|
||||
this.qrContent += e.targetId
|
||||
RongIMLib.getConversationNotificationStatus(this.conversationType, this.targetId, ({
|
||||
status
|
||||
}) => {
|
||||
@@ -146,6 +156,9 @@
|
||||
url: '/pages/im/group/announcement?targetId=' + this.targetId
|
||||
})
|
||||
},
|
||||
showGroupQrCode() {
|
||||
this.qrCodeShow = true
|
||||
},
|
||||
onGroupName() {
|
||||
this.modalShow = true
|
||||
console.log(this.$refs.groupNameRef);
|
||||
@@ -226,10 +239,10 @@
|
||||
})
|
||||
},
|
||||
// 修改群头像
|
||||
onGroupAvatar() {
|
||||
uni.showToast({
|
||||
icon: 'none',
|
||||
title: '正在打开相册'
|
||||
onGroupAvatar() {
|
||||
uni.showToast({
|
||||
icon: 'none',
|
||||
title: '正在打开相册'
|
||||
})
|
||||
uni.chooseImage({
|
||||
count: 1,
|
||||
@@ -266,9 +279,9 @@
|
||||
icon: 'none'
|
||||
})
|
||||
})
|
||||
},
|
||||
fail: (err) => {
|
||||
console.log(err);
|
||||
},
|
||||
fail: (err) => {
|
||||
console.log(err);
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<view class="user" v-if="isAdmin">
|
||||
<u-avatar @click="inviteUser" size="44" shape="square" icon="plus" bg-color="#eeeeee" color="#999999">
|
||||
</u-avatar>
|
||||
<view class="name">邀请用户</view>
|
||||
<view class="name">邀请好友</view>
|
||||
</view>
|
||||
<view :class="['user', {'active': item.targetId == currentUser.targetId}]" @longpress="showAction(item)"
|
||||
v-for="(item, index) in members" :key="index" @click="toUser(item)">
|
||||
|
||||
@@ -72,15 +72,10 @@
|
||||
uni.$off('onReceiveMessage')
|
||||
},
|
||||
methods: {
|
||||
checkNewFriendPending() {
|
||||
// 获取是否有新的好友申请
|
||||
RongIMLib.getConversationList([RongIMLib.ConversationType.SYSTEM], 1000, 0, (res) => {
|
||||
if (res.code === 0) {
|
||||
this.hasNewFriends = res.conversations.filter((item) => {
|
||||
return item.objectName == RongIMLib.ObjectName.ContactNotification
|
||||
}).length
|
||||
}
|
||||
})
|
||||
checkNewFriendPending() {
|
||||
im.getPendingList((pendings) => {
|
||||
this.hasNewFriends = pendings.length
|
||||
})
|
||||
},
|
||||
// 检查登录
|
||||
toLogin() {
|
||||
|
||||
@@ -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 消息类型
|
||||
@@ -57,16 +72,16 @@ const sentText = (conversationType, targetId, content, user, callback) => {
|
||||
content: content,
|
||||
userInfo: user
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
RongIMLib.sendMessage(msg, ({
|
||||
code,
|
||||
messageId
|
||||
}) => {
|
||||
if (code === 0) {
|
||||
callback(messageId)
|
||||
} else {
|
||||
console.log('发送失败', msg);
|
||||
} else {
|
||||
console.log('发送失败', msg);
|
||||
uni.showToast({
|
||||
icon: 'none',
|
||||
title: '发送失败' + code
|
||||
@@ -189,7 +204,8 @@ const sendFile = (conversationType, targetId, fileUrl, time, callback) => {
|
||||
}
|
||||
|
||||
export default {
|
||||
getMessageList,
|
||||
getMessageList,
|
||||
getPendingList,
|
||||
sentText,
|
||||
sentVoice,
|
||||
sentImage,
|
||||
|
||||
Reference in New Issue
Block a user