公告,群资料

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

View File

@@ -2,7 +2,7 @@
<view class="create">
<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>
</template>
@@ -20,6 +20,11 @@
},
onLoad(e) {
this.targetId = e.targetId
},
computed: {
disabled() {
return this.content.length == 0 || this.content.length > 200
}
},
methods: {
onCreate() {

View File

@@ -1,7 +1,7 @@
<template>
<view class="announce">
<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">
<u-avatar :src="item.user.portraitUrl"></u-avatar>
<view class="user">
@@ -63,8 +63,19 @@
})
},
onDelete(aId) {
deleteGroupAnnouncement(this.targetId, aId).then(res => {
this.initData()
uni.showModal({
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>
.announce {
padding: $padding;
padding: 0 $padding $padding $padding;
.header {
display: flex;
flex-direction: row;
.item {
border-bottom: solid 1rpx #f9f9f9 !important;
padding-top: $padding;
.user {
margin-left: $padding;
flex: 1;
.header {
display: flex;
flex-direction: row;
align-items: center;
.name {
line-height: 44rpx;
.user {
margin-left: $padding;
flex: 1;
display: flex;
flex-direction: column;
justify-content: space-between;
.name {}
.time {
font-size: 24rpx;
color: $text-gray-m;
}
}
.time {
margin-top: 15rpx;
font-size: 24rpx;
color: $text-gray-m;
.delete {
color: $text-price;
font-size: 28rpx;
}
}
.delete {
color: $text-price;
font-size: 32rpx;
.content {
padding: $padding;
font-size: 34rpx;
}
}
.content {
padding: $padding;
font-size: 34rpx;
}
}
</style>

View File

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