From 1c93dc914bddd5c16e6e93eee18e57911b69e68f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8C=83=E9=B9=8F?= Date: Mon, 7 Apr 2025 17:01:22 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=AE=8C=E6=88=90twcall=E7=9B=B8?= =?UTF-8?q?=E5=85=B3UI+=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App.vue | 20 ++++ api/{p2p.js => sdk.js} | 6 +- manifest.json | 9 ++ pages.json | 7 +- pages/main/customBox.vue | 185 ++++++++++++++++++++++++++++++++++ pages/main/lockDetail.vue | 2 +- pages/p2p/authorizeWechat.vue | 146 ++++++++++++++++++++++++++- pages/p2p/p2pPlayer.vue | 4 +- 8 files changed, 364 insertions(+), 15 deletions(-) rename api/{p2p.js => sdk.js} (64%) create mode 100644 pages/main/customBox.vue diff --git a/App.vue b/App.vue index b2795b5..6b24e74 100644 --- a/App.vue +++ b/App.vue @@ -39,6 +39,8 @@ this.updateMiniProgram() // 监听蓝牙开关状态 this.onBluetoothState() + // 设置voip配置 + this.setVoipConfig() // 检查蓝牙权限 const checkResult = await this.checkSetting() console.log(checkResult) @@ -65,6 +67,24 @@ 'initAndListenBluetooth' ]), ...mapActions(useUserStore, ['updateLoginStatus']), + // voip设置 + setVoipConfig() { + const wmpfVoip = requirePlugin('wmpf-voip').default + wmpfVoip.setUIConfig({ + btnText: '去开门', + customBoxHeight: '75vh', + listenerUI: { + cameraRotation: 270, + objectFit: 'fill', + enableToggleCamera: false + } + }) + wmpfVoip.setVoipEndPagePath({ + url: '/pages/main/home', + key: 'Call', + routeType: 'switchTab' + }) + }, // 强制升级 updateMiniProgram() { const updateManager = uni.getUpdateManager() diff --git a/api/p2p.js b/api/sdk.js similarity index 64% rename from api/p2p.js rename to api/sdk.js index fb0d2a0..5ec215c 100644 --- a/api/p2p.js +++ b/api/sdk.js @@ -1,9 +1,9 @@ import request from '../utils/request' -// p2p 模块 +// sdk 模块 -// 获取p2pInfo -export function getP2pInfo(data) { +// 透传 +export function passthrough(data) { return request({ url: '/passthrough', method: 'POST', diff --git a/manifest.json b/manifest.json index ae4600e..fdb5525 100644 --- a/manifest.json +++ b/manifest.json @@ -29,6 +29,15 @@ "version": "latest", "provider": "wx1319af22356934bf", "export": "exportForXp2pPlugin.js" + }, + "wmpf-voip": { + "version": "latest", + "provider": "wxf830863afde621eb", + "genericsImplementation": { + "call-page-plugin": { + "custombox": "pages/main/customBox" + } + } } } }, diff --git a/pages.json b/pages.json index be1321e..fbe944f 100644 --- a/pages.json +++ b/pages.json @@ -38,10 +38,6 @@ "version": "latest", "provider": "wx9e8fbc98ceac2628", "export": "exportForPlayerPlugin.js" - }, - "wmpf-voip": { - "version": "latest", - "provider": "wxf830863afde621eb" } } }, @@ -579,6 +575,9 @@ { "path": "pages/main/mine" }, + { + "path": "pages/main/customBox" + }, { "path": "pages/main/notificationList", "style": { diff --git a/pages/main/customBox.vue b/pages/main/customBox.vue new file mode 100644 index 0000000..0893cda --- /dev/null +++ b/pages/main/customBox.vue @@ -0,0 +1,185 @@ + + + + + diff --git a/pages/main/lockDetail.vue b/pages/main/lockDetail.vue index 018f1be..b2a3cee 100644 --- a/pages/main/lockDetail.vue +++ b/pages/main/lockDetail.vue @@ -223,7 +223,7 @@ - 授权微信 + 授权后,设备可呼叫该微信 + + + 授权 + + + 您已授权 + + 您已拒绝授权,请去设置中 + 打开语音、视频通话提醒开关 + + 打开设置 + + + + \ No newline at end of file + + const openSetting = () => { + uni.openSetting({ + success: res => { + console.log(res) + } + }) + } + + const getInfo = async () => { + const result = await passthrough({ + request_method: 'GET', + request_uri: '/api/v1/tencentYun/getWechatDeviceTicket', + post_args: { + lockId: $bluetooth.currentLockInfo.lockId + } + }) + return result + } + + const handleAuthorize = async () => { + if (pending.value) return + pending.value = true + uni.showLoading({ + title: '授权中...' + }) + const result = await getInfo() + if (result.code === 0) { + wx.requestDeviceVoIP({ + sn: result.data.WXIoTDeviceInfo.SN, + snTicket: result.data.WXIoTDeviceInfo.SNTicket, + modelId: result.data.WXIoTDeviceInfo.ModelId, + deviceName: '智能', + success() { + isAuthorized.value = true + uni.hideLoading() + pending.value = false + uni.showToast({ + title: '授权成功', + icon: 'none' + }) + }, + fail() { + isAuthorized.value = true + reject.value = true + uni.hideLoading() + pending.value = false + uni.showToast({ + title: '授权失败', + icon: 'none' + }) + } + }) + } else { + uni.hideLoading() + pending.value = false + uni.showToast({ + title: result.message, + icon: 'none' + }) + } + } + diff --git a/pages/p2p/p2pPlayer.vue b/pages/p2p/p2pPlayer.vue index 323f519..3057b2b 100644 --- a/pages/p2p/p2pPlayer.vue +++ b/pages/p2p/p2pPlayer.vue @@ -123,7 +123,7 @@ import { useBasicStore } from '@/stores/basic' import { onMounted, ref } from 'vue' import { onUnload } from '@dcloudio/uni-app' - import { getP2pInfo } from '@/api/p2p' + import { passthrough } from '@/api/sdk' const $bluetooth = useBluetoothStore() const $basic = useBasicStore() @@ -148,7 +148,7 @@ onMounted(async () => { buttonInfo.value = await $basic.getButtonInfo() - const { code, data, message } = await getP2pInfo({ + const { code, data, message } = await passthrough({ request_method: 'GET', request_uri: '/api/v1/tencentYun/getDeviceDetailData', post_args: {