aed.vue 12 KB

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