公告,群资料

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

@@ -113,7 +113,7 @@ const getGroupInfo = (groupId) => {
*/ */
const getGroupBase = (groupId) => { const getGroupBase = (groupId) => {
return request({ return request({
url: 'im/groups/' + groupId+ '/base' url: 'im/groups/' + groupId + '/base'
}) })
} }
@@ -188,6 +188,16 @@ const quitGroup = (groupId) => {
}) })
} }
/**
* 解散群聊
*/
const dismissGroup = (groupId) => {
return request({
method: 'DELETE',
url: 'im/groups/' + groupId
})
}
export { export {
getImToken, getImToken,
deleteFriend, deleteFriend,
@@ -211,5 +221,6 @@ export {
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>
@@ -21,6 +21,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() {
createGroupAnnouncement(this.targetId, this.content).then(res => { createGroupAnnouncement(this.targetId, this.content).then(res => {

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,32 +63,48 @@
}) })
}, },
onDelete(aId) { onDelete(aId) {
uni.showModal({
title: '删除公告',
success: (res) => {
if (res.confirm) {
deleteGroupAnnouncement(this.targetId, aId).then(res => { deleteGroupAnnouncement(this.targetId, aId).then(res => {
uni.showToast({
icon: 'none',
title: '删除成功'
})
this.initData() this.initData()
}) })
} }
} }
})
}
}
} }
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.announce { .announce {
padding: $padding; padding: 0 $padding $padding $padding;
.item {
border-bottom: solid 1rpx #f9f9f9 !important;
padding-top: $padding;
.header { .header {
display: flex; display: flex;
flex-direction: row; flex-direction: row;
align-items: center;
.user { .user {
margin-left: $padding; margin-left: $padding;
flex: 1; flex: 1;
display: flex;
flex-direction: column;
justify-content: space-between;
.name { .name {}
line-height: 44rpx;
}
.time { .time {
margin-top: 15rpx;
font-size: 24rpx; font-size: 24rpx;
color: $text-gray-m; color: $text-gray-m;
} }
@@ -96,7 +112,7 @@
.delete { .delete {
color: $text-price; color: $text-price;
font-size: 32rpx; font-size: 28rpx;
} }
} }
@@ -105,4 +121,5 @@
font-size: 34rpx; 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,8 +148,10 @@
}, },
onGroupName() { onGroupName() {
this.modalShow = true this.modalShow = true
console.log(this.$refs.groupNameRef);
}, },
onChangeGroupName() { onChangeGroupName() {
if (this.groupName != this.group.name) {
updateGroup(this.targetId, { updateGroup(this.targetId, {
name: this.groupName name: this.groupName
}).then(res => { }).then(res => {
@@ -151,6 +161,12 @@
title: '群名称修改成功' title: '群名称修改成功'
}) })
}) })
} else {
uni.showToast({
icon: 'none',
title: '无修改'
})
}
}, },
onHideModal() { onHideModal() {
this.modalShow = false this.modalShow = false
@@ -174,19 +190,47 @@
}) })
}, },
onDismiss() { onDismiss() {
uni.showModal({
title: '解散群聊',
success: (res) => {
if (res.confirm) {
dismissGroup(this.targetId).then(res => {
uni.showToast({ uni.showToast({
icon: 'none', icon: 'none',
title: '开发中' title: '解散成功'
})
uni.switchTab({
url: '/pages/im/index'
})
})
}
}
}) })
}, },
onQuite() { onQuite() {
uni.showModal({
title: '退出群聊',
success: (res) => {
if (res.confirm) {
quitGroup(this.targetId).then(res => {
uni.showToast({ uni.showToast({
icon: 'none', icon: 'none',
title: '开发中' 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);
} }
}) })
} }