|
|
@@ -1,5 +1,5 @@
|
|
|
<template>
|
|
|
- <web-view :src="src">
|
|
|
+ <web-view :src="src" >
|
|
|
</web-view>
|
|
|
</template>
|
|
|
|
|
|
@@ -10,6 +10,14 @@ import {
|
|
|
} from '@/utils/config.js'
|
|
|
var wv;
|
|
|
const bgAudioManager = uni.getBackgroundAudioManager();
|
|
|
+bgAudioManager.onPlay(() => {
|
|
|
+ console.log('开始播放');
|
|
|
+});
|
|
|
+
|
|
|
+bgAudioManager.onError((res) => {
|
|
|
+ console.log('播放错误', res);
|
|
|
+});
|
|
|
+let lockintervalId, setTimeoutId;
|
|
|
export default {
|
|
|
data() {
|
|
|
return {
|
|
|
@@ -111,21 +119,15 @@ export default {
|
|
|
return;
|
|
|
}
|
|
|
console.log('调用语音播放');
|
|
|
-
|
|
|
+ bgAudioManager.stop()
|
|
|
bgAudioManager.title = '报警播报';
|
|
|
bgAudioManager.singer = '暂无';
|
|
|
bgAudioManager.coverImgUrl = 'https://qiniu-web-assets.dcloud.net.cn/unidoc/zh/music-a.png';
|
|
|
bgAudioManager.src = url;
|
|
|
bgAudioManager.play()
|
|
|
- bgAudioManager.onPlay(() => {
|
|
|
- console.log('开始播放');
|
|
|
- });
|
|
|
|
|
|
- bgAudioManager.onError((res) => {
|
|
|
- console.log('播放错误', res);
|
|
|
- });
|
|
|
// 更新上次播放时间
|
|
|
- // this.lastPlayTime = now;
|
|
|
+ this.lastPlayTime = now;
|
|
|
|
|
|
} catch (error) {
|
|
|
//TODO handle the exception
|
|
|
@@ -169,6 +171,65 @@ export default {
|
|
|
this.src = `${this.webviewServer}/mobile/pages/attachedVessel/index/?${urlParams}`
|
|
|
console.log('webview地址', this.src)
|
|
|
this.uuid = this.getUuid()
|
|
|
+ this.getStartLocationUpdate()
|
|
|
+ },
|
|
|
+ // 实时定位
|
|
|
+ getStartLocationUpdate() {
|
|
|
+ let this_ = this
|
|
|
+ let lock = false
|
|
|
+ if (lockintervalId) clearInterval(lockintervalId);
|
|
|
+ lockintervalId = setInterval(() => { //节流
|
|
|
+ lock = false
|
|
|
+ }, 4000);
|
|
|
+
|
|
|
+ try {
|
|
|
+ // 持续定位
|
|
|
+ uni.startLocationUpdate({
|
|
|
+ type: 'gcj02',
|
|
|
+ // success: res => console.log('开启小程序接收位置消息成功'),
|
|
|
+ fail: err => console.error('开启接收位置消息失败:', err),
|
|
|
+ complete: msg => console.log('调用开启接收位置消息 API 完成')
|
|
|
+ });
|
|
|
+
|
|
|
+ uni.onLocationChange((res) => {
|
|
|
+ console.log('持续位置信息', res)
|
|
|
+ if (!lock) {
|
|
|
+ let datas = {
|
|
|
+ deviceId: this_.uuid,
|
|
|
+ gpsTime: this_.dayjs().format('YYYY-MM-DD HH:mm:ss'),
|
|
|
+ lat02: res.latitude,
|
|
|
+ lng02: res.longitude,
|
|
|
+ accuracy: res.accuracy,
|
|
|
+ speed: res.speed
|
|
|
+ }
|
|
|
+ console.log('上传定位信息', datas)
|
|
|
+ lock = true
|
|
|
+ sendPos(datas).then(res => {
|
|
|
+ console.log('位置信息上传成功', res)
|
|
|
+ if (res.code == 0) {
|
|
|
+ this_.PlayVoice(`https://yhdd.dasongyuhe.com${res.data}`);
|
|
|
+ }
|
|
|
+ }).catch(err => {
|
|
|
+ console.log('位置信息上传失败', err)
|
|
|
+ })
|
|
|
+ }
|
|
|
+ });
|
|
|
+ uni.startLocationUpdateBackground({
|
|
|
+ type: 'gcj02',
|
|
|
+ // success: res => console.log('开启小程序接收位置消息成功'),
|
|
|
+ fail: err => console.error('开启接收位置消息失败:', err),
|
|
|
+ complete: msg => console.log('调用开启接收位置消息 API 完成')
|
|
|
+ });
|
|
|
+ } catch (error) {
|
|
|
+ console.log('获取位置信息失败', error)
|
|
|
+ uni.showToast({
|
|
|
+ title: error,
|
|
|
+ icon: 'none'
|
|
|
+ })
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // // 高精度定位
|
|
|
+ getisHighAccuracy() {
|
|
|
|
|
|
try {
|
|
|
let this_ = this
|
|
|
@@ -177,7 +238,7 @@ export default {
|
|
|
this.timer = setInterval(() => {
|
|
|
uni.getLocation({
|
|
|
type: 'gcj02',
|
|
|
- // isHighAccuracy: true,
|
|
|
+ isHighAccuracy: true,
|
|
|
success: function (res) {
|
|
|
console.log('持续位置信息', res)
|
|
|
// console.log('当前位置的经度:' + res.longitude);
|
|
|
@@ -204,48 +265,10 @@ export default {
|
|
|
}, 8 * 1000)
|
|
|
|
|
|
|
|
|
-
|
|
|
- // 持续定位
|
|
|
- // uni.startLocationUpdate({
|
|
|
- // type: 'gcj02',
|
|
|
- // // success: res => console.log('开启小程序接收位置消息成功'),
|
|
|
- // fail: err => console.error('开启接收位置消息失败:', err),
|
|
|
- // complete: msg => console.log('调用开启接收位置消息 API 完成')
|
|
|
- // });
|
|
|
-
|
|
|
- // uni.onLocationChange((res) => {
|
|
|
- // console.log('持续位置信息', res)
|
|
|
- // let datas = {
|
|
|
- // deviceId: this_.uuid,
|
|
|
- // gpsTime: this_.dayjs().format('YYYY-MM-DD HH:mm:ss'),
|
|
|
- // lat02: res.latitude,
|
|
|
- // lng02: res.longitude,
|
|
|
- // accuracy: res.accuracy,
|
|
|
- // speed: res.speed
|
|
|
- // }
|
|
|
- // console.log('上传定位信息', datas)
|
|
|
- // sendPos(datas).then(res => {
|
|
|
- // console.log('位置信息上传成功', res)
|
|
|
- // if (res.code == 0) {
|
|
|
- // this_.PlayVoice(`https://yhdd.dasongyuhe.com${res.data}`);
|
|
|
- // }
|
|
|
- // }).catch(err => {
|
|
|
- // console.log('位置信息上传失败', err)
|
|
|
- // })
|
|
|
- // });
|
|
|
- // uni.startLocationUpdateBackground({
|
|
|
- // type:'gcj02',
|
|
|
- // // success: res => console.log('开启小程序接收位置消息成功'),
|
|
|
- // fail: err => console.error('开启接收位置消息失败:', err),
|
|
|
- // complete: msg => console.log('调用开启接收位置消息 API 完成')
|
|
|
- // });
|
|
|
} catch (error) {
|
|
|
console.log('获取定位失败', error)
|
|
|
}
|
|
|
},
|
|
|
- getLocation() {
|
|
|
-
|
|
|
- },
|
|
|
scanCode() {
|
|
|
|
|
|
}
|