This commit is contained in:
唐明明
2022-02-18 10:50:30 +08:00
9 changed files with 97 additions and 22 deletions

View File

@@ -631,6 +631,12 @@
"navigationBarBackgroundColor": "#34CE98",
"navigationBarTextStyle": "white"
}
},
{
"path": "pages/im/chatDemo",
"style": {
"navigationBarTitleText": "demo"
}
}
],
"tabBar": {

28
pages/im/chatDemo.nvue Normal file
View File

@@ -0,0 +1,28 @@
<template>
<view class="">
<input placeholder="输入内容" />
</view>
</template>
<script>
export default {
onShow() {
},
onLoad() {
},
data() {
return {
};
},
methods: {
}
};
</script>
<style>
</style>

View File

@@ -11,8 +11,8 @@
<sent-voice v-if="chatType === 0" :conversationType="conversationType" :targetId="targetId"
@success="onSuccess" />
<sent-text v-if="chatType === 1" :conversationType="conversationType" :targetId="targetId"
@success="onSuccess" />
<view class="msg-type msg-popups" @click="showPopups = !showPopups">
@success="onSuccess" @focus="onHidePopus" />
<view class="msg-type msg-popups" @click="() => { showPopups = !showPopups, onHidePopus }">
<image class="icon" src="@/static/icon/popups-icon.png"></image>
</view>
</view>
@@ -56,7 +56,13 @@
},
onSuccess() {
this.$emit('onSuccess')
}
},
// 处理弹出层
onHidePopus(){
if(this.showPopups){
this.showPopups = false
}
}
}
}
</script>

View File

@@ -110,14 +110,14 @@
this.callShow = true
break;
case 'location':
uni.showToast({
icon: 'none',
title: '功能正在开发中'
})
// uni.showToast({
// icon: 'none',
// title: '功能正在开发中'
// })
// uni.chooseLocation({
// success: res => {
// console.log(res);
// this.success()
// // this.success()
// }
// })
break;

View File

@@ -1,8 +1,8 @@
<template>
<view class="sent--text">
<input class="input" type="text" @focus="focus" @blur="blur" v-model="inputTxt" confirm-type="send"
<input class="input" type="text" :auto-blur="true" @focus="focus" @blur="blur" :focus="focusState" v-model="inputTxt" confirm-type="send"
@confirm="sent" cursor-spacing="10" />
<!-- <button class="button" size="mini" :disabled="disabled" @click="sent">发送</button> -->
<!-- <button class="button" size="mini" :disabled="disabled" @click="demo">{{focusState ? '失焦': '聚焦'}}</button> -->
</view>
</template>
@@ -44,6 +44,11 @@
RongIMLib.saveTextMessageDraft(this.conversationType, this.targetId, this.inputTxt, (res) => {
console.log('销毁组件之前,保存草稿信息,但是没有执行', res);
})
},
data() {
return {
focusState: false,
}
},
methods: {
// 发送文本消息
@@ -55,11 +60,17 @@
this.inputTxt = ''
})
}
},
demo(){
console.log(this.focusState)
this.focusState = !this.focusState
},
focus() {
this.$emit('focus')
focus() {
this.$emit('focus')
},
blur() {
blur() {
uni.hideKeyboard()
this.$emit('blur')
}
}

View File

@@ -1,6 +1,6 @@
<template>
<view class="group--chat">
<list class="body" :show-scrollbar="false">
<list class="body" :show-scrollbar="false" @click="onScroll">
<cell class="cell" v-for="(item, index) in messages" :key="index">
<view class="cell-item" :class="item.messageDirection == 1 ? 'right' : 'left'">
<u-avatar class="avatar" @click="toUser(item)" size="36" shape="square"
@@ -17,7 +17,7 @@
</cell>
<cell class="cell-footer" ref="chatBottom"></cell>
</list>
<sent-message-bar :conversationType="conversationType" :targetId="targetId" @onSuccess="getNewMessage()" />
<sent-message-bar ref="messageBar" :conversationType="conversationType" :targetId="targetId" @onSuccess="getNewMessage()" />
</view>
</template>
@@ -53,7 +53,13 @@
},
computed: {
latestMessage() {
return this.messages[this.messages.length - 1]
if (this.messages.length > 1) {
return this.messages[this.messages.length - 1]
} else {
return {
sentTime: 0
}
}
}
},
onLoad(e) {
@@ -75,7 +81,10 @@
url: '/pages/im/group/info?targetId=' + this.targetId
})
},
methods: {
methods: {
onScroll(e){
this.$refs.messageBar.onHidePopus()
},
toUser(item) {
if (item.senderUserId == '__system__') {
return

View File

@@ -20,7 +20,8 @@
</view>
<u-alert type="warning" v-if="connection != 0" description="网络似乎断开了,请检查网络" :show-icon="true" />
<!-- content -->
<view v-if="$store.state.token !== ''">
<view v-if="$store.state.token !== ''">
<view @click="onDemo">临时测试用</view>
<conversation-list @refresh="getConversationList()" :conversations="conversations" />
</view>
<!-- 未登录 -->
@@ -71,7 +72,13 @@
onHide() {
uni.$off('onReceiveMessage')
},
methods: {
methods: {
onDemo(){
console.log('1111')
uni.navigateTo({
url: '/pages/im/chatDemo'
})
},
checkNewFriendPending() {
im.getPendingList((pendings) => {
this.hasNewFriends = pendings.length

View File

@@ -61,8 +61,14 @@
}
},
computed: {
latestMessage() {
return this.messages[this.messages.length - 1]
latestMessage() {
if (this.messages.length > 1) {
return this.messages[this.messages.length - 1]
} else {
return {
sentTime: 0
}
}
}
},
onLoad(e) {
@@ -103,7 +109,7 @@
im.getMessageList(
this.conversationType,
this.targetId,
this.latestMessage.sentTime,
this.latestMessage.sentTime || 0,
1,
false,
(messages) => {

View File

@@ -13,6 +13,8 @@ const ROUTES = [{
"path": "/pages/im/private/chat"
}, {
"path": "/pages/im/group/chat"
}, {
"path": "/pages/im/chatDemo"
}];
// #endif