aed.vue 14 KB

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