aid.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533
  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="jhzmarker"></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.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. getDistance
  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. loaded: false,
  66. jhzmarker: [],
  67. loadtype: 'more',
  68. page: 1,
  69. limit: 10,
  70. AEDList: [],
  71. height: '',
  72. list: [],
  73. latitude: "30.353495",
  74. longitude: "114.316738",
  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. uni.showLoading({
  119. title: '加载中',
  120. mask: true
  121. });
  122. this.getDy()
  123. },
  124. computed: {
  125. ...mapState('user', ['hasLogin', 'userInfo'])
  126. },
  127. methods: {
  128. ...mapMutations('user', ['setUserInfo']),
  129. getDy() {
  130. let that = this
  131. console.log('这');
  132. uni.getLocation({
  133. type: 'gcj02',
  134. success: function(res) {
  135. console.log('当前位置的经度:' + res.longitude);
  136. console.log('当前位置的纬度:' + res.latitude);
  137. that.longitude = res.longitude
  138. that.latitude = res.latitude
  139. that.marker = [{
  140. latitude: that.latitude,
  141. longitude: that.longitude,
  142. iconPath: '/static/img/img19.png',
  143. width: '45',
  144. height: '45',
  145. }, ]
  146. that.loadData();
  147. },
  148. fail() {
  149. console.log('err');
  150. that.longitude = "114.316738"
  151. that.latitude = "30.353495"
  152. that.marker = [{
  153. latitude: that.latitude,
  154. longitude: that.longitude,
  155. iconPath: '/static/img/img19.png',
  156. width: '45',
  157. height: '45',
  158. }, ]
  159. that.loadData();
  160. }
  161. });
  162. },
  163. // 地图渲染完毕事件
  164. mapChange(e) {
  165. console.log(e);
  166. },
  167. // 载入数据
  168. async loadData() {
  169. let obj = this;
  170. if (obj.loadtype == 'loading' || obj.loadtype == 'noMore') {
  171. return
  172. }
  173. getDistance({
  174. lng1: obj.longitude,
  175. lat1: obj.latitude
  176. }).then(({
  177. data
  178. }) => {
  179. uni.hideLoading();
  180. console.log(data, 999);
  181. for (let i = 0; i < data.length; i++) {
  182. data[i].space = obj.space(obj.latitude, obj.longitude, data[i].latitude, data[i]
  183. .longitude);
  184. }
  185. let arr = data.map(item => ({
  186. latitude: item.latitude,
  187. longitude: item.longitude,
  188. iconPath: '/static/icon/jhz.png',
  189. width: '35',
  190. height: '35',
  191. id: item.id,
  192. address: item.address
  193. }));
  194. obj.jhzmarker = obj.marker.concat(arr)
  195. obj.AEDList = obj.AEDList.concat(data);
  196. console.log(obj.AEDList, 'obj.AEDList+++++++');
  197. // obj.markerList = data;
  198. obj.loaded = true
  199. if (obj.limit == data.length) {
  200. obj.loadtype = 'more';
  201. obj.page++;
  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>