aid.vue 15 KB

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