dtl.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664
  1. <template>
  2. <div class="app-container">
  3. <div class="scoped-top-tips">洪楼plus小程序提示:点击图中区域、楼盘、学校可查看更多</div>
  4. <div class="scoped-bg"></div>
  5. <div v-if="$route.query.id === '95542fdc-b542-4582-9be2-9ab8005728d3' || $route.query.id === '95542ff1-8176-4267-8344-2aa7f1034ac5'" class="scoped-tab">
  6. <div @click="linkChange('95542fdc-b542-4582-9be2-9ab8005728d3')" :class="$route.query.id === '95542fdc-b542-4582-9be2-9ab8005728d3' ? 'op cur' : 'op'">小学</div>
  7. <div @click="linkChange('95542ff1-8176-4267-8344-2aa7f1034ac5')" :class="$route.query.id === '95542ff1-8176-4267-8344-2aa7f1034ac5' ? 'op cur' : 'op'">初中</div>
  8. </div>
  9. <el-amap
  10. class="amap-box"
  11. :vid="'amap-vue'"
  12. :amap-manager="amapManager"
  13. :zoom="mapDiyObj.zoom"
  14. :zooms="mapDiyObj.zooms"
  15. :mapStyle="mapDiyObj.mapStyle"
  16. :center="mapDiyObj.center"
  17. :events="mapEvents"
  18. :plugin="plugin"
  19. >
  20. <template v-if="mapDiyObj.zoom > 12">
  21. <template v-if="mapDiyObj.isSchoolShow === '1'">
  22. <el-amap-marker class="scoped-m-box" v-for="(marker, index) in schoolList" :key="3000 + index"
  23. icon="https://img2.honglounews.com/20220110041435-6276.png"
  24. width="20"
  25. height="20"
  26. :position="marker.position"
  27. :events="schoolEvents"
  28. :title="marker.school_name"
  29. :label="{content: marker.school_name, offset: [-10 * marker.school_name.length / 2, -20]}"
  30. :extData="{id: marker.id}"
  31. >
  32. </el-amap-marker>
  33. </template>
  34. <template v-if="mapDiyObj.isEstateShow === '1'">
  35. <el-amap-marker class="scoped-m-box" v-for="(marker, index) in estateList" :key="2000 + index"
  36. icon="https://img2.honglounews.com/20220110041411-6675.png"
  37. :position="marker.position"
  38. :events="estateEvents"
  39. :title="marker.estate_name"
  40. :label="{content: marker.estate_name, offset: [-10 * marker.estate_name.length / 2, -20]}"
  41. :extData="{id: marker.id}"
  42. >
  43. <!-- https://img2.honglounews.com/20220110041534-8330.png -->
  44. <!-- https://img2.honglounews.com/20220110041411-6675.png -->
  45. </el-amap-marker>
  46. </template>
  47. <el-amap-marker v-for="(marker, index) in markerData" :key="9000 + index"
  48. :position="marker.position"
  49. :draggable="marker.draggable"
  50. :animation="marker.animation"
  51. :offset="marker.offset"
  52. :extData="{index}"
  53. :icon="marker.icon"
  54. :title="marker.text"
  55. :events="markersEvents">
  56. <div class="scoped-marker-text" v-if="!marker.icon" :style="`color: ${marker.color}`">{{marker.text}}</div>
  57. </el-amap-marker>
  58. <!-- :label="{content: marker.text}" -->
  59. </template>
  60. <template v-else>
  61. <template v-if="mapDiyObj.isAreaShow === '1'">
  62. <el-amap-marker class="scoped-m-box" v-for="(marker, index) in areaList" :key="4000 + index"
  63. icon="https://img2.honglounews.com/20220110041435-6276.png"
  64. :position="marker.position"
  65. :events="areaEvents"
  66. :offset="[-40, -40]"
  67. :extData="{areaName: marker.areaName, areaType: marker.area_type}"
  68. >
  69. <div class="scoped-marker-area">
  70. <div class="p1">{{marker.areaName}}</div>
  71. <div class="p2">楼盘:{{marker.estate_total}}</div>
  72. <div class="p2">学校:{{marker.school_total}}</div>
  73. </div>
  74. </el-amap-marker>
  75. </template>
  76. </template>
  77. <el-amap-polygon
  78. v-for="(polygon, index) in polygons"
  79. :key="index"
  80. :path="polygon.path"
  81. :editable="polygon.editable"
  82. :fillColor="polygon.fillColor"
  83. :fillOpacity="polygon.fillOpacity"
  84. :strokeColor="polygon.strokeColor"
  85. :strokeWeight="polygon.strokeWeight"
  86. :strokeOpacity="polygon.strokeOpacity"
  87. :extData="{index}"
  88. :events="polygonEvents">
  89. </el-amap-polygon>
  90. <el-amap-polyline
  91. v-for="(polyline, index) in polylines"
  92. :key="index"
  93. :editable="polyline.editable"
  94. :fillColor="polyline.fillColor"
  95. :fillOpacity="polyline.fillOpacity"
  96. :strokeColor="polyline.strokeColor"
  97. :strokeWeight="polyline.strokeWeight"
  98. :strokeOpacity="polyline.strokeOpacity"
  99. :extData="{index}"
  100. :events="polylineEvents"
  101. :path="polyline.path">
  102. </el-amap-polyline>
  103. </el-amap>
  104. </div>
  105. </template>
  106. <script>
  107. import { AMapManager, lazyAMapApiLoaderInstance } from 'vue-amap'
  108. const amapManager = new AMapManager()
  109. import { arrToObj } from '@/utils'
  110. export default {
  111. name: 'map',
  112. components: {},
  113. data() {
  114. const that = this
  115. return {
  116. polylines: [],
  117. estateList: [],
  118. schoolList: [],
  119. medium_school_list: [],
  120. small_school_list: [],
  121. areaList: [],
  122. isDbShow: true,
  123. isMapSetShow: false,
  124. formData: [],
  125. isMteShow: false,
  126. mapDiyObj: {
  127. center: [115.852386, 28.684076],
  128. zoom: 17,
  129. zooms: [15, 19],
  130. },
  131. amapManager,
  132. polygons: [
  133. // {
  134. // path: [[115.823481,28.702359],[115.861933,28.672241],[115.812838,28.629609],[115.793784,28.657179]],
  135. // strokeWeight: 2,
  136. // fillColor: '#f00',
  137. // strokeStyle: 'solid',
  138. // },
  139. // {
  140. // path: [[115.859015,28.654919],[115.93386,28.630212],[115.841849,28.606101]],
  141. // editable: true,
  142. // strokeWeight: 1,
  143. // fillColor: '#ffffff',
  144. // strokeStyle: 'dashed',
  145. // },
  146. ],
  147. markerData: [],
  148. mapEvents: {
  149. init(map) {
  150. // map.setFeatures(['road', 'point', 'bg', 'building']); // 多个种类要素显示
  151. map.setFeatures(['road', 'bg', 'building']); // 多个种类要素显示
  152. // map.setMapStyle('amap://styles/647a4a7f773b3c7143b46e7c3e499f1f');
  153. AMapUI.loadUI(['control/BasicControl'], function(BasicControl) {
  154. //图层切换控件
  155. var layerControl = new BasicControl.LayerSwitcher({
  156. baseLayers: [
  157. {
  158. id: 'basic',//图层id,需唯一
  159. enable: true, //是否启用
  160. name: '基础地图',//显示名称,html
  161. layer: new AMap.TileLayer()
  162. },
  163. {
  164. id: 'Satellite',//图层id,需唯一
  165. enable: false, //是否启用
  166. name: '卫星图',//显示名称,html
  167. layer: new AMap.TileLayer.Satellite()
  168. },
  169. ],
  170. overlayLayers:[
  171. ],
  172. position: {
  173. bottom:'50px',
  174. right:'30px',
  175. },
  176. });
  177. map.addControl(layerControl);
  178. })
  179. },
  180. zoomchange (e) {
  181. const curMap = amapManager.getMap()
  182. that.mapDiyObj.zoom = curMap.getZoom() || 17
  183. },
  184. complete () {
  185. that.setCurFeatures(that.mapDiyObj.features)
  186. },
  187. // click(e) {
  188. // const { lng, lat } = e.lnglat
  189. // console.log(lng, lat)
  190. // },
  191. },
  192. markersEvents: {
  193. dragend(e) {
  194. const { lng, lat } = e.lnglat
  195. let markerData = JSON.parse(JSON.stringify(that.markerData))
  196. markerData[that.curMarkersIndex].position = [lng, lat]
  197. that.markerData = [...markerData]
  198. },
  199. click(e) {
  200. const eData = e.target.getExtData()
  201. that.curMarkersIndex = eData.index
  202. },
  203. },
  204. polygonEvents: {
  205. click(e) {
  206. const eData = e.target.getExtData()
  207. that.polygonIndex = eData.index
  208. // wx.miniProgram.navigateTo({url: '/pagesSchool/indexDtl?id=25'})
  209. },
  210. },
  211. polylineEvents: {
  212. click(e) {
  213. const eData = e.target.getExtData()
  214. that.polylineIndex = eData.index
  215. },
  216. },
  217. estateEvents: {
  218. click(e) {
  219. const eData = e.target.getExtData()
  220. wx.miniProgram.navigateTo({url: `/pagesHouse/indexDtl?id=${eData.id}`})
  221. },
  222. },
  223. schoolEvents: {
  224. click(e) {
  225. const eData = e.target.getExtData()
  226. wx.miniProgram.navigateTo({url: `/pagesSchool/indexDtl?id=${eData.id}`})
  227. },
  228. },
  229. areaEvents: {
  230. click(e) {
  231. const eData = e.target.getExtData()
  232. wx.miniProgram.navigateTo({url: `/pagesSchool/index?areaName=${eData.areaName}&areaType=${eData.areaType}`})
  233. },
  234. },
  235. polygonIndex: 0,
  236. polylineIndex: 0,
  237. curMarkersIndex: 0,
  238. plugin: [{
  239. pName: 'MouseTool',
  240. }],
  241. mteStr: 'polygonAdd',
  242. mteObj: {},
  243. dictData: {
  244. sys_yesno: [
  245. {key: '是', val: '1'},
  246. {key: '否', val: '2'},
  247. ],
  248. area_type: [
  249. {
  250. "key": "红谷滩中心区",
  251. "val": "hgt"
  252. },
  253. {
  254. "key": "红角洲",
  255. "val": "hjz"
  256. },
  257. {
  258. "key": "朝阳新城",
  259. "val": "cyxc"
  260. },
  261. {
  262. "key": "九龙湖",
  263. "val": "jlh"
  264. },
  265. {
  266. "key": "凤凰洲",
  267. "val": "fhz"
  268. },
  269. {
  270. "key": "西湖区",
  271. "val": "xhq"
  272. },
  273. {
  274. "key": "东湖区",
  275. "val": "dhq"
  276. },
  277. {
  278. "key": "象湖滨江",
  279. "val": "xhbj"
  280. },
  281. {
  282. "key": "青山湖区",
  283. "val": "qshq"
  284. },
  285. {
  286. "key": "新建区",
  287. "val": "xjq"
  288. },
  289. {
  290. "key": "湾里区",
  291. "val": "wlq"
  292. },
  293. {
  294. "key": "青云谱区",
  295. "val": "qypq"
  296. },
  297. {
  298. "key": "高新区",
  299. "val": "gxq"
  300. },
  301. {
  302. "key": "欣悦湖",
  303. "val": "xyh"
  304. },
  305. {
  306. "key": "经开区",
  307. "val": "jkq"
  308. },
  309. {
  310. "key": "象湖新城",
  311. "val": "xhxc"
  312. },
  313. {
  314. "key": "望城",
  315. "val": "wcxq"
  316. },
  317. {
  318. "key": "南昌县",
  319. "val": "ncx"
  320. },
  321. {
  322. "key": "赣江新区",
  323. "val": "gjxq"
  324. }
  325. ],
  326. map_area_lnglat: [
  327. {
  328. "option1": "望城",
  329. "key": "115.74219,28.622854",
  330. "val": "wcxq"
  331. },
  332. {
  333. "option1": "湾里区",
  334. "key": "115.781385,28.709504",
  335. "val": "wlq"
  336. },
  337. {
  338. "option1": "欣悦湖",
  339. "key": "115.787513,28.685376",
  340. "val": "xyh"
  341. },
  342. {
  343. "option1": "九龙湖",
  344. "key": "115.792951,28.587435",
  345. "val": "jlh"
  346. },
  347. {
  348. "option1": "新建区",
  349. "key": "115.818441,28.692623",
  350. "val": "xjq"
  351. },
  352. {
  353. "option1": "红角洲",
  354. "key": "115.824219,28.63926",
  355. "val": "hjz"
  356. },
  357. {
  358. "option1": "经开区",
  359. "key": "115.830506,28.747641",
  360. "val": "jkq"
  361. },
  362. {
  363. "option1": "象湖滨江",
  364. "key": "115.847217,28.582374",
  365. "val": "xhbj"
  366. },
  367. {
  368. "option1": "红谷滩中心区",
  369. "key": "115.852886,28.683902",
  370. "val": "hgt"
  371. },
  372. {
  373. "option1": "朝阳新城",
  374. "key": "115.858884,28.633789",
  375. "val": "cyxc"
  376. },
  377. {
  378. "option1": "凤凰洲",
  379. "key": "115.875846,28.709236",
  380. "val": "fhz"
  381. },
  382. {
  383. "option1": "西湖区",
  384. "key": "115.889966,28.664366",
  385. "val": "xhq"
  386. },
  387. {
  388. "option1": "东湖区",
  389. "key": "115.901112,28.680259",
  390. "val": "dhq"
  391. },
  392. {
  393. "option1": "青云谱区",
  394. "key": "115.908247,28.623327",
  395. "val": "qypq"
  396. },
  397. {
  398. "option1": "南昌县",
  399. "key": "115.932183,28.550813",
  400. "val": "ncx"
  401. },
  402. {
  403. "option1": "赣江新区",
  404. "key": "115.93303,28.803368",
  405. "val": "gjxq"
  406. },
  407. {
  408. "option1": "青山湖区",
  409. "key": "115.949679,28.701298",
  410. "val": "qshq"
  411. },
  412. {
  413. "option1": "高新区",
  414. "key": "116.033624,28.697981",
  415. "val": "gxq"
  416. }
  417. ]
  418. },
  419. }
  420. },
  421. computed: {},
  422. created() {
  423. this.getData()
  424. this.$api.base.apiareainfolist().then(areaArr => {
  425. const arr = areaArr.map((a, aIndex) => {
  426. return {
  427. key: aIndex,
  428. val: a.option1,
  429. longitude: a.longitude,
  430. latitude: a.latitude,
  431. areaName: a.area_name,
  432. }
  433. })
  434. this.$api.base.admmapcoordinall().then(res => {
  435. let estateList = res.estate_list || []
  436. estateList.map(item => {
  437. item.position = [item.longitude, item.latitude]
  438. })
  439. this.estateList = [...estateList]
  440. const query = this.$route.query
  441. if (query.id === '95542fdc-b542-4582-9be2-9ab8005728d3') {
  442. let small_school_list = res.small_school_list || []
  443. small_school_list.map(item => {
  444. item.position = [item.longitude, item.latitude]
  445. })
  446. this.schoolList = [...small_school_list]
  447. } else if (query.id === '95542ff1-8176-4267-8344-2aa7f1034ac5') {
  448. let medium_school_list = res.medium_school_list || []
  449. medium_school_list.map(item => {
  450. item.position = [item.longitude, item.latitude]
  451. })
  452. this.schoolList = [...medium_school_list]
  453. } else {
  454. let schoolList = res.school_list || []
  455. schoolList.map(item => {
  456. item.position = [item.longitude, item.latitude]
  457. })
  458. this.schoolList = [...schoolList]
  459. }
  460. let areaList = res.area_total || []
  461. let newAreaList = []
  462. areaList.forEach(item => {
  463. // let lnglatArr = arrToObj(this.dictData.map_area_lnglat)[item.area_type].split(',')
  464. // item.position = [lnglatArr[0], lnglatArr[1]]
  465. // item.areaName = arrToObj(this.dictData.area_type)[item.area_type]
  466. const areaIndex = arrToObj(arr)[item.area_type]
  467. if (arr[areaIndex] && arr[areaIndex].longitude) {
  468. newAreaList.push({
  469. ...item,
  470. position: [arr[areaIndex].longitude, arr[areaIndex].latitude],
  471. areaName: arr[areaIndex].areaName
  472. })
  473. }
  474. })
  475. this.areaList = [...newAreaList]
  476. })
  477. })
  478. },
  479. mounted() {},
  480. methods: {
  481. linkChange (str) {
  482. const query = this.$route.query
  483. if (query.e) {
  484. this.$router.push(`/map/dtl?e=${query.e}&id=${str}`)
  485. } else {
  486. this.$router.push(`/map/dtl?id=${str}`)
  487. }
  488. this.$router.go(0)
  489. },
  490. setCurFeatures (data) {
  491. const curMap = this.amapManager.getMap()
  492. curMap.setFeatures(data)
  493. },
  494. getData () {
  495. const query = this.$route.query
  496. this.$api.base.admmapcoordindetail({
  497. uuid: query.id
  498. }).then(res => {
  499. if (res.data) {
  500. const data = JSON.parse(res.data)
  501. this.polylines = data.polylines && data.polylines.length > 0 ? [...data.polylines] : []
  502. this.polygons = [...data.polygons]
  503. this.markerData = [...data.markerData]
  504. this.mapDiyObj = {
  505. ...data.mapDiyObj,
  506. title: res.title,
  507. }
  508. } else {
  509. this.mapDiyObj = {
  510. mapStyle: 'normal',
  511. zoom: 13,
  512. zooms: [11, 19],
  513. center: [115.852386, 28.684076],
  514. isEstateShow: '2',
  515. isSchoolShow: '2',
  516. isAreaShow: '2',
  517. title: res.title,
  518. features: ['road', 'bg', 'building']
  519. }
  520. }
  521. document.title = res.title || '洪楼地图1'
  522. // this.getDef()
  523. })
  524. },
  525. }
  526. }
  527. </script>
  528. <style lang="scss" scoped>
  529. .app-container {
  530. height: 100%;
  531. padding: 0;
  532. margin: 0;
  533. position: relative;
  534. .amap-box {
  535. height: 100%;
  536. }
  537. }
  538. .scoped-marker-text {
  539. color: #fff;
  540. min-width: 100px;
  541. font-weight: bold;
  542. box-shadow: 0 0 2px #fff;
  543. text-align: center;
  544. padding: 2px 6px;
  545. border-radius: 6px;
  546. background: #369af7;
  547. }
  548. .scoped-select-center {
  549. position: absolute;
  550. left: -75px;
  551. top: 0px;
  552. cursor: pointer;
  553. width: 60px;
  554. line-height: 14px;
  555. color: #313131;
  556. .s {
  557. color: #f00;
  558. font-size: 12px;
  559. }
  560. }
  561. ::v-deep .amap-marker-label {
  562. border-color: #dcdcdc;
  563. border-radius: 2px;
  564. padding: 3px 5px;
  565. color: #666;
  566. background: #fff;
  567. box-shadow: 0 0 3px #ccc;
  568. }
  569. ::v-deep .amap-logo{
  570. display: none!important;;
  571. }
  572. ::v-deep .amap-copyright {
  573. opacity:0;
  574. }
  575. ::v-deep .amap-icon img {
  576. width: 20px !important;
  577. height: 20px !important;
  578. }
  579. .scoped-marker-area {
  580. background: #369af7;
  581. box-shadow: 0 0 5px #369af7;
  582. color: #fff;
  583. width: 80px;
  584. height: 80px;
  585. text-align: center;
  586. font-size: 12px;
  587. border-radius: 50%;
  588. padding-top: 20px;
  589. box-sizing: border-box;
  590. }
  591. .scoped-bg {
  592. width: 180px;
  593. height: 30px;
  594. background: url(./img/bg.png);
  595. background-size: 100%;
  596. position: fixed;
  597. z-index: 999999;
  598. // left: 50%;
  599. // top: 50%;
  600. // margin-left: -150px;
  601. // margin-top: -25px;
  602. // transform: rotate(-45deg);
  603. left: 10px;
  604. bottom: 0;
  605. }
  606. .scoped-top-tips {
  607. position: fixed;
  608. z-index: 999999;
  609. top: 0;
  610. left: 0;
  611. width: 100%;
  612. color: #5caac1; //#de8c17;
  613. background: #fcf6ed;
  614. font-size: 12px;
  615. padding: 10px;
  616. opacity: .8;
  617. font-weight: bold;
  618. }
  619. .scoped-tab {
  620. position: fixed;
  621. right: 0;
  622. top: 50%;
  623. background: #fff;
  624. z-index: 9999999;
  625. cursor: pointer;
  626. padding: 10px;
  627. border-radius: 20px 0 0 20px;
  628. box-shadow: 0 0 10px #ccc;
  629. .op {
  630. color: #313131;
  631. height: 30px;
  632. line-height: 30px;
  633. padding: 0 2px;
  634. font-size: 14px;
  635. &:last-child {
  636. border-top: 1px solid #dcdcdc;
  637. }
  638. &.cur {
  639. color: #409eff;
  640. font-weight: bold;
  641. }
  642. }
  643. }
  644. </style>