Compare commits
No commits in common. "d3164014eec48832171523ad3c28338a5100d3e5" and "8afcfb73bd46af385c5229d19c125b4cd3916180" have entirely different histories.
d3164014ee
...
8afcfb73bd
@ -1,7 +1,6 @@
|
|||||||
import request from '@/service/index.js'
|
import request from '@/service/index.js'
|
||||||
import qs from 'qs'
|
import qs from 'qs'
|
||||||
import { useTalkStore, useDialogueStore } from '@/store'
|
import { useTalkStore, useDialogueStore } from '@/store'
|
||||||
import { handleFindWebview } from '@/utils/common'
|
|
||||||
|
|
||||||
// 获取聊天列表服务接口
|
// 获取聊天列表服务接口
|
||||||
export const ServeGetTalkList = (data) => {
|
export const ServeGetTalkList = (data) => {
|
||||||
@ -47,7 +46,23 @@ export const ServeClearTalkUnreadNum = (data, unReadNum) => {
|
|||||||
useTalkStore().findTalkIndex(useDialogueStore().index_name)
|
useTalkStore().findTalkIndex(useDialogueStore().index_name)
|
||||||
]?.is_disturb
|
]?.is_disturb
|
||||||
) {
|
) {
|
||||||
handleFindWebview(`updateUnreadMsgNumReduce('${unReadNum}')`)
|
if (typeof plus !== 'undefined') {
|
||||||
|
let OAWebView = plus.webview.all()
|
||||||
|
OAWebView.forEach((webview) => {
|
||||||
|
if (webview.id === 'webviewId1') {
|
||||||
|
webview.evalJS(`updateUnreadMsgNumReduce('${unReadNum}')`)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
document.addEventListener('plusready', () => {
|
||||||
|
let OAWebView = plus.webview.all()
|
||||||
|
OAWebView.forEach((webview) => {
|
||||||
|
if (webview.id === 'webviewId1') {
|
||||||
|
webview.evalJS(`updateUnreadMsgNumReduce('${unReadNum}')`)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return request({
|
return request({
|
||||||
url: '/api/v1/talk/unread/clear',
|
url: '/api/v1/talk/unread/clear',
|
||||||
|
@ -1,155 +1,109 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { ref, reactive, onMounted, onUnmounted, computed } from 'vue'
|
import { ref, reactive, onMounted } from "vue";
|
||||||
import { PlayOne, PauseOne } from '@icon-park/vue-next'
|
import { PlayOne, PauseOne } from "@icon-park/vue-next";
|
||||||
import { ITalkRecordExtraAudio, ITalkRecord } from '@/types/chat'
|
import { ITalkRecordExtraAudio, ITalkRecord } from "@/types/chat";
|
||||||
import { onHide } from '@dcloudio/uni-app'
|
|
||||||
import aTrumpet from '@/uni_modules/a-trumpet/components/a-trumpet/a-trumpet.vue'
|
|
||||||
import { useUserStore } from '@/store'
|
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
extra: ITalkRecordExtraAudio
|
extra: ITalkRecordExtraAudio;
|
||||||
data: ITalkRecord
|
data: ITalkRecord;
|
||||||
maxWidth?: Boolean
|
maxWidth?: Boolean;
|
||||||
}>()
|
}>();
|
||||||
|
|
||||||
const userStore = useUserStore()
|
const audioRef = ref();
|
||||||
const talkParams = reactive({
|
const audioContext = ref<any>(null);
|
||||||
uid: computed(() => userStore.uid),
|
|
||||||
})
|
const durationDesc = ref("-");
|
||||||
|
|
||||||
const audioContext = ref<any>(null)
|
|
||||||
const durationDesc = ref('-')
|
|
||||||
const state = reactive({
|
const state = reactive({
|
||||||
isAudioPlay: false,
|
isAudioPlay: false,
|
||||||
progress: 0,
|
progress: 0,
|
||||||
duration: 0,
|
duration: 0,
|
||||||
currentTime: 0,
|
currentTime: 0,
|
||||||
loading: true,
|
loading: true,
|
||||||
})
|
});
|
||||||
|
|
||||||
// 监听其它音频播放事件
|
|
||||||
function onOtherAudioPlay(e) {
|
|
||||||
if (e.detail !== props.data.msg_id && state.isAudioPlay) {
|
|
||||||
audioContext.value.pause()
|
|
||||||
state.isAudioPlay = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
audioContext.value = uni.createInnerAudioContext()
|
// 使用uni-app的方式创建内部音频上下文
|
||||||
audioContext.value.src = props.extra.url
|
audioContext.value = uni.createInnerAudioContext();
|
||||||
|
audioContext.value.src = props.extra.url;
|
||||||
|
|
||||||
audioContext.value.onCanplay(() => {
|
audioContext.value.onCanplay(() => {
|
||||||
state.duration = audioContext.value.duration
|
state.duration = audioContext.value.duration;
|
||||||
durationDesc.value = formatTime(parseInt(audioContext.value.duration))
|
durationDesc.value = formatTime(parseInt(audioContext.value.duration));
|
||||||
state.loading = false
|
state.loading = false;
|
||||||
})
|
});
|
||||||
|
|
||||||
audioContext.value.onTimeUpdate(() => {
|
audioContext.value.onTimeUpdate(() => {
|
||||||
if (audioContext.value.duration == 0) {
|
if (audioContext.value.duration == 0) {
|
||||||
state.progress = 0
|
state.progress = 0;
|
||||||
} else {
|
} else {
|
||||||
state.currentTime = audioContext.value.currentTime
|
state.currentTime = audioContext.value.currentTime;
|
||||||
state.progress =
|
state.progress =
|
||||||
(audioContext.value.currentTime / audioContext.value.duration) * 100
|
(audioContext.value.currentTime / audioContext.value.duration) * 100;
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
|
|
||||||
audioContext.value.onEnded(() => {
|
audioContext.value.onEnded(() => {
|
||||||
state.isAudioPlay = false
|
state.isAudioPlay = false;
|
||||||
state.progress = 0
|
state.progress = 0;
|
||||||
})
|
});
|
||||||
|
|
||||||
audioContext.value.onError((e) => {
|
audioContext.value.onError((e) => {
|
||||||
console.log('音频播放异常===>', e)
|
console.log("音频播放异常===>", e);
|
||||||
})
|
});
|
||||||
|
});
|
||||||
window.addEventListener('audio-play', onOtherAudioPlay)
|
|
||||||
})
|
|
||||||
|
|
||||||
onUnmounted(() => {
|
|
||||||
window.removeEventListener('audio-play', onOtherAudioPlay)
|
|
||||||
audioContext.value &&
|
|
||||||
audioContext.value.destroy &&
|
|
||||||
audioContext.value.destroy()
|
|
||||||
})
|
|
||||||
|
|
||||||
onHide(() => {
|
|
||||||
if (audioContext.value && audioContext.value.pause) {
|
|
||||||
audioContext.value.pause()
|
|
||||||
state.isAudioPlay = false
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
const onPlay = () => {
|
const onPlay = () => {
|
||||||
if (state.isAudioPlay) {
|
if (state.isAudioPlay) {
|
||||||
audioContext.value.pause()
|
audioContext.value.pause();
|
||||||
state.isAudioPlay = false
|
|
||||||
} else {
|
} else {
|
||||||
// 通知其它音频暂停
|
audioContext.value.play();
|
||||||
window.dispatchEvent(
|
|
||||||
new CustomEvent('audio-play', { detail: props.data.msg_id }),
|
|
||||||
)
|
|
||||||
audioContext.value.play()
|
|
||||||
state.isAudioPlay = true
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
state.isAudioPlay = !state.isAudioPlay;
|
||||||
|
};
|
||||||
|
|
||||||
|
const onPlayEnd = () => {
|
||||||
|
state.isAudioPlay = false;
|
||||||
|
state.progress = 0;
|
||||||
|
};
|
||||||
|
|
||||||
const formatTime = (value: number = 0) => {
|
const formatTime = (value: number = 0) => {
|
||||||
if (value == 0) {
|
if (value == 0) {
|
||||||
return '-'
|
return "-";
|
||||||
}
|
}
|
||||||
const minutes = Math.floor(value / 60)
|
|
||||||
let seconds = value
|
const minutes = Math.floor(value / 60);
|
||||||
|
let seconds = value;
|
||||||
if (minutes > 0) {
|
if (minutes > 0) {
|
||||||
seconds = Math.floor(value - minutes * 60)
|
seconds = Math.floor(value - minutes * 60);
|
||||||
}
|
}
|
||||||
return `${minutes}'${seconds}"`
|
|
||||||
}
|
return `${minutes}'${seconds}"`;
|
||||||
|
};
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<div
|
<div class="im-message-audio">
|
||||||
class="audio-message"
|
<div class="play">
|
||||||
@click.stop="onPlay"
|
<div class="btn pointer" @click.stop="onPlay">
|
||||||
:class="
|
<n-icon
|
||||||
props?.data?.user_id == talkParams.uid
|
:size="18"
|
||||||
? 'justify-end py-[22rpx] pl-[30rpx] pr-[16rpx]'
|
:component="state.isAudioPlay ? PauseOne : PlayOne"
|
||||||
: 'justify-start py-[22rpx] pr-[30rpx] pl-[16rpx]'
|
/>
|
||||||
"
|
</div>
|
||||||
>
|
|
||||||
<a-trumpet
|
|
||||||
v-if="props?.data?.user_id != talkParams.uid"
|
|
||||||
:isPlay="state.isAudioPlay"
|
|
||||||
color="#C1C1C1"
|
|
||||||
:size="30"
|
|
||||||
></a-trumpet>
|
|
||||||
<div
|
|
||||||
:class="
|
|
||||||
props?.data?.user_id == talkParams.uid ? 'mr-[8rpx]' : 'ml-[8rpx]'
|
|
||||||
"
|
|
||||||
>
|
|
||||||
{{ props?.extra?.duration }}s
|
|
||||||
</div>
|
</div>
|
||||||
<a-trumpet
|
<div class="desc">
|
||||||
v-if="props?.data?.user_id == talkParams.uid"
|
<span class="line" v-for="i in 23" :key="i"></span>
|
||||||
:isPlay="state.isAudioPlay"
|
<span
|
||||||
color="#C1C1C1"
|
class="indicator"
|
||||||
:size="30"
|
:style="{ left: state.progress + '%' }"
|
||||||
direction="left"
|
v-show="state.progress > 0"
|
||||||
></a-trumpet>
|
></span>
|
||||||
|
</div>
|
||||||
|
<div class="time">{{ durationDesc }}</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<style lang="less" scoped>
|
<style lang="less" scoped>
|
||||||
.audio-message {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: row;
|
|
||||||
align-items: center;
|
|
||||||
width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
background-color: #fff;
|
|
||||||
border-radius: 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.im-message-audio {
|
.im-message-audio {
|
||||||
--audio-bg-color: #f5f5f5;
|
--audio-bg-color: #f5f5f5;
|
||||||
--audio-btn-bg-color: #ffffff;
|
--audio-btn-bg-color: #ffffff;
|
||||||
@ -291,7 +245,7 @@ const formatTime = (value: number = 0) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
html[theme-mode='dark'] {
|
html[theme-mode="dark"] {
|
||||||
.im-message-audio {
|
.im-message-audio {
|
||||||
--audio-bg-color: #2c2c32;
|
--audio-bg-color: #2c2c32;
|
||||||
--audio-btn-bg-color: rgb(78, 75, 75);
|
--audio-btn-bg-color: rgb(78, 75, 75);
|
||||||
|
@ -101,11 +101,10 @@ export const ForwardableMessageType = [
|
|||||||
ChatMsgTypeText,
|
ChatMsgTypeText,
|
||||||
ChatMsgTypeCode,
|
ChatMsgTypeCode,
|
||||||
ChatMsgTypeImage,
|
ChatMsgTypeImage,
|
||||||
// ChatMsgTypeAudio,
|
ChatMsgTypeAudio,
|
||||||
ChatMsgTypeVideo,
|
ChatMsgTypeVideo,
|
||||||
ChatMsgTypeFile,
|
ChatMsgTypeFile,
|
||||||
ChatMsgTypeLocation,
|
ChatMsgTypeLocation,
|
||||||
ChatMsgTypeCard,
|
ChatMsgTypeCard,
|
||||||
ChatMsgTypeLink,
|
ChatMsgTypeLink
|
||||||
ChatMsgTypeForward
|
|
||||||
]
|
]
|
||||||
|
@ -15,7 +15,6 @@ import {
|
|||||||
useDialogueListStore,
|
useDialogueListStore,
|
||||||
useGroupStore,
|
useGroupStore,
|
||||||
} from '@/store'
|
} from '@/store'
|
||||||
import { handleFindWebview } from '@/utils/common'
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 好友状态事件
|
* 好友状态事件
|
||||||
@ -155,7 +154,23 @@ class Talk extends Base {
|
|||||||
|
|
||||||
//更新未读数量+1
|
//更新未读数量+1
|
||||||
updateUnreadMsgNumAdd() {
|
updateUnreadMsgNumAdd() {
|
||||||
handleFindWebview(`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()`)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
15
src/main.js
15
src/main.js
@ -18,7 +18,6 @@ import pageAnimation from '@/components/page-animation/index.vue'
|
|||||||
import * as plugins from './plugins'
|
import * as plugins from './plugins'
|
||||||
import { useDialogueStore, useTalkStore, useUserStore, useDialogueListStore } from '@/store'
|
import { useDialogueStore, useTalkStore, useUserStore, useDialogueListStore } from '@/store'
|
||||||
import {uniStorage} from "@/utils/uniStorage.js"
|
import {uniStorage} from "@/utils/uniStorage.js"
|
||||||
import { handleFindWebview } from '@/utils/common'
|
|
||||||
|
|
||||||
const { showMessage } = messagePopup()
|
const { showMessage } = messagePopup()
|
||||||
dayjs.locale('zh-cn')
|
dayjs.locale('zh-cn')
|
||||||
@ -68,7 +67,12 @@ export function createApp() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
console.log('===准备创建本地通知栏消息')
|
console.log('===准备创建本地通知栏消息')
|
||||||
handleFindWebview(`doCreatePushMessage('${msg}')`)
|
let OAWebView = plus.webview.all()
|
||||||
|
OAWebView.forEach((webview, index) => {
|
||||||
|
if (webview.id === 'webviewId1') {
|
||||||
|
webview.evalJS(`doCreatePushMessage('${msg}')`)
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
//处理聊天推送弹窗点开
|
//处理聊天推送弹窗点开
|
||||||
@ -110,7 +114,12 @@ export function createApp() {
|
|||||||
|
|
||||||
//检查聊天页面是否可用
|
//检查聊天页面是否可用
|
||||||
window.checkChatWebviewAvailable = () => {
|
window.checkChatWebviewAvailable = () => {
|
||||||
handleFindWebview(`doneCheckChatWebviewAvailable()`)
|
let OAWebView = plus.webview.all()
|
||||||
|
OAWebView.forEach((webview, index) => {
|
||||||
|
if (webview.id === 'webviewId1') {
|
||||||
|
webview.evalJS(`doneCheckChatWebviewAvailable()`)
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
//获取从base传来的多选视频列表
|
//获取从base传来的多选视频列表
|
||||||
|
@ -331,7 +331,7 @@ import avatarModule from '@/components/avatar-module/index.vue'
|
|||||||
|
|
||||||
import { ref, onMounted, reactive, watch } from 'vue'
|
import { ref, onMounted, reactive, watch } from 'vue'
|
||||||
import { onLoad } from '@dcloudio/uni-app'
|
import { onLoad } from '@dcloudio/uni-app'
|
||||||
import { handleSetWebviewStyle, handleFindWebview } from '@/utils/common'
|
import { handleSetWebviewStyle } from '@/utils/common'
|
||||||
import { ServeUserGroupChatList, ServeCreateTalkList } from '@/api/chat/index'
|
import { ServeUserGroupChatList, ServeCreateTalkList } from '@/api/chat/index'
|
||||||
import { ServeGetSessionId } from '@/api/search/index'
|
import { ServeGetSessionId } from '@/api/search/index'
|
||||||
import { formatTalkItem } from '@/utils/talk'
|
import { formatTalkItem } from '@/utils/talk'
|
||||||
@ -376,7 +376,12 @@ onLoad((options) => {
|
|||||||
|
|
||||||
const goWebHome = () => {
|
const goWebHome = () => {
|
||||||
uni.navigateBack()
|
uni.navigateBack()
|
||||||
handleFindWebview(`handleBackHost()`)
|
let OAWebView = plus.webview.all()
|
||||||
|
OAWebView.forEach((webview) => {
|
||||||
|
if (webview.id === 'webviewId1') {
|
||||||
|
webview.evalJS(`handleBackHost()`)
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
|
@ -342,8 +342,7 @@
|
|||||||
import checkBox from '@/components/checkBox/index.vue'
|
import checkBox from '@/components/checkBox/index.vue'
|
||||||
import lodash from 'lodash'
|
import lodash from 'lodash'
|
||||||
import {
|
import {
|
||||||
handleSetWebviewStyle,
|
handleSetWebviewStyle
|
||||||
handleFindWebview
|
|
||||||
} from '@/utils/common'
|
} from '@/utils/common'
|
||||||
|
|
||||||
import {
|
import {
|
||||||
@ -399,7 +398,12 @@
|
|||||||
})
|
})
|
||||||
const goWebHome = () => {
|
const goWebHome = () => {
|
||||||
uni.navigateBack()
|
uni.navigateBack()
|
||||||
handleFindWebview(`handleBackHost()`)
|
let OAWebView = plus.webview.all()
|
||||||
|
OAWebView.forEach((webview) => {
|
||||||
|
if (webview.id === 'webviewId1') {
|
||||||
|
webview.evalJS(`handleBackHost()`)
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
// 添加判断是否为预选成员的方法
|
// 添加判断是否为预选成员的方法
|
||||||
const isPreSelectedMember = (member) => {
|
const isPreSelectedMember = (member) => {
|
||||||
|
@ -57,7 +57,6 @@ import videoImg from '@/static/image/chatList/video@2x.png'
|
|||||||
import folder from '@/static/image/chatList/folder.png'
|
import folder from '@/static/image/chatList/folder.png'
|
||||||
import { uploadImg } from '@/api/chat'
|
import { uploadImg } from '@/api/chat'
|
||||||
import { uniqueId } from '@/utils'
|
import { uniqueId } from '@/utils'
|
||||||
import { handleFindWebview } from '@/utils/common'
|
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
sendUserInfo: {
|
sendUserInfo: {
|
||||||
@ -163,7 +162,12 @@ const photoActionsSelect = (index) => {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// handleFindWebview(`getPlusVideoPicker()`)
|
// let OAWebView = plus.webview.all()
|
||||||
|
// OAWebView.forEach((webview, index) => {
|
||||||
|
// if (webview.id === 'webviewId1') {
|
||||||
|
// webview.evalJS(`getPlusVideoPicker()`)
|
||||||
|
// }
|
||||||
|
// })
|
||||||
// return
|
// return
|
||||||
uni.chooseVideo({
|
uni.chooseVideo({
|
||||||
sourceType: ['album'],
|
sourceType: ['album'],
|
||||||
|
@ -227,21 +227,8 @@
|
|||||||
: 'justify-start'
|
: 'justify-start'
|
||||||
"
|
"
|
||||||
>
|
>
|
||||||
<div
|
<div class="talk-tools voice-content" v-if="item.voiceContent">
|
||||||
class="talk-tools voice-content"
|
<span>{{ item.voiceContent }}</span>
|
||||||
v-if="
|
|
||||||
item?.voiceContent ||
|
|
||||||
(!item?.voiceContent && item?.isVoiceToTexting)
|
|
||||||
"
|
|
||||||
@click="copyVoiceContent(item?.voiceContent || '')"
|
|
||||||
>
|
|
||||||
<wd-loading
|
|
||||||
v-if="item?.isVoiceToTexting && !item?.voiceContent"
|
|
||||||
color="#46299D"
|
|
||||||
:size="20"
|
|
||||||
style="margin: 0 12rpx 0 0;"
|
|
||||||
/>
|
|
||||||
<span v-if="item?.voiceContent">{{ item.voiceContent }}</span>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -317,10 +304,8 @@
|
|||||||
:src="state.isUseSpeech ? keyboardIcon : microphoneIcon"
|
:src="state.isUseSpeech ? keyboardIcon : microphoneIcon"
|
||||||
@click="changeEditorMode"
|
@click="changeEditorMode"
|
||||||
v-if="
|
v-if="
|
||||||
(state.isProd &&
|
userStore.mobile == '13580848136' ||
|
||||||
(userStore.mobile == '13580848136' ||
|
userStore.mobile == '18100591363'
|
||||||
userStore.mobile == '18100591363')) ||
|
|
||||||
!state.isProd
|
|
||||||
"
|
"
|
||||||
></tm-image>
|
></tm-image>
|
||||||
<div class="flex-1 quillBox" style="">
|
<div class="flex-1 quillBox" style="">
|
||||||
@ -782,7 +767,6 @@ import deepBubble from '@/components/deep-bubble/deep-bubble.vue'
|
|||||||
import { isRevoke } from './menu'
|
import { isRevoke } from './menu'
|
||||||
import useConfirm from '@/components/x-confirm/useConfirm.js'
|
import useConfirm from '@/components/x-confirm/useConfirm.js'
|
||||||
import { ServeCheckFriend, ServeAddFriend } from '@/api/addressBook/index'
|
import { ServeCheckFriend, ServeAddFriend } from '@/api/addressBook/index'
|
||||||
import { clipboard } from '@/utils/common'
|
|
||||||
import {
|
import {
|
||||||
onLoad as uniOnload,
|
onLoad as uniOnload,
|
||||||
onUnload as uniOnUnload,
|
onUnload as uniOnUnload,
|
||||||
@ -901,7 +885,6 @@ const state = ref({
|
|||||||
content: t('addressBook.message.notFriendsOrSameCompany'),
|
content: t('addressBook.message.notFriendsOrSameCompany'),
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
isProd: import.meta.env.PROD,
|
|
||||||
})
|
})
|
||||||
|
|
||||||
// 创建一个响应式的 Map 来维护已读数量
|
// 创建一个响应式的 Map 来维护已读数量
|
||||||
@ -1573,18 +1556,6 @@ const handleMergeForward = () => {
|
|||||||
if (selectedMessage.value.length == 0) {
|
if (selectedMessage.value.length == 0) {
|
||||||
return message.warning('未选择消息')
|
return message.warning('未选择消息')
|
||||||
}
|
}
|
||||||
let isForwardAble = true
|
|
||||||
let notForwardAbleHint = '不支持转发:'
|
|
||||||
selectedMessage.value.find((selectedItem) => {
|
|
||||||
if (!ForwardableMessageType.includes(selectedItem.msg_type)) {
|
|
||||||
notForwardAbleHint += ChatMsgTypeMapping[selectedItem.msg_type] + '、'
|
|
||||||
isForwardAble = false
|
|
||||||
}
|
|
||||||
})
|
|
||||||
if (!isForwardAble) {
|
|
||||||
message.warning(notForwardAbleHint.slice(0, notForwardAbleHint.length - 1))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
console.log('合并转发')
|
console.log('合并转发')
|
||||||
dialogueStore.setForwardType(2)
|
dialogueStore.setForwardType(2)
|
||||||
dialogueStore.setForwardMessages(selectedMessage.value)
|
dialogueStore.setForwardMessages(selectedMessage.value)
|
||||||
@ -1600,18 +1571,6 @@ const handleSingleForward = () => {
|
|||||||
if (selectedMessage.value.length == 0) {
|
if (selectedMessage.value.length == 0) {
|
||||||
return message.warning('未选择消息')
|
return message.warning('未选择消息')
|
||||||
}
|
}
|
||||||
let isForwardAble = true
|
|
||||||
let notForwardAbleHint = '不支持转发:'
|
|
||||||
selectedMessage.value.find((selectedItem) => {
|
|
||||||
if (!ForwardableMessageType.includes(selectedItem.msg_type)) {
|
|
||||||
notForwardAbleHint += ChatMsgTypeMapping[selectedItem.msg_type] + '、'
|
|
||||||
isForwardAble = false
|
|
||||||
}
|
|
||||||
})
|
|
||||||
if (!isForwardAble) {
|
|
||||||
message.warning(notForwardAbleHint.slice(0, notForwardAbleHint.length - 1))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
console.log('逐条转发')
|
console.log('逐条转发')
|
||||||
dialogueStore.setForwardType(1)
|
dialogueStore.setForwardType(1)
|
||||||
dialogueStore.setForwardMessages(selectedMessage.value)
|
dialogueStore.setForwardMessages(selectedMessage.value)
|
||||||
@ -2719,19 +2678,9 @@ const onProgressFn = (progress, id) => {
|
|||||||
// console.log((progress.loaded / progress.total) * 100, 'progress')
|
// console.log((progress.loaded / progress.total) * 100, 'progress')
|
||||||
}
|
}
|
||||||
|
|
||||||
//开始录音
|
|
||||||
const startRecord = () => {
|
|
||||||
// 唤起录音时,暂停所有语音播放
|
|
||||||
window.dispatchEvent(new CustomEvent('audio-play', { detail: null }))
|
|
||||||
}
|
|
||||||
|
|
||||||
//录音结束
|
//录音结束
|
||||||
const endRecord = (file, url, duration) => {
|
const endRecord = (file, url, duration) => {
|
||||||
console.log(file, url, duration)
|
console.log(file, url, duration)
|
||||||
if (duration < 1000) {
|
|
||||||
message.error(t('chat_voice_too_short'))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
const form = new FormData()
|
const form = new FormData()
|
||||||
form.append('file', file)
|
form.append('file', file)
|
||||||
form.append('source', 'fonchain-chat')
|
form.append('source', 'fonchain-chat')
|
||||||
@ -2751,9 +2700,6 @@ const endRecord = (file, url, duration) => {
|
|||||||
resp.catch(() => {})
|
resp.catch(() => {})
|
||||||
}
|
}
|
||||||
|
|
||||||
//取消录音
|
|
||||||
const cancelRecord = () => {}
|
|
||||||
|
|
||||||
//发送语音消息
|
//发送语音消息
|
||||||
const sendMediaMessage = (mediaUrl, duration, size) => {
|
const sendMediaMessage = (mediaUrl, duration, size) => {
|
||||||
// console.log(mediaUrl, 'mediaUrl')
|
// console.log(mediaUrl, 'mediaUrl')
|
||||||
@ -2782,21 +2728,17 @@ const sendMediaMessage = (mediaUrl, duration, size) => {
|
|||||||
|
|
||||||
//语音转文字
|
//语音转文字
|
||||||
const convertText = (msgItem) => {
|
const convertText = (msgItem) => {
|
||||||
msgItem.isVoiceToTexting = true
|
|
||||||
const resp = ServeConvertText({
|
const resp = ServeConvertText({
|
||||||
voiceUrl: msgItem.extra.url,
|
voiceUrl: msgItem.extra.url,
|
||||||
msgId: msgItem.msg_id,
|
msgId: msgItem.msg_id,
|
||||||
})
|
})
|
||||||
// console.log(resp, 'resp')
|
// console.log(resp, 'resp')
|
||||||
resp.then(({ code, data }) => {
|
resp.then(({ code, data }) => {
|
||||||
msgItem.isVoiceToTexting = false
|
|
||||||
// console.log(code, data, 'data')
|
// console.log(code, data, 'data')
|
||||||
if (code === 200) {
|
if (code === 200) {
|
||||||
console.log(data.convText, 'convText')
|
console.log(data.convText, 'convText')
|
||||||
msgItem.voiceContent = data.convText
|
msgItem.voiceContent = data.convText
|
||||||
}
|
}
|
||||||
}).catch(() => {
|
|
||||||
msgItem.isVoiceToTexting = false
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
//语音输入框高度
|
//语音输入框高度
|
||||||
@ -2833,23 +2775,6 @@ const doAddFriend = () => {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
//点击复制语音转文字的内容
|
|
||||||
const copyVoiceContent = (voiceContent) => {
|
|
||||||
if (!voiceContent) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
uni.setClipboardData({
|
|
||||||
data: voiceContent,
|
|
||||||
showToast: false,
|
|
||||||
success: () => {
|
|
||||||
message.success('复制成功')
|
|
||||||
},
|
|
||||||
})
|
|
||||||
// clipboard(voiceContent, () => {
|
|
||||||
// message.success('复制成功')
|
|
||||||
// })
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
<style scoped lang="less">
|
<style scoped lang="less">
|
||||||
.dialog-page {
|
.dialog-page {
|
||||||
@ -3066,6 +2991,7 @@ const copyVoiceContent = (voiceContent) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.voice-content {
|
.voice-content {
|
||||||
|
text-align: right;
|
||||||
color: #7a58de;
|
color: #7a58de;
|
||||||
font-size: 22rpx;
|
font-size: 22rpx;
|
||||||
font-weight: 400;
|
font-weight: 400;
|
||||||
|
@ -5,7 +5,6 @@ import lodash from 'lodash'
|
|||||||
import { ref } from 'vue'
|
import { ref } from 'vue'
|
||||||
import { createGlobalState, useStorage } from '@vueuse/core'
|
import { createGlobalState, useStorage } from '@vueuse/core'
|
||||||
import { uniStorage } from '@/utils/uniStorage.js'
|
import { uniStorage } from '@/utils/uniStorage.js'
|
||||||
import { handleFindWebview } from '@/utils/common'
|
|
||||||
|
|
||||||
export const useDialogueListStore = createGlobalState(() => {
|
export const useDialogueListStore = createGlobalState(() => {
|
||||||
const testDatabase = async () => {
|
const testDatabase = async () => {
|
||||||
@ -41,33 +40,19 @@ export const useDialogueListStore = createGlobalState(() => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const content = {
|
const content = {
|
||||||
content: '我试试传送文件和图片是不是一个接口',
|
content: "我试试传送文件和图片是不是一个接口",
|
||||||
name: '测试excel1.xlsx',
|
name: "测试excel1.xlsx",
|
||||||
path:
|
path: "https://cdn-test.szjixun.cn/fonchain-chat/chat/file/multipart/20250307/727a2371-ffc4-46da-b953-a7d449ff82ff-测试excel1.xlsx",
|
||||||
'https://cdn-test.szjixun.cn/fonchain-chat/chat/file/multipart/20250307/727a2371-ffc4-46da-b953-a7d449ff82ff-测试excel1.xlsx',
|
|
||||||
size: 9909,
|
size: 9909,
|
||||||
drive: 3,
|
drive: 3
|
||||||
}
|
};
|
||||||
const extra = JSON.stringify(content)
|
const extra = JSON.stringify(content);
|
||||||
|
|
||||||
let chatDBexecuteSql2 = {
|
let chatDBexecuteSql2 = {
|
||||||
eventType: 'executeSql',
|
eventType: 'executeSql',
|
||||||
eventParams: {
|
eventParams: {
|
||||||
name: 'chat',
|
name: 'chat',
|
||||||
sql:
|
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'+'")',
|
||||||
'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 = {
|
let chatDBSelectSql = {
|
||||||
@ -84,27 +69,38 @@ export const useDialogueListStore = createGlobalState(() => {
|
|||||||
path: '_doc/chat.db',
|
path: '_doc/chat.db',
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
// handleFindWebview(
|
document.addEventListener('plusready', () => {
|
||||||
// `operateSQLite('${encodeURIComponent(JSON.stringify(chatDatabase))}')`,
|
let OAWebView = plus.webview.all()
|
||||||
// )
|
OAWebView.forEach((webview, index) => {
|
||||||
// handleFindWebview(
|
if (webview.id === 'webviewId1') {
|
||||||
// `operateSQLite('${encodeURIComponent(
|
webview.evalJS(
|
||||||
// JSON.stringify(chatDBexecuteSql),
|
`operateSQLite('${encodeURIComponent(
|
||||||
// )}')`,
|
JSON.stringify(chatDatabase),
|
||||||
// )
|
)}')`,
|
||||||
// handleFindWebview(
|
)
|
||||||
// `operateSQLite('${encodeURIComponent(
|
webview.evalJS(
|
||||||
// JSON.stringify(chatDBexecuteSql2),
|
`operateSQLite('${encodeURIComponent(
|
||||||
// )}')`,
|
JSON.stringify(chatDBexecuteSql),
|
||||||
// )
|
)}')`,
|
||||||
// handleFindWebview(
|
)
|
||||||
// `operateSQLite('${encodeURIComponent(JSON.stringify(chatDBSelectSql))}')`,
|
webview.evalJS(
|
||||||
// )
|
`operateSQLite('${encodeURIComponent(
|
||||||
// handleFindWebview(
|
JSON.stringify(chatDBexecuteSql2),
|
||||||
// `operateSQLite('${encodeURIComponent(
|
)}')`,
|
||||||
// JSON.stringify(chatDBIsOpenDatabase),
|
)
|
||||||
// )}')`,
|
webview.evalJS(
|
||||||
// )
|
`operateSQLite('${encodeURIComponent(
|
||||||
|
JSON.stringify(chatDBSelectSql),
|
||||||
|
)}')`,
|
||||||
|
)
|
||||||
|
webview.evalJS(
|
||||||
|
`operateSQLite('${encodeURIComponent(
|
||||||
|
JSON.stringify(chatDBIsOpenDatabase),
|
||||||
|
)}')`,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
}
|
}
|
||||||
// testDatabase()
|
// testDatabase()
|
||||||
|
|
||||||
|
@ -2,7 +2,6 @@ import { defineStore } from 'pinia'
|
|||||||
import { ServeGetTalkList, ServeCreateTalkList } from '@/api/chat/index'
|
import { ServeGetTalkList, ServeCreateTalkList } from '@/api/chat/index'
|
||||||
import { formatTalkItem, ttime, KEY_INDEX_NAME } from '@/utils/talk'
|
import { formatTalkItem, ttime, KEY_INDEX_NAME } from '@/utils/talk'
|
||||||
import { useEditorDraftStore } from './editor-draft'
|
import { useEditorDraftStore } from './editor-draft'
|
||||||
import { handleFindWebview } from '@/utils/common'
|
|
||||||
// import { ISession } from '@/types/chat'
|
// import { ISession } from '@/types/chat'
|
||||||
|
|
||||||
export const useTalkStore = defineStore('talk', {
|
export const useTalkStore = defineStore('talk', {
|
||||||
@ -104,7 +103,23 @@ export const useTalkStore = defineStore('talk', {
|
|||||||
return resp.then(({ code, data }) => {
|
return resp.then(({ code, data }) => {
|
||||||
if (code == 200) {
|
if (code == 200) {
|
||||||
//向OA的webview通信,改变未读消息数量
|
//向OA的webview通信,改变未读消息数量
|
||||||
handleFindWebview(`doUpdateUnreadNum('${data.unread_num}')`)
|
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}')`)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
this.items = data.items.map((item) => {
|
this.items = data.items.map((item) => {
|
||||||
const value = formatTalkItem(item)
|
const value = formatTalkItem(item)
|
||||||
|
|
||||||
|
@ -1,2 +0,0 @@
|
|||||||
## 1.0.0(2023-09-05)
|
|
||||||
实现基础功能
|
|
@ -1,130 +0,0 @@
|
|||||||
<template>
|
|
||||||
<view :style="[boxStyel]" class="box">
|
|
||||||
<view class="audio-style" :style="[audioStyel]" :class="{ 'animation': isPlay }">
|
|
||||||
<view class="small" :style="{'background-color': color}"></view>
|
|
||||||
<view class="middle" :style="{'border-right-color': color}"></view>
|
|
||||||
<view class="large" :style="{'border-right-color': color}"></view>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
</template>
|
|
||||||
<script>
|
|
||||||
export default {
|
|
||||||
emits: [],
|
|
||||||
props: {
|
|
||||||
isPlay: {
|
|
||||||
type: [Boolean],
|
|
||||||
default: false
|
|
||||||
},
|
|
||||||
direction: {
|
|
||||||
type: String,
|
|
||||||
default: 'right'
|
|
||||||
},
|
|
||||||
size: {
|
|
||||||
type: Number,
|
|
||||||
default: 24
|
|
||||||
},
|
|
||||||
color: {
|
|
||||||
type: String,
|
|
||||||
default: '#222'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
};
|
|
||||||
},
|
|
||||||
computed: {
|
|
||||||
audioStyel() {
|
|
||||||
return {
|
|
||||||
transform: `scale(${this.size / 24})`
|
|
||||||
};
|
|
||||||
},
|
|
||||||
boxStyel() {
|
|
||||||
const directDic = { right: '0deg', bottom: '90deg', left: '180deg', top: '270deg' };
|
|
||||||
const dir = directDic[this.direction || 'left'];
|
|
||||||
const style = {
|
|
||||||
transform: `rotate(${dir})`,
|
|
||||||
width: this.size + 'px',
|
|
||||||
height: this.size + 'px'
|
|
||||||
};
|
|
||||||
return style;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
methods: {}
|
|
||||||
};
|
|
||||||
</script>
|
|
||||||
<style lang="scss" scoped>
|
|
||||||
view{
|
|
||||||
box-sizing: border-box;
|
|
||||||
}
|
|
||||||
.box {
|
|
||||||
// border: 1px solid #4c4c4c;
|
|
||||||
display: inline-flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
overflow: hidden;
|
|
||||||
}
|
|
||||||
.audio-style {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
overflow: hidden;
|
|
||||||
& > view {
|
|
||||||
border: 2px solid transparent;
|
|
||||||
border-radius: 50%;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
.small {
|
|
||||||
border: 0px solid;
|
|
||||||
width: 3px;
|
|
||||||
height: 3px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.middle {
|
|
||||||
width: 16px;
|
|
||||||
height: 16px;
|
|
||||||
margin-left: -11px;
|
|
||||||
opacity: 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
.large {
|
|
||||||
width: 24px;
|
|
||||||
height: 24px;
|
|
||||||
margin-left: -19px;
|
|
||||||
opacity: 1;
|
|
||||||
}
|
|
||||||
.animation {
|
|
||||||
.middle {
|
|
||||||
animation: middle 1.2s ease-in-out infinite;
|
|
||||||
}
|
|
||||||
.large {
|
|
||||||
animation: large 1.2s ease-in-out infinite;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// 语音播放动画
|
|
||||||
@keyframes middle {
|
|
||||||
0% {
|
|
||||||
opacity: 0;
|
|
||||||
}
|
|
||||||
10% {
|
|
||||||
opacity: 1;
|
|
||||||
}
|
|
||||||
100% {
|
|
||||||
opacity: 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@keyframes large {
|
|
||||||
0% {
|
|
||||||
opacity: 0;
|
|
||||||
}
|
|
||||||
50% {
|
|
||||||
opacity: 1;
|
|
||||||
}
|
|
||||||
60% {
|
|
||||||
opacity: 0;
|
|
||||||
}
|
|
||||||
100% {
|
|
||||||
opacity: 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</style>
|
|
@ -1,83 +0,0 @@
|
|||||||
{
|
|
||||||
"id": "a-trumpet",
|
|
||||||
"displayName": "纯css语音播放,语音聊天,播放小喇叭动画组件",
|
|
||||||
"version": "1.0.0",
|
|
||||||
"description": "纯css语音播放,语音聊天,播放小喇叭动画组件",
|
|
||||||
"keywords": [
|
|
||||||
"a-trumpet",
|
|
||||||
"语音播报",
|
|
||||||
"播放小喇叭",
|
|
||||||
"动画"
|
|
||||||
],
|
|
||||||
"repository": "",
|
|
||||||
"engines": {
|
|
||||||
},
|
|
||||||
"dcloudext": {
|
|
||||||
"type": "component-vue",
|
|
||||||
"sale": {
|
|
||||||
"regular": {
|
|
||||||
"price": "0.00"
|
|
||||||
},
|
|
||||||
"sourcecode": {
|
|
||||||
"price": "0.00"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"contact": {
|
|
||||||
"qq": ""
|
|
||||||
},
|
|
||||||
"declaration": {
|
|
||||||
"ads": "无",
|
|
||||||
"data": "无",
|
|
||||||
"permissions": "无"
|
|
||||||
},
|
|
||||||
"npmurl": ""
|
|
||||||
},
|
|
||||||
"uni_modules": {
|
|
||||||
"dependencies": [],
|
|
||||||
"encrypt": [],
|
|
||||||
"platforms": {
|
|
||||||
"cloud": {
|
|
||||||
"tcb": "y",
|
|
||||||
"aliyun": "y"
|
|
||||||
},
|
|
||||||
"client": {
|
|
||||||
"Vue": {
|
|
||||||
"vue2": "y",
|
|
||||||
"vue3": "y"
|
|
||||||
},
|
|
||||||
"App": {
|
|
||||||
"app-vue": "y",
|
|
||||||
"app-nvue": "y"
|
|
||||||
},
|
|
||||||
"H5-mobile": {
|
|
||||||
"Safari": "y",
|
|
||||||
"Android Browser": "y",
|
|
||||||
"微信浏览器(Android)": "y",
|
|
||||||
"QQ浏览器(Android)": "y"
|
|
||||||
},
|
|
||||||
"H5-pc": {
|
|
||||||
"Chrome": "y",
|
|
||||||
"IE": "y",
|
|
||||||
"Edge": "y",
|
|
||||||
"Firefox": "y",
|
|
||||||
"Safari": "y"
|
|
||||||
},
|
|
||||||
"小程序": {
|
|
||||||
"微信": "y",
|
|
||||||
"阿里": "y",
|
|
||||||
"百度": "y",
|
|
||||||
"字节跳动": "y",
|
|
||||||
"QQ": "y",
|
|
||||||
"钉钉": "y",
|
|
||||||
"快手": "y",
|
|
||||||
"飞书": "y",
|
|
||||||
"京东": "y"
|
|
||||||
},
|
|
||||||
"快应用": {
|
|
||||||
"华为": "y",
|
|
||||||
"联盟": "y"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,18 +0,0 @@
|
|||||||
# a-trumpet
|
|
||||||
|
|
||||||
## 用法
|
|
||||||
```html
|
|
||||||
<a-trumpet :isPlay="isplay"></a-trumpet>
|
|
||||||
<a-trumpet :isPlay="isplay" color="#1100ff"></a-trumpet>
|
|
||||||
<a-trumpet :isPlay="isplay" :size="50"></a-trumpet>
|
|
||||||
<a-trumpet :isPlay="isplay" direction="right"></a-trumpet>
|
|
||||||
```
|
|
||||||
|
|
||||||
## 属性说明:
|
|
||||||
|
|
||||||
| 属性名 | 类型 | 默认值 | 说明 |
|
|
||||||
| ---- | ---- | ---- | ---- |
|
|
||||||
| isplay | Boolean | false | 是否播放动画 |
|
|
||||||
| size | Number | 24 | 宽高的尺寸 |
|
|
||||||
| color | String | #222 | 颜色 |
|
|
||||||
| direction | String | top、bottom、left、ringt| 方向,上下左右 |
|
|
@ -21,19 +21,7 @@
|
|||||||
},
|
},
|
||||||
]"
|
]"
|
||||||
>
|
>
|
||||||
<wd-loading
|
<text>{{ btnTextContent }}</text>
|
||||||
v-if="isCheckingPermission"
|
|
||||||
color="#46299D"
|
|
||||||
:size="20"
|
|
||||||
style="margin: 0 12rpx 0 0;"
|
|
||||||
/>
|
|
||||||
<text>
|
|
||||||
{{
|
|
||||||
isCheckingPermission
|
|
||||||
? $t('chat_getting_microphone_permission')
|
|
||||||
: btnTextContent
|
|
||||||
}}
|
|
||||||
</text>
|
|
||||||
</view>
|
</view>
|
||||||
<!-- <view class="record-popup"
|
<!-- <view class="record-popup"
|
||||||
:style="{ '--popup-height': popupHeight, '--popup-width': upx2px(popupMaxWidth), '--popup-bottom': upx2px(popupFixBottom), '--popup-bg-color': popupBgColor }">
|
:style="{ '--popup-height': popupHeight, '--popup-width': upx2px(popupMaxWidth), '--popup-bottom': upx2px(popupFixBottom), '--popup-bg-color': popupBgColor }">
|
||||||
@ -160,7 +148,7 @@ import 'recorder-core/src/engine/mp3-engine'
|
|||||||
import 'recorder-core/src/extensions/waveview'
|
import 'recorder-core/src/extensions/waveview'
|
||||||
import recordCancelBg from '@/static/image/record/chat-voice-animation-bg-red.png'
|
import recordCancelBg from '@/static/image/record/chat-voice-animation-bg-red.png'
|
||||||
// #endif
|
// #endif
|
||||||
import { multiplication, handleFindWebview } from '@/utils/common'
|
import { multiplication } from '@/utils/common'
|
||||||
export default {
|
export default {
|
||||||
name: 'nbVoiceRecord',
|
name: 'nbVoiceRecord',
|
||||||
/**
|
/**
|
||||||
@ -295,7 +283,6 @@ export default {
|
|||||||
autoStopRecordCountDown: 0, //自动停止录音倒计时
|
autoStopRecordCountDown: 0, //自动停止录音倒计时
|
||||||
autoStopRecordInterval: null, //自动停止录音技术定时器
|
autoStopRecordInterval: null, //自动停止录音技术定时器
|
||||||
permisionState: false, //权限授权状态
|
permisionState: false, //权限授权状态
|
||||||
isCheckingPermission: true, //是否正在获取权限
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
@ -313,7 +300,7 @@ export default {
|
|||||||
let that = this
|
let that = this
|
||||||
|
|
||||||
// 请求权限
|
// 请求权限
|
||||||
that.checkPermission(true)
|
that.checkPermission()
|
||||||
|
|
||||||
// #ifdef APP-PLUS
|
// #ifdef APP-PLUS
|
||||||
recorderManager.onStop((res) => {
|
recorderManager.onStop((res) => {
|
||||||
@ -355,11 +342,7 @@ export default {
|
|||||||
// }, 1000)
|
// }, 1000)
|
||||||
if (Number(permissionStatus) === 1) {
|
if (Number(permissionStatus) === 1) {
|
||||||
that.continueAppMicro()
|
that.continueAppMicro()
|
||||||
} else if (
|
} else if (Number(permissionStatus) === -1) {
|
||||||
Number(permissionStatus) === -1 ||
|
|
||||||
(Number(permissionStatus) === 0 &&
|
|
||||||
uni.getSystemInfoSync().osName === 'ios')
|
|
||||||
) {
|
|
||||||
uni.showModal({
|
uni.showModal({
|
||||||
title: '提示',
|
title: '提示',
|
||||||
content: '检测到您还未授权麦克风哦',
|
content: '检测到您还未授权麦克风哦',
|
||||||
@ -368,10 +351,12 @@ export default {
|
|||||||
cancelText: '保持拒绝',
|
cancelText: '保持拒绝',
|
||||||
success: ({ confirm, cancel }) => {
|
success: ({ confirm, cancel }) => {
|
||||||
if (confirm) {
|
if (confirm) {
|
||||||
handleFindWebview(`handleRequestAndroidPermission('settings')`)
|
let OAWebView = plus.webview.all()
|
||||||
}
|
OAWebView.forEach((webview, index) => {
|
||||||
if (cancel) {
|
if (webview.id === 'webviewId1') {
|
||||||
that.isCheckingPermission = false
|
webview.evalJS(`handleRequestAndroidPermission('settings')`)
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
@ -393,20 +378,15 @@ export default {
|
|||||||
that.permissionInfo = permissionInfo
|
that.permissionInfo = permissionInfo
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
continueAppMicro(isFirstRequestPer = false) {
|
continueAppMicro() {
|
||||||
let that = this
|
let that = this
|
||||||
RecordApp.UniWebViewActivate(that) //App环境下必须先切换成当前页面WebView
|
RecordApp.UniWebViewActivate(that) //App环境下必须先切换成当前页面WebView
|
||||||
RecordApp.RequestPermission(
|
RecordApp.RequestPermission(
|
||||||
() => {
|
() => {
|
||||||
console.log('已获得录音权限,可以开始录音了')
|
console.log('已获得录音权限,可以开始录音了')
|
||||||
that.permisionState = true
|
that.permisionState = true
|
||||||
that.isCheckingPermission = false
|
|
||||||
if (isFirstRequestPer) {
|
|
||||||
that.stopRecord()
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
(msg, isUserNotAllow) => {
|
(msg, isUserNotAllow) => {
|
||||||
that.isCheckingPermission = false
|
|
||||||
if (isUserNotAllow) {
|
if (isUserNotAllow) {
|
||||||
//用户拒绝了录音权限
|
//用户拒绝了录音权限
|
||||||
//这里你应当编写代码进行引导用户给录音权限,不同平台分别进行编写
|
//这里你应当编写代码进行引导用户给录音权限,不同平台分别进行编写
|
||||||
@ -415,7 +395,7 @@ export default {
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
async checkPermission(isFirstRequestPer = false) {
|
async checkPermission() {
|
||||||
let that = this
|
let that = this
|
||||||
// #ifdef APP-PLUS
|
// #ifdef APP-PLUS
|
||||||
// 先判断os
|
// 先判断os
|
||||||
@ -453,9 +433,14 @@ export default {
|
|||||||
// #endif
|
// #endif
|
||||||
// #ifdef H5
|
// #ifdef H5
|
||||||
if (typeof plus !== 'undefined') {
|
if (typeof plus !== 'undefined') {
|
||||||
handleFindWebview(`handleRequestAndroidPermission('micro')`)
|
let OAWebView = plus.webview.all()
|
||||||
|
OAWebView.forEach((webview, index) => {
|
||||||
|
if (webview.id === 'webviewId1') {
|
||||||
|
webview.evalJS(`handleRequestAndroidPermission('micro')`)
|
||||||
|
}
|
||||||
|
})
|
||||||
} else {
|
} else {
|
||||||
that.continueAppMicro(isFirstRequestPer)
|
that.continueAppMicro()
|
||||||
}
|
}
|
||||||
// #endif
|
// #endif
|
||||||
// #endif
|
// #endif
|
||||||
|
@ -194,9 +194,6 @@
|
|||||||
"release_hand_to_cancel": "松开取消",
|
"release_hand_to_cancel": "松开取消",
|
||||||
"hold_to": "按住",
|
"hold_to": "按住",
|
||||||
"speak": "说话",
|
"speak": "说话",
|
||||||
"auto_stop_record": "s后自动结束录音",
|
|
||||||
"chat_voice_too_short": "说话时间太短",
|
|
||||||
"chat_getting_microphone_permission": "获取麦克风权限中...",
|
|
||||||
"addressBook": {
|
"addressBook": {
|
||||||
"tabs": {
|
"tabs": {
|
||||||
"company": "组织架构",
|
"company": "组织架构",
|
||||||
|
@ -214,27 +214,6 @@ 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()
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 通用运算函数
|
// 通用运算函数
|
||||||
/*
|
/*
|
||||||
函数,加法函数,用来得到精确的加法结果
|
函数,加法函数,用来得到精确的加法结果
|
||||||
@ -244,16 +223,16 @@ export function handleFindWebview(evalJS_) {
|
|||||||
返回值:两数相加的结果
|
返回值:两数相加的结果
|
||||||
*/
|
*/
|
||||||
export function addition(arg1, arg2) {
|
export function addition(arg1, arg2) {
|
||||||
;(arg1 = arg1.toString()), (arg2 = arg2.toString())
|
arg1 = arg1.toString(), arg2 = arg2.toString();
|
||||||
var arg1Arr = arg1.split('.'),
|
var arg1Arr = arg1.split("."),
|
||||||
arg2Arr = arg2.split('.'),
|
arg2Arr = arg2.split("."),
|
||||||
d1 = arg1Arr.length == 2 ? arg1Arr[1] : '',
|
d1 = arg1Arr.length == 2 ? arg1Arr[1] : "",
|
||||||
d2 = arg2Arr.length == 2 ? arg2Arr[1] : ''
|
d2 = arg2Arr.length == 2 ? arg2Arr[1] : "";
|
||||||
var maxLen = Math.max(d1.length, d2.length)
|
var maxLen = Math.max(d1.length, d2.length);
|
||||||
var m = Math.pow(10, maxLen)
|
var m = Math.pow(10, maxLen);
|
||||||
var result = Number(((arg1 * m + arg2 * m) / m).toFixed(maxLen))
|
var result = Number(((arg1 * m + arg2 * m) / m).toFixed(maxLen));
|
||||||
var d = arguments[2]
|
var d = arguments[2];
|
||||||
return typeof d === 'number' ? Number(result.toFixed(d)) : result
|
return typeof d === "number" ? Number((result).toFixed(d)) : result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -272,20 +251,12 @@ export function addition(arg1, arg2) {
|
|||||||
返回值:两数相乘的结果
|
返回值:两数相乘的结果
|
||||||
*/
|
*/
|
||||||
export function multiplication(arg1, arg2) {
|
export function multiplication(arg1, arg2) {
|
||||||
var r1 = arg1.toString(),
|
var r1 = arg1.toString(),
|
||||||
r2 = arg2.toString(),
|
r2 = arg2.toString(),
|
||||||
m,
|
m, resultVal, d = arguments[2];
|
||||||
resultVal,
|
m = (r1.split(".")[1] ? r1.split(".")[1].length : 0) + (r2.split(".")[1] ? r2.split(".")[1].length : 0);
|
||||||
d = arguments[2]
|
resultVal = Number(r1.replace(".", "")) * Number(r2.replace(".", "")) / Math.pow(10, m);
|
||||||
m =
|
return typeof d !== "number" ? Number(resultVal) : Number(resultVal.toFixed(parseInt(d)));
|
||||||
(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)))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -296,18 +267,10 @@ export function multiplication(arg1, arg2) {
|
|||||||
返回值:arg1除于arg2的结果
|
返回值:arg1除于arg2的结果
|
||||||
*/
|
*/
|
||||||
export function division(arg1, arg2) {
|
export function division(arg1, arg2) {
|
||||||
var r1 = arg1.toString(),
|
var r1 = arg1.toString(),
|
||||||
r2 = arg2.toString(),
|
r2 = arg2.toString(),
|
||||||
m,
|
m, resultVal, d = arguments[2];
|
||||||
resultVal,
|
m = (r2.split(".")[1] ? r2.split(".")[1].length : 0) - (r1.split(".")[1] ? r1.split(".")[1].length : 0);
|
||||||
d = arguments[2]
|
resultVal = Number(r1.replace(".", "")) / Number(r2.replace(".", "")) * Math.pow(10, m);
|
||||||
m =
|
return typeof d !== "number" ? Number(resultVal) : Number(resultVal.toFixed(parseInt(d)));
|
||||||
(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)))
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user