aed.vue 15 KB

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