aid.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721
  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 weichatBrowser = uni.getStorageSync('weichatBrowser')
  194. if(weichatBrowser) {
  195. let wxOjb = require('jweixin-module');
  196. wxOjb.ready(()=> {
  197. wxOjb.getLocation({
  198. type: 'gcj02',
  199. success(e) {
  200. console.log(e)
  201. obj.latitude = Math.abs(e.latitude)
  202. obj.longitude = Math.abs(e.longitude)
  203. console.log('本地坐标', obj.latitude, obj.longitude)
  204. let item = {
  205. id: 0,
  206. latitude: obj.latitude,
  207. longitude: obj.longitude,
  208. iconPath: '/static/img/img19.png',
  209. width: '35',
  210. height: '35',
  211. }
  212. obj.marker.push(item)
  213. obj.loadData()
  214. },
  215. fail(err) {
  216. obj.getLocal()
  217. }
  218. })
  219. })
  220. }else {
  221. uni.getLocation({
  222. type: 'gcj02',
  223. success(e) {
  224. console.log(e)
  225. obj.latitude = Math.abs(e.latitude)
  226. obj.longitude = Math.abs(e.longitude)
  227. console.log('本地坐标', obj.latitude, obj.longitude)
  228. let item = {
  229. id: 0,
  230. latitude: obj.latitude,
  231. longitude: obj.longitude,
  232. iconPath: '/static/img/img19.png',
  233. width: '35',
  234. height: '35',
  235. }
  236. obj.marker.push(item)
  237. obj.loadData()
  238. },
  239. fail(err) {
  240. obj.getLocal()
  241. }
  242. })
  243. }
  244. },
  245. // 地图渲染完毕事件
  246. mapChange(e) {
  247. console.log(e);
  248. },
  249. // 载入数据
  250. async loadData() {
  251. let obj = this;
  252. if (obj.loadingType == 'loading' || obj.loadingType == 'noMore') {
  253. return
  254. }
  255. obj.loadingType = 'loading'
  256. getAidList({
  257. latitude: obj.latitude,
  258. longitude: obj.longitude,
  259. page: obj.page,
  260. limit: obj.limit,
  261. }).then(({
  262. data
  263. }) => {
  264. console.log(data, 'aed++++++++++++++')
  265. obj.AEDList = obj.AEDList.concat(data);
  266. let arr = data.map(item => ({
  267. latitude: item.latitude,
  268. longitude: item.longitude,
  269. iconPath: '/static/img/img014.png',
  270. width: '35',
  271. height: '35',
  272. id: item.id,
  273. address: item.address
  274. }));
  275. if (data.length == obj.limit) {
  276. obj.loadingType = 'more'
  277. } else {
  278. obj.loadingType = 'noMore'
  279. }
  280. obj.marker = obj.marker.concat(arr)
  281. })
  282. },
  283. // 调用高德
  284. toGaodeMap() {
  285. let latitude = this.showAed.lat;
  286. let longitude = this.showAed.lon;
  287. let address = this.showAed.name;
  288. console.log(address)
  289. console.log('选择高德', latitude, longitude, address);
  290. window.location.href = `https://uri.amap.com/marker?position=${longitude},${latitude}&name=${address}`;
  291. },
  292. // 调用腾讯
  293. totengxunMap() {
  294. let latitude = this.showAed.lat;
  295. let longitude = this.showAed.lon;
  296. let address = this.showAed.name;
  297. console.log('选择腾讯', latitude, longitude);
  298. window.location.href =
  299. `http://apis.map.qq.com/uri/v1/marker?marker=coord:${latitude},${longitude};addr:${address}`;
  300. },
  301. // 调用百度
  302. tobaiDuMap() {
  303. let latlon = this.bd_encrypt(this.showAed.lon, this.showAed.lat)
  304. let latlon1 = this.bd_encrypt(this.longitude, this.latitude)
  305. let latitude = latlon.bd_lat;
  306. let longitude = latlon.bd_lng;
  307. let latitude6 = latlon1.bd_lat;
  308. let longitude6 = latlon1.bd_lng;
  309. let address =this.showAed.name;
  310. console.log('选择百度', latitude, longitude);
  311. console.log('获取当前经纬度', latitude6, longitude6);
  312. window.location.href =
  313. `http://api.map.baidu.com/direction?origin=latlng:${latitude6},${longitude6}|name:我的位置&destination=${latitude},${longitude}&mode=driving&region=${address}&output=html&src=webapp.baidu.openAPIdemo`;
  314. },
  315. // 高德坐标、腾讯坐标转百度坐标
  316. bd_encrypt(gg_lng, gg_lat) {
  317. var X_PI = Math.PI * 3000.0 / 180.0;
  318. var x = gg_lng,
  319. y = gg_lat;
  320. var z = Math.sqrt(x * x + y * y) + 0.00002 * Math.sin(y * X_PI);
  321. var theta = Math.atan2(y, x) + 0.000003 * Math.cos(x * X_PI);
  322. var bd_lng = z * Math.cos(theta) + 0.0065;
  323. var bd_lat = z * Math.sin(theta) + 0.006;
  324. return {
  325. bd_lat: bd_lat,
  326. bd_lng: bd_lng
  327. };
  328. }
  329. }
  330. }
  331. </script>
  332. <style lang="scss">
  333. body,
  334. page {
  335. height: 100%;
  336. width: 100%;
  337. background-color: #fff;
  338. }
  339. .content {
  340. height: 100%;
  341. width: 100%;
  342. background-color: #fff;
  343. }
  344. .map {
  345. width: 100%;
  346. height: 100%;
  347. }
  348. /* #ifdef H5 */
  349. .location {
  350. overflow-y: scroll; //溢出就滑动起来
  351. // z-index: 990;
  352. position: fixed;
  353. bottom: 0;
  354. height: 55%;
  355. width: 100%;
  356. background-color: #fff;
  357. padding: 24rpx;
  358. //搜索框
  359. .Search-box {
  360. height: 80rpx;
  361. padding-right: 24rpx;
  362. padding-left: 24rpx;
  363. .Search-box-sort {
  364. float: left;
  365. margin-left: 32rpx;
  366. margin-right: 19rpx;
  367. .sort-text {
  368. width: 57rpx;
  369. height: 29rpx;
  370. font-size: 30rpx;
  371. font-weight: 500;
  372. color: rgba(51, 51, 51, 1);
  373. line-height: 58rpx;
  374. margin-right: 19rpx;
  375. }
  376. .sort-img {
  377. width: 21rpx;
  378. height: 11rpx;
  379. margin-bottom: 4rpx;
  380. }
  381. }
  382. .Search-box-size {
  383. // width:70%;
  384. height: 58rpx;
  385. border-radius: 32rpx;
  386. background-color: #f1f1f1;
  387. padding-left: 36rpx;
  388. display: flex;
  389. align-items: center;
  390. .box-img {
  391. height: 32rpx;
  392. width: 32rpx;
  393. margin-right: 16rpx;
  394. }
  395. .box-word {
  396. width: 100%;
  397. font-size: 26rpx;
  398. font-weight: 500;
  399. color: rgba(205, 203, 203, 1);
  400. line-height: 55rpx;
  401. }
  402. }
  403. }
  404. .location-item {
  405. z-index: 1000;
  406. display: flex;
  407. justify-content: space-between;
  408. align-items: center;
  409. border-bottom: 1rpx solid #E7E8EA;
  410. padding: 15rpx 0;
  411. .box-left {
  412. display: flex;
  413. .img01 {
  414. width: 8rpx;
  415. height: 28rpx;
  416. margin-right: 18rpx;
  417. image {
  418. width: 8rpx;
  419. height: 28rpx;
  420. }
  421. }
  422. .img02 {
  423. width: 117rpx;
  424. height: 117rpx;
  425. border-radius: 50%;
  426. image {
  427. width: 117rpx;
  428. height: 117rpx;
  429. border-radius: 50%;
  430. }
  431. }
  432. .info {
  433. margin-left: 16rpx;
  434. .info-header {
  435. display: flex;
  436. align-items: center;
  437. .name {
  438. font-size: 32rpx;
  439. color: #333333;
  440. }
  441. .distance {
  442. margin-left: 25rpx;
  443. font-size: 28rpx;
  444. color: #303133;
  445. }
  446. .location-icon {
  447. margin-left: 10rpx;
  448. width: 20rpx;
  449. height: 26rpx;
  450. image {
  451. width: 20rpx;
  452. height: 26rpx;
  453. display: inline;
  454. }
  455. }
  456. }
  457. .address {
  458. font-size: 26rpx;
  459. color: #333333;
  460. margin-top: 33rpx;
  461. }
  462. }
  463. }
  464. .box-right {
  465. .img {
  466. height: 107rpx;
  467. image {
  468. width: 107rpx;
  469. height: 107rpx;
  470. }
  471. }
  472. .called {
  473. margin-right: 16rpx;
  474. height: 107rpx;
  475. line-height: 107rpx;
  476. font-size: 28rpx;
  477. color: #CB131C;
  478. }
  479. }
  480. }
  481. }
  482. /* #endif */
  483. .list-tpl {
  484. background-color: #ffffff;
  485. margin-bottom: 25rpx;
  486. padding: 25rpx 25rpx;
  487. font-size: 28rpx;
  488. border-radius: 15rpx;
  489. display: flex;
  490. justify-content: space-between;
  491. align-items: center;
  492. border-bottom: 1px solid #f1f1f1;
  493. .list-left {
  494. display: flex;
  495. width: 100%;
  496. .number {
  497. font-size: 32rpx;
  498. margin-right: 14rpx;
  499. }
  500. .info {
  501. width: 100%;
  502. .title {
  503. font-size: 32rpx;
  504. color: #222222;
  505. font-weight: 500;
  506. }
  507. .addr {
  508. width: 400rpx;
  509. margin-top: 20rpx;
  510. font-size: 20rpx;
  511. font-family: PingFang SC;
  512. font-weight: 500;
  513. color: #999999;
  514. }
  515. }
  516. }
  517. .image {
  518. width: 20%;
  519. text-align: center;
  520. image {
  521. width: 50rpx;
  522. height: 50rpx;
  523. }
  524. .tip {
  525. color: #7f7f7f;
  526. font-size: 21rpx;
  527. }
  528. }
  529. }
  530. .popup_row {
  531. width: 100%;
  532. height: 500rpx;
  533. background-color: #ffffff;
  534. border-radius: 20rpx;
  535. display: flex;
  536. justify-content: center;
  537. align-items: center;
  538. .rows {
  539. width: 100%;
  540. padding: 0 24rpx;
  541. .rows-item {
  542. height: 80rpx;
  543. line-height: 80rpx;
  544. text-align: center;
  545. width: 100%;
  546. font-size: 32rpx;
  547. color: #303133;
  548. }
  549. }
  550. }
  551. .scroll-wrapper {
  552. padding-top: 20rpx;
  553. }
  554. .aedxq-wrap {
  555. margin: auto;
  556. width: 710rpx;
  557. min-height: 200rpx;
  558. border-radius: 20rpx;
  559. padding: 25rpx 25rpx 25rpx 25rpx;
  560. background-color: rgba($color: #000000, $alpha: 0.9);
  561. color: #fff;
  562. position: relative;
  563. .logo-wrap {
  564. width: 460rpx;
  565. // background-color: red;
  566. align-items: center;
  567. .logo {
  568. width: 100rpx;
  569. height: 100rpx;
  570. border-radius: 50%;
  571. }
  572. .aid-name {
  573. display: inline-block;
  574. width: 340rpx;
  575. padding-left: 20rpx;
  576. font-size: 32rpx;
  577. // background-color: #bfa;
  578. // text-align: center;
  579. }
  580. }
  581. .xq-top {
  582. padding-top: 25rpx;
  583. width: 660rpx;
  584. height: 297rpx;
  585. border-bottom: 1px solid #fff;
  586. .aed-name {
  587. font-size: 28rpx;
  588. width: 479rpx;
  589. }
  590. .aed-dis {
  591. padding-top: 10rpx;
  592. font-size: 22rpx;
  593. width: 479rpx;
  594. }
  595. }
  596. .xq-img-wrap {
  597. height: 165rpx;
  598. width: 660rpx;
  599. display: flex;
  600. align-items: center;
  601. justify-content: space-between;
  602. .aed-img-scroll {
  603. height: 107rpx;
  604. width: 508rpx;
  605. .aed-img {
  606. height: 107rpx;
  607. margin-right: 15rpx;
  608. flex-shrink: 0;
  609. }
  610. }
  611. }
  612. .aed-dh {
  613. width: 147rpx;
  614. height: 82rpx;
  615. line-height: 82rpx;
  616. text-align: center;
  617. background-color: #4d8bd6;
  618. border-radius: 15rpx;
  619. position: absolute;
  620. right: 25rpx;
  621. top: 25rpx;
  622. }
  623. .aed-phone {
  624. width: 112rpx;
  625. height: 52rpx;
  626. line-height: 52rpx;
  627. text-align: center;
  628. border: 1px solid #fff;
  629. border-radius: 10rpx;
  630. position: absolute;
  631. right: 25rpx;
  632. top: 225rpx;
  633. }
  634. }
  635. .pop-wrap {
  636. width: 522rpx;
  637. height: 800rpx;
  638. // background-color: red;
  639. }
  640. .popup-box {
  641. width: 522rpx;
  642. height: 800rpx;
  643. border-radius: 20rpx;
  644. position: relative;
  645. overflow: hidden;
  646. background-color: #fff;
  647. .popup-item {
  648. width: 100%;
  649. height: 100%;
  650. image {
  651. width: 100%;
  652. }
  653. }
  654. }
  655. .close {
  656. display: block;
  657. width: 40rpx;
  658. height: 40rpx;
  659. border: 50%;
  660. position: absolute;
  661. // background-color: red;
  662. bottom: -100rpx;
  663. left: 0;
  664. right: 0;
  665. margin: 0 auto;
  666. }
  667. </style>