aid.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694
  1. <template>
  2. <view class="content">
  3. <view id="map" class="map">
  4. <map @updated='mapChange' id="map_1" ref='map_1' style="width:750rpx;" :style="{'height': height}"
  5. :latitude="latitude" :longitude="longitude" :markers="marker" @markertap="lookmore"></map>
  6. </view>
  7. <!-- <scroll-view scroll-y="true" class="scroll-wrapper" :style="{'height': height}" @scrolltolower="loadData">
  8. <espempty v-if="loaded && AEDList.length === 0" :tit="'智能AED列表为空'"></espempty>
  9. <view class="list-tpl flex" @click="openAddress(item)" v-for="(item, index) in AEDList" :key="item.id">
  10. <template>
  11. <view class="list-left">
  12. <view class="info">
  13. <view class="title">{{ item.name }}</view>
  14. <view class="addr">地址:{{ item.install_address }}</view>
  15. </view>
  16. </view>
  17. <view class="image">
  18. <image src="../../static/img/img10.png"></image>
  19. <view class="tip">{{item.distance >= 1000 ? item.range + 'km': item.distance + 'm'}}</view>
  20. </view>
  21. </template>
  22. </view>
  23. <uni-load-more :status="loadingType"></uni-load-more>
  24. </scroll-view> -->
  25. <uni-popup ref="popup" type="bottom" @click="close">
  26. <view class="popup_row">
  27. <view class="rows">
  28. <view class="rows-item" @click="toGaodeMap">高德地图</view>
  29. <view class="rows-item" @click="tobaiDuMap">百度地图</view>
  30. <view class="rows-item" @click="totengxunMap">腾讯地图</view>
  31. </view>
  32. </view>
  33. </uni-popup>
  34. <uni-popup ref="aedxq" type="bottom" @click="closeAedXq">
  35. <view class="aedxq-wrap">
  36. <view class="logo-wrap flex">
  37. <image :src="baseURL + showAed.imgs" mode="" class="logo"></image>
  38. <view class="aid-name">
  39. {{showAed.name}}
  40. </view>
  41. </view>
  42. <view class="aed-dis" style="padding-top: 20rpx;">
  43. 距离:{{showAed.dis}}
  44. </view>
  45. <view class="aed-address" style="padding-top: 10rpx;">
  46. 地址:{{showAed.address}}
  47. </view>
  48. <view class="aed-address" style="padding-top: 10rpx;">
  49. 联系方式:{{showAed.phone}}
  50. </view>
  51. <view class="aed-dh" @click="opendh">
  52. 导航
  53. </view>
  54. <view class="aed-phone" @click="makecall(showAed.phone)">
  55. 电话
  56. </view>
  57. </view>
  58. </uni-popup>
  59. <uni-popup ref="lookimg" type="center">
  60. <view class="pop-wrap" style="position: relative;">
  61. <movable-area class="popup-box">
  62. <movable-view class="popup-item" :scale="true" direction="all">
  63. <image :src="chooseImg" mode="widthFix"></image>
  64. </movable-view>
  65. </movable-area>
  66. <image src="../../static/icon/close.png" mode="" class="close" style="width: 80rpx;height: 80rpx;"
  67. @click="closePup"></image>
  68. </view>
  69. </uni-popup>
  70. </view>
  71. </template>
  72. <script>
  73. import {
  74. mapState,
  75. mapMutations
  76. } from 'vuex';
  77. import espempty from '@/components/espempty';
  78. import uniPopup from '@/components/uni-popup/uni-popup.vue';
  79. import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
  80. import {
  81. getAed,
  82. getAidList
  83. } from '@/api/category.js'
  84. export default {
  85. components: {
  86. uniPopup,
  87. espempty,
  88. uniLoadMore
  89. },
  90. //相关配置参数
  91. data() {
  92. return {
  93. aedmarker: [],
  94. loaded: false,
  95. loadingType: 'more',
  96. page: 1,
  97. limit: 100,
  98. AEDList: [],
  99. height: '',
  100. list: [],
  101. latitude: '', // 本地坐标
  102. longitude: '', // 本地坐标
  103. phone: '',
  104. marker: [],
  105. showAed: {
  106. name: '',
  107. address: '',
  108. addressxq: '',
  109. dis: '',
  110. lat: '',
  111. lon: '',
  112. imgs: '',
  113. phone: ''
  114. },
  115. chooseImg: '',
  116. }
  117. },
  118. onReady(res) {
  119. var _this = this;
  120. uni.getSystemInfo({
  121. success: resu => {
  122. const query = uni.createSelectorQuery();
  123. query.select('.map').boundingClientRect();
  124. query.exec(function(res) {
  125. console.log(res, 'ddddddddddddd');
  126. _this.height = resu.windowHeight - res[0].top + 'px';
  127. console.log('打印页面的剩余高度', _this.height);
  128. });
  129. },
  130. fail: res => {}
  131. });
  132. },
  133. onLoad() {
  134. let obj = this;
  135. this.getLocal()
  136. },
  137. computed: {
  138. ...mapState('user', ['hasLogin', 'userInfo']),
  139. ...mapState(['baseURL'])
  140. },
  141. methods: {
  142. ...mapMutations('user', ['setUserInfo']),
  143. // 导航
  144. opendh() {
  145. console.log('导航')
  146. this.$refs.aedxq.close()
  147. this.$refs.popup.open();
  148. },
  149. // 关闭图片弹窗
  150. closePup() {
  151. this.$refs.lookimg.close()
  152. },
  153. // 打开图片弹窗
  154. openimg(src) {
  155. this.chooseImg = this.baseURL + src
  156. this.$refs.lookimg.open()
  157. },
  158. // 拨打电话
  159. makecall(num) {
  160. uni.makePhoneCall({
  161. phoneNumber: num + ''
  162. })
  163. },
  164. // 关闭aed详情
  165. closeAedXq() {
  166. this.$refs.aedxq.close()
  167. },
  168. // 打开aed详情
  169. lookmore(e) {
  170. console.log(e)
  171. let obj = this
  172. obj.AEDList.forEach(item => {
  173. if (item.id == e.detail.markerId) {
  174. obj.showAed = {
  175. name: item.name,
  176. address: item.address,
  177. addressxq: item.install_address,
  178. dis: item.range >= 1 ? (item.range + 'km') : (item.distance + 'm'),
  179. lat: item.latitude,
  180. lon: item.longitude,
  181. imgs: item.image,
  182. phone: item.phone
  183. }
  184. // break
  185. }
  186. })
  187. this.$refs.aedxq.open()
  188. },
  189. // 获取本地坐标
  190. getLocal() {
  191. let obj = this;
  192. console.log('ddddddddddddddddddddddddd')
  193. let wxOjb = require('jweixin-module');
  194. wxOjb.ready(()=> {
  195. wxOjb.getLocation({
  196. type: 'gcj02',
  197. success(e) {
  198. console.log(e)
  199. obj.latitude = Math.abs(e.latitude)
  200. obj.longitude = Math.abs(e.longitude)
  201. console.log('本地坐标', obj.latitude, obj.longitude)
  202. let item = {
  203. id: 0,
  204. latitude: obj.latitude,
  205. longitude: obj.longitude,
  206. iconPath: '/static/img/img19.png',
  207. width: '35',
  208. height: '35',
  209. }
  210. obj.marker.push(item)
  211. obj.loadData()
  212. },
  213. fail(err) {
  214. obj.getLocal()
  215. }
  216. })
  217. })
  218. },
  219. // 地图渲染完毕事件
  220. mapChange(e) {
  221. console.log(e);
  222. },
  223. // 载入数据
  224. async loadData() {
  225. let obj = this;
  226. if (obj.loadingType == 'loading' || obj.loadingType == 'noMore') {
  227. return
  228. }
  229. obj.loadingType = 'loading'
  230. getAidList({
  231. latitude: obj.latitude,
  232. longitude: obj.longitude,
  233. page: obj.page,
  234. limit: obj.limit,
  235. }).then(({
  236. data
  237. }) => {
  238. console.log(data, 'aed++++++++++++++')
  239. obj.AEDList = obj.AEDList.concat(data);
  240. let arr = data.map(item => ({
  241. latitude: item.latitude,
  242. longitude: item.longitude,
  243. iconPath: '/static/img/img014.png',
  244. width: '35',
  245. height: '35',
  246. id: item.id,
  247. address: item.address
  248. }));
  249. if (data.length == obj.limit) {
  250. obj.loadingType = 'more'
  251. } else {
  252. obj.loadingType = 'noMore'
  253. }
  254. obj.marker = obj.marker.concat(arr)
  255. })
  256. },
  257. // 调用高德
  258. toGaodeMap() {
  259. let latitude = this.showAed.lat;
  260. let longitude = this.showAed.lon;
  261. let address = this.showAed.name;
  262. console.log(address)
  263. console.log('选择高德', latitude, longitude, address);
  264. window.location.href = `https://uri.amap.com/marker?position=${longitude},${latitude}&name=${address}`;
  265. },
  266. // 调用腾讯
  267. totengxunMap() {
  268. let latitude = this.showAed.lat;
  269. let longitude = this.showAed.lon;
  270. let address = this.showAed.name;
  271. console.log('选择腾讯', latitude, longitude);
  272. window.location.href =
  273. `http://apis.map.qq.com/uri/v1/marker?marker=coord:${latitude},${longitude};addr:${address}`;
  274. },
  275. // 调用百度
  276. tobaiDuMap() {
  277. let latlon = this.bd_encrypt(this.showAed.lon, this.showAed.lat)
  278. let latlon1 = this.bd_encrypt(this.longitude, this.latitude)
  279. let latitude = latlon.bd_lat;
  280. let longitude = latlon.bd_lng;
  281. let latitude6 = latlon1.bd_lat;
  282. let longitude6 = latlon1.bd_lng;
  283. let address =this.showAed.name;
  284. console.log('选择百度', latitude, longitude);
  285. console.log('获取当前经纬度', latitude6, longitude6);
  286. window.location.href =
  287. `http://api.map.baidu.com/direction?origin=latlng:${latitude6},${longitude6}|name:我的位置&destination=${latitude},${longitude}&mode=driving&region=${address}&output=html&src=webapp.baidu.openAPIdemo`;
  288. },
  289. // 高德坐标、腾讯坐标转百度坐标
  290. bd_encrypt(gg_lng, gg_lat) {
  291. var X_PI = Math.PI * 3000.0 / 180.0;
  292. var x = gg_lng,
  293. y = gg_lat;
  294. var z = Math.sqrt(x * x + y * y) + 0.00002 * Math.sin(y * X_PI);
  295. var theta = Math.atan2(y, x) + 0.000003 * Math.cos(x * X_PI);
  296. var bd_lng = z * Math.cos(theta) + 0.0065;
  297. var bd_lat = z * Math.sin(theta) + 0.006;
  298. return {
  299. bd_lat: bd_lat,
  300. bd_lng: bd_lng
  301. };
  302. }
  303. }
  304. }
  305. </script>
  306. <style lang="scss">
  307. body,
  308. page {
  309. height: 100%;
  310. width: 100%;
  311. background-color: #fff;
  312. }
  313. .content {
  314. height: 100%;
  315. width: 100%;
  316. background-color: #fff;
  317. }
  318. .map {
  319. width: 100%;
  320. height: 100%;
  321. }
  322. /* #ifdef H5 */
  323. .location {
  324. overflow-y: scroll; //溢出就滑动起来
  325. // z-index: 990;
  326. position: fixed;
  327. bottom: 0;
  328. height: 55%;
  329. width: 100%;
  330. background-color: #fff;
  331. padding: 24rpx;
  332. //搜索框
  333. .Search-box {
  334. height: 80rpx;
  335. padding-right: 24rpx;
  336. padding-left: 24rpx;
  337. .Search-box-sort {
  338. float: left;
  339. margin-left: 32rpx;
  340. margin-right: 19rpx;
  341. .sort-text {
  342. width: 57rpx;
  343. height: 29rpx;
  344. font-size: 30rpx;
  345. font-weight: 500;
  346. color: rgba(51, 51, 51, 1);
  347. line-height: 58rpx;
  348. margin-right: 19rpx;
  349. }
  350. .sort-img {
  351. width: 21rpx;
  352. height: 11rpx;
  353. margin-bottom: 4rpx;
  354. }
  355. }
  356. .Search-box-size {
  357. // width:70%;
  358. height: 58rpx;
  359. border-radius: 32rpx;
  360. background-color: #f1f1f1;
  361. padding-left: 36rpx;
  362. display: flex;
  363. align-items: center;
  364. .box-img {
  365. height: 32rpx;
  366. width: 32rpx;
  367. margin-right: 16rpx;
  368. }
  369. .box-word {
  370. width: 100%;
  371. font-size: 26rpx;
  372. font-weight: 500;
  373. color: rgba(205, 203, 203, 1);
  374. line-height: 55rpx;
  375. }
  376. }
  377. }
  378. .location-item {
  379. z-index: 1000;
  380. display: flex;
  381. justify-content: space-between;
  382. align-items: center;
  383. border-bottom: 1rpx solid #E7E8EA;
  384. padding: 15rpx 0;
  385. .box-left {
  386. display: flex;
  387. .img01 {
  388. width: 8rpx;
  389. height: 28rpx;
  390. margin-right: 18rpx;
  391. image {
  392. width: 8rpx;
  393. height: 28rpx;
  394. }
  395. }
  396. .img02 {
  397. width: 117rpx;
  398. height: 117rpx;
  399. border-radius: 50%;
  400. image {
  401. width: 117rpx;
  402. height: 117rpx;
  403. border-radius: 50%;
  404. }
  405. }
  406. .info {
  407. margin-left: 16rpx;
  408. .info-header {
  409. display: flex;
  410. align-items: center;
  411. .name {
  412. font-size: 32rpx;
  413. color: #333333;
  414. }
  415. .distance {
  416. margin-left: 25rpx;
  417. font-size: 28rpx;
  418. color: #303133;
  419. }
  420. .location-icon {
  421. margin-left: 10rpx;
  422. width: 20rpx;
  423. height: 26rpx;
  424. image {
  425. width: 20rpx;
  426. height: 26rpx;
  427. display: inline;
  428. }
  429. }
  430. }
  431. .address {
  432. font-size: 26rpx;
  433. color: #333333;
  434. margin-top: 33rpx;
  435. }
  436. }
  437. }
  438. .box-right {
  439. .img {
  440. height: 107rpx;
  441. image {
  442. width: 107rpx;
  443. height: 107rpx;
  444. }
  445. }
  446. .called {
  447. margin-right: 16rpx;
  448. height: 107rpx;
  449. line-height: 107rpx;
  450. font-size: 28rpx;
  451. color: #CB131C;
  452. }
  453. }
  454. }
  455. }
  456. /* #endif */
  457. .list-tpl {
  458. background-color: #ffffff;
  459. margin-bottom: 25rpx;
  460. padding: 25rpx 25rpx;
  461. font-size: 28rpx;
  462. border-radius: 15rpx;
  463. display: flex;
  464. justify-content: space-between;
  465. align-items: center;
  466. border-bottom: 1px solid #f1f1f1;
  467. .list-left {
  468. display: flex;
  469. width: 100%;
  470. .number {
  471. font-size: 32rpx;
  472. margin-right: 14rpx;
  473. }
  474. .info {
  475. width: 100%;
  476. .title {
  477. font-size: 32rpx;
  478. color: #222222;
  479. font-weight: 500;
  480. }
  481. .addr {
  482. width: 400rpx;
  483. margin-top: 20rpx;
  484. font-size: 20rpx;
  485. font-family: PingFang SC;
  486. font-weight: 500;
  487. color: #999999;
  488. }
  489. }
  490. }
  491. .image {
  492. width: 20%;
  493. text-align: center;
  494. image {
  495. width: 50rpx;
  496. height: 50rpx;
  497. }
  498. .tip {
  499. color: #7f7f7f;
  500. font-size: 21rpx;
  501. }
  502. }
  503. }
  504. .popup_row {
  505. width: 100%;
  506. height: 500rpx;
  507. background-color: #ffffff;
  508. border-radius: 20rpx;
  509. display: flex;
  510. justify-content: center;
  511. align-items: center;
  512. .rows {
  513. width: 100%;
  514. padding: 0 24rpx;
  515. .rows-item {
  516. height: 80rpx;
  517. line-height: 80rpx;
  518. text-align: center;
  519. width: 100%;
  520. font-size: 32rpx;
  521. color: #303133;
  522. }
  523. }
  524. }
  525. .scroll-wrapper {
  526. padding-top: 20rpx;
  527. }
  528. .aedxq-wrap {
  529. margin: auto;
  530. width: 710rpx;
  531. min-height: 200rpx;
  532. border-radius: 20rpx;
  533. padding: 25rpx 25rpx 25rpx 25rpx;
  534. background-color: rgba($color: #000000, $alpha: 0.9);
  535. color: #fff;
  536. position: relative;
  537. .logo-wrap {
  538. width: 460rpx;
  539. // background-color: red;
  540. align-items: center;
  541. .logo {
  542. width: 100rpx;
  543. height: 100rpx;
  544. border-radius: 50%;
  545. }
  546. .aid-name {
  547. display: inline-block;
  548. width: 340rpx;
  549. padding-left: 20rpx;
  550. font-size: 32rpx;
  551. // background-color: #bfa;
  552. // text-align: center;
  553. }
  554. }
  555. .xq-top {
  556. padding-top: 25rpx;
  557. width: 660rpx;
  558. height: 297rpx;
  559. border-bottom: 1px solid #fff;
  560. .aed-name {
  561. font-size: 28rpx;
  562. width: 479rpx;
  563. }
  564. .aed-dis {
  565. padding-top: 10rpx;
  566. font-size: 22rpx;
  567. width: 479rpx;
  568. }
  569. }
  570. .xq-img-wrap {
  571. height: 165rpx;
  572. width: 660rpx;
  573. display: flex;
  574. align-items: center;
  575. justify-content: space-between;
  576. .aed-img-scroll {
  577. height: 107rpx;
  578. width: 508rpx;
  579. .aed-img {
  580. height: 107rpx;
  581. margin-right: 15rpx;
  582. flex-shrink: 0;
  583. }
  584. }
  585. }
  586. .aed-dh {
  587. width: 147rpx;
  588. height: 82rpx;
  589. line-height: 82rpx;
  590. text-align: center;
  591. background-color: #4d8bd6;
  592. border-radius: 15rpx;
  593. position: absolute;
  594. right: 25rpx;
  595. top: 25rpx;
  596. }
  597. .aed-phone {
  598. width: 112rpx;
  599. height: 52rpx;
  600. line-height: 52rpx;
  601. text-align: center;
  602. border: 1px solid #fff;
  603. border-radius: 10rpx;
  604. position: absolute;
  605. right: 25rpx;
  606. top: 225rpx;
  607. }
  608. }
  609. .pop-wrap {
  610. width: 522rpx;
  611. height: 800rpx;
  612. // background-color: red;
  613. }
  614. .popup-box {
  615. width: 522rpx;
  616. height: 800rpx;
  617. border-radius: 20rpx;
  618. position: relative;
  619. overflow: hidden;
  620. background-color: #fff;
  621. .popup-item {
  622. width: 100%;
  623. height: 100%;
  624. image {
  625. width: 100%;
  626. }
  627. }
  628. }
  629. .close {
  630. display: block;
  631. width: 40rpx;
  632. height: 40rpx;
  633. border: 50%;
  634. position: absolute;
  635. // background-color: red;
  636. bottom: -100rpx;
  637. left: 0;
  638. right: 0;
  639. margin: 0 auto;
  640. }
  641. </style>