dev
sunyongyan 2024-08-29 15:43:04 +08:00
parent 3ea0a28ff6
commit 0300cf037f
1 changed files with 137 additions and 83 deletions

View File

@ -1,16 +1,17 @@
<!-- 消息聊天 -->
<template>
<view class="content">
<!-- -->
<view class="header_are" >
<view class="header_are">
<uni-nav-bar statusBar="false" left-icon="left" @clickLeft="ReturnPage" :fixed="true" :border="false"
background-color="#ffffff" :title="title" />
</view>
<!-- -->
<view class="middle_area" @click="hideFuncBox()" :style="`padding-bottom:${KeyboardHeight}px`">
<scroll-view class="scroll-container" :class="{ show: IsShwo }" scroll-y="true"
:scroll-with-animation="true" :scroll-into-view="lastMessageId" @touchstart="checkmsg" style="padding-top: 20rpx;">
:scroll-with-animation="true" :scroll-into-view="lastMessageId" @touchstart="checkmsg"
style="padding-top: 20rpx;">
<view class="bigbox" @touchmove="watchjilu">
@ -19,13 +20,11 @@
<view>
<view class="contentmessagetimes" v-if="IsSendTime(item.sendTime)">
<text class="contentmessagetimetext">{{ ReturnTime(item.sendTime) }}</text>
</view>
</view>
</view>
<view class="contentmessage">
<view @click="toPerson">
<!-- <image class="contentmessageimage" :src="bindIcon(youavatar)"></image> -->
<image v-if="youavatar" class="contentmessageimage" :src="bindIcon(youavatar)"></image>
<image v-else class="contentmessageimage" src="../../static/images/icon/tu4-1.jpg" mode=""></image>
<image class="contentmessageimage" :src="bindIcon(youavatar)"></image>
</view>
<view style="margin-left: 16rpx;">
<view class="message" v-if="item.messageType == 51">
@ -39,7 +38,7 @@
</view>
</view>
<view class="funcBox" v-if="visibleFuncBoxId === item.id" @click.stop="handleFuncBoxClick">
<view class="moveFunc" @click="delOne(item.id,item.senderId,item.receiverId)">
<view class="moveFunc" @click="delOne(item.id, item.senderId, item.receiverId)">
删除
</view>
<!-- <view class="moveFunc">
@ -81,8 +80,9 @@
<image class="mycontentmessageimage" :src="avatar"></image>
</view>
</view>
<view class="funcBox funcBoxT" v-if="visibleFuncBoxId === item.id" @click.stop="handleFuncBoxClick">
<view class="moveFunc" @click="delOne(item.id,item.senderId,item.receiverId)">
<view class="funcBox funcBoxT" v-if="visibleFuncBoxId === item.id"
@click.stop="handleFuncBoxClick">
<view class="moveFunc" @click="delOne(item.id, item.senderId, item.receiverId)">
删除
</view>
<view class="moveFunc">
@ -107,18 +107,23 @@
</scroll-view>
</view>
<!-- -->
<view class="bottom_area" :class="{ show: IsShwo }" :style="IsShwo!=true?`transform: translateY(${-KeyboardHeight}px);`:`transform: translateY(${-210}rpx);`">
<view class="bottom_area" :class="{ show: IsShwo }"
:style="IsShwo != true ? `transform: translateY(${-KeyboardHeight}px);` : `transform: translateY(${-210}rpx);`">
<!-- 输入区域 -->
<view class="bottm" >
<view class="bottm">
<view class="botomview">
<view class="viewtextarea">
<textarea class="classtextarea" v-model="messageinput" :adjust-position="false"
:disabled="ifdisab" auto-height placeholder="请输入内容" @focus="onFocus"
@linechange="input_text" :focus="false" cursor-spacing="15" @keyboardheightchange="hightchange" />
@linechange="input_text" :focus="false" cursor-spacing="15"
@keyboardheightchange="hightchange" />
<view class="right_shuru">
<view class="bottombutton" @click="ButtonSend()">
<view class="bottombuttont" v-if="ifdisab">
<text>发送</text>
</view>
<view class="bottombutton" @click="ButtonSend()" v-else>
<text>发送</text>
</view>
</view>
@ -126,15 +131,15 @@
</view>
</view>
<view class="imageview" @click="ShowBottom()">
<view class="imageview" @click="ifdisab == false ? ShowBottom() : ''">
<image class="messageaddimage" src="../../static/images/sign/messageadd.png"></image>
</view>
</view>
<!-- 发送照片区域 -->
<view class="popup" >
<view class="popup" v-show="isChooseImg">
<view style="display: flex;margin-left: 32rpx;margin-top: 24rpx;">
<view >
<view>
<fileUpload v-model="messageinput" @dropDownValueChange="fruitValueChange" :limit="1">
</fileUpload>
<view @click="UpPorops()">
@ -186,7 +191,10 @@
import {
delMeMessage,
withdrawMessage
}from "@/api/signln/FriendShip/FriendShip";
} from "@/api/signln/FriendShip/FriendShip";
import {
getBanned
} from "@/api/banned/banned.js";
const {
proxy
} = getCurrentInstance();
@ -203,7 +211,7 @@
const socket = ref(null);
const message = ref('');
const IsShwo = ref(false)
const isChooseImg = ref(false)
const funcBoxIsShow = ref(false)
import {
@ -224,28 +232,35 @@
onShow(() => {
//$("#")
const getuser = GetListid().then(res => {
myuserid.value = res;
console.log("党情登录用户" + myuserid.value)
const getuser = GetListid().then(res => {
myuserid.value = res;
console.log("党情登录用户" + myuserid.value)
getBans(myuserid.value);
if (myuserid.value != 0) {
WebSockOpen(myuserid.value)
setTimeout(() => {
console.log(uid.value);
GetList();
}, 100)
if (myuserid.value != 0) {
WebSockOpen(myuserid.value)
setTimeout(() => {
GetList();
}, 100)
}
})
}
})
uni.getStorage({
key: 'userInfo',
success: function(res) {
const storedUserInfo = res.data;
console.log(storedUserInfo);
uid.value = storedUserInfo.friendid;
console.log(uid.value);
title.value = storedUserInfo.title;
myavatar.value = storedUserInfo.myavatar;
youavatar.value = storedUserInfo.youavatar;
console.log('User info retrieved successfully:', storedUserInfo.myavatar);
GetList();
},
fail: function(err) {
console.error('Failed to retrieve user info:', err);
@ -316,6 +331,25 @@
// };
// };
const getBans = (userId) => {
getBanned(userId).then(response => {
console.log('接口返回response', response);
if (response.data) {
if (response.data.status == 1) {
ifdisab.value = true
uni.showToast({
icon: "error",
title: '禁言中'
})
} else {
console.log('有禁言数据,但未被禁言')
}
}
}).catch(error => {
console.error('API 调用出错:', error);
});
};
const lastMessageId = ref(null);
@ -360,7 +394,7 @@
}
onLoad(() => {
//proxy.$store.dispatch('webSockerInfo')
GetList();
})
@ -375,16 +409,16 @@
visibleFuncBoxId.value = null;
}
};
const cancelBox = (messageId) => {
visibleFuncBoxId.value = null;
}
// ()
const delOne = (messageId,senId,recId) => {
const delOne = (messageId, senId, recId) => {
var data = {
senderId: senId,
receiverId: recId,
id:messageId
id: messageId
}
delMeMessage(data).then(response => {
console.log('接口返回response', response)
@ -392,13 +426,13 @@
});
visibleFuncBoxId.value = null;
}
// ()
const withdrawOne = (messageId) => {
var data = {
senderId: myuserid.value,
receiverId: uid.value,
id:messageId
id: messageId
}
withdrawMessage(data).then(response => {
console.log('撤回接口返回response', response)
@ -409,13 +443,13 @@
//
const handleFuncBoxClick = (event) => {
event.stopPropagation();
};
event.stopPropagation();
};
//
function onFocus() {
// console.log("")
IsShwo.value=false
IsShwo.value = false
setTimeout(() => {
lastMessageId.value = 'test';
}, 40);
@ -450,18 +484,18 @@
}
data.senderId = myuserid.value;
data.receiverId = uid.value;
console.log(data.receiverId, '数据我要的');
// console.log(data);
listNotificationHistoricalUser(data).then(response => {
// console.log(response.rows.length)
const filteredRows = response.rows.filter(row => row.withdraw === 0);
arrlist.value = filteredRows;
console.log(arrlist.value,"arrlist.value1111111");
arrlist.value = filteredRows;
console.log(arrlist.value, "arrlist.value1111111");
IsSendTime();
if (arrlist.value != null) {
setTimeout(() => {
lastMessageId.value = 'ms' + arrlist.value[arrlist.value.length - 1].id;
// lastMessageId.value = 'ms' + arrlist.value[arrlist.value.length - 1].id;
// console.log(lastMessageId.value)
// lastMessageId.value = 'boxlastsss';
}, 30);
@ -506,11 +540,8 @@
//
function ShowBottom() {
IsShwo.value = !IsShwo.value;
movebottom()
isChooseImg.value = !isChooseImg.value
}
@ -519,18 +550,19 @@
}
var KeyboardHeight = ref(0)
function hightchange(e){
console.log('键盘变化',e.detail.height);
KeyboardHeight.value=e.detail.height
setTimeout(() => {
lastMessageId.value = 'test';
}, 40);
setTimeout(() => {
lastMessageId.value = 'ms' + arrlist.value[arrlist.value.length - 1].id;
// console.log(lastMessageId.value)
// lastMessageId.value = 'boxlastsss';
}, 50);
}
function hightchange(e) {
console.log('键盘变化', e.detail.height);
KeyboardHeight.value = e.detail.height
setTimeout(() => {
lastMessageId.value = 'test';
}, 40);
setTimeout(() => {
lastMessageId.value = 'ms' + arrlist.value[arrlist.value.length - 1].id;
// console.log(lastMessageId.value)
// lastMessageId.value = 'boxlastsss';
}, 50);
}
//
@ -556,15 +588,14 @@ function hightchange(e){
useStore
} from 'vuex';
const store = useStore();
const avatar = ref(proxy.$store.state.user.avatar)
// URL
const avatarUrl = ref("/static/images/icon/tu4-1.jpg");
const useDefaultAvatar = ref(true); // 使
const QNDomain = store.state.user.QNDomain;
function bindIcon(icon) {
return store.state.user.QNDomain + icon;;
}
useDefaultAvatar.value = false;
return QNDomain + icon;
}
const avatar = ref(proxy.$store.state.user.avatar)
@ -651,7 +682,7 @@ function hightchange(e){
lastMessageId.value = '';
}, 40);
setTimeout(() => {
lastMessageId.value = 'ms' + arrlist.value[arrlist.value.length - 1].id;
// lastMessageId.value = 'ms' + arrlist.value[arrlist.value.length - 1].id;
}, 50);
}
@ -705,20 +736,20 @@ function hightchange(e){
// 5
function IsSendTime(time) {
var time = new Date(time).getDate();
if(arrlist.value.length>2){
if (arrlist.value.length > 2) {
var lasttime = new Date(arrlist.value[arrlist.value.length - 2].sendTime).getDate();
var result = time - lasttime;
if (result == 0) {
return false;
// console.log(result)
} else {
return true;
return false;
// console.log(result)
} else {
return true;
}
}
}
}
//
// function watchjilu(){
@ -804,6 +835,15 @@ function hightchange(e){
margin-left: 1rpx;
}
.bottombuttont {
width: 104rpx;
height: 56rpx;
border-radius: 28rpx 28rpx 28rpx 28rpx;
background: #adadad;
margin-right: 12rpx;
margin-left: 1rpx;
}
.bottombutton>text {
font-weight: 400;
width: 57rpx;
@ -817,6 +857,19 @@ function hightchange(e){
}
.bottombuttont>text {
font-weight: 400;
width: 57rpx;
height: 28rpx;
font-size: 28rpx;
text-align: left;
color: #FFFFFF;
display: block;
margin: auto;
line-height: 56rpx;
}
.scroll-container {
flex: 1;
overflow: hidden;
@ -866,7 +919,7 @@ function hightchange(e){
}
.show {
transform: translateY(-210rpx);
/* 显示视图 */
}
@ -1067,7 +1120,7 @@ function hightchange(e){
width: 100%;
height: 200rpx;
flex-grow: 1;
}
.bottom_area {
@ -1075,7 +1128,7 @@ function hightchange(e){
width: 100%;
min-height: 100rpx;
background-color: #fff;
}
.funcBox {
@ -1088,7 +1141,8 @@ function hightchange(e){
justify-content: space-between;
margin-left: 116rpx;
}
.funcBoxT{
.funcBoxT {
width: 300rpx;
margin-left: 334rpx;
}