yz.vue 14 KB

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