This commit is contained in:
2022-01-28 09:41:41 +08:00
9 changed files with 295 additions and 97 deletions

View File

@@ -5,7 +5,6 @@
export default { export default {
onLaunch: function() { onLaunch: function() {
im.initIm('lmxuhwaglu76d') im.initIm('lmxuhwaglu76d')
return
//#ifdef APP-PLUS //#ifdef APP-PLUS
// 获取系统版本号 // 获取系统版本号
getVersions({ getVersions({

20
components/im/imAUDIO.vue Normal file
View File

@@ -0,0 +1,20 @@
<template>
<view>
语音消息
</view>
</template>
<script>
export default {
name:"im",
data() {
return {
};
}
}
</script>
<style lang="scss">
</style>

20
components/im/imIMG.vue Normal file
View File

@@ -0,0 +1,20 @@
<template>
<view>
图片消息
</view>
</template>
<script>
export default {
name:"im",
data() {
return {
};
}
}
</script>
<style lang="scss">
</style>

20
components/im/imTXT.vue Normal file
View File

@@ -0,0 +1,20 @@
<template>
<view>
文字消息
</view>
</template>
<script>
export default {
name:"im",
data() {
return {
};
}
}
</script>
<style lang="scss">
</style>

View File

@@ -573,6 +573,14 @@
"navigationBarBackgroundColor": "#34CE98", "navigationBarBackgroundColor": "#34CE98",
"navigationBarTextStyle": "white" "navigationBarTextStyle": "white"
} }
},{
"path" : "pages/im/private/chat",
"style" : {
"disableScroll": true,
"navigationBarTitleText": "聊天",
"enablePullDownRefresh": false,
"navigationBarBackgroundColor":"#F3F6FB"
}
} }
], ],
"tabBar": { "tabBar": {

View File

@@ -1,20 +0,0 @@
<template>
<div>
<u-button @click="toIndex">会首页</u-button>
</div>
</template>
<script>
export default {
methods: {
toIndex() {
uni.switchTab({
url: '/pages/im/index'
})
}
}
}
</script>
<style>
</style>

View File

@@ -55,7 +55,7 @@
<u-icon class="icon-u" name="camera-fill" color="#fff" size="26"></u-icon> <u-icon class="icon-u" name="camera-fill" color="#fff" size="26"></u-icon>
</view> </view>
<view class="text">视频通话</view> <view class="text">视频通话</view>
</view> </view>
</view> </view>
</block> </block>
<block v-else> <block v-else>
@@ -124,84 +124,122 @@
if (code == 0) { if (code == 0) {
this.isTop = conversation.isTop this.isTop = conversation.isTop
} }
}) });
}, },
methods: { toPrivate() {
copyAddress() { uni.redirectTo({
uni.setClipboardData({ url: '/pages/im/private/index?conversationType=1&targetId=' + this.targetId
data: this.userInfo.address, });
success: () => { },
uni.showToast({ setRemark() {
icon: 'none', uni.showToast({
title: '复制区块链成功' title: '开发中',
icon: 'none'
});
},
deleteFriend() {
uni.showModal({
title: '删除确认',
content: '确认删除后不可恢复',
success: e => {
if (e.confirm) {
deleteFriend(this.targetId).then(res => {
// 删除聊天记录
RongIMLib.deleteMessages(1, this.targetId);
RongIMLib.removeConversation(1, this.targetId);
uni.showToast({
icon: 'none',
title: '好友删除成功',
success() {
uni.switchTab({
url: '/pages/im/index'
});
}
});
});
}
}) })
} },
}) toPrivate() {
}, uni.redirectTo({
toPrivate() { url: '/pages/im/private/index?conversationType=1&targetId=' + this.targetId
uni.redirectTo({ })
url: '/pages/im/private/index?conversationType=1&targetId=' + this.targetId },
}) setRemark() {
}, uni.showToast({
setRemark() { title: '开发中',
uni.showToast({ icon: 'none'
title: '开发中', })
icon: 'none' },
}) deleteFriend() {
}, uni.showModal({
deleteFriend() { title: '删除确认',
uni.showModal({ content: '确认删除后不可恢复',
title: '删除确认', success: (e) => {
content: '确认删除后不可恢复', if (e.confirm) {
success: (e) => { deleteFriend(this.targetId).then(res => {
if (e.confirm) { // 删除聊天记录
deleteFriend(this.targetId).then(res => { RongIMLib.deleteMessages(1, this.targetId)
// 删除聊天记录 RongIMLib.removeConversation(1, this.targetId)
RongIMLib.deleteMessages(1, this.targetId) uni.showToast({
RongIMLib.removeConversation(1, this.targetId) icon: 'none',
uni.showToast({ title: '好友删除成功',
icon: 'none', success() {
title: '好友删除成功', uni.switchTab({
success() { url: '/pages/im/index'
uni.switchTab({ })
url: '/pages/im/index' }
}) })
}
}) })
}) }
} }
} })
}) },
}, setStatus() {
setStatus() { RongIMLib.setConversationNotificationStatus(this.conversationType, this.targetId, this.status, ({
RongIMLib.setConversationNotificationStatus(this.conversationType, this.targetId, this.status, ({ status
status
}) => {
this.status = !Boolean(status)
})
},
setTop() {
RongIMLib.setConversationToTop(this.conversationType, this.targetId, this.isTop, (res) => {
RongIMLib.getConversation(this.conversationType, this.targetId, ({
conversation
}) => { }) => {
this.isTop = conversation.isTop this.status = !Boolean(status)
}) })
}) },
}, setTop() {
// 申请好友 RongIMLib.setConversationToTop(this.conversationType, this.targetId, this.isTop, (res) => {
toBeFriend() { RongIMLib.getConversation(this.conversationType, this.targetId, ({
pedingFriend(this.targetId).then(res => { conversation
uni.showToast({ }) => {
title: '申请成功', this.isTop = conversation.isTop
icon: "none" })
}) })
}).catch(err => { },
uni.showToast({ // 申请好友
icon: 'error', toBeFriend() {
title: err.message, pedingFriend(this.targetId).then(res => {
duration: 2000 uni.showToast({
title: '申请成功',
icon: 'none'
});
})
.catch(err => {
uni.showToast({
icon: 'error',
title: err.message,
duration: 2000
})
})
},
singleCall(e) {
CallLib.startSingleCall(this.targetId, e.type, '');
uni.redirectTo({
url: '/pages/im/private/call',
success: (err) => {
console.log('跳转视频通话成功');
},
fail: (err) => {
console.log('跳转视频页失败', err);
}
}) })
<<<<<<< HEAD
}) })
}, },
singleCall(e) { singleCall(e) {
@@ -216,7 +254,11 @@
} }
}) })
}, },
=======
},
>>>>>>> d3c351f58f900a4484c2811b73ef00ace4632e2b
} }
}
}; };
</script> </script>

View File

@@ -56,7 +56,7 @@
{{item}} {{item}}
</view> </view>
</view> </view>
</view> </view>
</block> </block>
</view> </view>
<!-- 未登录 --> <!-- 未登录 -->
@@ -74,10 +74,7 @@
import * as RongIMLib from "@/uni_modules/RongCloud-IMWrapper/js_sdk/index" import * as RongIMLib from "@/uni_modules/RongCloud-IMWrapper/js_sdk/index"
import im from '@/utils/im/index.js' import im from '@/utils/im/index.js'
import userAuth from '@/public/userAuth' import userAuth from '@/public/userAuth'
import { import { getImToken } from '@/apis/interfaces/im.js'
getImToken
} from '@/apis/interfaces/im.js'
export default { export default {
data() { data() {
return { return {

112
pages/im/private/chat.nvue Normal file
View File

@@ -0,0 +1,112 @@
<template>
<view class="chat">
<!-- chat -->
<scroll-view class="chat-scroll" scroll-y="true" :scroll-into-view="toMsg" scroll-with-animation>
<view v-for="(item, index) in msgArr" :key="index" :id="'msg'+index">{{toMsg || '-'}} / msg{{item}} - {{index}}</view>
</scroll-view>
<!-- chat-footer -->
<view class="chat-footer">
<view class="msg-type" @click="msgType">
<image class="msg-type-icon" src="@/static/icon/key-icon.png" v-if="importTabs === 0" mode="widthFix"></image>
<image class="msg-type-icon" src="@/static/icon/msg-icon.png" v-if="importTabs === 1" mode="widthFix"></image>
</view>
<block v-if="importTabs === 0">
<view class="chat-mp3" hover-class="chat-hover" @touchstart="startAudio" @touchend="chendAudio">
<text class="chat-mp3-text">按住说话</text>
</view>
</block>
<block v-if="importTabs === 1">
<input class="chat-input" type="text" v-model="inputTxt" confirm-type="发送" @confirm="send" cursor-spacing="10" />
</block>
<text class="chat-push" :disabled="disabled" size="mini" @click="send">发送</text>
</view>
</view>
</template>
<script>
export default {
data() {
return {
toMsg : '',
msgArr : [
"NVUE界面信息"
],
importTabs: 1
}
},
created() {
},
methods: {
send(){
this.msgArr.push("新消息NVUE")
this.toMsg = 'msg' + (this.msgArr.length - 1)
},
msgType(){
this.importTabs = this.importTabs === 1 ? 0 : 1
}
}
}
</script>
<style scoped>
/* 窗口 */
.chat{
background: #F3F6FB;
flex: 1;
}
.chat-scroll{
flex: 1;
}
/* footer */
.chat-footer{
background: white;
padding: 20upx 30upx;
display: flex;
justify-content: space-between;
flex-direction: row;
}
.msg-type{
width: 70upx;
height: 70upx;
}
.msg-type > .msg-type-icon{
margin: 5upx;
width: 60upx;
height: 60upx;
}
.chat-mp3{
background: #F3F6FB;
height: 70upx;
line-height: 70upx;
justify-content: center;
align-items: center;
width: 460upx;
border-radius: 10upx;
margin-right: 15upx;
}
.chat-mp3-text{
font-size: 30upx;
color: #333;
}
.chat-input{
background: #F3F6FB;
height: 70upx;
width: 460upx;
border-radius: 10upx;
margin-right: 15upx;
padding: 0 20upx;
}
.chat-push{
background: #34CE98;
color: white;
width: 120upx;
line-height: 70upx;
text-align: center;
border-radius: 10upx;
font-size: 30upx;
font-weight: bold;
}
</style>