群组基础接口

This commit is contained in:
2022-02-10 18:00:22 +08:00
parent 8656ddef55
commit b9364be40b
5 changed files with 116 additions and 57 deletions

View File

@@ -99,6 +99,20 @@ const getMyGroups = () => {
}) })
} }
const getGroupInfo = (groupId) => {
return request({
url: 'im/groups/' + groupId
})
}
const createGroup = (data) => {
return request({
method: 'POST',
url: 'im/groups',
data: data
})
}
export { export {
getImToken, getImToken,
deleteFriend, deleteFriend,
@@ -111,5 +125,7 @@ export {
rejectFriend, rejectFriend,
searchFriend, searchFriend,
pedingFriend, pedingFriend,
getMyGroups getMyGroups,
createGroup,
getGroupInfo
} }

View File

@@ -68,7 +68,7 @@
}, },
onNavigationBarButtonTap() { onNavigationBarButtonTap() {
uni.navigateTo({ uni.navigateTo({
url: '/pages/im/group/info' url: '/pages/im/group/info?targetId=' + this.targetId
}) })
}, },
methods: { methods: {

View File

@@ -1,19 +1,44 @@
<template> <template>
<view> <view>
<u--input placeholder="请输入内容" border="surround" v-model="group_name"></u--input>
<u-button type="primary" text="确定" @click="onCreate"></u-button>
</view> </view>
</template> </template>
<script> <script>
import {
createGroup
} from '@/apis/interfaces/im.js'
export default { export default {
data() { data() {
return {
group_name: '',
}
}, },
onLoad() { onLoad() {
}, },
methods: { 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> </script>

View File

@@ -23,8 +23,27 @@
</template> </template>
<script> <script>
export default { import {
getGroupInfo
} from '@/apis/interfaces/im.js'
export default {
data() {
return {
targetId: '',
group: {},
members: []
}
},
onLoad(e) {
this.targetId = e.targetId
getGroupInfo(this.targetId).then(res => {
this.info = res.group
this.members = res.members
}).catch(err => {
console.log(err);
})
}
} }
</script> </script>

View File

@@ -12,7 +12,6 @@ export default {
contactInfo: (state) => (targetId) => { contactInfo: (state) => (targetId) => {
if (state.contacts[targetId]) { if (state.contacts[targetId]) {
const info = state.contacts[targetId] const info = state.contacts[targetId]
console.log(targetId, info);
return { return {
name: info.name, name: info.name,