袁磊 4 months ago
parent
commit
127d414379
  1. 4
      pages/setting/about.vue
  2. 4
      pages/setting/contact.vue
  3. 2
      pages/setting/setting.vue
  4. 20
      pages/user/login.vue
  5. 2
      static/style/nine-btn-001.scss
  6. 100
      uni_modules/vrapile-im/pages/chat/chatFriend.vue
  7. 13
      uni_modules/vrapile-im/pages/home/chatHome.vue
  8. 44
      uni_modules/vrapile-im/static/style/nine-chat-friend-001.scss
  9. 1
      uni_modules/vrapile-im/store/modules/chat.js
  10. 12
      uni_modules/vrapile-im/store/modules/socket.js

4
pages/setting/about.vue

@ -30,10 +30,10 @@
</view>
<view class="ptb30">
<view class="text-center color-blue font-size15">
九云科技有限公司服务协议
开放平台服务协议
</view>
<view class="text-center font-size15">
九云科技 版权所有
平台开发者 版权所有
</view>
<view class="text-center font-size15">
Copyright © 2024-2031 NineCloud.

4
pages/setting/contact.vue

@ -40,10 +40,10 @@
</view>
<view class="ptb30">
<view class="text-center color-blue font-size15">
九云科技有限公司服务协议
开放平台服务协议
</view>
<view class="text-center font-size15">
九云科技 版权所有
平台开发者 版权所有
</view>
<view class="text-center font-size15">
Copyright © 2024-2031 NineCloud.

2
pages/setting/setting.vue

@ -2,7 +2,7 @@
<view class="nine-content-001">
<!-- 功能列表 -->
<view class="nine-nav-001">
<view class="nine-nav-001-item mt10">
<view class="nine-nav-001-item">
<view class="nine-nav-001-item-left">
<text class="nine-nav-001-item-left-text">公告中心</text>
</view>

20
pages/user/login.vue

@ -37,11 +37,23 @@
</view>
<view class="nine-btn-save-001 ma20" @click="loginClick"> </view>
<!--#ifndef MP-WEIXIN-->
<view class="text-center ma20">没有账号?
<view class="text-center mt30 mb20">没有账号?
<span class="ml10 color-blue" @click="registerClick">
立即注册
</span>
</view>
<view class="text-center mt30 mb20">
<span class="ml10 color-blue" @click="visitorLogin">
演示账号登录
</span>
</view>
<!--#endif-->
<!--#ifdef MP-WEIXIN-->
<view class="text-center mt30 mb20">
<span class="ml10 color-blue" @click="wxLoginClick">
微信一键登录
</span>
</view>
<!--#endif-->
</view>
</view>
@ -131,6 +143,12 @@
this.verifyText = "发送验证码";
}
},
visitorLogin(){
this.loginType = 0;
this.userName = "visitor";
this.password = "visitor";
this.loginClick();
},
loginClick(){
if(!this.userName){
this.usernamefocus();

2
static/style/nine-btn-001.scss

@ -9,7 +9,7 @@
padding: 20rpx;
border-radius: 10rpx;
color: #fff;
background-color: #0000ff;
background-color: #0294ee;
text-align: center;
}
// 退出登录

100
uni_modules/vrapile-im/pages/chat/chatFriend.vue

@ -16,9 +16,23 @@
<image class="chat-conversation-image-image" v-else :src="userInfo.avatar || defaultAvatar"></image>
</view>
<view class="chat-conversation-text">
<view class="chat-conversation-text-time" v-if="item.sendType == 1 && item.fromId != userInfo.userId">{{getUserName(item.fromId, item.fromName)}}</view>
<view class="chat-conversation-text-time">{{formatTime(item.sendTime)}}</view>
<view class="chat-conversation-text-text nine-user-select">{{item.content}}</view>
<view class="conversation-text-time" v-if="item.sendType == 1 && item.fromId != userInfo.userId">{{getUserName(item.fromId, item.toId, item.fromName)}}</view>
<view class="conversation-text-time">{{formatTime(item.sendTime)}}</view>
<view v-if="item.messageType==1" class="chat-conversation-text-text chat-conversation-text-image">
<image lazy-load="true" class="chat-conversation-text-image-image" :src="item.content" mode="widthFix"></image>
</view>
<view v-else-if="item.messageType==2" class="chat-conversation-text-text chat-conversation-text-emoji">
<template v-for="(image, index) in getEmojiList(item.content)" :key="'image-' + key">
<image lazy-load="true" class="chat-conversation-text-emoji-image" :src="getEmoji(image)"></image>
</template>
</view>
<view v-else-if="item.messageType==3" class="chat-conversation-text-text chat-conversation-text-voice">
<image class="chat-conversation-text-voice-image" src="/uni_modules/vrapile-im/static/image/chat/voice-right.png" mode="widthFix"></image>
<span class="chat-conversation-text-voice-number" :style="{'width': (40 + item.content*10) + 'rpx'}">{{item.content}}" </span>
</view>
<view v-else class="chat-conversation-text-text nine-user-select">
{{item.content}}
</view>
</view>
</view>
</view>
@ -30,7 +44,11 @@
<view @click="handleVoice" class="chat-footer-send-voice">
<image class="chat-footer-send-image" :src="iconVoice"></image>
</view>
<view v-if="isVoice" @longpress="handleSay" class="chat-footer-send-say">
<view v-if="isVoice" class="chat-footer-send-say"
@touchstart="handleTouchStart"
@touchend="handleTouchEnd"
@longpress="startRecord"
@contextmenu.prevent="() => {}">
<span>按住 说话</span>
</view>
<view v-else class="chat-footer-send-input">
@ -68,6 +86,8 @@
isVoice: false,
inputText: "",
startTime: 0,
// key
key: null,
@ -168,13 +188,31 @@
handleVoice() {
this.isVoice = !this.isVoice;
},
handleTouchStart(e){
this.startTime = Date.now();
//
e.preventDefault();
},
handleTouchEnd(e) {
this.handleSay();
//
e.preventDefault();
},
startRecord(e) {
//
e.preventDefault();
},
//
handleSay() {
const duration = Date.now() - this.startTime
if (duration < 500) {
return
}
let sendInfo = {
code: 2,
message: {
// 0-|1-|2-|3-|4-
messageType: 0,
// 0-|1-|2-|3-|4-|5-|9-|99-
messageType: 3,
//id
toId: this.chatObject.id,
//
@ -182,7 +220,7 @@
//
fromName: this.userInfo.userName,
//
content: "您发送了一条语音消息",
content: Math.ceil(duration/1000),
//0-|1-
sendType: this.chatObject.type,
//
@ -195,11 +233,24 @@
},
//
handleEmoji() {
let emojiList = [
'daxiao.png',
'danao.png',
'shengqi.png',
'sile.png',
'xianwen.png'
]
let randomIndex
let content = []
do{
randomIndex = Math.floor(Math.random() * emojiList.length)
content.push(emojiList[randomIndex])
}while(randomIndex % 3 != 0);
let sendInfo = {
code: 2,
message: {
// 0-|1-|2-|3-|4-
messageType: 0,
// 0-|1-|2-|3-|4-|5-|9-|99-
messageType: 2,
//id
toId: this.chatObject.id,
//
@ -207,7 +258,7 @@
//
fromName: this.userInfo.userName,
//
content: "您发送了一个表情消息",
content: content,
//0-|1-
sendType: this.chatObject.type,
//
@ -224,7 +275,7 @@
code: 2,
message: {
// 0-|1-|2-|3-|4-
messageType: 0,
messageType: 1,
//id
toId: this.chatObject.id,
//
@ -232,7 +283,7 @@
//
fromName: this.userInfo.userName,
//
content: "您发送了一个更多的消息",
content: this.userInfo.avatar || "https://www.ninecloud.top/unine/static/image/app/nine-app-all.png",
//0-|1-
sendType: this.chatObject.type,
//
@ -305,10 +356,18 @@
this.chatObject["messageList"] = this.messageList;
let lastMessage = res.data[res.data.length-1];
this.chatObject["messageLast"] = lastMessage;
let content = lastMessage["content"]
if(lastMessage["messageType"] == 3){
content = "[语音]"
}else if(lastMessage["messageType"] == 2){
content = "[表情]"
}else if(lastMessage["messageType"] == 1){
content = "[图片]"
}
if(lastMessage["sendType"] == 0){
this.chatObject["messageShow"] = lastMessage["content"];
this.chatObject["messageShow"] = content;
}else{
this.chatObject["messageShow"] = store.getters.getUserName(lastMessage["fromId"], lastMessage["fromName"]) + ": " + lastMessage["content"]
this.chatObject["messageShow"] = store.getters.getUserName(lastMessage["fromId"], lastMessage["fromName"]) + ": " + content
}
this.chatObject["messageTime"] = this.formatDate(lastMessage["sendTime"]);
}
@ -326,6 +385,19 @@
this.scrollToBottom();
}
});
},
getEmojiList(content){
if(typeof content === 'object'){
return content;
}
try{
return JSON.parse(content.replace(/(\w+\.png)/g, '"$1"'));
}catch(e){
return new Array;
}
},
getEmoji(image){
return '/uni_modules/vrapile-im/static/image/emoji/'+image
}
}
}

13
uni_modules/vrapile-im/pages/home/chatHome.vue

@ -146,6 +146,7 @@
//
handleHistoryMessage(i, scrollFlag){
let limit = this.getChatList[i]["messageList"].length + 10;
// /im/message/getMessageByPatchChatKey
getMessageByChatKey({
type: this.getChatList[i].type,
key: this.getChatList[i]["key"],
@ -156,10 +157,18 @@
this.getChatList[i]["messageList"] = res.data;
let lastMessage = res.data[res.data.length-1];
this.getChatList[i]["messageLast"] = lastMessage;
let content = lastMessage["content"]
if(lastMessage["messageType"] == 3){
content = "[语音]"
}else if(lastMessage["messageType"] == 2){
content = "[表情]"
}else if(lastMessage["messageType"] == 1){
content = "[图片]"
}
if(lastMessage["sendType"] == 0){
this.getChatList[i]["messageShow"] = lastMessage["content"];
this.getChatList[i]["messageShow"] = content;
}else{
this.getChatList[i]["messageShow"] = store.getters.getUserName(lastMessage["fromId"], lastMessage["fromName"]) + ": " + lastMessage["content"]
this.getChatList[i]["messageShow"] = store.getters.getUserName(lastMessage["fromId"], lastMessage["fromName"]) + ": " + content
}
this.getChatList[i]["messageTime"] = this.formatDate(lastMessage["sendTime"]);
}

44
uni_modules/vrapile-im/static/style/nine-chat-friend-001.scss

@ -107,6 +107,50 @@ html, body, #app{
padding: 5rpx;
border-radius: 10rpx;
}
.chat-conversation-text-image{
padding: 5px;
width: 100%;
}
.chat-conversation-text-image-image{
width: 100%;
}
.chat-conversation-text-emoji{
flex-direction: row;
flex-wrap: wrap;
align-content: flex-start;
}
.chat-conversation-text-emoji-image{
width: 80rpx;
height: 80rpx;
margin: 2rpx;
}
.chat-conversation-text-voice{
flex-direction: row;
align-items: center;
padding: 15rpx;
}
.chat-conversation-text-voice-number{
text-align: left;
white-space: nowrap;
overflow: hidden;
flex: 1;
}
.chat-conversation-text-voice-image{
margin-right: 25rpx;
width: 30rpx;
height: 30rpx;
}
.chat-conversation-mine .chat-conversation-text-voice{
flex-direction: row-reverse;
}
.chat-conversation-mine .chat-conversation-text-voice-number{
text-align: right;
}
.chat-conversation-mine .chat-conversation-text-voice-image{
margin-right: 0rpx;
margin-left: 25rpx;
transform: rotate(180deg);
}
.chat-footer {
position: fixed;

1
uni_modules/vrapile-im/store/modules/chat.js

@ -104,6 +104,7 @@ const chat = {
delete itemGroup["updateTime"];
listGroup.push({type: 1, ...itemGroup});
// 查询群组人员
// 后面将作废此接口 改为批量查询 /im/groupUser/getPatchGroupUser
getGroupUser(itemGroup.id).then(res2 => {
for(let itemGroupUser of res2.data){
delete itemGroupUser["createBy"];

12
uni_modules/vrapile-im/store/modules/socket.js

@ -36,10 +36,18 @@ const socket = {
// if(store.state.user.userInfo.userId && store.state.user.userInfo.userId != message["fromId"]){
store.state.chat.chatList[i]["messageNum"] += 1;
// }
let content = message["content"]
if(message["messageType"] == 3){
content = "[语音]"
}else if(message["messageType"] == 2){
content = "[表情]"
}else if(message["messageType"] == 1){
content = "[图片]"
}
if(store.state.chat.chatList[i]["type"] == 0){
store.state.chat.chatList[i]["messageShow"] = message["content"];
store.state.chat.chatList[i]["messageShow"] = content;
}else{
store.state.chat.chatList[i]["messageShow"] = store.getters.getUserName(message["fromId"], message["fromName"]) + ": " + message["content"]
store.state.chat.chatList[i]["messageShow"] = store.getters.getUserName(message["fromId"], message["fromName"]) + ": " + content
}
storage.set(constant.chatList, store.state.chat.chatList);
break;

Loading…
Cancel
Save