feat: 完成监控页面相关逻辑

This commit is contained in:
范鹏 2025-04-06 15:19:55 +08:00
parent 7070999811
commit 52959a97d2
12 changed files with 224 additions and 488 deletions

View File

@ -1,12 +0,0 @@
import request from '../utils/request'
// sdk 模块
// 获取SDK Token
export function getSdkToken(data) {
return request({
url: '/wechat/tencentYunBind',
method: 'POST',
data
})
}

View File

@ -1,9 +0,0 @@
/**
* 应用全局常量配置
*/
// P2P相关常量
export const P2P_PLAYER_ID = 'p2p-player'
export const P2P_PUSHER_ID = 'p2p-pusher'
// 其他常量可以在这里添加

254
package-lock.json generated
View File

@ -7,10 +7,6 @@
"dependencies": {
"pinia": "^2.2.0",
"pinia-plugin-unistorage": "^0.1.2",
"qcloud-iotexplorer-appdev-plugin-wificonf-blecombo": "^3.0.118",
"qcloud-iotexplorer-appdev-plugin-wificonf-core": "^3.0.118",
"qcloud-iotexplorer-appdev-sdk": "^3.0.118",
"qcloud-iotexplorer-bluetooth-adapter": "^3.0.118",
"uview-plus": "^3.3.12"
},
"devDependencies": {
@ -1152,31 +1148,6 @@
"buffer": "^6.0.3"
}
},
"node_modules/@keyv/serialize/node_modules/buffer": {
"version": "6.0.3",
"resolved": "https://registry.npmjs.org/buffer/-/buffer-6.0.3.tgz",
"integrity": "sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==",
"dev": true,
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/feross"
},
{
"type": "patreon",
"url": "https://www.patreon.com/feross"
},
{
"type": "consulting",
"url": "https://feross.org/support"
}
],
"license": "MIT",
"dependencies": {
"base64-js": "^1.3.1",
"ieee754": "^1.2.1"
}
},
"node_modules/@meoc/utils": {
"version": "0.2.9",
"resolved": "https://registry.npmjs.org/@meoc/utils/-/utils-0.2.9.tgz",
@ -2464,6 +2435,31 @@
"readable-stream": "^3.4.0"
}
},
"node_modules/bl/node_modules/buffer": {
"version": "5.7.1",
"resolved": "https://registry.npmjs.org/buffer/-/buffer-5.7.1.tgz",
"integrity": "sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==",
"dev": true,
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/feross"
},
{
"type": "patreon",
"url": "https://www.patreon.com/feross"
},
{
"type": "consulting",
"url": "https://feross.org/support"
}
],
"license": "MIT",
"dependencies": {
"base64-js": "^1.3.1",
"ieee754": "^1.1.13"
}
},
"node_modules/boolbase": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/boolbase/-/boolbase-1.0.0.tgz",
@ -2496,9 +2492,9 @@
}
},
"node_modules/buffer": {
"version": "5.7.1",
"resolved": "https://registry.npmjs.org/buffer/-/buffer-5.7.1.tgz",
"integrity": "sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==",
"version": "6.0.3",
"resolved": "https://registry.npmjs.org/buffer/-/buffer-6.0.3.tgz",
"integrity": "sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==",
"dev": true,
"funding": [
{
@ -2517,7 +2513,7 @@
"license": "MIT",
"dependencies": {
"base64-js": "^1.3.1",
"ieee754": "^1.1.13"
"ieee754": "^1.2.1"
}
},
"node_modules/cac": {
@ -3303,15 +3299,6 @@
}
}
},
"node_modules/decode-uri-component": {
"version": "0.2.2",
"resolved": "https://registry.npmjs.org/decode-uri-component/-/decode-uri-component-0.2.2.tgz",
"integrity": "sha512-FqUYQ+8o158GyGTrMFJms9qh3CqTKvAqgqsTnkLI8sKu0028orqBhxNMFkFen0zGyg6epACD32pjVk58ngIErQ==",
"license": "MIT",
"engines": {
"node": ">=0.10"
}
},
"node_modules/dedent": {
"version": "0.7.0",
"resolved": "https://registry.npmjs.org/dedent/-/dedent-0.7.0.tgz",
@ -4339,12 +4326,6 @@
"node": ">=0.10.0"
}
},
"node_modules/event-emitter-for-miniprogram": {
"version": "3.0.118",
"resolved": "https://registry.npmjs.org/event-emitter-for-miniprogram/-/event-emitter-for-miniprogram-3.0.118.tgz",
"integrity": "sha512-1PcFkCGtSrYX7Fwwrrz5OxmO1vrkDZuLOrrS/Ok2XYjADcTUspxXENlh/PaizTH3VIlF1T3W27QXEoixrzKyQA==",
"license": "MIT"
},
"node_modules/eventemitter3": {
"version": "5.0.1",
"resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-5.0.1.tgz",
@ -4558,15 +4539,6 @@
"node": ">=8"
}
},
"node_modules/filter-obj": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/filter-obj/-/filter-obj-1.1.0.tgz",
"integrity": "sha512-8rXg1ZnX7xzy2NGDVkBVaAy+lSlPNwad13BtgSlLuxfIslyt5Vg64U7tFcCt4WS1R0hvtnQybT/IyCkGZ3DpXQ==",
"license": "MIT",
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/find-node-modules": {
"version": "2.1.3",
"resolved": "https://registry.npmjs.org/find-node-modules/-/find-node-modules-2.1.3.tgz",
@ -5453,15 +5425,6 @@
"node": ">= 0.4"
}
},
"node_modules/iotexplorer-ui-dev-config": {
"version": "3.0.118",
"resolved": "https://registry.npmjs.org/iotexplorer-ui-dev-config/-/iotexplorer-ui-dev-config-3.0.118.tgz",
"integrity": "sha512-XC1tQ+oY/0C0/n7qG4ofxAGxfONFDGHQ3tpgK2F2JmF2sQIlRSAd4L80cHQKxPFqyIbmIB751DEqupCPnh+F4w==",
"license": "MIT",
"dependencies": {
"tslib": "^2.1.0"
}
},
"node_modules/is-array-buffer": {
"version": "3.0.5",
"resolved": "https://registry.npmjs.org/is-array-buffer/-/is-array-buffer-3.0.5.tgz",
@ -5993,12 +5956,6 @@
"jiti": "lib/jiti-cli.mjs"
}
},
"node_modules/js-base64": {
"version": "3.7.7",
"resolved": "https://registry.npmjs.org/js-base64/-/js-base64-3.7.7.tgz",
"integrity": "sha512-7rCnleh0z2CkXhH67J8K1Ytz0b2Y+yxTPL+/KOJoa20hfnVQ/3/T6W/KflYI4bRHRagNeXeU2bkNGI3v1oS/lw==",
"license": "BSD-3-Clause"
},
"node_modules/js-md5": {
"version": "0.8.3",
"resolved": "https://registry.npmjs.org/js-md5/-/js-md5-0.8.3.tgz",
@ -6411,12 +6368,6 @@
"dev": true,
"license": "MIT"
},
"node_modules/lodash.uniqwith": {
"version": "4.5.0",
"resolved": "https://registry.npmjs.org/lodash.uniqwith/-/lodash.uniqwith-4.5.0.tgz",
"integrity": "sha512-7lYL8bLopMoy4CTICbxygAUq6CdRJ36vFc80DucPueUee+d5NBRxz3FdT9Pes/HEx5mPoT9jwnsEJWz1N7uq7Q==",
"license": "MIT"
},
"node_modules/lodash.upperfirst": {
"version": "4.3.1",
"resolved": "https://registry.npmjs.org/lodash.upperfirst/-/lodash.upperfirst-4.3.1.tgz",
@ -7664,103 +7615,6 @@
"node": ">=6"
}
},
"node_modules/qcloud-iotexplorer-appdev-plugin-wificonf-blecombo": {
"version": "3.0.118",
"resolved": "https://registry.npmjs.org/qcloud-iotexplorer-appdev-plugin-wificonf-blecombo/-/qcloud-iotexplorer-appdev-plugin-wificonf-blecombo-3.0.118.tgz",
"integrity": "sha512-ni8uOa8m1L2gSPkAa2/afKOzaLpeCPdmEW39Hbn2j7S4V5UPbWL+1lObNy8stlRUR++vKPIhb/DOlW1OTHAcDQ==",
"license": "MIT",
"dependencies": {
"iotexplorer-ui-dev-config": "3.0.118",
"qcloud-iotexplorer-appdev-plugin-wificonf-core": "3.0.118",
"qcloud-iotexplorer-appdev-sdk": "3.0.118",
"qcloud-iotexplorer-bluetooth-adapter": "3.0.118",
"qcloud-iotexplorer-bluetooth-adapter-llsync": "3.0.118",
"qcloud-iotexplorer-common-libs": "3.0.118",
"qcloud-iotexplorer-logger": "3.0.118",
"shortid-for-miniprogram": "^2.2.15",
"spark-md5": "^3.0.1",
"tslib": "^2.1.0"
}
},
"node_modules/qcloud-iotexplorer-appdev-plugin-wificonf-core": {
"version": "3.0.118",
"resolved": "https://registry.npmjs.org/qcloud-iotexplorer-appdev-plugin-wificonf-core/-/qcloud-iotexplorer-appdev-plugin-wificonf-core-3.0.118.tgz",
"integrity": "sha512-2iObI2Hifi3ew+5EraINeNm0APF0jv2BYs2vyIuRwuJwNN6bPTrDGo1LIPyQpGBq03y4h9MUy11VxSVbeN9jbA==",
"license": "MIT",
"dependencies": {
"iotexplorer-ui-dev-config": "3.0.118",
"qcloud-iotexplorer-appdev-sdk": "3.0.118",
"tslib": "^2.1.0"
}
},
"node_modules/qcloud-iotexplorer-appdev-sdk": {
"version": "3.0.118",
"resolved": "https://registry.npmjs.org/qcloud-iotexplorer-appdev-sdk/-/qcloud-iotexplorer-appdev-sdk-3.0.118.tgz",
"integrity": "sha512-UzlvJgizhWeKGh75gaj3w6fuHNKF0oB418U733/lyexlUX5a9KWySrSO49AYwfOrPPp4vllTbZ2vP5jXJ7+l2w==",
"license": "MIT",
"dependencies": {
"event-emitter-for-miniprogram": "3.0.118",
"js-base64": "^3.2.4",
"qcloud-iotexplorer-common-libs": "3.0.118",
"qcloud-iotexplorer-logger": "3.0.118",
"query-string": "^6.9.0",
"shortid-for-miniprogram": "^2.2.15",
"tslib": "^2.1.0"
}
},
"node_modules/qcloud-iotexplorer-bluetooth-adapter": {
"version": "3.0.118",
"resolved": "https://registry.npmjs.org/qcloud-iotexplorer-bluetooth-adapter/-/qcloud-iotexplorer-bluetooth-adapter-3.0.118.tgz",
"integrity": "sha512-K/Qw14PID86VxL6vA6JiuxOYrnOgiX7yUSxlmuXlqNsJcbc7AaSUUCQUPP3Ds0AKcRp5EIzdMy8f5ANF9WIv1w==",
"license": "MIT",
"dependencies": {
"event-emitter-for-miniprogram": "3.0.118",
"lodash.uniqwith": "^4.5.0",
"qcloud-iotexplorer-appdev-sdk": "3.0.118",
"qcloud-iotexplorer-common-libs": "3.0.118",
"qcloud-iotexplorer-logger": "3.0.118",
"tslib": "^2.1.0"
}
},
"node_modules/qcloud-iotexplorer-bluetooth-adapter-llsync": {
"version": "3.0.118",
"resolved": "https://registry.npmjs.org/qcloud-iotexplorer-bluetooth-adapter-llsync/-/qcloud-iotexplorer-bluetooth-adapter-llsync-3.0.118.tgz",
"integrity": "sha512-dklNG7VFyQJkwnhl/aUxBMKhqhghl4y7RrcPih6q8AjJPHLY5k7DpP8tUVcLKCymXaiq3K6S6d1C9CTgL5AA9g==",
"license": "MIT",
"dependencies": {
"event-emitter-for-miniprogram": "3.0.118",
"iotexplorer-ui-dev-config": "3.0.118",
"qcloud-iotexplorer-appdev-sdk": "3.0.118",
"qcloud-iotexplorer-bluetooth-adapter": "3.0.118",
"qcloud-iotexplorer-common-libs": "3.0.118",
"qcloud-iotexplorer-logger": "3.0.118",
"shortid-for-miniprogram": "^2.2.15",
"spark-md5": "^3.0.1",
"tslib": "^2.1.0"
}
},
"node_modules/qcloud-iotexplorer-common-libs": {
"version": "3.0.118",
"resolved": "https://registry.npmjs.org/qcloud-iotexplorer-common-libs/-/qcloud-iotexplorer-common-libs-3.0.118.tgz",
"integrity": "sha512-nnCnfMwDjzCOY3wjNxvdkZZwLn91tYSie1TgwuC6oOD4pDRcbkOSRHG7W24l8gX/VLqOMkF+OiJzL6LRCQ3q+A==",
"license": "MIT",
"dependencies": {
"qcloud-iotexplorer-logger": "3.0.118",
"rxjs": "^7.8.0",
"shortid-for-miniprogram": "^2.2.15",
"spark-md5": "^3.0.1",
"tslib": "^2.1.0"
}
},
"node_modules/qcloud-iotexplorer-logger": {
"version": "3.0.118",
"resolved": "https://registry.npmjs.org/qcloud-iotexplorer-logger/-/qcloud-iotexplorer-logger-3.0.118.tgz",
"integrity": "sha512-kVW5Kq1vqBwRMAUs2wOYLMCCfrs1FKt0AFDRPnIEoZiTeBzXtk9QF1K50rb+zMtmZ6RUlwIKoomWZRMI3oqR/w==",
"license": "MIT",
"dependencies": {
"tslib": "^2.1.0"
}
},
"node_modules/quansync": {
"version": "0.2.10",
"resolved": "https://registry.npmjs.org/quansync/-/quansync-0.2.10.tgz",
@ -7778,24 +7632,6 @@
],
"license": "MIT"
},
"node_modules/query-string": {
"version": "6.14.1",
"resolved": "https://registry.npmjs.org/query-string/-/query-string-6.14.1.tgz",
"integrity": "sha512-XDxAeVmpfu1/6IjyT/gXHOl+S0vQ9owggJ30hhWKdHAsNPOcasn5o9BW0eejZqL2e4vMjhAxoW3jVHcD6mbcYw==",
"license": "MIT",
"dependencies": {
"decode-uri-component": "^0.2.0",
"filter-obj": "^1.1.0",
"split-on-first": "^1.0.0",
"strict-uri-encode": "^2.0.0"
},
"engines": {
"node": ">=6"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/queue-microtask": {
"version": "1.2.3",
"resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz",
@ -8115,6 +7951,7 @@
"version": "7.8.2",
"resolved": "https://registry.npmjs.org/rxjs/-/rxjs-7.8.2.tgz",
"integrity": "sha512-dhKf903U/PQZY6boNNtAGdWbG85WAbjT/1xYoZIC7FAY0yWapOBQVsVrDl58W86//e1VpMNBtRV4MaXfdMySFA==",
"dev": true,
"license": "Apache-2.0",
"dependencies": {
"tslib": "^2.1.0"
@ -8294,12 +8131,6 @@
"node": ">=8"
}
},
"node_modules/shortid-for-miniprogram": {
"version": "2.2.15",
"resolved": "https://registry.npmjs.org/shortid-for-miniprogram/-/shortid-for-miniprogram-2.2.15.tgz",
"integrity": "sha512-Ulw76O5R9UtanxKhiaN9fbQJc0B3YtqFHhDCV8B6/Ay/tjq0RlS4thRxWNI5rnxMVq7EOTrlFFE6QVFsWKLz5w==",
"license": "MIT"
},
"node_modules/side-channel": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.1.0.tgz",
@ -8450,21 +8281,6 @@
"node": ">=0.10.0"
}
},
"node_modules/spark-md5": {
"version": "3.0.2",
"resolved": "https://registry.npmjs.org/spark-md5/-/spark-md5-3.0.2.tgz",
"integrity": "sha512-wcFzz9cDfbuqe0FZzfi2or1sgyIrsDwmPwfZC4hiNidPdPINjeUwNfv5kldczoEAcjl9Y1L3SM7Uz2PUEQzxQw==",
"license": "(WTFPL OR MIT)"
},
"node_modules/split-on-first": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/split-on-first/-/split-on-first-1.1.0.tgz",
"integrity": "sha512-43ZssAJaMusuKWL8sKUBQXHWOpq8d6CfN/u1p4gUzfJkM05C8rxTmYrkIPTXapZpORA6LkkzcUulJ8FqA7Uudw==",
"license": "MIT",
"engines": {
"node": ">=6"
}
},
"node_modules/split2": {
"version": "4.2.0",
"resolved": "https://registry.npmjs.org/split2/-/split2-4.2.0.tgz",
@ -8475,15 +8291,6 @@
"node": ">= 10.x"
}
},
"node_modules/strict-uri-encode": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/strict-uri-encode/-/strict-uri-encode-2.0.0.tgz",
"integrity": "sha512-QwiXZgpRcKkhTj2Scnn++4PKtWsH0kpzZ62L2R6c/LUVYv7hVnZqcg2+sMuT6R7Jusu1vviK/MFsu6kNJfWlEQ==",
"license": "MIT",
"engines": {
"node": ">=4"
}
},
"node_modules/string_decoder": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz",
@ -9343,6 +9150,7 @@
"version": "2.8.1",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz",
"integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==",
"dev": true,
"license": "0BSD"
},
"node_modules/type-check": {

View File

@ -2,10 +2,6 @@
"dependencies": {
"pinia": "^2.2.0",
"pinia-plugin-unistorage": "^0.1.2",
"qcloud-iotexplorer-appdev-plugin-wificonf-blecombo": "^3.0.118",
"qcloud-iotexplorer-appdev-plugin-wificonf-core": "^3.0.118",
"qcloud-iotexplorer-appdev-sdk": "^3.0.118",
"qcloud-iotexplorer-bluetooth-adapter": "^3.0.118",
"uview-plus": "^3.3.12"
},
"devDependencies": {

View File

@ -14,6 +14,7 @@
{
"path": "p2pPlayer",
"style": {
"navigationStyle": "custom",
"navigationBarTitleText": "监控",
"mp-weixin": {
"usingComponents": {
@ -61,13 +62,6 @@
"navigationBarTitleText": "WiFi配网",
"disableScroll": true
}
},
{
"path": "selectDeviceType",
"style": {
"navigationBarTitleText": "选择设备类型",
"disableScroll": true
}
}
]
},

View File

@ -109,23 +109,9 @@
<script setup>
import { onMounted, ref } from 'vue'
import { constants as WifiConfConstants } from 'qcloud-iotexplorer-appdev-plugin-wificonf-core'
import { BlueToothAdapter } from 'qcloud-iotexplorer-bluetooth-adapter'
import {
BleComboEspDeviceAdapter,
BleComboLLSyncDeviceAdapter
} from 'qcloud-iotexplorer-appdev-plugin-wificonf-blecombo'
import { useBasicStore } from '@/stores/basic'
import { useSdkStore } from '@/stores/sdk'
const bluetoothAdapter = new BlueToothAdapter({
deviceAdapters: [BleComboEspDeviceAdapter, BleComboLLSyncDeviceAdapter]
})
const { WifiConfStepCode, WifiConfErrorMsg } = WifiConfConstants
const $basic = useBasicStore()
const $sdk = useSdkStore()
const current = ref(0)
const wifiList = ref([])
@ -230,87 +216,43 @@
wifiIndex.value = e.detail.value
}
function bleComboConfigure({ token, wifiInfo, familyId = 'default', roomId, deviceAdapter }) {
const onStepChange = progress => {
step.value = progress
}
const onProgress = data => {
console.info(data.code, data.detail)
switch (data.code) {
case WifiConfStepCode.PROTOCOL_START:
onStepChange(1)
break
case WifiConfStepCode.PROTOCOL_SUCCESS:
onStepChange(2)
break
case WifiConfStepCode.BUSINESS_QUERY_TOKEN_STATE_SUCCESS:
onStepChange(3)
break
case WifiConfStepCode.WIFI_CONF_SUCCESS:
onStepChange(4)
break
default:
break
}
}
const onComplete = ({ productId, deviceName }) => {
console.log('配网成功', productId, deviceName)
}
const onError = async ({ code, detail }) => {
const msg = WifiConfErrorMsg[code]
console.log('配网错误(onError)', code, msg, detail)
}
$sdk.getSdk().plugins.wifiConfBleCombo.start({
wifiConfToken: token,
targetWifiInfo: wifiInfo,
deviceAdapter,
familyId,
roomId,
onProgress,
onError,
onComplete
})
}
function bleComboConfigure() {}
const connectDevice = async device => {
try {
const deviceAdapter = await bluetoothAdapter.connectDevice(device)
console.log(1111, deviceAdapter)
bleComboConfigure({
token: '1234567890',
wifiInfo: wifiInfo.value,
familyId: 'default',
roomId: 'default',
deviceAdapter
})
current.value++
} catch (err) {
console.error('连接设备出错', err)
}
// try {
// const deviceAdapter = await bluetoothAdapter.connectDevice(device)
// console.log(1111, deviceAdapter)
// bleComboConfigure({
// token: '1234567890',
// wifiInfo: wifiInfo.value,
// familyId: 'default',
// roomId: 'default',
// deviceAdapter
// })
// current.value++
// } catch (err) {
// console.error('', err)
// }
}
const searchDevice = async () => {
try {
await bluetoothAdapter.startSearch({
onError: error => {
console.log('搜索设备出错', error)
bluetoothAdapter.stopSearch()
},
onSearch: devices => {
if (devices.length > 0) {
console.log('搜索到设备', devices)
deviceList.value = devices
}
},
timeout: 1.4 * 15 * 1000
})
} catch (error) {
console.log('搜索设备出错1', error)
}
// try {
// await bluetoothAdapter.startSearch({
// onError: error => {
// console.log('', error)
// bluetoothAdapter.stopSearch()
// },
// onSearch: devices => {
// if (devices.length > 0) {
// console.log('', devices)
// deviceList.value = devices
// }
// },
// timeout: 1.4 * 15 * 1000
// })
// } catch (error) {
// console.log('1', error)
// }
}
const handleNext = () => {

View File

@ -1,39 +0,0 @@
<template>
<view>
<view
class="flex items-center bg-white shadow-sm py-3 px-4 mx-2 rounded-lg mt-4"
@click="toJump('addLockGuid', { type: 'bluetooth' })"
>
<image src="https://oss-lock.xhjcn.ltd/mp/bluetooth-lock.png" class="w-80rpx h-80rpx"></image>
<view class="ml-4">蓝牙锁</view>
<view class="ml-a"><up-icon name="arrow-right"></up-icon></view>
</view>
<view
class="flex items-center bg-white shadow-sm py-3 px-4 mx-2 rounded-lg mt-4"
@click="toJump('addLockGuid', { type: 'wifi' })"
>
<image src="https://oss-lock.xhjcn.ltd/mp/wifi-lock.png" class="w-80rpx h-80rpx"></image>
<view class="ml-4">WiFi锁</view>
<view class="ml-a"><up-icon name="arrow-right"></up-icon></view>
</view>
</view>
</template>
<script setup>
import { useBasicStore } from '@/stores/basic'
const $basic = useBasicStore()
const toJump = (name, params) => {
$basic.routeJump({
name,
params
})
}
</script>
<style lang="scss">
page {
background-color: $uni-bg-color-grey;
}
</style>

View File

@ -182,7 +182,6 @@
import { deleteKeyRequest } from '@/api/key'
import { deleteLockRequest } from '@/api/lock'
import { setStorage, getStorage } from '@/utils/storage'
import { useSdkStore } from '@/stores/sdk'
export default {
data() {
@ -225,11 +224,7 @@
this.deviceInfo = await this.getDeviceInfo()
const token = getStorage('token')
if (token) {
await Promise.all([
this.getLockList(this.lockSearch),
this.getUserInfo(),
this.initSdk()
]).then(res => {
await Promise.all([this.getLockList(this.lockSearch), this.getUserInfo()]).then(res => {
this.pending = false
uni.hideLoading()
const list = getStorage('lockList')
@ -277,7 +272,6 @@
'resetDevice'
]),
...mapActions(useBasicStore, ['routeJump', 'getDeviceInfo', 'getNetworkType', 'shareJump']),
...mapActions(useSdkStore, ['initSdk']),
async deleteLock(lock, groupIndex, lockIndex) {
const that = this
const netWork = await this.getNetworkType()
@ -422,7 +416,6 @@
that.getLockList(that.lockSearch)
await that.getUserInfo()
that.updateLoginStatus(true)
that.initSdk()
resolve(true)
} else {
that.updateLoginStatus(false)
@ -537,11 +530,8 @@
this.focus = false
},
async toSearchDevice() {
// this.routeJump({
// name: 'selectDeviceType'
// })
this.routeJump({
name: 'p2pPlayer'
name: 'addLockGuid'
})
},
async toLockDetail(lock) {

View File

@ -172,6 +172,13 @@
></image>
<view>掌静脉</view>
</view>
<view class="menu-main-view" @click="$basic.routeJump({ name: 'p2pPlayer' })">
<image
class="menu-main-image transform-scale-140"
src="https://oss-lock.xhjcn.ltd/mp/icon_control.png"
></image>
<view>监控</view>
</view>
<view
v-if="$bluetooth.currentLockInfo.userType === 110301"
class="menu-main-view"
@ -193,6 +200,16 @@
></image>
<view>操作记录</view>
</view>
<view
class="menu-main-view transform-scale-105"
@click="$basic.routeJump({ name: 'p2pPlayer' })"
>
<image
class="menu-main-image"
src="https://oss-lock.xhjcn.ltd/mp/icon_record.png"
></image>
<view>视频日志</view>
</view>
<view
v-if="$bluetooth.currentLockInfo.keyRight === 1"
class="menu-main-view"

View File

@ -5,89 +5,188 @@
:deviceInfo="deviceInfo"
:xp2pInfo="xp2pInfo"
:rotate="90"
:muted="isMute"
streamQuality="high"
:minCache="0.2"
:maxCache="0.8"
:fill="true"
orientation="horizontal"
@statechange="handleStateChange"
>
</iot-p2p-player-with-mjpg>
<iot-p2p-voice
id="voiceComponent"
:deviceInfo="deviceInfo"
:xp2pInfo="xp2pInfo"
class="w-5 h-5"
voiceType="Pusher"
id="voiceComponent"
:showLog="true"
@voicestatechange="handleVoiceStateChange"
@voiceerror="handleVoiceError"
>
</iot-p2p-voice>
<view class="fixed bottom-20">
<button v-if="!isVoice" @click="startVoice">开始语音</button>
<button v-else @click="stopVoice">停止语音</button>
<view
class="fixed bottom-[calc(32rpx+env(safe-area-inset-bottom))] bg-[rgba(0,0,0,0.3)] rounded-xl p-4 shadow-lg mx-4 w-622"
>
<view class="flex items-center justify-around mx-10">
<image
@click="isMute = !isMute"
:src="
isMute
? 'https://oss-lock.xhjcn.ltd/mp/icon_mute.png'
: 'https://oss-lock.xhjcn.ltd/mp/icon_not_mute.png'
"
class="w-48 h-48 p-2"
></image>
<image
@click="handleScreenshot"
src="https://oss-lock.xhjcn.ltd/mp/icon_screenshot.png"
class="w-48 h-48 p-2"
></image>
</view>
<view class="flex items-center justify-around text-white mt-2">
<view class="flex flex-col items-center" @longpress="startVoice" @touchend="stopVoice">
<view class="bg-white w-80 h-80 rounded-full flex items-center justify-center">
<image
:src="
isVoice
? 'https://oss-lock.xhjcn.ltd/mp/icon_microphone.png'
: 'https://oss-lock.xhjcn.ltd/mp/icon_no_microphone.png'
"
class="w-55 h-55"
></image>
</view>
<view class="mt-2">长按说话</view>
</view>
<view class="flex flex-col items-center" @click="handleHangUp">
<view class="bg-[#eb292b] w-80 h-80 rounded-full flex items-center justify-center">
<image src="https://oss-lock.xhjcn.ltd/mp/icon_hang_up.png" class="w-60 h-60"></image>
</view>
<view class="mt-2">挂断</view>
</view>
<view class="flex flex-col items-center" @click="handleLock">
<view class="bg-[#63b8af] w-80 h-80 rounded-full flex items-center justify-center">
<image
src="https://oss-lock.xhjcn.ltd/mp/icon_lock_white.png"
class="w-60 h-60"
></image>
</view>
<view class="mt-2">开锁</view>
</view>
</view>
</view>
</view>
</template>
<script setup>
import { getXp2pManager } from './xp2pManager'
import { useBluetoothStore } from '@/stores/bluetooth'
import { useBasicStore } from '@/stores/basic'
import { onMounted, ref } from 'vue'
import { onUnload } from '@dcloudio/uni-app'
import { getP2pInfo } from '@/api/p2p'
const $bluetooth = useBluetoothStore()
const $basic = useBasicStore()
let xp2pManager = null
const deviceInfo = ref({
deviceId: 'NIHQMTTLM4/1000000000',
productId: 'NIHQMTTLM4',
deviceName: '1000000000'
})
const xp2pInfo = ref('XP2Pd2ZVIS4Um5pNW1Wydny5ow==%2.4.49')
const deviceInfo = ref()
const xp2pInfo = ref()
const isVoice = ref(false)
const isMute = ref(false)
onMounted(async () => {
if (!xp2pManager) {
xp2pManager = getXp2pManager()
}
const servicePromise = await xp2pManager.startP2PService({
deviceInfo: deviceInfo.value,
xp2pInfo: xp2pInfo.value,
caller: 1
const { code, data, message } = await getP2pInfo({
lockId: $bluetooth.currentLockInfo.lockId
})
if (code === 0) {
deviceInfo.value = {
deviceId: `${data.productId}/${data.deviceId}`,
productId: data.productId,
deviceName: data.deviceName
}
xp2pInfo.value = data.xp2pInfo
await xp2pManager.startP2PService({
deviceInfo: deviceInfo.value,
xp2pInfo: xp2pInfo.value,
caller: 1
})
} else {
$basic.backAndToast(message)
}
})
const handleVoiceStateChange = state => {
console.log(111111, state)
onUnload(() => {
const page = getCurrentPages().pop()
const player = page.selectComponent('#playerRef')
if (player.stopAll) {
player.stopAll()
}
})
const handleScreenshot = () => {
const page = getCurrentPages().pop()
const player = page.selectComponent('#playerRef')
player.snapshot().then(res => {
uni.saveImageToPhotosAlbum({
filePath: res.tempImagePath,
success: () => {
uni.showToast({
title: '截图已保存到相册',
icon: 'none'
})
},
fail: () => {
uni.showToast({
title: '保存失败',
icon: 'none'
})
}
})
})
}
const handleVoiceError = error => {
console.log(1111113, error)
const handleHangUp = () => {
const page = getCurrentPages().pop()
const player = page.selectComponent('#playerRef')
if (player.stopAll) {
player.stopAll()
}
uni.navigateBack()
}
const handleLock = () => {
console.log('handleLock')
}
const startVoice = () => {
uni.vibrateLong()
isVoice.value = true
const page = getCurrentPages().pop()
const playerRef = page.selectComponent('#playerRef')
console.log(1111113, playerRef)
playerRef.requestFullScreen()
// const voiceNode = res[0].node
// if (voiceNode) {
// voiceNode.startVoice({
// needRecord: false,
// customPusher: {}
// })
// }
const voice = page.selectComponent('#voiceComponent')
voice.startVoice()
}
const stopVoice = () => {
isVoice.value = false
const query = uni.createSelectorQuery()
query
.select('#voiceComponent')
.node()
.exec(res => {
const voiceNode = res[0].node
if (voiceNode) {
voiceNode.stopVoice()
}
})
const page = getCurrentPages().pop()
const voice = page.selectComponent('#voiceComponent')
voice.stopVoice()
}
const handleStateChange = state => {
console.log(11111111, state)
}
</script>
<style lang="scss" scoped>
:deep(.mjpg-player--iot-player) {
height: 100vh !important;
}
</style>

View File

@ -382,11 +382,6 @@ const pages = [
path: '/pages/setting/passageMode',
tabBar: false
},
{
name: 'selectDeviceType',
path: '/pages/addDevice/selectDeviceType',
tabBar: false
},
{
name: 'distributionNetwork',
path: '/pages/addDevice/distributionNetwork',

View File

@ -1,45 +0,0 @@
import { defineStore } from 'pinia'
import { AppDevSdk } from 'qcloud-iotexplorer-appdev-sdk'
import { getSdkToken } from '@/api/sdk'
export const useSdkStore = defineStore('sdk', {
state() {
return {
sdk: null
}
},
actions: {
async getSdk() {
if (this.sdk.loginManager.isLogin) {
return this.sdk
}
await this.initSdk()
return this.sdk
},
async initSdk() {
try {
const getAccessToken = async () => {
const { code, data, message } = await getSdkToken()
if (code === 0) {
return data
}
uni.showToast({
title: message,
icon: 'none'
})
return null
}
this.sdk = await new AppDevSdk({
appKey: 'mtBfaXFtISXFYVVsd',
getAccessToken
})
this.sdk.init()
} catch (error) {
console.log(111, this.sdk)
console.log('error', error)
}
}
}
})