aed.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535
  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.introduction }}</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" 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="popup" type="bottom" @click="close">
  27. <view class="popup_row">
  28. <view class="rows">
  29. <view class="rows-item" @click="toGaodeMap">高德地图</view>
  30. <view class="rows-item" @click="tobaiDuMap">百度地图</view>
  31. <view class="rows-item" @click="totengxunMap">腾讯地图</view>
  32. </view>
  33. </view>
  34. </uni-popup>
  35. </view>
  36. </template>
  37. <script>
  38. import {
  39. mapState,
  40. mapMutations
  41. } from 'vuex';
  42. import espempty from '@/components/espempty';
  43. import uniPopup from '@/components/uni-popup/uni-popup.vue';
  44. import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
  45. import {
  46. getdis,
  47. tocall,
  48. getListAED
  49. } from '@/api/index.js';
  50. import {
  51. userinfo
  52. } from '@/api/user.js';
  53. import {
  54. getcomAddress
  55. } from '@/api/index.js';
  56. import {
  57. getAed
  58. } from '@/api/category.js'
  59. export default {
  60. components: {
  61. uniPopup,
  62. espempty,
  63. uniLoadMore
  64. },
  65. //相关配置参数
  66. data() {
  67. return {
  68. aedmarker: [],
  69. loaded: false,
  70. loadtype: 'more',
  71. page: 1,
  72. limit: 10,
  73. AEDList: [],
  74. height: '',
  75. list: [],
  76. latitude: '',
  77. // 本地坐标
  78. longitude: '',
  79. current: 0,
  80. name: '',
  81. uid: '',
  82. name: '',
  83. phone: '',
  84. to_phone: '',
  85. marker: [],
  86. specificAdd: '',
  87. addressData: {
  88. name: '',
  89. mobile: '',
  90. latitude: 0, //纬度
  91. longitude: 0, //经度
  92. address: {
  93. province: '',
  94. city: '',
  95. district: '',
  96. detail: '',
  97. },
  98. area: '',
  99. default: false
  100. },
  101. }
  102. },
  103. onReady(res) {
  104. var _this = this;
  105. uni.getSystemInfo({
  106. success: resu => {
  107. const query = uni.createSelectorQuery();
  108. query.select('.scroll-wrapper').boundingClientRect();
  109. query.exec(function(res) {
  110. console.log(res, 'ddddddddddddd');
  111. _this.height = resu.windowHeight - res[0].top + 'px';
  112. console.log('打印页面的剩余高度', _this.height);
  113. });
  114. },
  115. fail: res => {}
  116. });
  117. },
  118. onLoad() {
  119. let obj = this;
  120. this.getLocal()
  121. },
  122. computed: {
  123. ...mapState('user', ['hasLogin', 'userInfo'])
  124. },
  125. methods: {
  126. ...mapMutations('user', ['setUserInfo']),
  127. // 获取本地坐标
  128. getLocal() {
  129. let obj = this;
  130. console.log('ddddddddddddddddddddddddd')
  131. uni.getLocation({
  132. type: 'gcj02',
  133. success(e) {
  134. console.log(e)
  135. obj.latitude = Math.abs(e.latitude)
  136. obj.longitude = Math.abs(e.longitude)
  137. console.log('本地坐标', obj.latitude, obj.longitude)
  138. obj.loadData()
  139. // 逆地址解析
  140. // geocoder({
  141. // latitude: obj.latitude,
  142. // longitude: obj.longitude
  143. // }).then(res => {
  144. // console.log(res)
  145. // obj.user_address = res.data.result.address
  146. // console.log(obj.user_address, 'obj.user_address')
  147. // })
  148. let item = {
  149. id: 0,
  150. latitude: obj.latitude,
  151. longitude: obj.longitude,
  152. iconPath: '/static/img/img19.png',
  153. width: '35',
  154. height: '35',
  155. }
  156. obj.marker.push(item)
  157. // obj.getRescuerList(obj.latitude, obj.longitude)
  158. }
  159. })
  160. },
  161. // 地图渲染完毕事件
  162. mapChange(e) {
  163. console.log(e);
  164. },
  165. // 载入数据
  166. async loadData() {
  167. let obj = this;
  168. if (obj.loadtype == 'loading' || obj.loadtype == 'noMore') {
  169. return
  170. }
  171. obj.loadtype = 'loading'
  172. getAed({
  173. latitude: obj.latitude,
  174. longitude: obj.longitude,
  175. page: obj.page,
  176. limit: obj.limit,
  177. }).then(({
  178. data
  179. }) => {
  180. console.log(data,'aed++++++++++++++')
  181. // console.log(data, 999);
  182. // for (let i = 0; i < data.length; i++) {
  183. // data[i].space = obj.space(obj.latitude, obj.longitude, data[i].latitude, data[i]
  184. // .longitude);
  185. // }
  186. // obj.AEDList = obj.AEDList.concat(data);
  187. // console.log(obj.AEDList, 'obj.AEDList+++++++');
  188. // let arr = data.map(item => ({
  189. // latitude: item.latitude,
  190. // longitude: item.longitude,
  191. // iconPath: '/static/img/img014.png',
  192. // width: '35',
  193. // height: '35',
  194. // id: item.id,
  195. // address: item.address
  196. // }));
  197. // obj.aedmarker = obj.marker.concat(arr)
  198. // obj.loaded = true
  199. // obj.page++;
  200. // if (obj.limit == data.length) {
  201. // obj.loadtype = 'more';
  202. // } else {
  203. // obj.loadtype = 'noMore';
  204. // }
  205. })
  206. },
  207. space(lat1, lng1, lat2, lng2) {
  208. console.log(lat1, lng1, lat2, lng2);
  209. var radLat1 = (lat1 * Math.PI) / 180.0;
  210. var radLat2 = (lat2 * Math.PI) / 180.0;
  211. var a = radLat1 - radLat2;
  212. var b = (lng1 * Math.PI) / 180.0 - (lng2 * Math.PI) / 180.0;
  213. var s = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(a / 2), 2) + Math.cos(radLat1) * Math.cos(radLat2) * Math
  214. .pow(Math.sin(b / 2), 2)));
  215. s = s * 6378.137;
  216. s = Math.round(s * 10000) / 10000;
  217. return s * 1000; // 单位米
  218. },
  219. openAddress(item) {
  220. let obj = this;
  221. obj.latitude2 = item.latitude;
  222. obj.longitude2 = item.longitude;
  223. obj.address = item.address;
  224. this.$refs.popup.open();
  225. },
  226. // 调用高德
  227. toGaodeMap() {
  228. let latitude = this.latitude2;
  229. let longitude = this.longitude2;
  230. let address = this.address;
  231. console.log('选择高德', latitude, longitude, address);
  232. window.location.href = `https://uri.amap.com/marker?position=${longitude},${latitude}&name=${address}`;
  233. },
  234. // 调用腾讯
  235. totengxunMap() {
  236. let latitude = this.latitude2;
  237. let longitude = this.longitude2;
  238. let address = this.address;
  239. console.log('选择腾讯', latitude, longitude);
  240. window.location.href =
  241. `http://apis.map.qq.com/uri/v1/marker?marker=coord:${latitude},${longitude};addr:${address}`;
  242. },
  243. // 调用百度
  244. tobaiDuMap() {
  245. let latitude = this.latitude2;
  246. let longitude = this.longitude2;
  247. let latitude6 = this.latitude;
  248. let longitude6 = this.longitude;
  249. let address = this.address;
  250. console.log('选择百度', latitude, longitude);
  251. console.log('获取当前经纬度', latitude6, longitude6);
  252. window.location.href =
  253. `http://api.map.baidu.com/direction?origin=latlng:${latitude6},${longitude6}|name:我的位置&destination=${latitude},${longitude}&mode=driving&region=${address}&output=html&src=webapp.baidu.openAPIdemo`;
  254. //`bdapp://map/navi?location=${longitude},${latitude}&coord_type=gc02&title=${address}&content=${address}&output=html&src=andr.baidu.openAPIdemo `
  255. },
  256. }
  257. }
  258. </script>
  259. <style lang="scss">
  260. body,
  261. page {
  262. height: 100%;
  263. width: 100%;
  264. background-color: #fff;
  265. }
  266. .content {
  267. height: 100%;
  268. width: 100%;
  269. background-color: #fff;
  270. }
  271. .map {
  272. width: 100%;
  273. height: 600rpx;
  274. }
  275. /* #ifdef H5 */
  276. .location {
  277. overflow-y: scroll; //溢出就滑动起来
  278. // z-index: 990;
  279. position: fixed;
  280. bottom: 0;
  281. height: 55%;
  282. width: 100%;
  283. background-color: #fff;
  284. padding: 24rpx;
  285. //搜索框
  286. .Search-box {
  287. // z-index: 999;
  288. height: 80rpx;
  289. // position: fixed;
  290. // top: 0;
  291. // left: 0;
  292. // width: 100%;
  293. // background: #FFFFFF;
  294. // padding-top: 10rpx;
  295. padding-right: 24rpx;
  296. padding-left: 24rpx;
  297. .Search-box-sort {
  298. float: left;
  299. margin-left: 32rpx;
  300. margin-right: 19rpx;
  301. .sort-text {
  302. width: 57rpx;
  303. height: 29rpx;
  304. font-size: 30rpx;
  305. font-weight: 500;
  306. color: rgba(51, 51, 51, 1);
  307. line-height: 58rpx;
  308. margin-right: 19rpx;
  309. }
  310. .sort-img {
  311. width: 21rpx;
  312. height: 11rpx;
  313. margin-bottom: 4rpx;
  314. }
  315. }
  316. .Search-box-size {
  317. // width:70%;
  318. height: 58rpx;
  319. border-radius: 32rpx;
  320. background-color: #f1f1f1;
  321. padding-left: 36rpx;
  322. display: flex;
  323. align-items: center;
  324. .box-img {
  325. height: 32rpx;
  326. width: 32rpx;
  327. margin-right: 16rpx;
  328. }
  329. // .box-right{
  330. // height: 58rpx;
  331. // // width: 100%;
  332. // background-color: pink;
  333. // }
  334. .box-word {
  335. width: 100%;
  336. font-size: 26rpx;
  337. font-weight: 500;
  338. color: rgba(205, 203, 203, 1);
  339. line-height: 55rpx;
  340. }
  341. }
  342. }
  343. .location-item {
  344. z-index: 1000;
  345. display: flex;
  346. justify-content: space-between;
  347. align-items: center;
  348. border-bottom: 1rpx solid #E7E8EA;
  349. padding: 15rpx 0;
  350. .box-left {
  351. display: flex;
  352. .img01 {
  353. width: 8rpx;
  354. height: 28rpx;
  355. margin-right: 18rpx;
  356. image {
  357. width: 8rpx;
  358. height: 28rpx;
  359. }
  360. }
  361. .img02 {
  362. width: 117rpx;
  363. height: 117rpx;
  364. border-radius: 50%;
  365. image {
  366. width: 117rpx;
  367. height: 117rpx;
  368. border-radius: 50%;
  369. }
  370. }
  371. .info {
  372. margin-left: 16rpx;
  373. .info-header {
  374. display: flex;
  375. align-items: center;
  376. .name {
  377. font-size: 32rpx;
  378. color: #333333;
  379. }
  380. .distance {
  381. margin-left: 25rpx;
  382. font-size: 28rpx;
  383. color: #303133;
  384. }
  385. .location-icon {
  386. margin-left: 10rpx;
  387. width: 20rpx;
  388. height: 26rpx;
  389. image {
  390. width: 20rpx;
  391. height: 26rpx;
  392. display: inline;
  393. }
  394. }
  395. }
  396. .address {
  397. font-size: 26rpx;
  398. color: #333333;
  399. margin-top: 33rpx;
  400. }
  401. }
  402. }
  403. .box-right {
  404. .img {
  405. height: 107rpx;
  406. image {
  407. width: 107rpx;
  408. height: 107rpx;
  409. }
  410. }
  411. .called {
  412. margin-right: 16rpx;
  413. height: 107rpx;
  414. line-height: 107rpx;
  415. font-size: 28rpx;
  416. color: #CB131C;
  417. }
  418. }
  419. }
  420. }
  421. /* #endif */
  422. .list-tpl {
  423. background-color: #ffffff;
  424. margin: 25rpx 0rpx;
  425. padding: 25rpx 25rpx;
  426. font-size: 28rpx;
  427. border-radius: 15rpx;
  428. display: flex;
  429. justify-content: space-between;
  430. align-items: center;
  431. border-bottom: 1px solid #f1f1f1;
  432. .list-left {
  433. display: flex;
  434. width: 100%;
  435. .number {
  436. font-size: 32rpx;
  437. margin-right: 14rpx;
  438. }
  439. .info {
  440. width: 100%;
  441. .title {
  442. font-size: 32rpx;
  443. color: #222222;
  444. font-weight: 500;
  445. }
  446. .addr {
  447. width: 400rpx;
  448. margin-top: 20rpx;
  449. font-size: 20rpx;
  450. font-family: PingFang SC;
  451. font-weight: 500;
  452. color: #999999;
  453. }
  454. }
  455. }
  456. .image {
  457. width: 10%;
  458. text-align: center;
  459. image {
  460. width: 50rpx;
  461. height: 50rpx;
  462. }
  463. .tip {
  464. color: #7f7f7f;
  465. font-size: 21rpx;
  466. }
  467. }
  468. }
  469. .popup_row {
  470. width: 100%;
  471. height: 500rpx;
  472. background-color: #ffffff;
  473. border-radius: 20rpx;
  474. display: flex;
  475. justify-content: center;
  476. align-items: center;
  477. .rows {
  478. width: 100%;
  479. padding: 0 24rpx;
  480. .rows-item {
  481. height: 80rpx;
  482. line-height: 80rpx;
  483. text-align: center;
  484. width: 100%;
  485. font-size: 32rpx;
  486. color: #303133;
  487. }
  488. }
  489. }
  490. </style>