index.vue 31 KB

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