Initial commit
This commit is contained in:
@@ -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>
|
||||
@@ -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>
|
||||
353
pages/conversation/chating/components/ChatingFooter/index.vue
Normal file
353
pages/conversation/chating/components/ChatingFooter/index.vue
Normal 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>
|
||||
294
pages/conversation/chating/components/ChatingHeader.vue
Normal file
294
pages/conversation/chating/components/ChatingHeader.vue
Normal 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>
|
||||
256
pages/conversation/chating/components/ChatingList.vue
Normal file
256
pages/conversation/chating/components/ChatingList.vue
Normal 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>
|
||||
@@ -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>
|
||||
@@ -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>
|
||||
@@ -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>
|
||||
311
pages/conversation/chating/components/MessageItem/index.vue
Normal file
311
pages/conversation/chating/components/MessageItem/index.vue
Normal 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>
|
||||
Reference in New Issue
Block a user