index.vue 31 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231
  1. <template>
  2. <view>
  3. <view class="map-box" v-if="!deviceCode">
  4. <!-- <view class="mp-header">
  5. <view class="sys-head" :style="'height:'+(statusBarHeight)+'px;'"></view>
  6. <view class="serch-box" :style="{height:barHeight+'px'}">
  7. <view class="serch-wrapper flex" @click="goEquList">
  8. <image class="logo" src='/static/img/addequ.png' mode="" />
  9. <view class="name">奶奶</view>
  10. <image class="arrow" src="/static/img/arrow.png" mode=""></image>
  11. </view>
  12. </view>
  13. </view> -->
  14. <!-- <map id='map' :latitude="latitude" :longitude="longitude" :markers="covers" :polyline="polyline"
  15. :scale="scale">
  16. </map> -->
  17. <view class="top-input" v-if="!deviceId">
  18. <image src="../../static/img/noneEqu.png" mode=""></image>
  19. <view class="btn-box" @click="goEquList">
  20. <view class="btn">添加设备</view>
  21. </view>
  22. </view>
  23. <view class="info-box" v-if="deviceId" @click="goBindPage">
  24. <view class="scroll-view_H">
  25. <scroll-view class="scroll-view-content" scroll-x @scroll="scroll" scroll-left="0">
  26. <view id="demo1" class="scroll-view-item_H uni-bg-red" @click="toHeartRate">
  27. <image class="bg-image" src="../../static/img/heart.png" mode=""></image>
  28. <view class="text-wrapper">
  29. <view class="text-overlay black">
  30. <view class="top-box">
  31. <view class="top-left">
  32. <view class="english">Heart rate</view>
  33. <view class="chinese">心率</view>
  34. </view>
  35. <image class="top-right"
  36. src="https://app.tjzhxx.cn:11443/image/enterprise_icon.png" mode=""></image>
  37. </view>
  38. <view class="under-box">
  39. <view class="under-left">
  40. <view class="number">98</view>
  41. <view class="unit">bpm</view>
  42. </view>
  43. <view class="under-right">
  44. <view class="range">75~96 bpm</view>
  45. <view class="range-word">平局区间</view>
  46. </view>
  47. </view>
  48. </view>
  49. </view>
  50. </view>
  51. <view id="demo2" class="scroll-view-item_H uni-bg-green">
  52. <image class="bg-image" src="../../static/img/sleep.png" mode=""></image>
  53. <view class="text-wrapper white">
  54. <view class="text-overlay">
  55. <view class="top-box">
  56. <view class="top-left">
  57. <view class="english">Sleep log</view>
  58. <view class="chinese">睡眠</view>
  59. </view>
  60. </view>
  61. <view class="under-box">
  62. <view class="under-left white">
  63. <view class="number">5h</view>
  64. <view class="unit">28 min</view>
  65. </view>
  66. <view class="under-left white">
  67. <view class="number">66%</view>
  68. <view class="unit">深睡</view>
  69. </view>
  70. </view>
  71. </view>
  72. </view>
  73. </view>
  74. <view id="demo3" class="scroll-view-item_H uni-bg-blue">
  75. <image class="bg-image" src="../../static/img/breathe.png" mode=""></image>
  76. <view class="text-wrapper white">
  77. <view class="text-overlay">
  78. <view class="top-box">
  79. <view class="top-left">
  80. <view class="english">Breathe log</view>
  81. <view class="chinese">呼吸</view>
  82. </view>
  83. </view>
  84. <view class="under-box">
  85. <view class="under-left white">
  86. <view class="number">21次</view>
  87. <view class="unit">最高</view>
  88. </view>
  89. <view class="under-left white">
  90. <view class="number">17次</view>
  91. <view class="unit">平均呼吸</view>
  92. </view>
  93. </view>
  94. </view>
  95. </view>
  96. </view>
  97. </scroll-view>
  98. </view>
  99. <view class="sos-btn">
  100. <image src="../../static/img/sos.png" mode=""></image>
  101. </view>
  102. </view>
  103. <view class="icon-box-right" v-if="showBtn">
  104. <image src="/static/image/calendarIcon.png" mode="" @click="showDayPicker = true"></image>
  105. </view>
  106. <van-loading class="loading" v-if="showLoading" type="spinner" color="#000" />
  107. </view>
  108. <view class="" v-if="deviceCode">
  109. <web-view :src="h5url"></web-view>
  110. </view>
  111. <!-- </page-container> -->
  112. <van-popup :show="showDayPicker" position="bottom">
  113. <van-datetime-picker @cancel="showDayPicker=false" @confirm="onConfirm" :value="currentDay" type="date" />
  114. <!-- :min-date="minDate" -->
  115. </van-popup>
  116. </view>
  117. </template>
  118. <script>
  119. // import AMapLoader from "@amap/amap-jsapi-loader";
  120. import {
  121. toLogin
  122. } from '@/libs/login.js';
  123. import {
  124. mapGetters
  125. } from "vuex";
  126. import * as hrApi from '@/api/sleep/index.js';
  127. // import * as infoApi from '@/api/info/index.js';
  128. // import dayjs from "@/plugin/dayjs/dayjs.min.js";
  129. // #ifdef MP
  130. const menuButtonInfo = uni.getMenuButtonBoundingClientRect();
  131. const statusBarHeight = uni.getSystemInfoSync().statusBarHeight;
  132. // 获取导航栏高度
  133. const barHeight = menuButtonInfo.height + (menuButtonInfo.top - statusBarHeight) * 2
  134. // #endif
  135. export default {
  136. computed: mapGetters(['deviceCode', 'isLogin']),
  137. data() {
  138. return {
  139. statusBarHeight: statusBarHeight,
  140. barHeight: barHeight,
  141. showPage: false,
  142. aaa: [117.662369, 39.032391],
  143. showInfo: true,
  144. map: null,
  145. windowHeight: 0,
  146. mapHeight: 0,
  147. timer: null,
  148. showDayPicker: false, //日
  149. dateTime: '',
  150. navigationBarTitle: '定位',
  151. currentDay: new Date().getTime(),
  152. showLoading: false,
  153. isDisabled: false,
  154. isStart: false,
  155. playIndex: 1,
  156. showBtn: false, //展示右边日历按钮
  157. scale: 13,
  158. id: 0, // 使用 marker点击事件 需要填写id
  159. title: 'map',
  160. latitude: 39.0313466,
  161. longitude: 117.6637305,
  162. // latitude: '',
  163. // longitude: '',
  164. // deviceCode: '',
  165. onlineForce: false,
  166. onlineStatus: false,
  167. gpsUpdateTime: '',
  168. addressDesc: '',
  169. // 标记点
  170. // covers: [{
  171. // id: 1,
  172. // width: 42,
  173. // height: 47,
  174. // // rotate: 270,
  175. // // latitude: '',
  176. // // longitude: '',
  177. // latitude: 39.0313466,
  178. // longitude: 117.6637305,
  179. // iconPath: "https://app.tjzhxx.cn:11443/image/enterprise_icon.png",
  180. // // callout: {
  181. // // content: "陕A·88888", // 车牌信息
  182. // // display: "ALWAYS",
  183. // // fontWeight: "bold",
  184. // // color: "#5A7BEE", //文本颜色
  185. // // fontSize: "12px",
  186. // // bgColor: "#ffffff", //背景色
  187. // // padding: 5, //文本边缘留白
  188. // // textAlign: "center",
  189. // // },
  190. // // anchor: {
  191. // // x: 0.5,
  192. // // y: 0.5,
  193. // // }
  194. // },
  195. // // 找到当前数据得id,在这个数据得前面造出一个没有id得json,用作北京图片,前提是经纬度一样
  196. // {
  197. // id: 2,
  198. // width: 47,
  199. // height: 49,
  200. // latitude: 39.037,
  201. // longitude: 117.660,
  202. // iconPath: "https://app.tjzhxx.cn:11443/image/gender_man.png",
  203. // },
  204. // {
  205. // // id: 3,
  206. // width: 40,
  207. // height: 45,
  208. // latitude: 39.037,
  209. // longitude: 117.660,
  210. // iconPath: "https://app.tjzhxx.cn:11443/image/enterprise_icon.png",
  211. // },
  212. // {
  213. // id: 3,
  214. // width: 42,
  215. // height: 47,
  216. // latitude: 39.052,
  217. // longitude: 117.657,
  218. // iconPath: "https://app.tjzhxx.cn:11443/image/enterprise_icon.png",
  219. // },
  220. // ],
  221. covers:[],
  222. // 线
  223. polyline: [],
  224. // 坐标数据
  225. coordinates: [{
  226. id: 1,
  227. latitude: 23.098994,
  228. longitude: 113.322520,
  229. },
  230. {
  231. id: 2,
  232. latitude: 23.097994,
  233. longitude: 113.323520,
  234. // iconPath: '/image/location.png',
  235. },
  236. ],
  237. coordinate: [], //坐标数据
  238. posi: { // 汽车定位点的数据,后面只用改latitude、longitude即可
  239. id: 1,
  240. width: 32,
  241. height: 32,
  242. latitude: 0,
  243. longitude: 0,
  244. iconPath: "/static/image/positonimg.png",
  245. callout: {
  246. content: "陕A·85Q1Q", // 车牌信息
  247. display: "BYCLICK",
  248. fontWeight: "bold",
  249. color: "#5A7BEE", //文本颜色
  250. fontSize: "12px",
  251. bgColor: "#ffffff", //背景色
  252. padding: 5, //文本边缘留白
  253. textAlign: "center",
  254. },
  255. anchor: {
  256. x: 0.5,
  257. y: 0.5,
  258. },
  259. },
  260. h5url:''
  261. }
  262. },
  263. beforeCreate() {
  264. console.log('我只行啊')
  265. uni.setStorageSync('useSleep', true);
  266. },
  267. onReady() {
  268. // 创建map对象
  269. this.map = uni.createMapContext('map');
  270. // 获取屏幕高度
  271. uni.getSystemInfo({
  272. success: res => {
  273. this.windowHeight = res.windowHeight;
  274. }
  275. });
  276. },
  277. onShow() {
  278. // this.initAmap();
  279. this.getLocationInfo()
  280. // this.getHrdata()
  281. console.log(this.deviceCode,'deviceCodedeviceCode')
  282. if(this.deviceCode){
  283. this.geth5Url()
  284. }
  285. },
  286. onPageUnload: function() {
  287. uni.navigateBack({
  288. delta: 0
  289. })
  290. },
  291. onLoad() {
  292. let that =this
  293. uni.getLocation({
  294. type: 'wgs84',
  295. success: function (res) {
  296. console.log(res,'我是定位接口得返回数据')
  297. console.log('当前位置的经度:' + res.longitude);
  298. console.log('当前位置的纬度:' + res.latitude);
  299. },
  300. fail: function (error) {
  301. console.log('获取位置信息失败:', error.errMsg);
  302. // 或者将错误信息显示在页面上
  303. // this.errorMessage = '获取位置信息失败: ' + error.errMsg;
  304. }
  305. });
  306. },
  307. onHide: function() {
  308. uni.setStorageSync('useSleep', false);
  309. },
  310. mounted() {
  311. },
  312. methods: {
  313. geth5Url(){
  314. hrApi.geth5url({sn:this.deviceCode}).then(res=>{
  315. console.log(res,777)
  316. this.h5url=res.data.httpsURL
  317. // this.$set("this.h5url",res.data.httpsURL)
  318. })
  319. },
  320. getHrdata(){
  321. hrApi.getHrInfo({sn:"B1E507CD076164C7",date:"2024-06-30"}).then(res=>{
  322. console.log('我是首页得心率数据',res)
  323. })
  324. },
  325. toHeartRate() {
  326. uni.navigateTo({
  327. url: '/pages/index/condition/heart_rate/index'
  328. })
  329. },
  330. goEquList() {
  331. console.log('走到这')
  332. // 记得放开
  333. if (!this.isLogin) {
  334. console.log('进来了')
  335. toLogin();
  336. return
  337. }
  338. console.log('点击了')
  339. uni.navigateTo({
  340. url: '/pages/equ_list/index',
  341. })
  342. },
  343. beforeleave() {
  344. console.log('出发了');
  345. this.showPage = false
  346. //判断是上一个页面进入(返回),还是直接进入这个页面(回首页)
  347. let pages = getCurrentPages()
  348. console.log(pages.length, 5555);
  349. pages.length = 2
  350. console.log(pages.length, 6666);
  351. console.log(this.showBtn, '轨迹');
  352. console.log(!this.showBtn, '定位');
  353. if (pages.length == 2 && this.showBtn) {
  354. this.showPage = true
  355. uni.navigateTo({
  356. url: '/pages/index/map/index'
  357. })
  358. } else {
  359. this.showPage = true
  360. uni.switchTab({
  361. url: '/pages/index/index'
  362. })
  363. }
  364. },
  365. onConfirm(e) {
  366. this.dateTime = this.formatDate(e.detail)
  367. this.showDayPicker = false
  368. this.initAmap(3)
  369. },
  370. getLocationInfo() {
  371. this.showLoading = true
  372. return
  373. infoApi.getLocationInfo({
  374. deviceId: this.deviceId
  375. }).then(res => {
  376. this.showLoading = false
  377. this.latitude = res.data.lat
  378. this.longitude = res.data.lng
  379. this.covers[0].latitude = res.data.lat
  380. this.covers[0].longitude = res.data.lng
  381. this.deviceCode = res.data.deviceCode
  382. this.onlineForce = res.data.onlineForce
  383. this.onlineStatus = res.data.onlineStatus
  384. this.gpsUpdateTime = this.formaTime(res.data.gpsUpdateTime)
  385. this.addressDesc = res.data.addressDesc
  386. })
  387. },
  388. formaTime: function(date) {
  389. return dayjs(date).format("YYYY-MM-DD HH:mm:ss");
  390. },
  391. formatDate: function(date) {
  392. return dayjs(date).format("YYYY-MM-DD");
  393. },
  394. goFenceList() {
  395. let center = `${this.longitude},${this.latitude}`
  396. uni.navigateTo({
  397. url: `/pages/index/map/fencelist?center=${center}`,
  398. });
  399. },
  400. goBindPage() {
  401. },
  402. formatDate: function(date) {
  403. return dayjs(date).format("YYYY-MM-DD");
  404. },
  405. initAmap(type) {
  406. let _this = this;
  407. // _this.addMarkers()
  408. if (type === 2) {
  409. this.showLoading = true
  410. infoApi.refreshLocation({
  411. deviceId: this.deviceId
  412. }).then(res => {
  413. this.showLoading = false
  414. this.latitude = res.data.lat
  415. this.longitude = res.data.lng
  416. this.covers[0].latitude = res.data.lat
  417. this.covers[0].longitude = res.data.lng
  418. this.gpsUpdateTime = this.formaTime(res.data.gpsUpdateTime)
  419. this.addressDesc = res.data.addressDesc
  420. })
  421. }
  422. if (type === 3) {
  423. uni.navigateTo({
  424. url: '/pages/index/map/driving'
  425. })
  426. // return
  427. // this.showBtn = true
  428. // this.scale = 18
  429. // wx.setNavigationBarTitle({
  430. // title: "轨迹"
  431. // })
  432. // // this.onLoad()//重新调方法 改标题,有问题
  433. // this.dateTime = this.dateTime ? this.dateTime : this.formatDate(new Date())
  434. // let params = {
  435. // deviceId: this.deviceId,
  436. // dateTime: this.dateTime,
  437. // // deviceId:this.deviceId,
  438. // // dateTime:this.formatDate(new Date())
  439. // }
  440. // infoApi.getLocationLocus(params).then(res => {
  441. // if (res.code === 0 && res.data.length) {
  442. // this.coordinate = res.data.map(item => {
  443. // console.log('11111');
  444. // return {
  445. // latitude: item.lat,
  446. // longitude: item.lng,
  447. // }
  448. // })
  449. // _this.polyline = [{
  450. // points: this.coordinate,
  451. // color: '#F35546',
  452. // width: 4,
  453. // dottedLine: false,
  454. // }];
  455. // // TODO 找相关api,将轨迹缩放到合适比例,将起点终点放上图标
  456. // _this.map.translateMarker({
  457. // markerId: 1,
  458. // fail(e) {
  459. // // 轨迹回放失败
  460. // },
  461. // });
  462. // } else {
  463. // _this.polyline = [{
  464. // points: [],
  465. // color: '#F35546',
  466. // width: 4,
  467. // dottedLine: false,
  468. // }];
  469. // this.$util.Tips({
  470. // title: `${this.dateTime}暂无轨迹数据`,
  471. // }, () => {
  472. // });
  473. // }
  474. // })
  475. }
  476. },
  477. // start() {
  478. // this.isStart = true;
  479. // this.isDisabled = true;
  480. // let data = this.coordinate;
  481. // let len = data.length;
  482. // let datai = data[this.playIndex];
  483. // let _this = this;
  484. // _this.map.translateMarker({
  485. // markerId: 1,
  486. // autoRotate: true,
  487. // destination: {
  488. // longitude: datai.longitude, // 车辆即将移动到的下一个点的经度
  489. // latitude: datai.latitude, // 车辆即将移动到的下一个点的纬度
  490. // },
  491. // duration: 700,
  492. // complete: function() {
  493. // _this.playIndex++;
  494. // if (_this.playIndex < len) {
  495. // _this.start(_this.playIndex, data);
  496. // } else {
  497. // console.log('okokok');
  498. // uni.showToast({
  499. // title: '播放完成',
  500. // duration: 1400,
  501. // icon: 'none'
  502. // });
  503. // _this.playIndex = 0;
  504. // _this.isStart = false;
  505. // _this.isDisabled = false;
  506. // }
  507. // },
  508. // animationEnd: function() {
  509. // // 轨迹回放完成 处理H5端
  510. // _this.playIndex++;
  511. // if (_this.playIndex < len) {
  512. // _this.start(_this.playIndex, data);
  513. // } else {
  514. // console.log('okokok');
  515. // uni.showToast({
  516. // title: '播放完成',
  517. // duration: 1400,
  518. // icon: 'none'
  519. // });
  520. // _this.playIndex = 0;
  521. // _this.isStart = false;
  522. // _this.isDisabled = false;
  523. // }
  524. // },
  525. // fail(e) {
  526. // // 轨迹回放失败
  527. // },
  528. // });
  529. // },
  530. // },
  531. // addMarkers() {
  532. // let _this = this;
  533. // const positions = [{
  534. // latitude: 23.099994,
  535. // longitude: 113.324520,
  536. // }, {
  537. // latitude: 23.099994,
  538. // longitude: 113.322520,
  539. // }, {
  540. // latitude: 23.099994,
  541. // longitude: 113.326520,
  542. // }, {
  543. // latitude: 23.096994,
  544. // longitude: 113.329520,
  545. // }]
  546. // const markers = []
  547. // positions.forEach((p, i) => {
  548. // console.log(i)
  549. // markers.push(
  550. // Object.assign({}, {
  551. // id: i + 1,
  552. // iconPath: "http://cdn.zhoukaiwen.com/car.png",
  553. // width: 50,
  554. // height: 50,
  555. // joinCluster: true, // 指定了该参数才会参与聚合
  556. // label: {
  557. // width: 50,
  558. // height: 30,
  559. // borderWidth: 1,
  560. // borderRadius: 10,
  561. // bgColor: '#ffffff',
  562. // content: `label ${i + 1}`
  563. // }
  564. // }, p)
  565. // )
  566. // })
  567. // _this.map.addMarkers({
  568. // markers,
  569. // clear: false,
  570. // complete(res) {
  571. // console.log('addMarkers', res)
  572. // }
  573. // })
  574. // },
  575. initmap(type) {
  576. AMapLoader.load({
  577. // key: '2d7215a1d0f8893f2417d134af7c3798',
  578. key: 'c968deab485d6e688e7c68689722ffb4',
  579. version: '2.0', // 指定要加载的 JSAPI 的版本,缺省时默认为 1.4.15
  580. plugins: [
  581. 'AMap.Autocomplete',
  582. 'AMap.PlaceSearch',
  583. 'AMap.Scale',
  584. 'AMap.OverView',
  585. 'AMap.ToolBar',
  586. 'AMap.MapType',
  587. 'AMap.PolyEditor',
  588. 'AMap.CircleEditor',
  589. 'MarkerClusterer',
  590. 'AMap.Geocoder'
  591. ]
  592. })
  593. .then((AMap) => {
  594. console.log('AMap', AMap)
  595. // 地图初始化
  596. // Map构造函数第一个传参的map为初始化地图的容器的id,第二个传参是配置对象
  597. var map = new AMap.Map('amap', {
  598. zoom: 15, //显示的缩放级别
  599. // zooms: [2, 30], //地图显示的缩放级别范围, 默认为 [2, 20] ,取值范围 [2 ~ 30]
  600. // center: [108.954239, 34.265472], //todo 中心点坐标
  601. mapStyle: 'amap://styles/macaron', //todo 地图样式
  602. resizeEnable: true //是否监控地图容器尺寸变化
  603. });
  604. /** 定位 */
  605. let marker = new AMap.Marker();
  606. if (this.aaa.length) {
  607. map.setCenter(this.aaa);
  608. map.add(marker);
  609. marker.setPosition(this.aaa);
  610. }
  611. /** 轨迹 */
  612. if (type === 3) {
  613. this.showInfo = false
  614. console.log('进来');
  615. map.clearMap();
  616. marker?.hide()
  617. const historyList = [{
  618. "lat": 39.91055750509886,
  619. "lng": 116.4036806180665,
  620. "gpsTime": "2023-10-08 13:47:14",
  621. "gpsId": 867605051108718,
  622. "compensate": null
  623. },
  624. {
  625. "lat": 39.910380195191074,
  626. "lng": 116.74977990361894,
  627. "gpsTime": "2023-10-08 14:08:14",
  628. "gpsId": 867605051108718,
  629. "compensate": null
  630. },
  631. {
  632. "lat": 39.91055750509886,
  633. "lng": 116.4036806180665,
  634. "gpsTime": "2023-10-08 14:26:00",
  635. "gpsId": 867605051108718,
  636. "compensate": null
  637. },
  638. {
  639. "lat": 39.91055750509886,
  640. "lng": 116.4036806180665,
  641. "gpsTime": "2023-10-08 14:27:00",
  642. "gpsId": 867605051108718,
  643. "compensate": null
  644. },
  645. {
  646. "lat": 39.91055750509886,
  647. "lng": 116.4036806180665,
  648. "gpsTime": "2023-10-08 14:30:00",
  649. "gpsId": 867605051108718,
  650. "compensate": null
  651. },
  652. {
  653. "lat": 39.910557505765034,
  654. "lng": 116.40368361866521,
  655. "gpsTime": "2023-10-08 14:31:00",
  656. "gpsId": 867605051108718,
  657. "compensate": null
  658. },
  659. {
  660. "lat": 39.032391,
  661. "lng": 117.662369,
  662. "gpsTime": "2023-10-08 19:10:00",
  663. "gpsId": 867605051108718,
  664. "compensate": null
  665. }
  666. ]
  667. AMap.plugin('AMap.Driving', function() {
  668. if (historyList.length >= 2) {
  669. var drivingOption = {
  670. policy: AMap.DrivingPolicy
  671. .LEAST_TIME, // 其它policy参数请参考 https://lbs.amap.com/api/javascript-api/reference/route-search#m_DrivingPolicy
  672. ferry: 1, // 是否可以使用轮渡
  673. province: '京', // 车牌省份的汉字缩写
  674. }
  675. // 构造路线导航类
  676. var driving = new AMap.Driving(drivingOption)
  677. // 根据起终点经纬度规划驾车导航路线
  678. driving.search(new AMap.LngLat(historyList[0].lng, historyList[0]
  679. .lat),
  680. new AMap.LngLat(historyList[historyList.length - 1].lng,
  681. historyList[historyList.length - 1].lat),
  682. function(status, result) {
  683. if (status === 'complete') {
  684. if (result.routes && result.routes.length) {
  685. console.log(result.routes, 'result.routes');
  686. // 绘制第一条路线,也可以按需求绘制其它几条路线
  687. drawRoute(result.routes[0])
  688. console.log('绘制驾车路线完成')
  689. }
  690. } else {
  691. console.log('获取驾车数据失败:' + result)
  692. }
  693. });
  694. function drawRoute(route) {
  695. var path = parseRouteToPath(route)
  696. var startMarker = new AMap.Marker({
  697. position: path[0],
  698. icon: 'https://webapi.amap.com/theme/v1.3/markers/n/start.png',
  699. map: map
  700. })
  701. var endMarker = new AMap.Marker({
  702. position: path[path.length - 1],
  703. icon: 'https://webapi.amap.com/theme/v1.3/markers/n/end.png',
  704. map: map
  705. })
  706. var routeLine = new AMap.Polyline({
  707. path: path,
  708. isOutline: true,
  709. outlineColor: '#ffeeee',
  710. borderWeight: 2,
  711. strokeWeight: 5,
  712. strokeOpacity: 0.9,
  713. strokeColor: '#F35546',
  714. lineJoin: 'round'
  715. })
  716. map.add(routeLine);
  717. // 调整视野达到最佳显示区域
  718. map.setFitView([startMarker, endMarker, routeLine])
  719. }
  720. // 解析DrivingRoute对象,构造成AMap.Polyline的path参数需要的格式
  721. // DrivingResult对象结构参考文档 https://lbs.amap.com/api/javascript-api/reference/route-search#m_DriveRoute
  722. function parseRouteToPath(route) {
  723. var path = []
  724. for (var i = 0, l = route.steps.length; i < l; i++) {
  725. var step = route.steps[i]
  726. for (var j = 0, n = step.path.length; j < n; j++) {
  727. path.push(step.path[j])
  728. }
  729. }
  730. return path
  731. }
  732. }
  733. })
  734. }
  735. })
  736. .catch((e) => {
  737. console.error(e) //加载错误提示
  738. })
  739. },
  740. }
  741. };
  742. </script>
  743. <style lang="scss">
  744. .map-box {
  745. z-index: 888;
  746. width: 100%;
  747. height: 100vh;
  748. position: relative;
  749. .mp-header {
  750. z-index: 999;
  751. position: fixed;
  752. left: 0;
  753. top: 0;
  754. width: 100%;
  755. /* #ifdef H5 */
  756. padding-bottom: 20rpx;
  757. /* #endif */
  758. // background-color: $theme-color;
  759. .serch-box {
  760. height: 100%;
  761. width: 210rpx;
  762. background-color: #fff;
  763. border-radius: 35rpx;
  764. // margin: 33rpx 0 0 30rpx;
  765. margin: 0 0 0 30rpx;
  766. .serch-wrapper {
  767. height: 100%;
  768. align-items: center;
  769. padding: 19rpx;
  770. box-sizing: border-box;
  771. image {
  772. width: 118rpx;
  773. height: 42rpx;
  774. }
  775. .logo {
  776. width: 32rpx;
  777. height: 32rpx;
  778. display: flex;
  779. }
  780. .arrow {
  781. width: 48rpx;
  782. height: 48rpx;
  783. }
  784. .name {
  785. flex: 1;
  786. text-align: center;
  787. color: #7C7C7C;
  788. font-size: 36rpx;
  789. margin: 0 13rpx 0 18rpx;
  790. white-space: nowrap;
  791. }
  792. .input {
  793. display: flex;
  794. align-items: center;
  795. /* #ifdef MP */
  796. width: 305rpx;
  797. /* #endif */
  798. height: 50rpx;
  799. padding: 0 0 0 30rpx;
  800. background: rgba(247, 247, 247, 1);
  801. border: 1px solid rgba(241, 241, 241, 1);
  802. border-radius: 29rpx;
  803. color: #BBBBBB;
  804. font-size: 28rpx;
  805. .iconfont {
  806. margin-right: 20rpx;
  807. }
  808. }
  809. }
  810. }
  811. }
  812. #map {
  813. width: 100%;
  814. height: 100%;
  815. }
  816. ::v-deep .uni-image[src^="https://app.tjzhxx.cn:11443/"] {
  817. border: 2px solid red;
  818. /* 添加2px宽的红色边框 */
  819. border-radius: 50%;
  820. /* 可选,设置为圆形边框 */
  821. }
  822. .custom-marker {
  823. position: relative;
  824. width: 42px;
  825. /* 根据您的标记点图标宽度调整 */
  826. height: 47px;
  827. /* 根据您的标记点图标高度调整 */
  828. }
  829. .custom-marker img {
  830. width: 100%;
  831. height: 100%;
  832. /* 在这里添加您需要的自定义CSS样式 */
  833. border: 1rpx solid red;
  834. }
  835. .loading {
  836. z-index: 999;
  837. width: 100%;
  838. top: 30%;
  839. // left:50%;
  840. position: absolute;
  841. }
  842. .top-input::before {
  843. content: "";
  844. position: absolute;
  845. top: 0;
  846. left: 0;
  847. width: 100%;
  848. height: 100%;
  849. background: #FF0000;
  850. opacity: 0.1;
  851. filter: blur(50px);
  852. z-index: 66;
  853. pointer-events: none;
  854. }
  855. .top-input {
  856. width: 70%;
  857. height: 45%;
  858. top: 20%;
  859. left: 15%;
  860. text-align: center;
  861. position: absolute;
  862. box-sizing: border-box;
  863. font-size: 32rpx;
  864. font-weight: 500;
  865. color: #000000;
  866. // border: 1rpx solid red;
  867. padding: 119rpx 90rpx;
  868. image {
  869. width: 100%;
  870. height: 368rpx;
  871. }
  872. .btn-box {
  873. z-index: 999;
  874. width: 100%;
  875. display: flex;
  876. align-items: center;
  877. justify-content: center;
  878. .btn {
  879. background: rgba(255, 247, 247, 0.3);
  880. border-radius: 35rpx;
  881. border: 3rpx solid #EC3534;
  882. margin-top: 42rpx;
  883. width: 236rpx;
  884. height: 70rpx;
  885. display: flex;
  886. align-items: center;
  887. justify-content: center;
  888. font-weight: 600;
  889. font-size: 36rpx;
  890. color: #EC3534;
  891. }
  892. }
  893. }
  894. // .top-input {
  895. // width: 70%;
  896. // height: 45%;
  897. // top: 20%;
  898. // left: 15%;
  899. // text-align: center;
  900. // position: absolute;
  901. // box-sizing: border-box;
  902. // font-size: 32rpx;
  903. // font-weight: 500;
  904. // color: #000000;
  905. // border: 1rpx solid red;
  906. // background: #FF0000;
  907. // opacity: 0.4;
  908. // filter: blur(50px);
  909. // padding:119rpx 90rpx;
  910. // image{
  911. // width: 100%;
  912. // height: 368rpx;
  913. // }
  914. // .btn-box{
  915. // width: 100%;
  916. // display: flex;
  917. // align-items: center;
  918. // justify-content: center;
  919. // .btn{
  920. // background: rgba(255,247,247,0.3);
  921. // border-radius: 35rpx;
  922. // border: 3rpx solid #EC3534;
  923. // margin-top: 42rpx;
  924. // width: 236rpx;
  925. // height: 70rpx;
  926. // display: flex;
  927. // align-items: center;
  928. // justify-content: center;
  929. // }
  930. // }
  931. // }
  932. .info-box {
  933. width: 100%;
  934. height: 40%;
  935. display: flex;
  936. justify-content: center;
  937. flex-direction: column;
  938. position: absolute;
  939. bottom: 75rpx;
  940. z-index: 1000;
  941. // background-color: #fff;
  942. padding: 0 30rpx 0;
  943. font-size: 32rpx;
  944. font-weight: 400;
  945. color: #000000;
  946. box-sizing: border-box;
  947. .scroll-view_H {
  948. width: 100%;
  949. height: 80%;
  950. /* 设置适当的高度 */
  951. .scroll-view-content {
  952. height: 100%;
  953. white-space: nowrap;
  954. font-size: 0;
  955. overflow-x: auto;
  956. .scroll-view-item_H {
  957. width: 50%;
  958. height: 100%;
  959. display: inline-block;
  960. font-size: 16px;
  961. margin-right: 15rpx;
  962. position: relative;
  963. .bg-image {
  964. width: 100%;
  965. height: 100%;
  966. object-fit: cover;
  967. }
  968. .text-wrapper {
  969. position: absolute;
  970. top: 0;
  971. left: 0;
  972. width: 100%;
  973. height: 100%;
  974. display: flex;
  975. justify-content: flex-start;
  976. padding: 60rpx 30rpx 0;
  977. }
  978. .black {
  979. color: #2D2D2D;
  980. }
  981. .white {
  982. color: #fff;
  983. }
  984. .text-overlay {
  985. // color: white;
  986. font-size: 16px;
  987. width: 100%;
  988. overflow: hidden;
  989. .top-box {
  990. display: flex;
  991. justify-content: space-between;
  992. .top-left {
  993. .english {
  994. font-size: 24rpx;
  995. }
  996. .chinese {
  997. font-size: 32rpx;
  998. }
  999. }
  1000. .top-right {
  1001. width: 76rpx;
  1002. height: 76rpx;
  1003. border-radius: 50%;
  1004. }
  1005. }
  1006. .under-box {
  1007. margin-top: 8rpx;
  1008. display: flex;
  1009. justify-content: space-between;
  1010. align-items: flex-end;
  1011. .under-left {
  1012. color: #EC3534;
  1013. .number {
  1014. font-size: 36rpx;
  1015. font-weight: 600;
  1016. }
  1017. .unit {
  1018. font-size: 28rpx;
  1019. font-weight: 500;
  1020. }
  1021. }
  1022. .under-right {
  1023. font-weight: 500;
  1024. .range {
  1025. font-size: 24rpx;
  1026. }
  1027. .range-word {
  1028. font-size: 24rpx;
  1029. }
  1030. }
  1031. .white {
  1032. color: #fff;
  1033. }
  1034. }
  1035. }
  1036. }
  1037. }
  1038. }
  1039. .sos-btn {
  1040. width: 100%;
  1041. height: 140rpx;
  1042. image {
  1043. width: 100%;
  1044. height: 100%;
  1045. }
  1046. }
  1047. .code {
  1048. font-size: 32rpx;
  1049. font-weight: 600;
  1050. color: #000000;
  1051. }
  1052. .time {
  1053. font-size: 28rpx;
  1054. font-weight: 400;
  1055. color: #999999;
  1056. margin: 10rpx 0 16rpx;
  1057. display: flex;
  1058. align-items: center;
  1059. .online-box {
  1060. margin-right: 25rpx;
  1061. width: 55rpx;
  1062. height: 30rpx;
  1063. image {
  1064. width: 100%;
  1065. height: 100%;
  1066. }
  1067. }
  1068. }
  1069. .position {
  1070. // margin-top: 16rpx;
  1071. }
  1072. }
  1073. .icon-box {
  1074. width: 10%;
  1075. height: 30%;
  1076. top: 20%;
  1077. position: absolute;
  1078. left: 5%;
  1079. display: flex;
  1080. background-color: #ECECEC;
  1081. flex-direction: column;
  1082. justify-content: space-between;
  1083. border-radius: 10rpx;
  1084. .img-box {
  1085. text-align: center;
  1086. height: 24.5%;
  1087. line-height: 130rpx;
  1088. background-color: #fff;
  1089. image {
  1090. width: 42rpx;
  1091. height: 42rpx;
  1092. }
  1093. }
  1094. .first {
  1095. border-radius: 10rpx 10rpx 0 0;
  1096. }
  1097. .last {
  1098. border-radius: 0 0 10rpx 10rpx;
  1099. }
  1100. image {
  1101. width: 42rpx;
  1102. height: 42rpx;
  1103. }
  1104. }
  1105. .icon-box-right {
  1106. width: 10%;
  1107. height: 25%;
  1108. top: 10%;
  1109. position: absolute;
  1110. right: 5%;
  1111. display: flex;
  1112. flex-direction: column;
  1113. justify-content: space-between;
  1114. image {
  1115. width: 70rpx;
  1116. height: 70rpx;
  1117. }
  1118. }
  1119. }
  1120. </style>