aed.vue 15 KB

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