diff --git a/.vscode/settings.json b/.vscode/settings.json index e7b948a..f329344 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -7,6 +7,7 @@ "cSpell.words": [ "chahao", "columer", + "csobj", "perc" ] } diff --git a/public/static/offline/JSON/config.json b/public/static/offline/JSON/config.json index 4423e31..b1ded3b 100644 --- a/public/static/offline/JSON/config.json +++ b/public/static/offline/JSON/config.json @@ -1 +1,10 @@ -{"code":200,"msg":"操作成功","data":{"sourceUrl":"/static/offline","debug":false,"interfaceUrl":"https://project-iot.test.1000my.com/api","mobileNav":"https://1000my.obs.cn-east-2.myhuaweicloud.com/mobileqmgo/index.html#/","handWriteUrl":"http://saas.1000my.com:8014/words","fileUrl":"https://test-598d.obs.cn-east-2.myhuaweicloud.com","backSocket":"ws://127.0.0.1:7181","clickUploadUrl":"/analysis/v1/web/deviceUseClickDataUpload"}} \ No newline at end of file +{ + "code": 200, + "msg": "操作成功", + "data": { + "sourceUrl": "/static/offline", + "interfaceUrl": "https://project-iot.test.1000my.com/api", + "mobileNav": "https://1000my.obs.cn-east-2.myhuaweicloud.com/mobileqmgo/index.html#/", + "handWriteUrl": "http://saas.1000my.com:8014/words" + } +} \ No newline at end of file diff --git a/src/components/PublicComponent/PublicComponent.vue b/src/components/PublicComponent/PublicComponent.vue index 5fcb564..d4b3ba3 100644 --- a/src/components/PublicComponent/PublicComponent.vue +++ b/src/components/PublicComponent/PublicComponent.vue @@ -27,7 +27,7 @@ const AutoBackNotification = defineAsyncComponent(() => import('@/base/AutoBackN const router = useRouter() const route = useRoute() const store = useRootStore() -const { language, showSearch, showDetail, mapStatus } = storeToRefs(store) +const { language, showSearch, showDetail, mapStatus, nativeMethods } = storeToRefs(store) const { checkHandleScreen, showCountDownDialog, @@ -64,10 +64,14 @@ onBeforeUnmount(() => { window.removeEventListener('touchend', checkHandleScreen) }) -watch(mapStatus, newVal => { +watch(mapStatus, async newVal => { //当地图加载成功之后自动触发一次屏保弹框以便能进入屏保 if (newVal) { - sleepToWallpaper() + if (!nativeMethods.value?.hasProgram()) { + return + } + await sleepToWallpaper() + nativeMethods.value?.goScreenSave() } }) diff --git a/src/composables/useHandleScreen.ts b/src/composables/useHandleScreen.ts index 47beebf..4b37ca5 100644 --- a/src/composables/useHandleScreen.ts +++ b/src/composables/useHandleScreen.ts @@ -1,17 +1,19 @@ -import { ref, computed, onMounted, watch } from 'vue' +import { ref, computed, onMounted, watch, toRefs } from 'vue' +import { useRootStore } from '@/store/root' import { useRouter } from 'vue-router' import { getBackTime } from '@/http/api/base' import { useLogout } from '@/composables/useLogout' -import { isAndroid } from '@/utils/utils' export const useHandleScreen = (callback: () => void) => { const MIN_TIME = 0 const MAX_TIME = 5 const CHECK_TIME = 1000 const DELAY_CHECK_TIME = 400 - const _isAndroid = isAndroid() const router = useRouter() + const store = useRootStore() + const { isAndroid, nativeMethods } = toRefs(store) + const { logout, resetClickNumber, setLogout, addTotalClick } = useLogout() const totalTime = ref<[number, number]>([60, 60]) //总时间 @@ -53,8 +55,11 @@ export const useHandleScreen = (callback: () => void) => { }) } + //跳转屏保挂载到全局 供app使用 + window.sleepToWallpaper = sleepToWallpaper + async function checkHandleScreen(e: TouchEvent) { - !_isAndroid && addTotalClick(e) + !isAndroid && addTotalClick(e) toIndexTime.value = totalTime.value[0] toWallpaperTime.value = totalTime.value[1] @@ -68,12 +73,13 @@ export const useHandleScreen = (callback: () => void) => { callback() } - //时间为-1时的话不允许弹出屏保弹框 TODO:后期由容器通知 - if (toWallpaperTime.value === -1) { + //调用原生方法 判断有无节目 + if (!nativeMethods.value?.hasProgram()) { return } await sleepToWallpaper() callback() + nativeMethods.value?.goScreenSave() }, DELAY_CHECK_TIME) } diff --git a/src/enums/index.ts b/src/enums/index.ts index d31218f..70718a1 100644 --- a/src/enums/index.ts +++ b/src/enums/index.ts @@ -22,6 +22,6 @@ export enum HTTP_CODE { ERR_OK = 200, //数据请求成功(可用于语音状态码) ERR_DATA_NULL = 500, //语音无查询信息 ERR_OVER = 100, //语音播报完毕 - ERR_NULL = 401, //未识别到语音 + ERR_NULL = '401', //未识别到语音 ERR_DISCERNING = 201 //语音识别中 } diff --git a/src/store/root/getters.ts b/src/store/root/getters.ts index 9db316c..3de7da4 100644 --- a/src/store/root/getters.ts +++ b/src/store/root/getters.ts @@ -7,11 +7,18 @@ export type GettersMap = { recommendList(): PickRecommendShop[] brandFloorList(): Floor[] industryList(): Industry[] + nativeMethods(): NativeMethods } export type GenGetters = CreateGetters export const getters: GenGetters = { + nativeMethods() { + if (this.isAndroid) { + return window.android + } + return window.chrome?.webview?.hostObjects?.sync?.csobj + }, currentBuildingFloorsList() { const currentBuilding = this.buildingList.find(building => building.buildingCode === this.device.buildingCode) return currentBuilding?.floorList ?? [] diff --git a/src/store/root/state.ts b/src/store/root/state.ts index 8a69017..5041cb3 100644 --- a/src/store/root/state.ts +++ b/src/store/root/state.ts @@ -1,4 +1,5 @@ import type { GroupList, BrandRes } from '@/http/api/brand/types' +import { isAndroid } from '@/utils/utils' export interface State { shopList: Readonly //店铺列表 @@ -15,6 +16,7 @@ export interface State { mapStatus: boolean //地图加载是否成功 device: Device //当前设备信息 shop: Shop //店铺信息 + isAndroid: boolean } export const state = (): State => ({ @@ -31,5 +33,6 @@ export const state = (): State => ({ config: {} as Config, mapStatus: false, device: {} as Device, - shop: {} as Shop + shop: {} as Shop, + isAndroid: isAndroid() }) diff --git a/src/types/native.d.ts b/src/types/native.d.ts new file mode 100644 index 0000000..6172c08 --- /dev/null +++ b/src/types/native.d.ts @@ -0,0 +1,57 @@ +export declare global { + type VideoStream = { + age: 23 + genderMale: '女' | '男' + faceID: string + faceImage: string //人脸图片base64格式 需自行拼接前缀 data:image/jpg;base64, + } + + type HardwareInfo = { + width: string + height: string + ip: string + code: string + mac: string + serverIP: string + } + + type VoiceContent = { + code: number | string + msg: string | null + data: { + modelType: string + actionType: string + query: string + ttsMsg?: string + word?: string + reply?: string[] + } + } + + interface NativeMethods { + startFace(): boolean //通知APP开启摄像头,开始采集 + stopFace(): boolean //通知APP结束识别 + pushFaceBase(): VideoStream //APP推送视频流给应用 + pushFaceAttribute(): VideoStream //APP获取人脸属性推送给应用 + takePhoto(): string //应用通知APP拍照 返回Base64 + startVoice(): boolean //应用通知APP开始语音识别 + stopVoice(): boolean //应用通知APP开始语音识别 + voiceContent(): VoiceContent //语音返回数据 + deviceInfo(): HardwareInfo //设备信息 + goScreenSave(): void // 针对导视应用与app之间屏保跳转进行通讯 + hasProgram(): boolean //是否有节目列表 用于前端导视是否弹起屏保弹框 + } + interface Window { + sleepToWallpaper(): Promise + android: NativeMethods + chrome: { + webview: { + hostObjects: { + sync: { + csobj: NativeMethods + } + } + } + } + } +}