aid.vue 17 KB

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