@@ -245,7 +263,7 @@ const formatTime = (value: number = 0) => {
}
}
-html[theme-mode="dark"] {
+html[theme-mode='dark'] {
.im-message-audio {
--audio-bg-color: #2c2c32;
--audio-btn-bg-color: rgb(78, 75, 75);
diff --git a/src/event/talk.js b/src/event/talk.js
index 23aa8e2..4cfc957 100644
--- a/src/event/talk.js
+++ b/src/event/talk.js
@@ -15,6 +15,7 @@ import {
useDialogueListStore,
useGroupStore,
} from '@/store'
+import { handleFindWebview } from '@/utils/common'
/**
* 好友状态事件
@@ -154,23 +155,7 @@ class Talk extends Base {
//更新未读数量+1
updateUnreadMsgNumAdd() {
- if (typeof plus !== 'undefined') {
- let OAWebView = plus.webview.all()
- OAWebView.forEach((webview) => {
- if (webview.id === 'webviewId1') {
- webview.evalJS(`updateUnreadMsgNumAdd()`)
- }
- })
- } else {
- document.addEventListener('plusready', () => {
- let OAWebView = plus.webview.all()
- OAWebView.forEach((webview) => {
- if (webview.id === 'webviewId1') {
- webview.evalJS(`updateUnreadMsgNumAdd()`)
- }
- })
- })
- }
+ handleFindWebview(`updateUnreadMsgNumAdd()`)
}
/**
diff --git a/src/main.js b/src/main.js
index 8835855..761c6a4 100644
--- a/src/main.js
+++ b/src/main.js
@@ -18,6 +18,7 @@ import pageAnimation from '@/components/page-animation/index.vue'
import * as plugins from './plugins'
import { useDialogueStore, useTalkStore, useUserStore, useDialogueListStore } from '@/store'
import {uniStorage} from "@/utils/uniStorage.js"
+import { handleFindWebview } from '@/utils/common'
const { showMessage } = messagePopup()
dayjs.locale('zh-cn')
@@ -67,12 +68,7 @@ export function createApp() {
return
}
console.log('===准备创建本地通知栏消息')
- let OAWebView = plus.webview.all()
- OAWebView.forEach((webview, index) => {
- if (webview.id === 'webviewId1') {
- webview.evalJS(`doCreatePushMessage('${msg}')`)
- }
- })
+ handleFindWebview(`doCreatePushMessage('${msg}')`)
}
//处理聊天推送弹窗点开
@@ -114,12 +110,7 @@ export function createApp() {
//检查聊天页面是否可用
window.checkChatWebviewAvailable = () => {
- let OAWebView = plus.webview.all()
- OAWebView.forEach((webview, index) => {
- if (webview.id === 'webviewId1') {
- webview.evalJS(`doneCheckChatWebviewAvailable()`)
- }
- })
+ handleFindWebview(`doneCheckChatWebviewAvailable()`)
}
//获取从base传来的多选视频列表
diff --git a/src/pages/addressBook/index.vue b/src/pages/addressBook/index.vue
index b802e19..0907b87 100644
--- a/src/pages/addressBook/index.vue
+++ b/src/pages/addressBook/index.vue
@@ -331,7 +331,7 @@ import avatarModule from '@/components/avatar-module/index.vue'
import { ref, onMounted, reactive, watch } from 'vue'
import { onLoad } from '@dcloudio/uni-app'
-import { handleSetWebviewStyle } from '@/utils/common'
+import { handleSetWebviewStyle, handleFindWebview } from '@/utils/common'
import { ServeUserGroupChatList, ServeCreateTalkList } from '@/api/chat/index'
import { ServeGetSessionId } from '@/api/search/index'
import { formatTalkItem } from '@/utils/talk'
@@ -376,12 +376,7 @@ onLoad((options) => {
const goWebHome = () => {
uni.navigateBack()
- let OAWebView = plus.webview.all()
- OAWebView.forEach((webview) => {
- if (webview.id === 'webviewId1') {
- webview.evalJS(`handleBackHost()`)
- }
- })
+ handleFindWebview(`handleBackHost()`)
}
onMounted(() => {
diff --git a/src/pages/chooseByDeps/index.vue b/src/pages/chooseByDeps/index.vue
index 77cea15..be07d68 100644
--- a/src/pages/chooseByDeps/index.vue
+++ b/src/pages/chooseByDeps/index.vue
@@ -342,7 +342,8 @@
import checkBox from '@/components/checkBox/index.vue'
import lodash from 'lodash'
import {
- handleSetWebviewStyle
+ handleSetWebviewStyle,
+ handleFindWebview
} from '@/utils/common'
import {
@@ -398,12 +399,7 @@
})
const goWebHome = () => {
uni.navigateBack()
- let OAWebView = plus.webview.all()
- OAWebView.forEach((webview) => {
- if (webview.id === 'webviewId1') {
- webview.evalJS(`handleBackHost()`)
- }
- })
+ handleFindWebview(`handleBackHost()`)
}
// 添加判断是否为预选成员的方法
const isPreSelectedMember = (member) => {
diff --git a/src/pages/dialog/components/filePanel.vue b/src/pages/dialog/components/filePanel.vue
index 1a2dc39..f2b25d1 100644
--- a/src/pages/dialog/components/filePanel.vue
+++ b/src/pages/dialog/components/filePanel.vue
@@ -57,6 +57,7 @@ import videoImg from '@/static/image/chatList/video@2x.png'
import folder from '@/static/image/chatList/folder.png'
import { uploadImg } from '@/api/chat'
import { uniqueId } from '@/utils'
+import { handleFindWebview } from '@/utils/common'
const props = defineProps({
sendUserInfo: {
@@ -162,12 +163,7 @@ const photoActionsSelect = (index) => {
)
}
} else {
- // let OAWebView = plus.webview.all()
- // OAWebView.forEach((webview, index) => {
- // if (webview.id === 'webviewId1') {
- // webview.evalJS(`getPlusVideoPicker()`)
- // }
- // })
+ // handleFindWebview(`getPlusVideoPicker()`)
// return
uni.chooseVideo({
sourceType: ['album'],
diff --git a/src/pages/dialog/index.vue b/src/pages/dialog/index.vue
index 5561fe2..1ddea8f 100644
--- a/src/pages/dialog/index.vue
+++ b/src/pages/dialog/index.vue
@@ -2710,6 +2710,12 @@ const onProgressFn = (progress, id) => {
// console.log((progress.loaded / progress.total) * 100, 'progress')
}
+//开始录音
+const startRecord = () => {
+ // 唤起录音时,暂停所有语音播放
+ window.dispatchEvent(new CustomEvent('audio-play', { detail: null }))
+}
+
//录音结束
const endRecord = (file, url, duration) => {
console.log(file, url, duration)
@@ -2736,6 +2742,9 @@ const endRecord = (file, url, duration) => {
resp.catch(() => {})
}
+//取消录音
+const cancelRecord = () => {}
+
//发送语音消息
const sendMediaMessage = (mediaUrl, duration, size) => {
// console.log(mediaUrl, 'mediaUrl')
diff --git a/src/store/modules/dialogueList.js b/src/store/modules/dialogueList.js
index 3d7c306..6068775 100644
--- a/src/store/modules/dialogueList.js
+++ b/src/store/modules/dialogueList.js
@@ -5,6 +5,7 @@ import lodash from 'lodash'
import { ref } from 'vue'
import { createGlobalState, useStorage } from '@vueuse/core'
import { uniStorage } from '@/utils/uniStorage.js'
+import { handleFindWebview } from '@/utils/common'
export const useDialogueListStore = createGlobalState(() => {
const testDatabase = async () => {
@@ -40,19 +41,33 @@ export const useDialogueListStore = createGlobalState(() => {
}
const content = {
- content: "我试试传送文件和图片是不是一个接口",
- name: "测试excel1.xlsx",
- path: "https://cdn-test.szjixun.cn/fonchain-chat/chat/file/multipart/20250307/727a2371-ffc4-46da-b953-a7d449ff82ff-测试excel1.xlsx",
+ content: '我试试传送文件和图片是不是一个接口',
+ name: '测试excel1.xlsx',
+ path:
+ 'https://cdn-test.szjixun.cn/fonchain-chat/chat/file/multipart/20250307/727a2371-ffc4-46da-b953-a7d449ff82ff-测试excel1.xlsx',
size: 9909,
- drive: 3
- };
- const extra = JSON.stringify(content);
+ drive: 3,
+ }
+ const extra = JSON.stringify(content)
let chatDBexecuteSql2 = {
eventType: 'executeSql',
eventParams: {
name: 'chat',
- sql: 'INSERT INTO talk_records (msg_id, sequence, talk_type, msg_type, user_id, receiver_id, is_revoke, is_mark, quote_id, extra, created_at, updated_at, biz_date) VALUES ("'+'77b715fb30f54f739a255a915ef72445'+'", 166, 2, 1, 1774, 888890, 0, 0, "'+''+'", "'+extra+'", "'+'2025-03-06T15:57:07.000Z'+'", "'+'2025-03-06T15:57:07.000Z'+'", "'+'20250306'+'")',
+ sql:
+ 'INSERT INTO talk_records (msg_id, sequence, talk_type, msg_type, user_id, receiver_id, is_revoke, is_mark, quote_id, extra, created_at, updated_at, biz_date) VALUES ("' +
+ '77b715fb30f54f739a255a915ef72445' +
+ '", 166, 2, 1, 1774, 888890, 0, 0, "' +
+ '' +
+ '", "' +
+ extra +
+ '", "' +
+ '2025-03-06T15:57:07.000Z' +
+ '", "' +
+ '2025-03-06T15:57:07.000Z' +
+ '", "' +
+ '20250306' +
+ '")',
},
}
let chatDBSelectSql = {
@@ -69,38 +84,27 @@ export const useDialogueListStore = createGlobalState(() => {
path: '_doc/chat.db',
},
}
- document.addEventListener('plusready', () => {
- let OAWebView = plus.webview.all()
- OAWebView.forEach((webview, index) => {
- if (webview.id === 'webviewId1') {
- webview.evalJS(
- `operateSQLite('${encodeURIComponent(
- JSON.stringify(chatDatabase),
- )}')`,
- )
- webview.evalJS(
- `operateSQLite('${encodeURIComponent(
- JSON.stringify(chatDBexecuteSql),
- )}')`,
- )
- webview.evalJS(
- `operateSQLite('${encodeURIComponent(
- JSON.stringify(chatDBexecuteSql2),
- )}')`,
- )
- webview.evalJS(
- `operateSQLite('${encodeURIComponent(
- JSON.stringify(chatDBSelectSql),
- )}')`,
- )
- webview.evalJS(
- `operateSQLite('${encodeURIComponent(
- JSON.stringify(chatDBIsOpenDatabase),
- )}')`,
- )
- }
- })
- })
+ // handleFindWebview(
+ // `operateSQLite('${encodeURIComponent(JSON.stringify(chatDatabase))}')`,
+ // )
+ // handleFindWebview(
+ // `operateSQLite('${encodeURIComponent(
+ // JSON.stringify(chatDBexecuteSql),
+ // )}')`,
+ // )
+ // handleFindWebview(
+ // `operateSQLite('${encodeURIComponent(
+ // JSON.stringify(chatDBexecuteSql2),
+ // )}')`,
+ // )
+ // handleFindWebview(
+ // `operateSQLite('${encodeURIComponent(JSON.stringify(chatDBSelectSql))}')`,
+ // )
+ // handleFindWebview(
+ // `operateSQLite('${encodeURIComponent(
+ // JSON.stringify(chatDBIsOpenDatabase),
+ // )}')`,
+ // )
}
// testDatabase()
diff --git a/src/store/modules/talk.js b/src/store/modules/talk.js
index cdf74ba..5ddff80 100644
--- a/src/store/modules/talk.js
+++ b/src/store/modules/talk.js
@@ -2,6 +2,7 @@ import { defineStore } from 'pinia'
import { ServeGetTalkList, ServeCreateTalkList } from '@/api/chat/index'
import { formatTalkItem, ttime, KEY_INDEX_NAME } from '@/utils/talk'
import { useEditorDraftStore } from './editor-draft'
+import { handleFindWebview } from '@/utils/common'
// import { ISession } from '@/types/chat'
export const useTalkStore = defineStore('talk', {
@@ -103,23 +104,7 @@ export const useTalkStore = defineStore('talk', {
return resp.then(({ code, data }) => {
if (code == 200) {
//向OA的webview通信,改变未读消息数量
- if (typeof plus !== 'undefined') {
- let OAWebView = plus.webview.all()
- OAWebView.forEach((webview) => {
- if (webview.id === 'webviewId1') {
- webview.evalJS(`doUpdateUnreadNum('${data.unread_num}')`)
- }
- })
- } else {
- document.addEventListener('plusready', () => {
- let OAWebView = plus.webview.all()
- OAWebView.forEach((webview) => {
- if (webview.id === 'webviewId1') {
- webview.evalJS(`doUpdateUnreadNum('${data.unread_num}')`)
- }
- })
- })
- }
+ handleFindWebview(`doUpdateUnreadNum('${data.unread_num}')`)
this.items = data.items.map((item) => {
const value = formatTalkItem(item)
diff --git a/src/uni_modules/all-speech/components/all-speech/all-speech.vue b/src/uni_modules/all-speech/components/all-speech/all-speech.vue
index 2523af8..a380f31 100644
--- a/src/uni_modules/all-speech/components/all-speech/all-speech.vue
+++ b/src/uni_modules/all-speech/components/all-speech/all-speech.vue
@@ -160,7 +160,7 @@ import 'recorder-core/src/engine/mp3-engine'
import 'recorder-core/src/extensions/waveview'
import recordCancelBg from '@/static/image/record/chat-voice-animation-bg-red.png'
// #endif
-import { multiplication } from '@/utils/common'
+import { multiplication, handleFindWebview } from '@/utils/common'
export default {
name: 'nbVoiceRecord',
/**
@@ -355,7 +355,11 @@ export default {
// }, 1000)
if (Number(permissionStatus) === 1) {
that.continueAppMicro()
- } else if (Number(permissionStatus) === -1) {
+ } else if (
+ Number(permissionStatus) === -1 ||
+ (Number(permissionStatus) === 0 &&
+ uni.getSystemInfoSync().osName === 'ios')
+ ) {
uni.showModal({
title: '提示',
content: '检测到您还未授权麦克风哦',
@@ -364,12 +368,10 @@ export default {
cancelText: '保持拒绝',
success: ({ confirm, cancel }) => {
if (confirm) {
- let OAWebView = plus.webview.all()
- OAWebView.forEach((webview, index) => {
- if (webview.id === 'webviewId1') {
- webview.evalJS(`handleRequestAndroidPermission('settings')`)
- }
- })
+ handleFindWebview(`handleRequestAndroidPermission('settings')`)
+ }
+ if (cancel) {
+ that.isCheckingPermission = false
}
},
})
@@ -451,12 +453,7 @@ export default {
// #endif
// #ifdef H5
if (typeof plus !== 'undefined') {
- let OAWebView = plus.webview.all()
- OAWebView.forEach((webview, index) => {
- if (webview.id === 'webviewId1') {
- webview.evalJS(`handleRequestAndroidPermission('micro')`)
- }
- })
+ handleFindWebview(`handleRequestAndroidPermission('micro')`)
} else {
that.continueAppMicro(isFirstRequestPer)
}
diff --git a/src/utils/common.js b/src/utils/common.js
index 0d2417d..07f0769 100644
--- a/src/utils/common.js
+++ b/src/utils/common.js
@@ -214,6 +214,27 @@ export function handleSetWebviewStyle(hasTabBar) {
}
}
+//遍历所有的webview并通信
+export function handleFindWebview(evalJS_) {
+ const findWebview = () => {
+ let allWebView = plus.webview.all()
+ allWebView.forEach((webview) => {
+ //由于webviewId后面的数字是动态分配的,在很小情况下OAWebview的Id并不是webviewId1
+ //因此不做限制,全局广播,由接收页面自行接收处理
+ // if (webview.id === 'webviewId1') {//找到OAWebview
+ webview.evalJS(evalJS_)
+ // }
+ })
+ }
+ if (typeof plus !== 'undefined') {
+ findWebview()
+ } else {
+ document.addEventListener('plusready', () => {
+ findWebview()
+ })
+ }
+}
+
// 通用运算函数
/*
函数,加法函数,用来得到精确的加法结果
@@ -223,16 +244,16 @@ export function handleSetWebviewStyle(hasTabBar) {
返回值:两数相加的结果
*/
export function addition(arg1, arg2) {
- arg1 = arg1.toString(), arg2 = arg2.toString();
- var arg1Arr = arg1.split("."),
- arg2Arr = arg2.split("."),
- d1 = arg1Arr.length == 2 ? arg1Arr[1] : "",
- d2 = arg2Arr.length == 2 ? arg2Arr[1] : "";
- var maxLen = Math.max(d1.length, d2.length);
- var m = Math.pow(10, maxLen);
- var result = Number(((arg1 * m + arg2 * m) / m).toFixed(maxLen));
- var d = arguments[2];
- return typeof d === "number" ? Number((result).toFixed(d)) : result;
+ ;(arg1 = arg1.toString()), (arg2 = arg2.toString())
+ var arg1Arr = arg1.split('.'),
+ arg2Arr = arg2.split('.'),
+ d1 = arg1Arr.length == 2 ? arg1Arr[1] : '',
+ d2 = arg2Arr.length == 2 ? arg2Arr[1] : ''
+ var maxLen = Math.max(d1.length, d2.length)
+ var m = Math.pow(10, maxLen)
+ var result = Number(((arg1 * m + arg2 * m) / m).toFixed(maxLen))
+ var d = arguments[2]
+ return typeof d === 'number' ? Number(result.toFixed(d)) : result
}
/*
@@ -251,12 +272,20 @@ export function addition(arg1, arg2) {
返回值:两数相乘的结果
*/
export function multiplication(arg1, arg2) {
- var r1 = arg1.toString(),
- r2 = arg2.toString(),
- m, resultVal, d = arguments[2];
- m = (r1.split(".")[1] ? r1.split(".")[1].length : 0) + (r2.split(".")[1] ? r2.split(".")[1].length : 0);
- resultVal = Number(r1.replace(".", "")) * Number(r2.replace(".", "")) / Math.pow(10, m);
- return typeof d !== "number" ? Number(resultVal) : Number(resultVal.toFixed(parseInt(d)));
+ var r1 = arg1.toString(),
+ r2 = arg2.toString(),
+ m,
+ resultVal,
+ d = arguments[2]
+ m =
+ (r1.split('.')[1] ? r1.split('.')[1].length : 0) +
+ (r2.split('.')[1] ? r2.split('.')[1].length : 0)
+ resultVal =
+ (Number(r1.replace('.', '')) * Number(r2.replace('.', ''))) /
+ Math.pow(10, m)
+ return typeof d !== 'number'
+ ? Number(resultVal)
+ : Number(resultVal.toFixed(parseInt(d)))
}
/*
@@ -267,10 +296,18 @@ export function multiplication(arg1, arg2) {
返回值:arg1除于arg2的结果
*/
export function division(arg1, arg2) {
- var r1 = arg1.toString(),
- r2 = arg2.toString(),
- m, resultVal, d = arguments[2];
- m = (r2.split(".")[1] ? r2.split(".")[1].length : 0) - (r1.split(".")[1] ? r1.split(".")[1].length : 0);
- resultVal = Number(r1.replace(".", "")) / Number(r2.replace(".", "")) * Math.pow(10, m);
- return typeof d !== "number" ? Number(resultVal) : Number(resultVal.toFixed(parseInt(d)));
+ var r1 = arg1.toString(),
+ r2 = arg2.toString(),
+ m,
+ resultVal,
+ d = arguments[2]
+ m =
+ (r2.split('.')[1] ? r2.split('.')[1].length : 0) -
+ (r1.split('.')[1] ? r1.split('.')[1].length : 0)
+ resultVal =
+ (Number(r1.replace('.', '')) / Number(r2.replace('.', ''))) *
+ Math.pow(10, m)
+ return typeof d !== 'number'
+ ? Number(resultVal)
+ : Number(resultVal.toFixed(parseInt(d)))
}