aed.vue 15 KB

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