Initial commit

This commit is contained in:
2025-07-04 16:18:58 +08:00
commit 2cf13f673d
770 changed files with 73394 additions and 0 deletions

View File

@@ -0,0 +1,88 @@
<template>
<view class="chat_action_bar">
<u-row class="action_row">
<u-col
v-for="item in actionList"
:key="item.idx"
@click="actionClick(item)"
span="3"
>
<view class="action_item">
<image :src="item.icon" alt="" srcset="" />
<text class="action_item_title">{{ item.title }}</text>
</view>
</u-col>
</u-row>
</view>
</template>
<script>
import {
ChatingFooterActionTypes,
} from "@/constant";
export default {
components: {},
data() {
return {
actionList: [
{
idx: 0,
type: ChatingFooterActionTypes.Album,
title: "相册",
icon: require("static/images/chating_action_image.png"),
},
{
idx: 1,
type: ChatingFooterActionTypes.File,
title: "文件",
icon: require("static/images/chating_action_file.png"),
}
],
};
},
methods: {
async actionClick(action) {
switch (action.type) {
case ChatingFooterActionTypes.Album:
this.$emit("prepareMediaMessage", action.type);
break;
case ChatingFooterActionTypes.File:
this.$emit("prepareMediaMessage", action.type);
default:
break;
}
},
},
};
</script>
<style lang="scss" scoped>
.chat_action_bar {
position: relative;
background: #f0f2f6;
padding: 24rpx 36rpx;
.action_row {
flex-wrap: wrap;
margin-bottom: 24rpx;
}
.action_item {
@include centerBox();
flex-direction: column;
margin-top: 24rpx;
image {
width: 96rpx;
height: 96rpx;
}
&_title {
font-size: 24rpx;
color: #999;
margin-top: 6rpx;
}
}
}
</style>

View File

@@ -0,0 +1,107 @@
<template>
<view
class="editor_wrap"
>
<editor
:placeholder="placeholder"
id="editor2"
@ready="editorReady"
@focus="editorFocus"
@blur="editorBlur"
@input="editorInput"
/>
</view>
</template>
<script>
import { html2Text } from "@/util/common";
export default {
props: {
placeholder: {
type: String,
default: "",
},
},
data() {
return {
editorCtx: null,
lastStr: "",
};
},
methods: {
editorReady() {
uni
.createSelectorQuery()
.select("#editor2")
.context((res) => {
this.$emit("ready", res);
this.editorCtx = res.context;
})
.exec();
},
editorFocus() {
this.$emit("focus");
},
editorBlur() {
this.$emit("blur");
},
editorInput(e) {
let str = e.detail.html;
const oldArr = (this.lastStr ?? '').split("");
let contentStr = str;
oldArr.forEach((str) => {
contentStr = contentStr.replace(str, "");
});
contentStr = html2Text(contentStr);
this.$emit("input", e);
this.lastStr = e.detail.html;
},
},
};
</script>
<style lang="scss" scoped>
.editor_wrap {
position: relative;
}
#editor2 {
background-color: #fff;
min-height: 30px;
max-height: 120px;
height: auto;
word-break: break-all;
}
/deep/.ql-editor {
img {
vertical-align: sub !important;
}
p {
padding: 4px;
}
}
.canvas_container {
position: fixed;
bottom: -99px;
z-index: -100;
&_name {
max-width: 480rpx;
display: inline-block;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
#atCanvas {
height: 20px;
}
.convas_container_name {
font-size: 16px !important;
}
}
</style>

View File

@@ -0,0 +1,353 @@
<template>
<view>
<view>
<view class="chat_footer">
<view class="footer_action_area">
<view class="input_content">
<CustomEditor
class="custom_editor"
ref="customEditor"
@ready="editorReady"
@focus="editorFocus"
@blur="editorBlur"
@input="editorInput"
/>
</view>
<view class="footer_action_area">
<!-- <image-->
<!-- v-show="!hasContent"-->
<!-- @click.prevent="updateActionBar"-->
<!-- src="@/static/images/chating_footer_add.png"-->
<!-- alt=""-->
<!-- srcset=""-->
<!-- />-->
<image
v-show="hasContent"
@touchend.prevent="sendTextMessage"
src="@/static/images/send_btn.png"
alt=""
srcset=""
/>
</view>
</view>
<chating-action-bar
@sendMessage="sendMessage"
@prepareMediaMessage="prepareMediaMessage"
v-show="actionBarVisible"
/>
<u-action-sheet
:safeAreaInsetBottom="true"
round="12"
:actions="actionSheetMenu"
@select="selectClick"
:closeOnClickOverlay="true"
:closeOnClickAction="true"
:show="showActionSheet"
@close="showActionSheet = false"
>
</u-action-sheet>
</view>
</view>
</template>
<script>
import { mapGetters, mapActions } from "vuex";
import { getPurePath, html2Text } from "@/util/common";
import { offlinePushInfo } from "@/util/imCommon";
import {
ChatingFooterActionTypes,
UpdateMessageTypes,
} from "@/constant";
import IMSDK, {
IMMethods,
MessageStatus,
MessageType,
} from "openim-uniapp-polyfill";
import UParse from "@/components/gaoyia-parse/parse.vue";
import CustomEditor from "./CustomEditor.vue";
import ChatingActionBar from "./ChatingActionBar.vue";
const needClearTypes = [MessageType.TextMessage];
const albumChoose = [
{
name: "图片",
type: ChatingFooterActionTypes.Album,
idx: 0,
},
{
name: "拍照",
type: ChatingFooterActionTypes.Camera,
idx: 1,
},
];
export default {
components: {
CustomEditor,
ChatingActionBar,
UParse,
},
props: {
footerOutsideFlag: Number,
},
data() {
return {
customEditorCtx: null,
inputHtml: "",
actionBarVisible: false,
isInputFocus: false,
actionSheetMenu: [],
showActionSheet: false,
};
},
computed: {
...mapGetters([
"storeCurrentConversation",
"storeCurrentGroup",
"storeBlackList",
]),
hasContent() {
return html2Text(this.inputHtml) !== "";
},
},
watch: {
footerOutsideFlag(newVal) {
this.onClickActionBarOutside();
},
},
mounted() {
this.setKeyboardListener();
},
beforeDestroy() {
this.disposeKeyboardListener();
},
methods: {
...mapActions("message", ["pushNewMessage", "updateOneMessage"]),
async createTextMessage() {
let message = "";
const text = html2Text(this.inputHtml);
message = await IMSDK.asyncApi(
IMMethods.CreateTextMessage,
IMSDK.uuid(),
text
);
console.log(message);
return message;
},
async sendTextMessage() {
if (!this.hasContent) return;
const message = await this.createTextMessage();
this.sendMessage(message);
},
sendMessage(message) {
this.pushNewMessage(message);
if (needClearTypes.includes(message.contentType)) {
this.customEditorCtx.clear();
}
this.$emit("scrollToBottom");
IMSDK.asyncApi(IMMethods.SendMessage, IMSDK.uuid(), {
recvID: this.storeCurrentConversation.userID,
groupID: this.storeCurrentConversation.groupID,
message,
offlinePushInfo,
})
.then(({ data }) => {
this.updateOneMessage({
message: data,
isSuccess: true,
});
})
.catch(({ data, errCode, errMsg }) => {
this.updateOneMessage({
message: data,
type: UpdateMessageTypes.KeyWords,
keyWords: [
{
key: "status",
value: MessageStatus.Failed,
},
{
key: "errCode",
value: errCode,
},
],
});
});
},
// action
onClickActionBarOutside() {
if (this.actionBarVisible) {
this.actionBarVisible = false;
}
},
updateActionBar() {
this.actionBarVisible = !this.actionBarVisible;
},
editorReady(e) {
this.customEditorCtx = e.context;
this.customEditorCtx.clear();
},
editorFocus() {
this.isInputFocus = true;
this.$emit("scrollToBottom");
},
editorBlur() {
this.isInputFocus = false;
},
editorInput(e) {
this.inputHtml = e.detail.html;
},
prepareMediaMessage(type) {
if (type === ChatingFooterActionTypes.Album) {
this.actionSheetMenu = [...albumChoose];
}
this.showActionSheet = true;
},
// from comp
batchCreateImageMesage(paths) {
paths.forEach(async (path) => {
const message = await IMSDK.asyncApi(
IMMethods.CreateImageMessageFromFullPath,
IMSDK.uuid(),
getPurePath(path)
);
this.sendMessage(message);
});
},
selectClick({ idx }) {
if (idx === 0) {
this.chooseOrShotImage(["album"]).then((paths) =>
this.batchCreateImageMesage(paths)
);
} else {
this.chooseOrShotImage(["camera"]).then((paths) =>
this.batchCreateImageMesage(paths)
);
}
},
chooseOrShotImage(sourceType) {
return new Promise((resolve, reject) => {
uni.chooseImage({
count: 9,
sizeType: ["compressed"],
sourceType,
success: function ({ tempFilePaths }) {
resolve(tempFilePaths);
},
fail: function (err) {
console.log(err);
reject(err);
},
});
});
},
// keyboard
keyboardChangeHander({ height }) {
if (height > 0) {
if (this.actionBarVisible) {
this.actionBarVisible = false;
}
}
},
setKeyboardListener() {
uni.onKeyboardHeightChange(this.keyboardChangeHander);
},
disposeKeyboardListener() {
uni.offKeyboardHeightChange(this.keyboardChangeHander);
},
},
};
</script>
<style lang="scss" scoped>
.custom_editor {
img {
vertical-align: sub;
}
}
.forbidden_footer {
width: 100%;
height: 112rpx;
color: #8e9ab0;
display: flex;
flex-direction: row;
justify-content: center;
align-items: center;
background: #f0f2f6;
}
.chat_footer {
display: flex;
align-items: center;
// background-color: #e9f4ff;
background: #f0f2f6;
// height: 50px;
max-height: 120px;
padding: 24rpx 20rpx;
.input_content {
flex: 1;
min-height: 30px;
max-height: 120px;
margin: 0 24rpx;
border-radius: 8rpx;
position: relative;
.record_btn {
// background-color: #3c9cff;
background: #fff;
color: black;
height: 30px;
font-size: 24rpx;
}
}
.quote_message {
@include vCenterBox();
justify-content: space-between;
margin-top: 12rpx;
padding: 8rpx;
// padding-top: 20rpx;
border-radius: 6rpx;
background-color: #fff;
color: #666;
.content {
/deep/ uni-view {
@include ellipsisWithLine(2);
}
}
}
.footer_action_area {
display: flex;
align-items: center;
.emoji_action {
margin-right: 24rpx;
}
image {
width: 26px;
height: 26px;
}
}
.send_btn {
height: 30px;
line-height: 30px;
background-color: #4a9cfc;
padding: 0 8px;
border-radius: 4px;
color: #fff;
}
}
</style>

View File

@@ -0,0 +1,294 @@
<template>
<u-navbar @click="click" placeholder class="chating_header">
<view @click="routeBack" class="u-nav-slot" slot="left">
<img
class="back_icon"
width="12"
height="20"
src="static/images/common_left_arrow.png"
alt=""
srcset=""
/>
</view>
<view class="u-nav-slot" slot="center">
<view class="chating_info" :class="{ chating_info_single: isSingle }">
<view class="conversation_info">
<view class="title">{{ storeCurrentConversation.showName }}</view>
<view v-if="!isSingle && !isNotify" class="sub_title"
>{{ groupMemberCount }}
</view>
</view>
</view>
</view>
<view class="u-nav-slot" slot="right">
<view class="right_action">
<u-icon
@click="goSetting"
class="action_item"
name="more-dot-fill"
size="23"
color="#0C1C33"
>
</u-icon>
</view>
</view>
</u-navbar>
</template>
<script>
import { mapGetters } from "vuex";
import { SessionType } from "openim-uniapp-polyfill";
import MyAvatar from "@/components/MyAvatar/index.vue";
export default {
name: "ChatingHeader",
components: {
MyAvatar,
},
props: {
},
data() {
return {
showMoreMember: false,
joinLock: false,
};
},
computed: {
...mapGetters([
"storeCurrentConversation",
"storeCurrentGroup",
"storeCurrentMemberInGroup",
"storeSelfInfo",
]),
isSingle() {
return (
this.storeCurrentConversation.conversationType === SessionType.Single
);
},
isNotify() {
return (
this.storeCurrentConversation.conversationType ===
SessionType.Notification
);
},
groupMemberCount() {
return `(${this.storeCurrentGroup?.memberCount ?? 0})`;
},
canGoSetting() {
if (this.isSingle) {
return true;
}
return (
this.storeCurrentMemberInGroup.groupID ===
this.storeCurrentConversation.groupID
);
},
},
methods: {
click(e) {
this.$emit("click", e);
},
routeBack() {
uni.switchTab({
url: "/pages/conversation/conversationList/index",
});
},
goSetting() {
const url = this.isSingle
? "/pages/conversation/singleSettings/index"
: "/pages/conversation/groupSettings/index";
uni.navigateTo({
url,
});
},
},
};
</script>
<style lang="scss" scoped>
.chating_header {
border: 2rpx solid #e8eaef;
/deep/ .u-navbar__content__left {
padding: 0;
}
.back_icon {
padding: 24rpx;
margin-left: 20rpx;
}
.chating_info {
@include vCenterBox();
flex-direction: column;
&_single {
margin-bottom: 24rpx;
}
.conversation_info {
flex-direction: row;
justify-content: center;
@include vCenterBox();
.title {
@include nomalEllipsis();
max-width: 280rpx;
font-size: 14px;
font-weight: 500;
}
.sub_title {
margin-left: 8rpx;
}
}
.online_state {
@include vCenterBox();
flex-direction: row;
margin-top: 6rpx;
// position: absolute;
// top: 2px;
// left: 50%;
// transform: translateX(-50%);
font-size: 20rpx;
color: #999;
.dot {
background-color: #10cc64;
width: 12rpx;
height: 12rpx;
border-radius: 50%;
margin-right: 12rpx;
}
.online_str {
@include nomalEllipsis();
max-width: 280rpx;
}
}
}
/deep/ .u-navbar__content__right {
padding: 0;
}
.right_action {
@include vCenterBox();
flex-direction: row;
margin-right: 24rpx;
.action_item {
padding: 12rpx;
}
.u-icon {
margin-left: 12rpx;
}
}
}
.group_announcement_tab {
display: flex;
flex-direction: column;
align-items: flex-start;
width: 80%;
position: absolute;
left: 6%;
// bottom: -44px;
margin-top: 40rpx;
padding: 14rpx 32rpx;
background-color: #f0f6ff;
border-radius: 12rpx;
.announcement_header {
@include vCenterBox();
width: 100%;
flex-direction: row;
justify-content: space-between;
margin-bottom: 16rpx;
&_left {
@include vCenterBox();
}
}
.announcement_content {
@include ellipsisWithLine(2);
margin: 0 12rpx;
font-size: 24rpx;
color: #617183;
}
image {
width: 16px;
height: 16px;
min-width: 16px;
}
}
.group_calling_tab {
position: absolute;
left: 0;
width: 80%;
margin-top: 12px;
margin-left: 5%;
padding: 24rpx;
background-color: #f4f9ff;
border-radius: 8rpx;
color: #5496eb;
font-size: 24rpx;
.base_row {
display: flex;
align-items: center;
image {
width: 10px;
height: 10px;
}
text {
margin-left: 16rpx;
}
.arrow {
width: 9px;
height: 6px;
position: absolute;
right: 24rpx;
}
}
.member_row {
display: flex;
// justify-content: space-between;
flex-wrap: wrap;
padding: 24rpx 28rpx;
margin-top: 24rpx;
background-color: #fff;
border-bottom: 1px solid rgba(151, 151, 151, 0.16);
border-top-left-radius: 8rpx;
border-top-right-radius: 8rpx;
.u-avatar {
margin-bottom: 16rpx;
&:not(:nth-child(6n)) {
margin-right: calc(6% / 2);
}
}
}
.action_row {
display: flex;
justify-content: center;
padding: 24rpx;
background-color: #fff;
font-size: 28rpx;
border-bottom-left-radius: 8rpx;
border-bottom-right-radius: 8rpx;
}
}
</style>

View File

@@ -0,0 +1,256 @@
<template>
<scroll-view
:scroll-with-animation="withAnimation"
@click="click"
id="scroll_view"
:style="{
height: '1px'
}"
@scroll="throttleScroll"
:scroll-top="scrollTop"
scroll-y
:scroll-into-view="scrollIntoView"
upper-threshold="250"
@scrolltoupper="scrolltoupper"
>
<view id="scroll_wrap">
<u-loadmore nomoreText="" :status="loadMoreStatus" />
<view
v-for="item in storeHistoryMessageList"
:key="item.clientMsgID"
>
<message-item-render
@messageItemRender="messageItemRender"
:source="item"
:isSender="item.sendID === storeCurrentUserID"
/>
</view>
<view
style="visibility: hidden; height: 12px"
id="auchormessage_bottom_item"
></view>
</view>
</scroll-view>
</template>
<script>
import { mapGetters, mapActions } from "vuex";
import MessageItemRender from "./MessageItem/index.vue";
export default {
name: "",
components: {
MessageItemRender,
},
props: {},
data() {
return {
scrollIntoView: "",
scrollWithAnimation: false,
scrollTop: 0,
old: {
scrollTop: 0
},
initFlag: true,
isOverflow: false,
needScoll: true,
withAnimation: false,
messageLoadState: {
loading: false,
},
};
},
computed: {
...mapGetters([
"storeCurrentConversation",
"storeHistoryMessageList",
"storeHasMoreMessage",
"storeCurrentUserID",
"storeSelfInfo",
]),
loadMoreStatus() {
if (!this.storeHasMoreMessage) {
return "nomore";
}
return this.messageLoadState.loading ? "loading" : "loadmore";
},
},
mounted() {
this.loadMessageList();
},
methods: {
...mapActions("message", ["getHistoryMesageList"]),
messageItemRender(clientMsgID) {
if (
this.initFlag &&
clientMsgID ===
this.storeHistoryMessageList[this.storeHistoryMessageList.length - 1]
.clientMsgID
) {
this.initFlag = false;
setTimeout(() => this.scrollToBottom(true), 200);
this.checkInitHeight();
}
},
async loadMessageList(isLoadMore = false) {
this.messageLoadState.loading = true;
const lastMsgID = this.storeHistoryMessageList[0]?.clientMsgID;
const options = {
conversationID: this.storeCurrentConversation.conversationID,
count: 20,
startClientMsgID: this.storeHistoryMessageList[0]?.clientMsgID ?? "",
viewType: 0,
};
try {
const { emptyFlag } =
await this.getHistoryMesageList(options);
if (emptyFlag) {
this.$emit("initSuccess");
}
} catch (e) {
console.log(e);
//TODO handle the exception
}
this.$nextTick(function () {
if (isLoadMore && lastMsgID) {
this.scrollToAnchor(`auchor${lastMsgID}`);
}
this.messageLoadState.loading = false;
});
},
click(e) {
this.$emit("click", e);
},
onScroll(event) {
const { scrollHeight, scrollTop } = event.target;
this.old.scrollTop = scrollTop
this.needScoll =
scrollHeight - scrollTop < uni.getWindowInfo().windowHeight * 1.2;
},
throttleScroll(event) {
uni.$u.throttle(() => this.onScroll(event), 150);
},
scrolltoupper() {
if (!this.messageLoadState.loading && this.storeHasMoreMessage) {
this.loadMessageList(true);
}
},
scrollToBottom(isInit = false, isRecv = false) {
if (isRecv && !this.needScoll) {
return;
}
if (!isInit) {
this.withAnimation = true;
setTimeout(() => (this.withAnimation = false), 100);
}
this.$nextTick(() => {
uni
.createSelectorQuery()
.in(this)
.select("#scroll_wrap")
.boundingClientRect((res) => {
// let top = res.height - this.scrollViewHeight;
// if (top > 0) {
this.scrollTop = this.old.scrollTop
this.$nextTick(() => this.scrollTop = res.height);
if (isInit) {
this.$emit("initSuccess");
}
// }
})
.exec();
});
},
scrollToAnchor(auchor) {
this.$nextTick(function () {
this.scrollIntoView = auchor;
});
},
checkInitHeight() {
this.getEl("#scroll_view").then(({ height }) => {
this.bgHeight = `${height}px`;
});
},
getEl(el) {
return new Promise((resolve) => {
const query = uni.createSelectorQuery().in(this);
query
.select(el)
.boundingClientRect((data) => {
resolve(data);
})
.exec();
});
},
},
};
</script>
<style lang="scss" scoped>
#scroll_view {
flex: 1;
background-repeat: no-repeat;
position: relative;
}
.watermark-view {
width: 100%;
height: 100%;
position: fixed;
}
.watermark {
font-size: 16px; /* 水印文字大小 */
color: #f0f2f6; /* 水印文字颜色,使用透明度控制可见度 */
position: absolute; /* 水印相对定位 */
transform: rotate(-45deg);
pointer-events: none; /* 防止水印文字干扰交互 */
}
.uni-scroll-view {
position: relative;
}
.new_message_flag {
position: sticky;
background: #ffffff;
box-shadow: 0px 3px 8px 0px rgba(0, 0, 0, 0.1);
border-radius: 14px;
padding: 4px 8px;
display: flex;
justify-content: center;
align-items: center;
bottom: 12px;
left: 50%;
transform: translateX(-50%);
width: fit-content;
font-size: 24rpx;
color: #006aff;
}
.time_gap_line {
position: relative;
padding: 0 10vw 12rpx;
text-align: center;
// font-size: 24rpx;
font-size: 0.93rem;
color: #999;
}
.fade-leave,
.fade-enter-to {
opacity: 1;
}
.fade-leave-active,
.fade-enter-active {
transition: all 0.3s;
}
.fade-leave-to,
.fade-enter {
opacity: 0;
}
</style>

View File

@@ -0,0 +1,17 @@
<template>
<view class="text_message_container bg_container">
<view> [暂未支持的消息类型] </view>
</view>
</template>
<script>
export default {
name: "ErrorMessagegRender",
components: {},
data() {
return {};
},
};
</script>
<style lang="scss" scoped></style>

View File

@@ -0,0 +1,81 @@
<template>
<view class="media_message_container" @click="clickMediaItem">
<u--image
@load="onLoaded"
:showLoading="true"
width="120"
:height="maxHeight"
mode="widthFix"
:src="getImgUrl"
@click="clickMediaItem"
>
<template v-slot:loading>
<u-loading-icon color="red"></u-loading-icon>
</template>
</u--image>
</view>
</template>
<script>
export default {
name: "",
props: {
message: Object,
},
data() {
return {
loadingWidth: "120px",
};
},
computed: {
getImgUrl() {
return (
this.message.pictureElem.snapshotPicture?.url ??
this.message.pictureElem.sourcePath
);
},
maxHeight() {
const imageHeight = this.message.pictureElem.sourcePicture.height;
const imageWidth = this.message.pictureElem.sourcePicture.width;
const aspectRatio = imageHeight / imageWidth;
return 120 * aspectRatio;
},
},
methods: {
clickMediaItem() {
uni.previewImage({
current: 0,
urls: [this.message.pictureElem.sourcePicture.url],
indicator: "none",
});
},
onLoaded() {
this.loadingWidth = "auto";
},
},
};
</script>
<style lang="scss" scoped>
.media_message_container {
position: relative;
border-radius: 16rpx;
overflow: hidden;
.play_icon {
width: 48px;
height: 48px;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
.video_duration {
position: absolute;
bottom: 12rpx;
right: 24rpx;
color: #fff;
}
}
</style>

View File

@@ -0,0 +1,35 @@
<template>
<view class="text_message_container bg_container">
<mp-html
:previewImg="false"
:showImgMenu="false"
:lazyLoad="false"
:content="getContent"
/>
</view>
</template>
<script>
import { parseBr } from "@/util/common";
export default {
name: "TextMessageRender",
components: {},
props: {
message: Object,
},
computed: {
getContent() {
return parseBr(this.message.textElem?.content);
},
},
data() {
return {};
},
methods: {
},
};
</script>
<style lang="scss" scoped></style>

View File

@@ -0,0 +1,311 @@
<template>
<view
v-if="!getNoticeContent"
:id="`auchor${source.clientMsgID}`"
class="message_item"
:class="{ message_item_self: isSender, message_item_active: isActive }"
>
<my-avatar
size="42"
:desc="source.senderNickname"
:src="source.senderFaceUrl"
/>
<view class="message_container">
<view
class="message_sender"
:style="{ 'flex-direction': !isSender ? 'row-reverse' : 'row' }"
>
<text>{{ formattedMessageTime }}</text>
<text style="margin-left: 2rpx; margin-right: 2rpx">{{ "" }}</text>
<text v-if="!isSingle">{{ source.senderNickname }}</text>
</view>
<view class="message_send_state_box">
<view
style="
height: 100%;
display: flex;
justify-items: center;
align-items: center;
"
>
<view class="message_send_state">
<u-loading-icon v-if="showSending && !isPreview" />
<image
v-if="isFailedMessage && !isPreview"
src="@/static/images/chating_message_failed.png"
/>
</view>
</view>
<view class="message_content_wrap message_content_wrap_shadow">
<text-message-render
v-if="showTextRender"
:message="source"
/>
<media-message-render v-else-if="showMediaRender" :message="source" />
<error-message-render v-else />
</view>
</view>
</view>
</view>
<view
v-else
class="notice_message_container"
:id="`auchor${source.clientMsgID}`"
>
<text>{{ getNoticeContent }}</text>
</view>
</template>
<script>
import { mapGetters } from "vuex";
import {
MessageStatus,
MessageType,
SessionType,
} from "openim-uniapp-polyfill";
import MyAvatar from "@/components/MyAvatar/index.vue";
import TextMessageRender from "./TextMessageRender.vue";
import MediaMessageRender from "./MediaMessageRender.vue";
import ErrorMessageRender from "./ErrorMessageRender.vue";
import { noticeMessageTypes } from "@/constant";
import { tipMessaggeFormat, formatMessageTime } from "@/util/imCommon";
const textRenderTypes = [MessageType.TextMessage];
const mediaRenderTypes = [MessageType.PictureMessage];
export default {
components: {
MyAvatar,
TextMessageRender,
MediaMessageRender,
ErrorMessageRender,
},
props: {
source: Object,
isSender: {
type: Boolean,
default: false,
},
isPreview: Boolean,
isActive: Boolean,
},
data() {
return {};
},
computed: {
...mapGetters([
"storeCurrentConversation",
"storeSelfInfo",
]),
isSingle() {
return (
this.storeCurrentConversation.conversationType === SessionType.Single
);
},
formattedMessageTime() {
return formatMessageTime(this.source.sendTime);
},
showTextRender() {
return textRenderTypes.includes(this.source.contentType);
},
showMediaRender() {
return mediaRenderTypes.includes(this.source.contentType);
},
getNoticeContent() {
const isNoticeMessage = noticeMessageTypes.includes(
this.source.contentType
);
return !isNoticeMessage
? ""
: tipMessaggeFormat(
this.source,
this.$store.getters.storeCurrentUserID
);
},
isSuccessMessage() {
return this.source.status === MessageStatus.Succeed;
},
isFailedMessage() {
return this.source.status === MessageStatus.Failed;
},
showSending() {
return this.source.status === MessageStatus.Sending && !this.sendingDelay;
},
},
mounted() {
this.$emit("messageItemRender", this.source.clientMsgID);
this.setSendingDelay();
},
methods: {
setSendingDelay() {
if (this.source.status === MessageStatus.Sending) {
setTimeout(() => {
this.sendingDelay = false;
}, 2000);
}
},
},
};
</script>
<style scoped lang="scss">
.message_item {
display: flex;
flex-direction: row;
padding: 16rpx 44rpx;
// padding-top: 48rpx;
position: relative;
.check_wrap {
@include centerBox();
box-sizing: border-box;
width: 40rpx;
min-width: 40rpx;
height: 40rpx;
min-height: 40rpx;
border: 2px solid #979797;
border-radius: 50%;
margin-top: 16rpx;
margin-right: 24rpx;
&_active {
background-color: #1d6bed;
border: none;
}
&_disabled {
background-color: #c8c9cc;
}
}
.message_container {
display: flex;
flex-direction: column;
align-items: flex-start;
margin-left: 20rpx;
// text-align: start;
max-width: 80%;
position: relative;
.message_sender {
@include nomalEllipsis();
display: flex;
max-width: 480rpx;
// font-size: 24rpx;
font-size: 0.85rem;
color: #666;
margin-bottom: 6rpx;
}
.message_content_wrap {
@include vCenterBox();
text-align: start;
// font-size: 14px;
color: $uni-text-color;
width: fit-content;
max-width: 100%;
.bg_container {
padding: 16rpx 24rpx;
border-radius: 0rpx 12rpx 12rpx 12rpx;
background-color: #f0f0f0;
}
}
}
.message_send_state_box {
display: flex;
flex-direction: row-reverse;
}
.message_send_state {
@include centerBox();
margin-left: 12rpx;
// margin-top: 48rpx;
width: 48rpx;
height: 48rpx;
.read_limit_count {
// font-size: 24rpx;
font-size: 0.85rem;
color: #999;
}
image {
width: 16px;
height: 16px;
}
}
/deep/.emoji_display {
width: 24px;
height: 18px;
vertical-align: sub;
}
&_self {
flex-direction: row-reverse;
.check_wrap {
margin-right: 0;
margin-left: 24rpx;
}
.message_container {
margin-left: 0;
margin-right: 20rpx;
// text-align: end;
align-items: flex-end;
.message_content_wrap {
flex-direction: row-reverse;
.bg_container {
border-radius: 12rpx 0 12rpx 12rpx;
background-color: #dcebfe !important;
}
}
}
.message_send_state_box {
flex-direction: row;
}
.message_send_state {
margin-left: 0rpx;
margin-right: 12rpx;
}
}
&_active {
background-color: #fdf5e9;
}
}
.notice_message_container {
@include ellipsisWithLine(2);
text-align: center;
margin: 24rpx 48rpx;
// font-size: 24rpx;
font-size: 0.85rem;
color: #999;
position: relative;
}
.fade-leave,
.fade-enter-to {
opacity: 1;
}
.fade-leave-active,
.fade-enter-active {
transition: all 0.5s;
}
.fade-leave-to,
.fade-enter {
opacity: 0;
}
</style>

View File

@@ -0,0 +1,151 @@
<template>
<view :style="{ backgroundColor: '#f8f8f8' }" class="chating_container">
<chating-header
@click="pageClick"
ref="chatingHeaderRef"
/>
<chating-list
@click="pageClick"
ref="chatingListRef"
@initSuccess="initSuccess"
/>
<chating-footer
ref="chatingFooterRef"
:footerOutsideFlag="footerOutsideFlag"
@scrollToBottom="scrollToBottom"
/>
<u-loading-page :loading="initLoading"></u-loading-page>
</view>
</template>
<script>
import { mapActions } from "vuex";
import {
PageEvents,
} from "@/constant";
import ChatingHeader from "./components/ChatingHeader.vue";
import ChatingFooter from "./components/ChatingFooter/index.vue";
import ChatingList from "./components/ChatingList.vue";
import { markConversationAsRead } from "@/util/imCommon";
export default {
components: {
ChatingHeader,
ChatingFooter,
ChatingList,
},
data() {
return {
listHeight: 0,
footerOutsideFlag: 0,
initLoading: true,
back2Tab: false,
};
},
onLoad(options) {
console.log("onload");
this.setPageListener();
if (options?.back2Tab) {
this.back2Tab = JSON.parse(options.back2Tab);
}
},
onUnload() {
console.log("unload");
this.disposePageListener();
markConversationAsRead(
{
...this.$store.getters.storeCurrentConversation,
},
true
);
this.resetConversationState();
this.resetMessageState();
},
methods: {
...mapActions("message", ["resetMessageState", "deleteMessages"]),
...mapActions("conversation", ["resetConversationState"]),
scrollToBottom(isRecv = false) {
this.$refs.chatingListRef.scrollToBottom(false, isRecv);
},
pageClick(e) {
this.footerOutsideFlag += 1;
},
initSuccess() {
console.log("initSuccess");
this.initLoading = false;
},
// page event
setPageListener() {
uni.$on(PageEvents.ScrollToBottom, this.scrollToBottom);
},
disposePageListener() {
uni.$off(PageEvents.ScrollToBottom, this.scrollToBottom);
},
},
onBackPress() {
uni.switchTab({
url: "/pages/conversation/conversationList/index",
});
return true;
},
beforeDestroy() {
uni.switchTab({
url: "/pages/conversation/conversationList/index",
});
},
};
</script>
<style lang="scss" scoped>
.chating_container {
@include colBox(false);
height: 100vh;
overflow: hidden;
background-color: #fff !important;
position: relative;
.watermark {
font-size: 16px; /* 水印文字大小 */
color: rgba(0, 0, 0, 0.2); /* 水印文字颜色,使用透明度控制可见度 */
position: absolute; /* 水印相对定位 */
transform: rotate(-45deg);
pointer-events: none; /* 防止水印文字干扰交互 */
/* 为不同的水印元素设置不同的偏移,以避免重叠 */
// transform-origin: top right;
// margin-top: 20px;
// margin-right: 20px;
}
// ::before {
// content: "Your Watermark Text"; /* 替换为你想要的水印文字 */
// font-size: 16px; /* 水印文字大小 */
// color: rgba(0, 0, 0, 0.2); /* 水印文字颜色,使用透明度控制可见度 */
// position: absolute; /* 水印相对定位 */
// top: 20px; /* 距离顶部的距离 */
// right: 20px; /* 距离右侧的距离 */
// transform: rotate(-45deg); /* 将水印旋转为倾斜状态 */
// pointer-events: none; /* 防止水印文字干扰交互 */
// z-index: -1; /* 将水印置于底层 */
// }
.mutiple_action_container {
display: flex;
border-top: 1px solid #eaebed;
background: #f0f2f6;
justify-content: space-evenly;
padding: 12px 24px;
.action_item {
@include centerBox();
flex-direction: column;
image {
width: 48px;
height: 48px;
}
}
}
}
</style>

View File

@@ -0,0 +1,329 @@
<template>
<view class="chat_header">
<view class="self_info">
<my-avatar
:src="storeSelfInfo.faceURL"
:desc="storeSelfInfo.nickname"
size="46"
/>
<view class="self_info_desc">
<view class="user_state">
<text class="nickname">{{ storeSelfInfo.nickname }}</text>
<view v-if="!storeReinstall">
<view class="tag" v-if="storeIsSyncing">
<img
class="loading"
style="height: 24rpx; width: 24rpx"
src="static/images/loading.png"
alt=""
/>
<text class="status">同步中</text>
</view>
<view class="tag" v-if="connectStart == 0">
<img
class="loading"
style="height: 24rpx; width: 24rpx"
src="static/images/loading.png"
alt=""
/>
<text class="status">连接中</text>
</view>
<view class="err-tag" v-if="connectStart == -1">
<img
style="height: 24rpx; width: 24rpx"
src="static/images/sync_error.png"
alt=""
/>
<text class="status">连接失败</text>
</view>
</view>
</view>
</view>
</view>
<view class="right_action">
<view class="call_icon"> </view>
<view @click="showMore" class="more_icon">
<image src="@/static/images/common_circle_add.png"></image>
</view>
<u-overlay
:show="moreMenuVisible"
@click="moreMenuVisible = false"
opacity="0"
>
<view
:style="{ top: popMenuPosition.top, right: popMenuPosition.right }"
class="more_menu"
>
<view
@click="clickMenu(item)"
v-for="item in moreMenus"
:key="item.idx"
class="menu_item"
>
<image :src="item.icon" mode=""></image>
<text>{{ item.title }}</text>
</view>
</view>
</u-overlay>
</view>
</view>
</template>
<script>
import { mapGetters } from "vuex";
import MyAvatar from "@/components/MyAvatar/index.vue";
import IMSDK from "openim-uniapp-polyfill";
export default {
name: "ChatHeader",
components: {
MyAvatar,
},
props: {},
data() {
return {
connectStart: -2,
moreMenuVisible: false,
popMenuPosition: {
top: 0,
right: 0,
},
moreMenus: [
{
idx: 1,
title: "添加好友",
icon: require("static/images/more_add_friend.png"),
},
{
idx: 2,
title: "添加群聊",
icon: require("static/images/more_add_group.png"),
},
{
idx: 3,
title: "创建群聊",
icon: require("static/images/more_create_group.png"),
},
],
};
},
computed: {
...mapGetters(["storeSelfInfo", "storeIsSyncing", "storeReinstall"]),
},
mounted() {
this.subscribeAll();
},
beforeDestroy() {
this.unsubscribeAll();
},
methods: {
setStateStart() {
this.connectStart = 0;
},
setStateSuccess() {
this.connectStart = 1;
},
setStateError() {
this.connectStart = -1;
},
subscribeAll() {
IMSDK.subscribe(IMSDK.IMEvents.OnConnecting, this.setStateStart);
IMSDK.subscribe(IMSDK.IMEvents.OnConnectSuccess, this.setStateSuccess);
IMSDK.subscribe(IMSDK.IMEvents.OnConnectFailed, this.setStateError);
},
unsubscribeAll() {
IMSDK.unsubscribe(IMSDK.IMEvents.OnConnecting, this.setStateStart);
IMSDK.unsubscribe(IMSDK.IMEvents.OnConnectSuccess, this.setStateSuccess);
IMSDK.unsubscribe(IMSDK.IMEvents.OnConnectFailed, this.setStateError);
},
clickMenu({ idx }) {
switch (idx) {
case 1:
case 2:
uni.navigateTo({
url: `/pages/common/searchUserOrGroup/index?isSearchGroup=${
idx === 2
}`,
});
break;
case 3:
uni.navigateTo({
url: `/pages/common/createGroup/index`,
});
break;
default:
break;
}
},
async showMore() {
const { right, bottom } = await this.getEl(".more_icon");
this.popMenuPosition.right =
uni.getWindowInfo().windowWidth - right + "px";
this.popMenuPosition.top = bottom + "px";
this.moreMenuVisible = true;
},
getEl(el) {
return new Promise((resolve) => {
const query = uni.createSelectorQuery().in(this);
query
.select(el)
.boundingClientRect((data) => {
// 存在data且存在宽和高视为渲染完毕
resolve(data);
})
.exec();
});
},
},
};
</script>
<style lang="scss" scoped>
@keyframes loading {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
.chat_header {
@include btwBox();
padding: 36rpx 44rpx;
margin-top: var(--status-bar-height);
.self_info {
@include btwBox();
&_desc {
@include colBox(true);
margin-left: 24rpx;
color: $uni-text-color;
.company {
@include nomalEllipsis();
font-size: 24rpx;
margin-bottom: 10rpx;
max-width: 300rpx;
}
.user_state {
@include vCenterBox();
.nickname {
@include nomalEllipsis();
font-size: 26rpx;
max-width: 240rpx;
}
.err-tag {
display: flex;
justify-content: center;
align-items: center;
width: 152rpx;
height: 44rpx;
background: #ffe1dd;
border-radius: 12rpx 12rpx 12rpx 12rpx;
margin-left: 8rpx;
.status {
font-size: 24rpx;
margin-left: 8rpx;
font-weight: 400;
color: #ff381f;
}
}
.tag {
display: flex;
justify-content: center;
align-items: center;
width: 152rpx;
height: 44rpx;
background: #f2f8ff;
border-radius: 12rpx 12rpx 12rpx 12rpx;
margin-left: 8rpx;
.loading {
animation: loading 1.5s infinite;
}
.status {
font-size: 24rpx;
margin-left: 8rpx;
font-weight: 400;
color: #0089ff;
}
}
.online_state {
@include vCenterBox();
margin-left: 24rpx;
font-size: 24rpx;
.dot {
background-color: #10cc64;
width: 12rpx;
height: 12rpx;
border-radius: 50%;
margin-right: 12rpx;
}
}
}
}
}
.right_action {
display: flex;
position: relative;
.call_icon {
margin-right: 24rpx;
image {
width: 56rpx;
height: 56rpx;
}
}
.more_icon {
image {
width: 56rpx;
height: 56rpx;
}
}
.more_menu {
position: absolute;
// bottom: 0;
// left: 100%;
z-index: 999;
// transform: translate(-100%, 100%);
box-shadow: 0px 0px 6px 2px rgba(0, 0, 0, 0.16);
width: max-content;
border-radius: 12rpx;
background-color: #fff;
.menu_item {
display: flex;
justify-content: flex-start;
align-items: center;
padding: 20rpx 24rpx;
font-size: 28rpx;
color: $uni-text-color;
border-bottom: 1px solid #f0f0f0;
image {
width: 24px;
height: 24px;
margin-right: 24rpx;
}
&:last-child {
border: none;
}
}
}
}
}
</style>

View File

@@ -0,0 +1,161 @@
<template>
<view @tap.prevent="clickConversationItem" class="conversation_item">
<view class="pinned" v-if="source.isPinned"></view>
<view class="left_info">
<my-avatar
:isGroup="isGroup"
:isNotify="isNotify"
:src="source.faceURL"
:desc="source.showName"
size="46"
/>
<view class="details">
<text class="conversation_name">{{ source.showName }}</text>
<view class="lastest_msg_wrap">
<text class="lastest_msg_content">{{ latestMessage }}</text>
</view>
</view>
</view>
<view class="right_desc">
<text class="send_time">{{ latestMessageTime }}</text>
<u-badge max="99" :value="source.unreadCount"></u-badge>
</view>
</view>
</template>
<script>
import {
SessionType,
} from "openim-uniapp-polyfill";
import MyAvatar from "@/components/MyAvatar/index.vue";
import UParse from "@/components/gaoyia-parse/parse.vue";
import {
getConversationContent,
formatConversionTime,
prepareConversationState,
} from "@/util/imCommon";
export default {
components: {
MyAvatar,
UParse,
},
props: {
source: {
type: Object,
default: () => {},
},
},
computed: {
latestMessage() {
if (this.source.latestMsg === "") return "";
let parsedMessage;
try {
parsedMessage = JSON.parse(this.source.latestMsg);
} catch (e) {}
if (!parsedMessage) return "";
return getConversationContent(parsedMessage);
},
latestMessageTime() {
return this.source.latestMsgSendTime
? formatConversionTime(this.source.latestMsgSendTime)
: "";
},
isGroup() {
return this.source.conversationType === SessionType.WorkingGroup;
},
isNotify() {
return this.source.conversationType === SessionType.Notification;
},
},
data() {
return {};
},
methods: {
clickConversationItem() {
console.log(this.source);
prepareConversationState(this.source);
},
},
};
</script>
<style lang="scss" scoped>
.conversation_item {
@include btwBox();
flex-direction: row;
padding: 12rpx 44rpx 20rpx;
position: relative;
&_active {
background-color: #f3f3f3;
}
.left_info {
@include btwBox();
.details {
@include colBox(true);
margin-left: 24rpx;
height: 46px;
color: $uni-text-color;
.conversation_name {
@include nomalEllipsis();
max-width: 40vw;
font-size: 28rpx;
}
.lastest_msg_wrap {
display: flex;
font-size: 24rpx;
margin-top: 10rpx;
color: #666;
.lastest_msg_prefix {
margin-right: 6rpx;
&_active {
color: $u-primary;
}
}
.lastest_msg_content {
flex: 1;
margin-right: 160rpx;
// /deep/uni-view {
@include ellipsisWithLine(1);
// }
}
}
}
}
.right_desc {
@include colBox(true);
align-items: flex-end;
width: max-content;
justify-content: space-between;
height: 46px;
.send_time {
width: max-content;
font-size: 24rpx;
color: #999;
}
.u-badge {
width: fit-content;
}
}
.pinned {
position: absolute;
top: 0;
right: 24rpx;
width: 17rpx;
height: 17rpx;
background-image: linear-gradient(to bottom left, #314ffe 50%, white 50%);
}
}
</style>

View File

@@ -0,0 +1,132 @@
<template>
<view class="conversation_container">
<chat-header ref="chatHeaderRef" />
<scroll-view
class="scroll-view"
scroll-y="true"
refresher-enabled="true"
:refresher-triggered="triggered"
:scroll-top="scrollTop"
:scroll-with-animation="true"
@scroll="scroll"
@refresherrefresh="onRefresh"
@refresherrestore="onRestore"
@scrolltolower="scrolltolower"
>
<conversation-item
v-for="item in storeConversationList"
:key="item.conversationID"
:source="item"
ref="conversationItem"
/>
</scroll-view>
<view class="loading_wrap" v-if="storeProgress > 0 && storeProgress < 100">
<u-loading-icon
:vertical="true"
:text="storeProgress + '%'"
></u-loading-icon>
</view>
</view>
</template>
<script>
import { mapGetters } from "vuex";
import ChatHeader from "./components/ChatHeader.vue";
import ConversationItem from "./components/ConversationItem.vue";
export default {
components: {
ChatHeader,
ConversationItem,
},
data() {
return {
scrollTop: 0,
old: {
scrollTop: 0,
},
doubleClick: 0,
triggered: false,
refreshing: false,
};
},
computed: {
...mapGetters(["storeConversationList", "storeIsSyncing", "storeProgress"]),
},
onReady() {
this.$nextTick(() => plus.navigator.closeSplashscreen());
},
onLoad() {
this._freshing = false;
this.triggered = true;
},
methods: {
scroll(e) {
this.old.scrollTop = e.detail.scrollTop;
},
onRefresh() {
if (this._freshing) return;
this._freshing = true;
this.queryList(true);
},
onRestore() {
this.triggered = "restore";
console.log("onRestore");
},
scrolltolower() {
this.queryList();
},
async queryList(isFirstPage = false) {
await this.$store.dispatch(
"conversation/getConversationList",
isFirstPage
);
this.triggered = false;
this._freshing = false;
},
closeAllSwipe() {
this.$refs.swipeWrapperRef.closeAll();
},
},
};
</script>
<style lang="scss" scoped>
.conversation_container {
@include colBox(false);
height: 100vh;
overflow-y: hidden;
}
.conversation_search {
padding: 0 44rpx 24rpx;
}
.z-paging-content {
flex: 1;
}
.swipe_wrapper {
@include colBox(false);
flex: 1;
width: 100%;
overflow-y: auto;
}
.scroll-view {
height: 0;
flex: 1;
}
.loading_wrap {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
/deep/.u-swipe-action-item__right__button__wrapper__text {
-webkit-line-clamp: 2 !important;
max-width: 32px;
}
</style>

View File

@@ -0,0 +1,57 @@
<template>
<view class="group_settings_container">
<custom-nav-bar title="群管理" />
<view class="setting_row">
<setting-item
@click="toTransfer"
title="群主管理权转让"
:border="false"
/>
</view>
</view>
</template>
<script>
import { mapGetters } from "vuex";
import { GroupMemberListTypes } from "@/constant";
import CustomNavBar from "@/components/CustomNavBar/index.vue";
import SettingItem from "@/components/SettingItem/index.vue";
export default {
components: {
CustomNavBar,
SettingItem,
},
data() {
return {};
},
computed: {
...mapGetters([
"storeCurrentConversation",
"storeCurrentMemberInGroup",
"storeCurrentGroup",
]),
},
methods: {
toTransfer() {
uni.navigateTo({
url: `/pages/conversation/groupMemberList/index?type=${GroupMemberListTypes.Transfer}&groupID=${this.storeCurrentGroup.groupID}`,
});
},
},
};
</script>
<style lang="scss" scoped>
.group_settings_container {
@include colBox(false);
height: 100vh;
background-color: #f6f6f6;
.setting_row {
background-color: #fff;
margin: 24rpx 24rpx 0;
border-radius: 6px;
overflow: hidden;
}
}
</style>

View File

@@ -0,0 +1,126 @@
<template>
<custom-nav-bar @leftClick="leftClick" :title="getTitle">
</custom-nav-bar>
</template>
<script>
import CustomNavBar from "@/components/CustomNavBar/index.vue";
import { ContactChooseTypes } from "@/constant";
export default {
name: "",
components: {
CustomNavBar,
},
props: {
checkVisible: {
type: Boolean,
default: false,
},
isNomal: {
type: Boolean,
default: false,
},
isTransfer: {
type: Boolean,
default: false,
},
isAt: {
type: Boolean,
default: false,
},
isSetAdmin: {
type: Boolean,
default: false,
},
isMute: {
type: Boolean,
default: false,
},
isCall: {
type: Boolean,
default: false,
},
groupID: String,
},
data() {
return {
moreMenuVisible: false,
};
},
computed: {
getTitle() {
if (this.isCall) {
return "邀请成员";
}
if (this.isAt) {
return "选择提醒的人";
}
if (this.isSetAdmin) {
return "设置管理员";
}
if (this.isMute) {
return "禁言成员";
}
if (this.checkVisible) {
return "移除群成员";
}
return "群成员";
},
},
methods: {
leftClick() {
if (this.checkVisible) {
this.$emit("update:checkVisible", false);
}
},
rightClick() {
this.moreMenuVisible = true;
},
checkMenu() {
if (this.moreMenuVisible) {
this.moreMenuVisible = false;
}
},
inviteMember() {
uni.navigateTo({
url: `/pages/common/contactChoose/index?type=${ContactChooseTypes.Invite}&groupID=${this.groupID}`,
});
},
removeMember() {
this.$emit("removeMember");
},
},
};
</script>
<style lang="scss">
.more_container {
position: relative;
.more_dot {
padding: 24rpx;
margin-right: 20rpx;
}
.more_menu {
position: absolute;
bottom: 0;
left: 50%;
transform: translate(-100%, 100%);
box-shadow: 0px 0px 6px 2px rgba(0, 0, 0, 0.16);
width: max-content;
border-radius: 8rpx;
background-color: #fff;
.menu_item {
padding: 20rpx 48rpx;
font-size: 28rpx;
color: $uni-text-color;
// &:nth-child(1) {
// border-bottom: 1px solid #F0F0F0;
// }
}
}
}
</style>

View File

@@ -0,0 +1,314 @@
<template>
<view @click="pageClick" class="group_members_container">
<group-member-list-header
ref="navHeaderRef"
:checkVisible.sync="showCheck"
:isTransfer="isTransfer"
:isNomal="!isOwner && !isAdmin"
:groupID="groupID"
@removeMember="showMemberCheck"
/>
<view class="search_bar_wrap">
<u-search
disabled
class="search_bar"
shape="square"
placeholder="搜索"
:showAction="false"
v-model="keyword"
/>
</view>
<u-list
class="member_list"
@scrolltolower="loadMore"
lowerThreshold="100"
height="1"
>
<u-list-item v-for="member in groupMemberList" :key="member.userID">
<user-item
@itemClick="userClick"
@updateCheck="updateCheck"
:checked="isChecked(member.userID)"
:checkVisible="showCheck"
:disabled="!canCheck(member) && showCheck"
:item="member"
/>
</u-list-item>
<view
v-show="loadState.loading"
class="member_loading"
>
<u-loading-icon></u-loading-icon>
</view>
</u-list>
<choose-index-footer
v-if="showCheck"
:comfirmLoading="comfirmLoading"
@removeItem="updateCheck"
@confirm="confirm"
:choosedData="getChoosedData"
:isRemove="isRemove"
:maxLength="groupMemberLength"
/>
<u-modal
:show="showConfirmModal"
asyncClose
showCancelButton
@confirm="modalConfirm"
@cancel="() => (showConfirmModal = false)"
:content="
isRemove
? '确定移除已选群成员?'
: `确定要把群主转移给${choosedTransferMember.nickname}吗?`
"
/>
<u-toast ref="uToast"></u-toast>
</view>
</template>
<script>
let moreActionArea;
import { GroupMemberListTypes } from "@/constant";
import IMSDK, { GroupMemberRole } from "openim-uniapp-polyfill";
import UserItem from "@/components/UserItem/index.vue";
import GroupMemberListHeader from "./components/GroupMemberListHeader.vue";
import ChooseIndexFooter from "@/components/ChooseIndexFooter/index.vue";
export default {
components: {
GroupMemberListHeader,
ChooseIndexFooter,
UserItem,
},
data() {
return {
showCheck: false,
groupID: "",
keyword: "",
showConfirmModal: false,
comfirmLoading: false,
groupMemberList: [],
choosedMemberIDList: [],
choosedTransferMember: {},
type: GroupMemberListTypes.Preview,
isRightKick: true,
loadState: {
hasMore: true,
loading: false,
},
};
},
computed: {
getChoosedData() {
const tmpList = [...this.choosedMemberIDList];
return this.groupMemberList.filter(
(member) => {
const idx = tmpList.findIndex((item) => item === member.userID);
if (idx > -1) {
tmpList.splice(idx, 1);
}
return idx > -1;
},
);
},
isRemove() {
return this.type === GroupMemberListTypes.Kickout;
},
isTransfer() {
return this.type === GroupMemberListTypes.Transfer;
},
isChecked() {
return (userID) => this.choosedMemberIDList.includes(userID);
},
isOwner() {
return (
this.$store.getters.storeCurrentMemberInGroup.roleLevel ===
GroupMemberRole.Owner
);
},
isAdmin() {
return (
this.$store.getters.storeCurrentMemberInGroup.roleLevel ===
GroupMemberRole.Admin
);
},
canCheck() {
return ({ roleLevel, userID }) => {
if (this.type === GroupMemberListTypes.Kickout) {
return (
(this.isOwner ||
(this.isAdmin && roleLevel !== GroupMemberRole.Owner)) &&
userID !== this.$store.getters.storeCurrentUserID
);
}
return userID !== this.$store.getters.storeCurrentUserID;
};
},
groupMemberLength() {
return this.$store.getters.storeCurrentGroup?.memberCount ?? 0;
},
},
onLoad(options) {
const { groupID, type } = options;
this.loadMemberList(groupID);
this.type = type;
this.groupID = groupID;
this.isRightKick = type === GroupMemberListTypes.Kickout;
if (
this.isRightKick
) {
this.showCheck = true;
}
},
methods: {
async pageClick(e) {
if (!moreActionArea) {
moreActionArea = await this.getEl(".more_container");
}
if (!moreActionArea) return;
if (
e.target.y < moreActionArea.top ||
e.target.y > moreActionArea.bottom ||
e.target.x < moreActionArea.left
) {
this.$refs.navHeaderRef.checkMenu();
}
},
confirm() {
this.showConfirmModal = true;
},
modalConfirm() {
let func = () => {};
if (this.type === GroupMemberListTypes.Kickout) {
func = IMSDK.asyncApi(IMSDK.IMMethods.KickGroupMember, IMSDK.uuid(), {
groupID: this.getChoosedData[0].groupID,
reason: "",
userIDList: this.getChoosedData.map((member) => member.userID),
});
} else {
func = IMSDK.asyncApi(
IMSDK.IMMethods.TransferGroupOwner,
IMSDK.uuid(),
{
groupID: this.choosedTransferMember.groupID,
newOwnerUserID: this.choosedTransferMember.userID,
},
);
}
func
.then(() => this.showToast("操作成功", () => uni.navigateBack()))
.catch(() => this.showToast("操作失败"))
.finally(() => (this.showConfirmModal = false));
},
updateChoosedData(userID) {
if (this.choosedMemberIDList.includes(userID)) {
const idx = this.choosedMemberIDList.findIndex(
(item) => item === userID,
);
const tmpArr = [...this.choosedMemberIDList];
tmpArr.splice(idx, 1);
this.choosedMemberIDList = tmpArr;
} else {
this.choosedMemberIDList = [...this.choosedMemberIDList, userID];
}
console.log(this.choosedMemberIDList);
},
userClick(member) {
if (this.type === GroupMemberListTypes.Transfer) {
if (member.userID === this.$store.getters.storeCurrentUserID) return;
this.choosedTransferMember = member;
this.showConfirmModal = true;
} else {
uni.$u.route("/pages/common/userCard/index", {
sourceID: member.userID,
memberInfo: JSON.stringify(member),
});
}
},
updateCheck(member) {
this.updateChoosedData(member.userID);
},
showMemberCheck() {
this.type = GroupMemberListTypes.Kickout;
this.showCheck = true;
},
loadMore() {
const stateKey = "loadState";
const methodKey = "loadMemberList";
if (this[stateKey].hasMore && !this[stateKey].loading) {
this[methodKey]();
}
},
loadMemberList(groupID) {
this.loadState.loading = true;
IMSDK.asyncApi(IMSDK.IMMethods.GetGroupMemberList, IMSDK.uuid(), {
groupID: groupID ?? this.groupID,
filter: 0,
offset: this.groupMemberList.length,
count: 500,
})
.then(({ data }) => {
this.groupMemberList = [...this.groupMemberList, ...data];
this.loadState.hasMore = data.length === 500;
})
.finally(() => (this.loadState.loading = false));
},
showToast(message, complete = null) {
this.$refs.uToast.show({
message,
complete,
});
},
getEl(el) {
return new Promise((resolve) => {
const query = uni.createSelectorQuery().in(this);
query
.select(el)
.boundingClientRect((data) => {
// 存在data且存在宽和高视为渲染完毕
resolve(data);
})
.exec();
});
},
},
onBackPress(options) {
if (this.showCheck && this.isRightKick) {
this.showCheck = false;
this.type = GroupMemberListTypes.Preview;
return true;
}
return false;
},
};
</script>
<style lang="scss" scoped>
.group_members_container {
@include colBox(false);
height: 100vh;
overflow: hidden;
.search_bar_wrap {
height: 34px;
padding: 12px 22px;
}
.at_all_btn {
font-weight: 500;
padding: 24rpx 44rpx;
}
/deep/.u-popup {
flex: none;
}
.member_list {
flex: 1;
}
}
</style>

View File

@@ -0,0 +1,57 @@
<template>
<u-action-sheet
safeAreaInsetBottom
closeOnClickOverlay
@close="onClose"
@select="onSelect"
round="24"
:actions="joinGroupActions"
:show="visible"
cancelText="取消"
/>
</template>
<script>
import IMSDK, { GroupVerificationType } from "openim-uniapp-polyfill";
export default {
name: "",
components: {},
props: {
visible: Boolean,
groupID: String,
},
data() {
return {
joinGroupActions: [
{
name: "允许任何人加群",
type: GroupVerificationType.AllNot,
},
{
name: "群成员邀请无需验证",
type: GroupVerificationType.ApplyNeedInviteNot,
},
{
name: "需要发送验证消息",
type: GroupVerificationType.AllNeed,
},
],
};
},
methods: {
onClose() {
this.$emit("update:visible", false);
},
onSelect({ type }) {
IMSDK.asyncApi(IMSDK.IMMethods.SetGroupVerification, IMSDK.uuid(), {
groupID: this.groupID,
verification: type,
})
.then(() => uni.$u.toast("操作成功"))
.catch(() => uni.$u.toast("操作失败"));
},
},
};
</script>
<style lang="scss"></style>

View File

@@ -0,0 +1,171 @@
<template>
<view @click="toMemberList" class="member_row">
<!-- <view class="member_title">
<text>群成员</text>
<view class="member_desc">
<text>{{ `${memberCount}` }}</text>
<u-icon name="arrow-right" color="#999" size="16" />
</view>
</view> -->
<view class="member_list">
<view class="member_item" v-for="(member, index) in groupMemberList">
<my-avatar
:src="member.faceURL"
:desc="member.nickname"
:key="member.userID"
size="48"
/>
<view class="ower" v-if="member.roleLevel === 100">群主</view>
<text class="member_item_name">{{ member.nickname }}</text>
</view>
<view class="member_item">
<image
style="width: 48px; height: 48px; min-width: 48px"
@click.stop="inviteMember"
src="@/static/images/group_setting_invite.png"
alt=""
/>
<text class="member_item_name">增加</text>
</view>
<view class="member_item" v-if="isAdmin || isOwner">
<image
style="width: 48px; height: 48px; min-width: 48px"
@click.stop="kickMember"
src="@/static/images/group_setting_remove.png"
alt=""
/>
<text class="member_item_name">移出</text>
</view>
</view>
<view @click="toMemberList" class="more">
<text>查看全部群成员({{ memberCount }})</text>
<view class="more_right">
<u-icon name="arrow-right" color="#999" size="18" />
</view>
</view>
</view>
</template>
<script>
import { mapGetters } from "vuex";
import IMSDK, { GroupMemberRole } from "openim-uniapp-polyfill";
import MyAvatar from "@/components/MyAvatar/index.vue";
import SettingItem from "@/components/SettingItem/index.vue";
import { ContactChooseTypes, GroupMemberListTypes } from "@/constant";
export default {
name: "",
components: {
MyAvatar,
SettingItem,
},
props: {
isNomal: Boolean,
memberCount: Number,
groupID: String,
groupMemberList: Array,
},
data() {
return {};
},
computed: {
...mapGetters([
"storeCurrentConversation",
"storeCurrentMemberInGroup",
"storeCurrentGroup",
]),
isOwner() {
return this.storeCurrentMemberInGroup.roleLevel === GroupMemberRole.Owner;
},
isAdmin() {
return this.storeCurrentMemberInGroup.roleLevel === GroupMemberRole.Admin;
},
},
methods: {
toMemberList() {
uni.navigateTo({
url: `/pages/conversation/groupMemberList/index?type=${GroupMemberListTypes.Preview}&groupID=${this.groupID}`,
});
},
inviteMember() {
uni.navigateTo({
url: `/pages/common/contactChoose/index?type=${ContactChooseTypes.Invite}&groupID=${this.groupID}`,
});
},
kickMember() {
uni.navigateTo({
url: `/pages/conversation/groupMemberList/index?type=${GroupMemberListTypes.Kickout}&groupID=${this.groupID}`,
});
},
},
};
</script>
<style lang="scss" scoped>
.member_row {
@include colBox(false);
padding: 36rpx 36rpx 0;
margin: 24rpx;
background-color: #fff;
color: $uni-text-color;
border-radius: 6px;
overflow: hidden;
.member_title {
@include btwBox();
.member_desc {
@include vCenterBox();
font-size: 26rpx;
}
}
.member_list {
@include vCenterBox();
flex-wrap: wrap;
.member_item {
position: relative;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
margin: 8rpx 14rpx;
&_name {
margin-top: 8rpx;
font-size: 24rpx;
color: #8e9ab0;
max-width: 48px;
display: inline-block;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
}
}
.ower{
width: 48px;
display: flex;
align-items: center;
justify-content: center;
bottom: 34rpx;
font-size: 24rpx;
position: absolute;
color: #0089FF;
background: #E8EAEF;
border-radius: 12rpx 12rpx 12rpx 12rpx;
}
.more {
@include btwBox();
margin-top: 20rpx;
padding: 20rpx 0rpx 20rpx;
border-top: 1px solid rgba(153, 153, 153, 0.2);
.more_right {
@include vCenterBox();
}
}
}
</style>

View File

@@ -0,0 +1,361 @@
<template>
<view class="group_settings_container">
<custom-nav-bar title="群聊设置" />
<view class="group_settings_content">
<view class="setting_row info_row">
<view class="group_avatar" @click="updateGroupAvatar">
<my-avatar
:src="storeCurrentConversation.faceURL"
:isGroup="true"
size="46"
/>
<image
v-if="isOwner"
class="edit_icon"
src="@/static/images/group_setting_edit.png"
alt=""
/>
</view>
<view class="group_info">
<view class="group_info_name">
<text class="group_name"
>{{ storeCurrentConversation.showName }}({{
storeCurrentGroup.memberCount
}})</text
>
<image
v-if="isOwner || isAdmin"
@click="toUpdateGroupName"
style="width: 24rpx; height: 24rpx"
src="@/static/images/group_edit.png"
alt=""
/>
</view>
<text @click="copyGroupID" class="sub_title">{{
storeCurrentConversation.groupID
}}</text>
</view>
</view>
<group-member-row
v-if="isJoinGroup"
:isNomal="!isAdmin && !isOwner"
:groupID="storeCurrentConversation.groupID"
:memberCount="storeCurrentGroup.memberCount"
:groupMemberList="groupMemberList"
/>
<view v-if="isJoinGroup" class="setting_row">
<setting-item
v-if="isOwner || isAdmin"
@click="toGroupManage"
title="群管理"
:border="false"
/>
</view>
<view class="setting_row">
<setting-item
v-if="isJoinGroup"
danger
@click="() => (confirmType = isOwner ? 'Dismiss' : 'Quit')"
:title="isOwner ? '解散群聊' : '退出群聊'"
:border="false"
/>
</view>
<u-modal
:content="getConfirmContent"
asyncClose
:show="confirmType !== null"
showCancelButton
@confirm="confirm"
@cancel="() => (confirmType = null)"
></u-modal>
</view>
<u-toast ref="uToast"></u-toast>
<action-sheet
:groupID="storeCurrentConversation.groupID"
:visible.sync="actionSheetVisible"
/>
</view>
</template>
<script>
import { mapGetters } from "vuex";
import { GroupMemberListTypes } from "@/constant";
import IMSDK, {
GroupMemberRole,
GroupStatus,
GroupVerificationType,
IMMethods,
MessageReceiveOptType,
} from "openim-uniapp-polyfill";
import CustomNavBar from "@/components/CustomNavBar/index.vue";
import MyAvatar from "@/components/MyAvatar/index.vue";
import SettingItem from "@/components/SettingItem/index.vue";
import GroupMemberRow from "./components/GroupMemberRow.vue";
import ActionSheet from "./components/ActionSheet.vue";
import { getPurePath } from "@/util/common";
const ConfirmTypes = {
Dismiss: "Dismiss",
Quit: "Quit",
};
export default {
components: {
CustomNavBar,
MyAvatar,
SettingItem,
GroupMemberRow,
ActionSheet,
},
props: {},
data() {
return {
actionSheetVisible: false,
confirmType: null,
switchLoading: {
pin: false,
opt: false,
mute: false,
},
groupMemberList: [],
isJoinGroup: true
};
},
onShow() {
this.getGroupMemberList();
if (this.storeCurrentConversation.groupID) {
IMSDK.asyncApi(
IMMethods.IsJoinGroup,
IMSDK.uuid(),
this.storeCurrentConversation.groupID
).then((res) => {
this.isJoinGroup = res.data
});
}
},
watch: {
"storeCurrentGroup.memberCount"() {
this.getGroupMemberList();
},
},
computed: {
...mapGetters([
"storeCurrentConversation",
"storeCurrentMemberInGroup",
"storeCurrentGroup",
]),
getConfirmContent() {
if (this.confirmType === ConfirmTypes.Quit) {
return "确定要退出当前群聊吗?";
}
if (this.confirmType === ConfirmTypes.Dismiss) {
return "确定要解散当前群聊吗?";
}
return "";
},
isOwner() {
return this.storeCurrentMemberInGroup.roleLevel === GroupMemberRole.Owner;
},
isAdmin() {
return this.storeCurrentMemberInGroup.roleLevel === GroupMemberRole.Admin;
},
getGroupVerStr() {
if (
this.storeCurrentGroup.needVerification ===
GroupVerificationType.ApplyNeedInviteNot
) {
return "群成员邀请无需验证";
}
if (
this.storeCurrentGroup.needVerification === GroupVerificationType.AllNot
) {
return "允许所有人加群";
}
return "需要发送验证消息";
},
isAllMuted() {
return this.storeCurrentGroup.status === GroupStatus.Muted;
},
},
methods: {
getGroupMemberList() {
IMSDK.asyncApi(IMSDK.IMMethods.GetGroupMemberList, IMSDK.uuid(), {
groupID: this.storeCurrentConversation.groupID,
filter: 0,
offset: 0,
count: !this.isAdmin && !this.isOwner ? 9 : 8,
})
.then(({ data }) => {
console.log(data);
this.groupMemberList = [...data];
})
.catch((err) => {
console.log(err);
});
},
toGroupManage() {
uni.navigateTo({
url: "/pages/conversation/groupManage/index",
});
},
toUpdateGroupName() {
if (!this.isAdmin && !this.isOwner) {
return;
}
uni.navigateTo({
url: `/pages/conversation/updateGroupOrNickname/index?sourceInfo=${JSON.stringify(
this.storeCurrentGroup,
)}`,
});
},
copyGroupID() {
uni.setClipboardData({
data: this.storeCurrentGroup.groupID,
success: () => {
uni.hideToast();
this.$nextTick(() => {
uni.$u.toast("复制成功");
});
},
});
},
showActionSheet() {
if (!this.isAdmin && !this.isOwner) {
return;
}
this.actionSheetVisible = true;
},
updateGroupAvatar() {
if (!this.isAdmin && !this.isOwner) {
return;
}
uni.chooseImage({
count: 1,
sizeType: ["compressed"],
success: async ({ tempFilePaths }) => {
const path = tempFilePaths[0];
const nameIdx = path.lastIndexOf("/") + 1;
const typeIdx = path.lastIndexOf(".") + 1;
const fileName = path.slice(nameIdx);
const fileType = path.slice(typeIdx);
try {
const {
data: { url },
} = await IMSDK.asyncApi(IMMethods.UploadFile, IMSDK.uuid(), {
filepath: getPurePath(tempFilePaths[0]),
name: fileName,
contentType: fileType,
uuid: IMSDK.uuid(),
});
await IMSDK.asyncApi(IMSDK.IMMethods.SetGroupInfo, IMSDK.uuid(), {
groupID: this.storeCurrentConversation.groupID,
faceURL: url,
});
uni.$u.toast("修改成功");
} catch (error) {
uni.$u.toast("修改失败");
}
},
});
},
confirm() {
let funcName = "";
let sourceID = this.storeCurrentConversation.groupID;
if (this.confirmType === ConfirmTypes.Quit) {
funcName = IMSDK.IMMethods.QuitGroup;
}
if (this.confirmType === ConfirmTypes.Dismiss) {
funcName = IMSDK.IMMethods.DismissGroup;
}
IMSDK.asyncApi(funcName, IMSDK.uuid(), sourceID)
.then(() => {
uni.$u.toast("操作成功");
setTimeout(
() =>
uni.switchTab({
url: "/pages/conversation/conversationList/index",
}),
250,
);
})
.catch(() => uni.$u.toast("操作失败"))
.finally(() => (this.confirmType = null));
},
},
};
</script>
<style lang="scss" scoped>
.group_settings_container {
@include colBox(false);
height: 100vh;
background-color: #f6f6f6;
.group_settings_content {
overflow-y: auto;
}
.setting_row {
background-color: #fff;
margin: 24rpx;
border-radius: 6px;
overflow: hidden;
}
.info_row {
@include vCenterBox();
padding: 36rpx 44rpx;
.group_avatar {
margin-right: 16rpx;
position: relative;
.edit_icon {
position: absolute;
right: -6rpx;
bottom: -6rpx;
width: 11px;
height: 11px;
}
}
.group_info {
min-height: 46px;
display: flex;
flex: 1;
flex-direction: column;
align-items: flex-start;
justify-content: space-between;
&_name {
display: flex;
flex-direction: row;
align-items: center;
justify-content: center;
.group_name {
// @include nomalEllipsis();
font-size: 34rpx;
max-width: 380rpx;
margin-right: 24rpx;
}
}
.sub_title {
@include nomalEllipsis();
margin-bottom: 0;
font-size: 28rpx;
color: #999;
}
}
}
}
</style>

View File

@@ -0,0 +1,107 @@
<template>
<view class="single_settings_container">
<custom-nav-bar title="好友设置" />
<view class="row_wrap">
<view class="setting_row info_row">
<view @click="toUserCard" class="user_info">
<my-avatar
:src="storeCurrentConversation.faceURL"
:desc="storeCurrentConversation.showName"
size="46"
/>
</view>
<view @click="invite2group" class="action">
<image
style="width: 46px; height: 46px"
src="@/static/images/single_setting_add.png"
alt=""
/>
</view>
</view>
</view>
</view>
</template>
<script>
import { mapGetters } from "vuex";
import CustomNavBar from "@/components/CustomNavBar/index.vue";
import MyAvatar from "@/components/MyAvatar/index.vue";
import SettingItem from "@/components/SettingItem/index.vue";
export default {
components: {
CustomNavBar,
MyAvatar,
SettingItem,
},
props: {},
data() {
return {
switchLoading: {
pin: false,
opt: false,
readLimit: false,
},
showConfirm: false,
};
},
computed: {
...mapGetters(["storeCurrentConversation"]),
},
methods: {
toUserCard() {
uni.navigateTo({
url: `/pages/common/userCard/index?sourceID=${this.storeCurrentConversation.userID}`,
});
},
invite2group() {
const checkedMemberList = JSON.stringify([
{
userID: this.storeCurrentConversation.userID,
faceURL: this.storeCurrentConversation.faceURL,
nickname: this.storeCurrentConversation.showName,
},
]);
uni.navigateTo({
url: `/pages/common/createGroup/index?checkedMemberList=${checkedMemberList}`,
});
},
},
};
</script>
<style lang="scss" scoped>
.single_settings_container {
@include colBox(false);
height: 100vh;
background-color: #f6f6f6;
.row_wrap {
flex: 1;
overflow-y: auto;
}
.setting_row {
margin: 24rpx 24rpx 0 24rpx;
background: #fff;
border-radius: 6px;
overflow: hidden;
}
.info_row {
display: flex;
align-items: center;
padding: 44rpx;
.user_info {
@include colBox(false);
margin-right: 36rpx;
.user_name {
margin-top: 20rpx;
color: #666;
}
}
}
}
</style>

View File

@@ -0,0 +1,92 @@
<template>
<view class="page_container">
<custom-nav-bar :title="getTitle">
<view class="nav_right_action" slot="more">
<text v-show="!updateLoading" @click="comfirmUpdate">保存</text>
<u-loading-icon v-show="updateLoading" />
</view>
</custom-nav-bar>
<view class="content_row">
<u-input
v-model="content"
disabledColor="transparent"
maxlength="16"
placeholder="请输入内容"
clearable
>
</u-input>
</view>
</view>
</template>
<script>
import IMSDK from "openim-uniapp-polyfill";
import CustomNavBar from "@/components/CustomNavBar/index.vue";
import MyAvatar from "@/components/MyAvatar/index.vue";
export default {
components: {
CustomNavBar,
MyAvatar,
},
data() {
return {
sourceInfo: {},
content: "",
updateLoading: false,
};
},
computed: {
getTitle() {
return "修改群聊名称";
},
getSubTitle() {
return "修改群名称后,将在群内通知其他成员";
},
},
onLoad(options) {
const { sourceInfo } = options;
this.sourceInfo = JSON.parse(sourceInfo);
this.content = this.sourceInfo.groupName;
},
methods: {
comfirmUpdate() {
this.updateLoading = true;
IMSDK.asyncApi(IMSDK.IMMethods.SetGroupInfo, IMSDK.uuid(), {
groupID: this.sourceInfo.groupID,
groupName: this.content,
})
.then(() => {
uni.$u.toast("修改成功");
setTimeout(() => uni.navigateBack(), 250);
})
.catch(() => uni.$u.toast("修改失败"))
.finally(() => (this.updateLoading = false));
},
},
};
</script>
<style lang="scss" scoped>
.page_container {
@include colBox(false);
height: 100vh;
.nav_right_action {
margin-right: 36rpx;
}
.content_row {
margin-top: 96rpx;
margin: 72rpx 44rpx 0;
.u-input {
background-color: #e8eaef;
}
.u-button {
height: 60rpx;
}
}
}
</style>