| | |
| | | <template> |
| | | <WebViewPlus :src="`${viewUrl}`" @webMessage="onPostMessage"/> |
| | | <up-toast ref="uNotifyRef"></up-toast> |
| | | </template> |
| | | <script setup> |
| | | import {onHide, onLoad, onShow} from "@dcloudio/uni-app"; |
| | | import WebViewPlus from "@/components/WebViewPlus.vue"; |
| | | import {getWebViewUrl} from "@/utils/index.js"; |
| | | import {getEnvObj, getWebViewUrl} from "@/utils/index.js"; |
| | | import {useUserStore} from "@/store/index.js"; |
| | | |
| | | const viewUrl = ref('') |
| | | const wayLineJodInfoId = ref(null) |
| | | function onPostMessage(event) { |
| | | function onPostMessage(data) { |
| | | if (data.type === 'back'){ |
| | | // #ifdef H5 |
| | | window.history.back() |
| | | // #endif |
| | | |
| | | // #ifdef APP-PLUS |
| | | uni.navigateBack({ |
| | | delta: 1 // 返回的页面数,默认1(返回上一页) |
| | | }); |
| | | // #endif |
| | | } |
| | | } |
| | | |
| | | |
| | | // 文件上传demo |
| | | const {VITE_API_BASE_URL} = getEnvObj() |
| | | function uploadUtil(options) { |
| | | const {formData, file, url} = options |
| | | return new Promise((resolve, reject) => { |
| | | let accessToken = useUserStore()?.$state?.userInfo?.access_token; |
| | | const file = new File([recorder.getWAVBlob()], '.wav') |
| | | uni.uploadFile({ |
| | | url: `${VITE_API_BASE_URL}${url}`, |
| | | name: 'file', |
| | | header: {'Blade-Auth': 'bearer ' + accessToken}, |
| | | file, |
| | | formData, |
| | | success: (res) => { |
| | | const resData = JSON.parse(res.data) |
| | | if (resData.code === 200 || resData.code === 0) { |
| | | resolve(res) |
| | | } else { |
| | | showToast(resData.message) |
| | | reject(res) |
| | | } |
| | | }, |
| | | fail: (err) => { |
| | | reject(err) |
| | | } |
| | | }); |
| | | }) |
| | | } |
| | | |
| | | function showToast(message) { |
| | | uNotifyRef.value.show({ |
| | | type: 'default', |
| | | message, |
| | | }); |
| | | } |
| | | |
| | | |
| | | // 保存喊话至广播列表内 |
| | | function saveSound(data) { |
| | | const recorder = 'xxx' |
| | | const file = new File([recorder?.getWAVBlob()], '.wav') |
| | | uploadUtil({ |
| | | file, |
| | | formData: { |
| | | fileName: 'xxx', |
| | | sn: 'xxx', |
| | | }, |
| | | url: '/drone-device-core/speak/api/v1/uploadSpeak' |
| | | }).then(res => { |
| | | showToast('保存成功') |
| | | }) |
| | | } |
| | | |
| | | const viewUrl = ref(""); |
| | | onLoad((options) => { |
| | | wayLineJodInfoId.value = options.wayLineJodInfoId |
| | | viewUrl.value = getWebViewUrl('/DroneConsole', {wayLineJodInfoId: wayLineJodInfoId.value}) |
| | | viewUrl.value = getWebViewUrl("/DroneConsole", { |
| | | wayLineJobInfoId: options.wayLineJobInfoId, |
| | | dockSn: options.dockSn, |
| | | }); |
| | | }) |
| | | |
| | | |
| | | // onShow(() => { |
| | | // // #ifdef APP-PLUS |
| | | // plus.screen.lockOrientation("landscape-primary"); |
| | | // // #endif |
| | | // }); |
| | | // |
| | | // onHide(() => { |
| | | // // #ifdef APP-PLUS |
| | | // plus.screen.lockOrientation("portrait-primary"); |
| | | // // #endif |
| | | // }); |
| | | onShow(() => { |
| | | // #ifdef APP-PLUS |
| | | plus.navigator.setFullscreen(true); // 加入全屏 |
| | | plus.screen.lockOrientation("landscape-primary");//横屏 |
| | | // #endif |
| | | }); |
| | | |
| | | onHide(() => { |
| | | // #ifdef APP-PLUS |
| | | plus.navigator.setFullscreen(false); |
| | | plus.screen.lockOrientation("portrait-primary"); |
| | | // #endif |
| | | }); |
| | | </script> |
| | | <style scoped lang="scss"> |
| | | |