diff --git a/uni_modules/uni-id-pages/components/cloud-image/cloud-image.vue b/uni_modules/uni-id-pages/components/cloud-image/cloud-image.vue
index 831d9310398fa57366c2a55a787d44a89ad58a56..f36bb91a7097a973d5c7d7597ecb0828c0ff08df 100644
--- a/uni_modules/uni-id-pages/components/cloud-image/cloud-image.vue
+++ b/uni_modules/uni-id-pages/components/cloud-image/cloud-image.vue
@@ -1,9 +1,9 @@
-
+
-
-
-
-
+
+
+
+
\ No newline at end of file
diff --git a/uni_modules/uni-im/changelog.md b/uni_modules/uni-im/changelog.md
index 3b37d797adf9bafcc1c19e726005b7ee0b9e5068..27c686ee79b164b667c43eebf4e64a804c5d16f0 100644
--- a/uni_modules/uni-im/changelog.md
+++ b/uni_modules/uni-im/changelog.md
@@ -1,3 +1,8 @@
+## 1.3.2(2022-12-05)
+- 修复 因vue2与vue3下 :key 的位置要求不同 引起的chat页面报错问题
+## 1.3.1(2022-12-05)
+- 修复 1.3.0版引起的截图粘贴发送失败的问题
+- 修复 集成到 uni-admin 中样式设置失败的问题
## 1.3.0(2022-12-02)
- 修复 APP端当消息未满半屏时,弹出的键盘会将消息顶出界面外
- 新增 消息类型支持代码模式
diff --git a/uni_modules/uni-im/common/store.js b/uni_modules/uni-im/common/store.js
index 40760a1896e8ef93de65fd5a4f6a11d7bff42a21..56daae58b85bb24a69cc38c9716ec041dbeadc7c 100644
--- a/uni_modules/uni-im/common/store.js
+++ b/uni_modules/uni-im/common/store.js
@@ -169,7 +169,7 @@ export default {
},
async initConversationData(context){
getConversationDatasPage = 0
- getApp().globalData.uniIm = {"msgManagers":{}}
+ getApp().globalData.uniIm.msgManagers = {}
await context.commit('clearConversationDatas')
await context.dispatch('loadMoreConversation')
},
diff --git a/uni_modules/uni-im/common/utils.js b/uni_modules/uni-im/common/utils.js
index d99e3f5ebc2cb70651c660921012013ce4281fd5..5739c2364cc7e1a9ee18838008e29b2e5ffb27ff 100644
--- a/uni_modules/uni-im/common/utils.js
+++ b/uni_modules/uni-im/common/utils.js
@@ -12,7 +12,10 @@ export default {
init(){
setTimeout(()=>{
// 初始化uniIm依赖的全局变量
- getApp().globalData.uniIm = {"msgManagers":{}}
+ getApp().globalData.uniIm = {
+ "msgManagers":{},
+ audioContext:uni.createInnerAudioContext()
+ }
},0)
//监听im消息
@@ -59,11 +62,23 @@ export default {
listenImMsg(){
uni.onPushMessage(async res => {
const {currentConversationId} = $store.state.uniIm
- // console.log('收到消息 onPushMessage===================',res.type, res.data,currentConversationId );
+ console.log('收到消息 onPushMessage===================',res.type, res.data,currentConversationId );
const {payload} = res.data
if (payload.type == 'im') {
const msg = payload.data
// console.log({msg});
+
+ const {msg_id} = payload
+ if(msg_id){
+ const db = uniCloud.database();
+ let res = await db.collection('uni-im-msg').doc(msg_id).get()
+ console.error(res);
+ if(res.result.code == 0){
+ payload.data.body = res.result.data[0].body
+ }
+ }
+
+
if(res.type =='receive'){
// console.log(777);
const {conversation_id} = msg
diff --git a/uni_modules/uni-im/components/uni-im-code-view/default.css b/uni_modules/uni-im/components/uni-im-code-view/default.css
new file mode 100644
index 0000000000000000000000000000000000000000..a75ea911626816107a2a126d4a990e187bc9d7ee
--- /dev/null
+++ b/uni_modules/uni-im/components/uni-im-code-view/default.css
@@ -0,0 +1,9 @@
+/*!
+ Theme: Default
+ Description: Original highlight.js style
+ Author: (c) Ivan Sagalaev
+ Maintainer: @highlightjs/core-team
+ Website: https://highlightjs.org/
+ License: see project LICENSE
+ Touched: 2021
+*/pre code.hljs{display:block;overflow-x:auto;padding:1em}code.hljs{padding:3px 5px}.hljs{background:#f3f3f3;color:#444}.hljs-comment{color:#697070}.hljs-punctuation,.hljs-tag{color:#444a}.hljs-tag .hljs-attr,.hljs-tag .hljs-name{color:#444}.hljs-attribute,.hljs-doctag,.hljs-keyword,.hljs-meta .hljs-keyword,.hljs-name,.hljs-selector-tag{font-weight:700}.hljs-deletion,.hljs-number,.hljs-quote,.hljs-selector-class,.hljs-selector-id,.hljs-string,.hljs-template-tag,.hljs-type{color:#800}.hljs-section,.hljs-title{color:#800;font-weight:700}.hljs-link,.hljs-operator,.hljs-regexp,.hljs-selector-attr,.hljs-selector-pseudo,.hljs-symbol,.hljs-template-variable,.hljs-variable{color:#ab5656}.hljs-literal{color:#695}.hljs-addition,.hljs-built_in,.hljs-bullet,.hljs-code{color:#397300}.hljs-meta{color:#1f7199}.hljs-meta .hljs-string{color:#38a}.hljs-emphasis{font-style:italic}.hljs-strong{font-weight:700}
\ No newline at end of file
diff --git a/uni_modules/uni-im/components/uni-im-code-view/package-lock.json b/uni_modules/uni-im/components/uni-im-code-view/package-lock.json
new file mode 100644
index 0000000000000000000000000000000000000000..c35689962ff786e565c29dcbfbd2c6a204b76a52
--- /dev/null
+++ b/uni_modules/uni-im/components/uni-im-code-view/package-lock.json
@@ -0,0 +1,31 @@
+{
+ "name": "uni-im-code-view",
+ "version": "1.0.0",
+ "lockfileVersion": 2,
+ "requires": true,
+ "packages": {
+ "": {
+ "name": "uni-im-code-view",
+ "version": "1.0.0",
+ "license": "ISC",
+ "dependencies": {
+ "highlight.js": "^11.7.0"
+ }
+ },
+ "node_modules/highlight.js": {
+ "version": "11.7.0",
+ "resolved": "https://registry.npmjs.org/highlight.js/-/highlight.js-11.7.0.tgz",
+ "integrity": "sha512-1rRqesRFhMO/PRF+G86evnyJkCgaZFOI+Z6kdj15TA18funfoqJXvgPCLSf0SWq3SRfg1j3HlDs8o4s3EGq1oQ==",
+ "engines": {
+ "node": ">=12.0.0"
+ }
+ }
+ },
+ "dependencies": {
+ "highlight.js": {
+ "version": "11.7.0",
+ "resolved": "https://registry.npmjs.org/highlight.js/-/highlight.js-11.7.0.tgz",
+ "integrity": "sha512-1rRqesRFhMO/PRF+G86evnyJkCgaZFOI+Z6kdj15TA18funfoqJXvgPCLSf0SWq3SRfg1j3HlDs8o4s3EGq1oQ=="
+ }
+ }
+}
diff --git a/uni_modules/uni-im/components/uni-im-code-view/package.json b/uni_modules/uni-im/components/uni-im-code-view/package.json
new file mode 100644
index 0000000000000000000000000000000000000000..d9bd0742e98db509eba5ea9d0e0ccc315d914013
--- /dev/null
+++ b/uni_modules/uni-im/components/uni-im-code-view/package.json
@@ -0,0 +1,14 @@
+{
+ "name": "uni-im-code-view",
+ "version": "1.0.0",
+ "description": "",
+ "main": "index.js",
+ "scripts": {
+ "test": "echo \"Error: no test specified\" && exit 1"
+ },
+ "author": "",
+ "license": "ISC",
+ "dependencies": {
+ "highlight.js": "^11.7.0"
+ }
+}
diff --git a/uni_modules/uni-im/components/uni-im-code-view/uni-im-code-view.vue b/uni_modules/uni-im/components/uni-im-code-view/uni-im-code-view.vue
new file mode 100644
index 0000000000000000000000000000000000000000..ac5e7482c53c540d5aa6f2a9de3ba9698fe25371
--- /dev/null
+++ b/uni_modules/uni-im/components/uni-im-code-view/uni-im-code-view.vue
@@ -0,0 +1,220 @@
+
+
+
+
+ - 展开
+
+
+
+
+
+
+
+
diff --git a/uni_modules/uni-im/components/uni-im-icons/uni-im-icons.ttf b/uni_modules/uni-im/components/uni-im-icons/uni-im-icons.ttf
new file mode 100644
index 0000000000000000000000000000000000000000..990da612d58da44bcd9ba7e88053acf4e93e4471
Binary files /dev/null and b/uni_modules/uni-im/components/uni-im-icons/uni-im-icons.ttf differ
diff --git a/uni_modules/uni-im/components/uni-im-icons/uni-im-icons.vue b/uni_modules/uni-im/components/uni-im-icons/uni-im-icons.vue
new file mode 100644
index 0000000000000000000000000000000000000000..65771d56568211784bd1dec870ca8e263c17243f
--- /dev/null
+++ b/uni_modules/uni-im/components/uni-im-icons/uni-im-icons.vue
@@ -0,0 +1,84 @@
+
+
+ {{unicode}}
+
+
+
+
+
+
diff --git a/uni_modules/uni-im/components/uni-im-msg/uni-im-msg.vue b/uni_modules/uni-im/components/uni-im-msg/uni-im-msg.vue
old mode 100755
new mode 100644
index dfb3ee5a27618c608da40591d4f84fbde5991efd..9cac881255ef104bafae185b5910df15e09bcd63
--- a/uni_modules/uni-im/components/uni-im-msg/uni-im-msg.vue
+++ b/uni_modules/uni-im/components/uni-im-msg/uni-im-msg.vue
@@ -6,12 +6,19 @@
-
-
-
+
+
+
+ {{msg.body.time}}''
+
+
+
+
-
@@ -27,21 +34,33 @@
{{ item.text }}
- {{item.attrs.href}}
+ {{item.attrs.href}}
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
-
+
+
+ {{fileName}}
+ {{fileSize}}
+
+
+
@@ -51,46 +70,54 @@
import {
store as uniIdStore,
} from '@/uni_modules/uni-id-pages/common/store'
- import parseHtml from './html-parser.js';
+ import parseHtml from './html-parser.js';
+
+ let audioContext
+ setTimeout(()=> {
+ audioContext = getApp().globalData.uniIm.audioContext
+ }, 0);
+
export default {
data() {
return {
- username: "用户名"
+ username: "用户名",
+ videoUrl: '',
+ soundPlayState: 0
};
},
- mounted() {
- if(this.msg.type == 'video'){
- this.videoUrl = this.msg.body.url
- // return
- // uniCloud.getTempFileURL({
- // fileList: [this.msg.body]
- // }).then(res => {
- // console.log(999999, res);
- // // 兼容uniCloud私有化部署
- // let fileList = res.fileList || res.result.fileList
- // this.videoUrl = fileList[0].tempFileURL
- // console.log('this.videoUrl', this.videoUrl);
- // }).catch(e => {
- // this.videoUrl = this.msg.body
- // })
- }else if(this.msg.type == 'sound'){
- audioContext.onPlay(() => {
- // console.log('soundPlayStart------------------');
- let src = getApp().globalData.uniIm.audioContext.src
- if(src == this.msg.body.url){
- this.soundPlayState = 1
- }
- });
-
- let soundPlayEnd = () => {
- // console.log('soundPlayEnd------------------');
- this.soundPlayState = 0
- }
- audioContext.onPause(soundPlayEnd);
- audioContext.onStop(soundPlayEnd);
- audioContext.onEnded(soundPlayEnd);
- audioContext.onError(soundPlayEnd);
- }
+ mounted() {
+ if(this.msg.type == 'video'){
+ this.videoUrl = this.msg.body.url
+ // return
+ // uniCloud.getTempFileURL({
+ // fileList: [this.msg.body]
+ // }).then(res => {
+ // console.log(999999, res);
+ // // 兼容uniCloud私有化部署
+ // let fileList = res.fileList || res.result.fileList
+ // this.videoUrl = fileList[0].tempFileURL
+ // console.log('this.videoUrl', this.videoUrl);
+ // }).catch(e => {
+ // this.videoUrl = this.msg.body
+ // })
+ }else if(this.msg.type == 'sound'){
+ audioContext.onPlay(() => {
+ // console.log('soundPlayStart------------------');
+ let src = getApp().globalData.uniIm.audioContext.src
+ if(src == this.msg.body.url){
+ this.soundPlayState = 1
+ }
+ });
+
+ let soundPlayEnd = () => {
+ // console.log('soundPlayEnd------------------');
+ this.soundPlayState = 0
+ }
+ audioContext.onPause(soundPlayEnd);
+ audioContext.onStop(soundPlayEnd);
+ audioContext.onEnded(soundPlayEnd);
+ audioContext.onError(soundPlayEnd);
+ }
},
props: {
msg: {
@@ -144,10 +171,13 @@
},
msgClass() {
var msgClass = ''
- let textLength = this.msg.body.replace(/[\u0000-\u007f]/g, "a").replace(/[\u0080-\u07ff]/g, "aa").replace(
- /[\u0800-\uffff]/g, "aa").length
- if (textLength > 30) {
- msgClass += ' exceed'
+ if (this.msg.type == 'text') {
+ let textLength = this.msg.body.replace(/[\u0000-\u007f]/g, "a").replace(/[\u0080-\u07ff]/g, "aa")
+ .replace(
+ /[\u0800-\uffff]/g, "aa").length
+ if (textLength > 30) {
+ msgClass += ' exceed'
+ }
}
if (this.self) {
msgClass += ' self-text-box'
@@ -162,61 +192,96 @@
return this.avatar_file?.url
}
},
+ soundBoxWidth() {
+ return uni.upx2px(750 / 60 * this.msg.body.time) + 50 + 'px'
+ },
htmlString() {
- let content = this.msg.body//.replace(/' + match + " ";
- });
- /*
- // 手机号正则
- const regPhone = /(13[0-9]|14[5-9]|15[012356789]|166|17[0-8]|18[0-9]|19[8-9])[0-9]{8}/g;
- content = content.replace(regPhone, " $&")
- // 固定电话正则
- const regTel = /(([0\+]\d{2,3}-)?(0\d{2,3})-)(\d{7,8})(-(\d{3,}))?/g;
- content = content.replace(regTel, " $&")
-
- // 邮箱正则
- const regMail = /([a-z0-9._-]+@[a-z0-9.-]+\.[a-z]{2,4})/ig;
- content = content.replace(regMail, " $&")
- */
- return content
+ }
+
+ // 找网址
+ let urlPattern = /(https?:\/\/|www\.)[-A-Za-z0-9+&@#/%?=~_|!:,.;]+[-A-Za-z0-9+&@#/%=~_|]/g;
+ content = content.replace(urlPattern, function(match) {
+ var href = match;
+ if (match.indexOf("http") == -1) {
+ //如果不带http://开头就带上
+ href = "http://" + match;
+ }
+ return '' + match + " ";
+ });
+ /*
+ // 手机号正则
+ const regPhone = /(13[0-9]|14[5-9]|15[012356789]|166|17[0-8]|18[0-9]|19[8-9])[0-9]{8}/g;
+ content = content.replace(regPhone, " $&")
+ // 固定电话正则
+ const regTel = /(([0\+]\d{2,3}-)?(0\d{2,3})-)(\d{7,8})(-(\d{3,}))?/g;
+ content = content.replace(regTel, " $&")
+
+ // 邮箱正则
+ const regMail = /([a-z0-9._-]+@[a-z0-9.-]+\.[a-z]{2,4})/ig;
+ content = content.replace(regMail, " $&")
+ */
+ return content
+
},
nodes() {
- if(this.msg.body == this.htmlString){
- return
+ if (this.msg.body == this.htmlString) {
+ return
}
- try{
- let nodes = parseHtml(this.htmlString)
+ try {
+ let nodes = parseHtml(this.htmlString)
// console.log('nodes',nodes);
- nodes.map(item=>{
+ nodes.map(item => {
// console.log('item',item);
- if(item.attrs&&item.attrs.class){
+ if (item.attrs && item.attrs.class) {
item.attrs.class += " msg-text"
- }else{
- item.attrs = {class:"msg-text"}
+ } else {
+ item.attrs = {
+ class: "msg-text"
+ }
}
return item
})
return nodes
- }catch(e){
- console.error('htmlString error:',e);
+ } catch (e) {
+ console.error('htmlString error:', e);
return ''
//TODO handle the exception
}
-
+
+ },
+ fileSize() {
+ if (this.msg.type == 'file') {
+ let size = this.msg.body.size
+ if(size < Math.pow(1024,1) ){
+ return parseInt(size * 10)/10 + 'B'
+ }else if(size < Math.pow(1024,2) ){
+ return parseInt(size/Math.pow(1024,1) * 10) / 10 + 'KB'
+ }else if(size < Math.pow(1024,3) ){
+ return parseInt(size/Math.pow(1024,2) * 10) / 10 + 'MB'
+ }else {
+ return 'err'
+ }
+
+ }
+ },
+ fileName(){
+ if (this.msg.type == 'file') {
+ let name = this.msg.body.name
+ if(name.length < 30){
+ return name
+ }else{
+ return name.slice(0,15) + '...'+name.slice(-15)
+ }
+ }
}
},
methods: {
@@ -237,21 +302,22 @@
});
// #endif
},
- playSound(url) {
- // console.log("playSound", url);
- audioContext.src = url;
- // console.log(78998797,audioContext);
- if(this.soundPlayState === 1){
- // console.log('播放中,执行关闭');
- audioContext.stop()
- }else{
- audioContext.stop()
- audioContext.play();
- }
+ playSound(url) {
+ // console.log("playSound", url);
+ audioContext.src = url;
+ // console.log(78998797,audioContext);
+ if(this.soundPlayState === 1){
+ // console.log('播放中,执行关闭');
+ audioContext.stop()
+ }else{
+ audioContext.stop()
+ audioContext.play();
+ }
},
previewImage(url) {
uni.showLoading();
- if (url.includes('://') && !url.includes('https://img-cdn-tc.dcloud.net.cn/uploads/avatar')&& !url.includes('https://ask.dcloud.net.cn/uploads/avatar')) {
+ if (url.includes('://') && !url.includes('https://img-cdn-tc.dcloud.net.cn/uploads/avatar') && !url
+ .includes('https://ask.dcloud.net.cn/uploads/avatar')) {
uniCloud.getTempFileURL({
fileList: [url]
}).then(res => {
@@ -275,7 +341,9 @@
},
playVideo() {
uni.navigateTo({
- url: "/pages/common/webview/webview?url=" + this.msg.body
+ url: "/uni_modules/uni-im/pages/common/video/video?url=" + this.videoUrl,
+ animationDuration: 300,
+ animationType: "fade-in"
})
},
async showControl() {
@@ -333,34 +401,33 @@
// }
this.$emit('retries', this.msg)
},
- downLoadFile() {
- // #ifdef H5
- return window.open(this.msg.body.url)
- // #endif
+ downLoadFile() {
+ // #ifdef H5
+ return window.open(this.msg.body.url)
+ // #endif
- // #ifndef H5
- uni.downloadFile({
- url: this.msg.body.url,
- success: (res) => {
- if (res.statusCode === 200) {
- // console.log('下载成功');
- // console.log(res.tempFilePath);
- uni.saveFile({
- tempFilePath: res.tempFilePath,
- success: (res)=> {
- // console.log('res',res);
- uni.openDocument({filePath:res.savedFilePath})
- }
- });
- }
- }
- });
+ // #ifndef H5
+ uni.downloadFile({
+ url: this.msg.body.url,
+ success: (res) => {
+ if (res.statusCode === 200) {
+ // console.log('下载成功');
+ // console.log(res.tempFilePath);
+ uni.saveFile({
+ tempFilePath: res.tempFilePath,
+ success: (res)=> {
+ // console.log('res',res);
+ uni.openDocument({filePath:res.savedFilePath})
+ }
+ });
+ }
+ }
+ });
// #endif
}
}
}
-
+
+ .video-box {
+ width: 200rpx;
+ height: 200rpx;
+ position: relative;
+ }
+
+ .video-img {
+ width: 200rpx;
+ height: 200rpx;
+ }
+
+ .play-video-icon {
+ position: absolute;
+ width: 60rpx;
+ height: 60rpx;
+ top: 70rpx;
+ left: 70rpx;
+ }
+
+ .video-box-mark {
+ position: absolute;
+ top: 0;
+ left: 0;
+ background-color: rgba(0, 0, 0, 0.1);
+ }
+
+ .sound-box {
+ flex-direction: row;
+ background-color: #94EB6A;
+ height: 44px;
+ padding: 10px;
+ width: 66px;
+ border-radius: 5px;
+ justify-content: flex-end;
+ align-items: center;
+ }
+
+ .sound-time {
+ font-size: 14px;
+ margin-right: 2px;
+ }
+
+ .sound-icon-active {
+ transform: option;
+ opacity: 10;
+ background-color: #007AFF;
+ transition-property: background-color;
+ transition-duration: 0.3s;
+ transition-delay: 0.1s;
+ transition-timing-function: cubic-bezier(0.25, 0.1, 0.25, 1.0);
+ }
+
+ .file-msg-box {
+ background-color: #FFFFFF;
+ width: 500rpx;
+ padding: 20rpx;
+ border-radius: 8px;
+ flex-direction: row;
+ justify-content: space-between;
+ }
+
+ .file-msg-info {
+ width: 300rpx;
+ flex-direction: column;
+ justify-content: space-around;
+ }
+
+ .file-msg-info-name {
+ /* #ifndef APP-NVUE */
+ word-wrap: break-word;
+ /* #endif */
+ font-size: 16px;
+ }
+
+ .file-msg-info-size {
+ font-size: 12px;
+ color: #666;
+ }
+
diff --git a/uni_modules/uni-im/components/uni-im-sound/uni-im-sound.vue b/uni_modules/uni-im/components/uni-im-sound/uni-im-sound.vue
new file mode 100644
index 0000000000000000000000000000000000000000..95bc36c877eb4b6d17b0f135750451e2e7cc7d7d
--- /dev/null
+++ b/uni_modules/uni-im/components/uni-im-sound/uni-im-sound.vue
@@ -0,0 +1,214 @@
+
+
+
+
+
+ {{soundState?'录音中('+time+'s)':'按住 说话'}}
+
+ {{cancel?'松手取消':'松手发送,上划取消'}}
+
+
+
+
+
+
+
+
+
+
+
diff --git a/uni_modules/uni-im/package.json b/uni_modules/uni-im/package.json
index 6f7f0bd18a3cc6a1b03ab4583aea5422192fc7b0..b0b1a7c31fb733d10b63441901e9d492ff72437a 100644
--- a/uni_modules/uni-im/package.json
+++ b/uni_modules/uni-im/package.json
@@ -1,10 +1,10 @@
{
"id": "uni-im",
"displayName": "uni-im",
- "version": "1.3.0",
+ "version": "1.3.2",
"description": "uni-im是云端一体的、全平台的、免费的、开源即时通讯系统",
"keywords": [
- "uni-im,即时通讯,客服,聊天"
+ "im,即时通讯,客服,聊天"
],
"repository": "https://gitcode.net/dcloud/hello-uni-im",
"engines": {
diff --git a/uni_modules/uni-im/pages/chat/chat.nvue b/uni_modules/uni-im/pages/chat/chat.nvue
index 8c0137dd3b0087d0d1faade6b6098df86948f0a3..df6a59d47dcabfb7ea526c7d37da64b771286048 100644
--- a/uni_modules/uni-im/pages/chat/chat.nvue
+++ b/uni_modules/uni-im/pages/chat/chat.nvue
@@ -1,5 +1,5 @@
-
+
@@ -49,37 +49,56 @@
- 暂无聊天记录 -
-
+
-
+
-
-
+
+
-
-
+
+
+
+
+
+
+
+
diff --git a/uni_modules/uni-im/pages/common/video/video.nvue b/uni_modules/uni-im/pages/common/video/video.nvue
new file mode 100644
index 0000000000000000000000000000000000000000..58e487b21342d74610a097b4b63e8b25aba6b7c5
--- /dev/null
+++ b/uni_modules/uni-im/pages/common/video/video.nvue
@@ -0,0 +1,51 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/uni_modules/uni-im/pages/index/index.nvue b/uni_modules/uni-im/pages/index/index.nvue
index 56683e6cd3b611095a8b1c319ee205f63f13670a..f700f168a5d14fc2cc7cd96c68c906c22106f652 100644
--- a/uni_modules/uni-im/pages/index/index.nvue
+++ b/uni_modules/uni-im/pages/index/index.nvue
@@ -126,7 +126,7 @@
wHeight: 'auto',
isWidescreen: false,
userInfo: {},
- scrollTop: 0
+ scrollTop: 0
};
},
async onShow() {
@@ -151,8 +151,11 @@
// #ifdef H5
uni.$on('uni-im-showLast', e => {
- // console.log('uni-im-showLast');
- this.scrollTop = document.querySelector('#chat-view .uni-scroll-view-content').scrollHeight
+ // console.log('uni-im-showLast');
+ let dom = document.querySelector('#chat-view .uni-scroll-view-content')
+ if(dom){
+ this.scrollTop = dom.scrollHeight
+ }
})
// #endif
},
@@ -163,7 +166,7 @@
conversation_id
}) {
// 发布新版本后,清理旧版本下的storage避免脏数据引发问题
- let version = '2022.11.23.01'
+ let version = '2022.12.01.01'
if (uni.getStorageSync('uni-im-storage-version') != version) {
let data = uni.getStorageInfoSync();
// console.log('data.keys', JSON.stringify(data.keys));
@@ -171,7 +174,6 @@
if (item.includes('uni-im-msg:') || item.includes('uni-im-conversation')) {
// console.log(item);
uni.removeStorageSync(item);
- console.log(uni.getStorageSync(item));
}
});
uni.setStorageSync('uni-im-storage-version',version)
@@ -192,28 +194,31 @@
let res = await uniImCo.login(token)
await uniIdMutations.updateUserInfo()
} else {
- if (!uniCloud.getCurrentUserInfo().uid) {
+ if (!uniCloud.getCurrentUserInfo().uid) {
return uni.redirectTo({
url: '/uni_modules/uni-id-pages/pages/login/login-withpwd'
})
- }
- }
- this.init({
- user_id,
- goods,
- conversation_id
- })
-
- uni.$on('uni-id-pages-login-success', async () => {
- this.init({
- user_id,
- goods,
- conversation_id
- })
- })
- },
- onUnload() {
- uni.$off('uni-id-pages-login-success')
+ }
+ }
+
+ this.$nextTick(()=>{
+ this.init({
+ user_id,
+ goods,
+ conversation_id
+ })
+ })
+
+ uni.$on('uni-id-pages-login-success', async () => {
+ this.init({
+ user_id,
+ goods,
+ conversation_id
+ })
+ })
+ },
+ onUnload() {
+ uni.$off('uni-id-pages-login-success')
},
onHide() {},
methods: {
@@ -232,8 +237,9 @@
conversation_id,
user_id,
goods
- }) {
+ }) {
// 初始化会话列表
+ // console.log('初始化会话列表');
await this.initConversationData()
if (conversation_id) {
console.log('conversation_id', conversation_id);
@@ -274,7 +280,7 @@
if (name && url) {
this.$refs['chat-view'].chatText = '【' + name + ':' + url + '】'
}
- }
+ }
},
search(e) {
// console.log("search-e: " + JSON.stringify(e));
@@ -310,9 +316,9 @@
// console.log('toChat',{conversation_id,'isWidescreen':this.isWidescreen});
this.setCurrentConversationId(conversation_id);
if (this.isWidescreen) { //若为宽屏,则触发右侧详情页的自定义事件,通知右侧窗体刷新详情
- if(this.$refs['chat-view']){
- this.$refs['chat-view'].load(conversation_id)
- }
+ if(this.$refs['chat-view']){
+ this.$refs['chat-view'].load(conversation_id)
+ }
} else { // 若为窄屏,则打开新窗体,在新窗体打开详情页面
uni.navigateTo({
url: '/uni_modules/uni-im/pages/chat/chat?conversation_id=' + conversation_id,
@@ -345,17 +351,36 @@
return
}
- const oldClassName = 'uni-body uni_modules-uni-im-pages-index-index'
- if (this.isWidescreen) {
- conversationDom.querySelector('uni-page-body').style.background = 'none'
- conversationDom.querySelector('.uni-page-head').style.display = 'none'
- conversationDom.querySelector('.uni-placeholder').style.display = 'none'
- conversationDom.querySelector('uni-page').style.transform = 'scale(0.86) translateY(-30px)';
+ const oldClassName = 'uni-body uni_modules-uni-im-pages-index-index'
+ let uniPageBodyDom = conversationDom.querySelector('uni-page-body'),
+ uniPageHeadDom = conversationDom.querySelector('.uni-page-head'),
+ uniPlaceholderDom = conversationDom.querySelector('.uni-placeholder'),
+ uniPageDom = conversationDom.querySelector('uni-page')
+
+ if (this.isWidescreen) {
+ if(uniPageBodyDom){
+ uniPageBodyDom.style.background = 'none'
+ }
+ if(uniPageHeadDom){
+ uniPageHeadDom.style.display = 'none'
+ }
+ if(uniPlaceholderDom){
+ uniPlaceholderDom.style.display = 'none'
+ }
+ if(uniPageDom){
+ uniPageDom.style.transform = 'scale(0.86) translateY(-30px)';
+ }
conversationDom.className = oldClassName + ' uni-im-dark'
- } else {
- conversationDom.querySelector('.uni-page-head').style.display = 'block'
- conversationDom.querySelector('.uni-placeholder').style.display = 'block'
- conversationDom.querySelector('uni-page').style.transform = 'scale(1)';
+ } else {
+ if(uniPageHeadDom){
+ uniPageHeadDom.style.display = 'block'
+ }
+ if(uniPlaceholderDom){
+ uniPlaceholderDom.style.display = 'block'
+ }
+ if(uniPageDom){
+ uniPageDom.style.transform = 'scale(1)';
+ }
conversationDom.className = oldClassName
}
// #endif
@@ -394,6 +419,9 @@