公告,群资料

This commit is contained in:
2022-02-14 13:36:33 +08:00
parent de7f0453bb
commit d8c1ab7090
4 changed files with 163 additions and 83 deletions

View File

@@ -107,15 +107,15 @@ const getGroupInfo = (groupId) => {
url: 'im/groups/' + groupId url: 'im/groups/' + groupId
}) })
} }
/** /**
* 群组基础信息 * 群组基础信息
*/ */
const getGroupBase = (groupId) => { const getGroupBase = (groupId) => {
return request({ return request({
url: 'im/groups/' + groupId+ '/base' url: 'im/groups/' + groupId + '/base'
}) })
} }
const getGroupUsers = (groupId) => { const getGroupUsers = (groupId) => {
return request({ return request({
@@ -127,24 +127,24 @@ const getGroupAnnouncements = (groupId) => {
return request({ return request({
url: 'im/groups/' + groupId + '/announcements' url: 'im/groups/' + groupId + '/announcements'
}) })
} }
const createGroupAnnouncement = (groupId, content) => { const createGroupAnnouncement = (groupId, content) => {
return request({ return request({
method: 'POST', method: 'POST',
url: 'im/groups/' + groupId + '/announcements', url: 'im/groups/' + groupId + '/announcements',
data: { data: {
content: content content: content
} }
}) })
} }
const deleteGroupAnnouncement = (groupId, announcementId) => { const deleteGroupAnnouncement = (groupId, announcementId) => {
return request({ return request({
method: 'DELETE', method: 'DELETE',
url: 'im/groups/' + groupId + '/announcements/' + announcementId url: 'im/groups/' + groupId + '/announcements/' + announcementId
}) })
} }
/** /**
* 创建群聊 * 创建群聊
@@ -155,14 +155,14 @@ const createGroup = (data) => {
url: 'im/groups', url: 'im/groups',
data: data data: data
}) })
} }
const updateGroup = (groupId, data) => { const updateGroup = (groupId, data) => {
return request({ return request({
method: 'PUT', method: 'PUT',
url: 'im/groups/' + groupId, url: 'im/groups/' + groupId,
data: data data: data
}) })
} }
/** /**
@@ -179,14 +179,24 @@ const joinGroup = (groupId) => {
method: 'POST', method: 'POST',
url: 'im/groups/' + groupId + '/join' url: 'im/groups/' + groupId + '/join'
}) })
} }
const quitGroup = (groupId) => { const quitGroup = (groupId) => {
return request({ return request({
method: 'POST', method: 'POST',
url: 'im/groups/' + groupId + '/quit' url: 'im/groups/' + groupId + '/quit'
}) })
} }
/**
* 解散群聊
*/
const dismissGroup = (groupId) => {
return request({
method: 'DELETE',
url: 'im/groups/' + groupId
})
}
export { export {
getImToken, getImToken,
@@ -201,15 +211,16 @@ export {
searchFriend, searchFriend,
pedingFriend, pedingFriend,
getMyGroups, getMyGroups,
createGroup, createGroup,
updateGroup, updateGroup,
getGroupInfo, getGroupInfo,
getGroupBase, getGroupBase,
getGroupUsers, getGroupUsers,
getGroupAnnouncements, getGroupAnnouncements,
createGroupAnnouncement, createGroupAnnouncement,
deleteGroupAnnouncement, deleteGroupAnnouncement,
searchGroup, searchGroup,
joinGroup, joinGroup,
quitGroup quitGroup,
dismissGroup
} }

View File

@@ -2,7 +2,7 @@
<view class="create"> <view class="create">
<u--textarea v-model="content" count height="200" maxlength="200" placeholder="请输入公告内容"></u--textarea> <u--textarea v-model="content" count height="200" maxlength="200" placeholder="请输入公告内容"></u--textarea>
<u-button type="primary" text="发布" @click="onCreate"></u-button> <u-button type="primary" text="发布" :disabled="disabled" @click="onCreate" color="#34CE98"></u-button>
</view> </view>
</template> </template>
@@ -20,6 +20,11 @@
}, },
onLoad(e) { onLoad(e) {
this.targetId = e.targetId this.targetId = e.targetId
},
computed: {
disabled() {
return this.content.length == 0 || this.content.length > 200
}
}, },
methods: { methods: {
onCreate() { onCreate() {

View File

@@ -1,7 +1,7 @@
<template> <template>
<view class="announce"> <view class="announce">
<u-skeleton rows="2" :loading="loading" avatar :rows="5"> <u-skeleton rows="2" :loading="loading" avatar :rows="5">
<view v-for="(item,index) in announcements" :key="index"> <view v-for="(item,index) in announcements" :key="index" class="item">
<view class="header"> <view class="header">
<u-avatar :src="item.user.portraitUrl"></u-avatar> <u-avatar :src="item.user.portraitUrl"></u-avatar>
<view class="user"> <view class="user">
@@ -63,8 +63,19 @@
}) })
}, },
onDelete(aId) { onDelete(aId) {
deleteGroupAnnouncement(this.targetId, aId).then(res => { uni.showModal({
this.initData() title: '删除公告',
success: (res) => {
if (res.confirm) {
deleteGroupAnnouncement(this.targetId, aId).then(res => {
uni.showToast({
icon: 'none',
title: '删除成功'
})
this.initData()
})
}
}
}) })
} }
} }
@@ -73,36 +84,42 @@
<style lang="scss" scoped> <style lang="scss" scoped>
.announce { .announce {
padding: $padding; padding: 0 $padding $padding $padding;
.header { .item {
display: flex; border-bottom: solid 1rpx #f9f9f9 !important;
flex-direction: row; padding-top: $padding;
.user { .header {
margin-left: $padding; display: flex;
flex: 1; flex-direction: row;
align-items: center;
.name { .user {
line-height: 44rpx; margin-left: $padding;
flex: 1;
display: flex;
flex-direction: column;
justify-content: space-between;
.name {}
.time {
font-size: 24rpx;
color: $text-gray-m;
}
} }
.time { .delete {
margin-top: 15rpx; color: $text-price;
font-size: 24rpx; font-size: 28rpx;
color: $text-gray-m;
} }
} }
.delete { .content {
color: $text-price; padding: $padding;
font-size: 32rpx; font-size: 34rpx;
} }
} }
.content {
padding: $padding;
font-size: 34rpx;
}
} }
</style> </style>

View File

@@ -39,9 +39,10 @@
<view class="action u-border-bottom" v-else @click="onQuite">删除并退出</view> <view class="action u-border-bottom" v-else @click="onQuite">删除并退出</view>
</view> </view>
<u-modal :show="modalShow" title="修改群名称" showCancelButton @cancel="onHideModal" @confirm="onChangeGroupName"> <u-modal negativeTop="300" :show="modalShow" title="修改群名称" showCancelButton @cancel="onHideModal"
@confirm="onChangeGroupName">
<view class="slot-content"> <view class="slot-content">
<u--input placeholder="群名称" border="surround" v-model="groupName"></u--input> <u--input placeholder="群名称" border="surround" focus v-model="groupName"></u--input>
</view> </view>
</u-modal> </u-modal>
</view> </view>
@@ -50,7 +51,9 @@
<script> <script>
import { import {
getGroupInfo, getGroupInfo,
updateGroup updateGroup,
quitGroup,
dismissGroup
} from '@/apis/interfaces/im.js' } from '@/apis/interfaces/im.js'
import { import {
uploads uploads
@@ -101,6 +104,11 @@
this.announcement = res.announcement this.announcement = res.announcement
this.members = res.members this.members = res.members
this.loaded = true this.loaded = true
}).catch(err => {
uni.showToast({
icon: 'none',
title: '群不存在'
})
}) })
}, },
setStatus() { setStatus() {
@@ -140,17 +148,25 @@
}, },
onGroupName() { onGroupName() {
this.modalShow = true this.modalShow = true
console.log(this.$refs.groupNameRef);
}, },
onChangeGroupName() { onChangeGroupName() {
updateGroup(this.targetId, { if (this.groupName != this.group.name) {
name: this.groupName updateGroup(this.targetId, {
}).then(res => { name: this.groupName
this.modalShow = false }).then(res => {
this.modalShow = false
uni.showToast({
icon: 'none',
title: '群名称修改成功'
})
})
} else {
uni.showToast({ uni.showToast({
icon: 'none', icon: 'none',
title: '群名称修改成功' title: '无修改'
}) })
}) }
}, },
onHideModal() { onHideModal() {
this.modalShow = false this.modalShow = false
@@ -174,19 +190,47 @@
}) })
}, },
onDismiss() { onDismiss() {
uni.showToast({ uni.showModal({
icon: 'none', title: '解散群聊',
title: '开发中' success: (res) => {
if (res.confirm) {
dismissGroup(this.targetId).then(res => {
uni.showToast({
icon: 'none',
title: '解散成功'
})
uni.switchTab({
url: '/pages/im/index'
})
})
}
}
}) })
}, },
onQuite() { onQuite() {
uni.showToast({ uni.showModal({
icon: 'none', title: '退出群聊',
title: '开发中' success: (res) => {
if (res.confirm) {
quitGroup(this.targetId).then(res => {
uni.showToast({
icon: 'none',
title: '退出群聊成功'
})
uni.switchTab({
url: '/pages/im/index'
})
})
}
}
}) })
}, },
// 修改群头像 // 修改群头像
onGroupAvatar() { onGroupAvatar() {
uni.showToast({
icon: 'none',
title: '正在打开相册'
})
uni.chooseImage({ uni.chooseImage({
count: 1, count: 1,
sizeType: ['original'], sizeType: ['original'],
@@ -222,6 +266,9 @@
icon: 'none' icon: 'none'
}) })
}) })
},
fail: (err) => {
console.log(err);
} }
}) })
} }