aid.vue 15 KB

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