map.js 40 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618
  1. import {
  2. imgUrl,
  3. newImgUrl
  4. } from "../api/request"
  5. import {
  6. getMapDataType,
  7. getHandMatterPage,
  8. getHandMatterBySearch,
  9. getMapDataAll,
  10. searchHandMatterByVal
  11. } from "../api/yxna-api"
  12. var QQMapWX = require('../../libs/qqmap-wx-jssdk.min.js');
  13. const popType = [
  14. [
  15. [{
  16. "name": "受理场所",
  17. "dictType": "jzs,bms",
  18. "type": ""
  19. }, {
  20. "name": "查阅场所",
  21. "dictType": "cycsbms,slcsjzs",
  22. "type": ""
  23. }, ],
  24. [{
  25. "name": "区级政务服务中心",
  26. "dictType": "xzfwzxs",
  27. "type": ""
  28. }, {
  29. "name": "镇(街道)便民服务中心",
  30. "dictType": "ggfwzxs",
  31. "type": ""
  32. }, {
  33. "name": "村(社区)便民服务站",
  34. "dictType": "bmfwzxs",
  35. "type": ""
  36. }, {
  37. "name": "生源地助学贷款办理点",
  38. "dictType": "dkblds",
  39. "type": ""
  40. }],
  41. [{
  42. "name": "党群服务中心",
  43. "dictType": "dqfwzxs",
  44. "type": ""
  45. }],
  46. [{
  47. "name": "职业教育学校",
  48. "dictType": "zyyxs",
  49. "type": ""
  50. }, {
  51. "name": "特殊教育学校",
  52. "dictType": "xxs",
  53. "type": ""
  54. }, {
  55. "name": "高等院校",
  56. "dictType": "dxs",
  57. "type": ""
  58. }, {
  59. "name": "小学",
  60. "dictType": "xxs",
  61. "type": "小学"
  62. }, {
  63. "name": "中学",
  64. "dictType": "xxs",
  65. "type": ""
  66. }, {
  67. "name": "幼儿园",
  68. "dictType": "yeys",
  69. "type": ""
  70. }, {
  71. "name": "教育考试中心",
  72. "dictType": "",
  73. "type": "jykszxs"
  74. }]
  75. ],
  76. [
  77. [{
  78. "name": "村卫生室",
  79. "dictType": "",
  80. "type": "cwsss"
  81. }, {
  82. "name": "社区卫生服务站",
  83. "dictType": "",
  84. "type": "sqwsfwzs"
  85. }, {
  86. "name": "儿科诊疗服务机构",
  87. "dictType": "ekzlfwjgs",
  88. "type": ""
  89. }, {
  90. "name": "狂犬病,破伤风处置门诊",
  91. "dictType": "kqbpsfczmzs",
  92. "type": ""
  93. }, {
  94. "name": "免疫规划预防接种门诊",
  95. "dictType": "myghyfjzmzs",
  96. "type": ""
  97. }, {
  98. "name": "二级医疗机构",
  99. "dictType": "ejyljgs",
  100. "type": ""
  101. }, {
  102. "name": "三级医疗机构",
  103. "dictType": "sjyljgs",
  104. "type": ""
  105. }, {
  106. "name": "社区卫生服务机构",
  107. "dictType": "sqwsfwjgs",
  108. "type": ""
  109. }, {
  110. "name": "职业病诊断机构",
  111. "dictType": "zybzdjgs",
  112. "type": ""
  113. }, {
  114. "name": "助产医疗机构",
  115. "dictType": "zcyljg",
  116. "type": ""
  117. }, {
  118. "name": "产科门诊服务机构",
  119. "dictType": "ckmzfwjgs",
  120. "type": ""
  121. }, {
  122. "name": "医疗保障事务中心",
  123. "dictType": "ybs",
  124. "type": ""
  125. }],
  126. [{
  127. "name": "派出所",
  128. "dictType": "pcss",
  129. "type": ""
  130. }, {
  131. "name": "出入境业务办理机构",
  132. "dictType": "crjywbljgs",
  133. "type": ""
  134. }],
  135. [{
  136. "name": "交通支大队",
  137. "dictType": "jtxljcdds",
  138. "type": ""
  139. }, {
  140. "name": "交通违法处理机构",
  141. "dictType": "jtwfcljgs",
  142. "type": ""
  143. }, {
  144. "name": "交通事故处理机构",
  145. "dictType": "jtsgcljgs",
  146. "type": ""
  147. }, {
  148. "name": "车管所",
  149. "dictType": "cgss",
  150. "type": ""
  151. }, {
  152. "name": "机动车检测场所",
  153. "dictType": "jdcjccss",
  154. "type": ""
  155. }, {
  156. "name": "驾驶人体检医院",
  157. "dictType": "jsrtjzs",
  158. "type": ""
  159. }, {
  160. "name": "车驾管社会服务站",
  161. "dictType": "cjgshfwzs",
  162. "type": ""
  163. }],
  164. [{
  165. "name": "就业和人才中心",
  166. "dictType": "jyhrczxs",
  167. "type": ""
  168. }, {
  169. "name": "社会保险事务中心",
  170. "dictType": "shbxswzxs",
  171. "type": ""
  172. }]
  173. ],
  174. [
  175. [{
  176. "name": "养老机构",
  177. "dictType": "ylfwjgs",
  178. "type": ""
  179. }],
  180. [{
  181. "name": "婚姻登记机构",
  182. "dictType": "hydjcs",
  183. "type": ""
  184. }, {
  185. "name": "殡仪服务机构",
  186. "dictType": "byfwjgs",
  187. "type": ""
  188. }],
  189. [],
  190. []
  191. ],
  192. [
  193. [],
  194. [],
  195. [],
  196. [{
  197. "name": "图书馆",
  198. "dictType": "tsgs",
  199. "type": ""
  200. }, {
  201. "name": "文化馆",
  202. "dictType": "whgs",
  203. "type": ""
  204. }, {
  205. "name": "文管所",
  206. "dictType": "wgss",
  207. "type": ""
  208. }, {
  209. "name": "公共体育馆",
  210. "dictType": "ggtys",
  211. "type": ""
  212. }, {
  213. "name": "旅游景点",
  214. "dictType": "jqs",
  215. "type": ""
  216. }, {
  217. "name": "公园",
  218. "dictType": "gys",
  219. "type": ""
  220. }]
  221. ],
  222. [
  223. [{
  224. "name": "公证处",
  225. "dictType": "gzcs",
  226. "type": ""
  227. }, {
  228. "name": "司法鉴定机构",
  229. "dictType": "sfjdjgs",
  230. "type": ""
  231. }, {
  232. "name": "基层司法所",
  233. "dictType": "jcfwfwss",
  234. "type": ""
  235. }, {
  236. "name": "法律援助机构",
  237. "dictType": "flyzzxs",
  238. "type": ""
  239. }, {
  240. "name": "矫正中心",
  241. "dictType": "jzzxs",
  242. "type": ""
  243. }],
  244. [{
  245. "name": "残疾人服务中心",
  246. "dictType": "cjrfwzxs",
  247. "type": ""
  248. }, {
  249. "name": "定点残疾人服务机构",
  250. "dictType": "qtcjrfwzxs",
  251. "type": ""
  252. }],
  253. [],
  254. [{
  255. "name": "商圈",
  256. "dictType": "sqs",
  257. "type": ""
  258. }, {
  259. "name": "购物中心",
  260. "dictType": "gwzxs",
  261. "type": ""
  262. }, {
  263. "name": "酒店",
  264. "dictType": "jds",
  265. "type": ""
  266. }]
  267. ],
  268. [
  269. [],
  270. [],
  271. [],
  272. []
  273. ]
  274. ]
  275. let BMap = {};
  276. let x = null;
  277. let y = null;
  278. const INIT_MARKER = {
  279. latitude: 0,
  280. longitude: 0,
  281. iconPath: imgUrl + "/location.png",
  282. width: '34px',
  283. height: '34px',
  284. rotate: 0,
  285. alpha: 1
  286. };
  287. Page({
  288. data: {
  289. issy:false,
  290. imgUrl: imgUrl,
  291. newImgUrl: newImgUrl,
  292. markers: [INIT_MARKER],
  293. latitude: '',
  294. longitude: '',
  295. custGap: 1000,
  296. type: [
  297. [{
  298. "id": 1,
  299. "name": "政务公开",
  300. "image": "fgk.png",
  301. "dictType": ""
  302. }, {
  303. "id": 2,
  304. "name": "政务服务",
  305. "image": "fzwfw.png",
  306. "dictType": ""
  307. }, {
  308. "id": 3,
  309. "name": "党群服务",
  310. "image": "fdqfwzx.png",
  311. "dictType": ""
  312. }, {
  313. "id": 4,
  314. "name": "教育资源",
  315. "image": "fjy.png",
  316. "dictType": ""
  317. }],
  318. [{
  319. "id": 1,
  320. "name": "医疗卫生",
  321. "image": "fyl.png",
  322. "dictType": ""
  323. }, {
  324. "id": 2,
  325. "name": "户籍管理",
  326. "image": "fhjgl.png",
  327. "dictType": ""
  328. }, {
  329. "id": 3,
  330. "name": "交通服务",
  331. "image": "fjtfw.png",
  332. "dictType": ""
  333. }, {
  334. "id": 4,
  335. "name": "社会保障",
  336. "image": "fshbz.png",
  337. "dictType": ""
  338. }],
  339. [{
  340. "id": 1,
  341. "name": "养老服务",
  342. "image": "fylfw.png",
  343. "dictType": ""
  344. }, {
  345. "id": 2,
  346. "name": "民政服务",
  347. "image": "fmzfw.png",
  348. "dictType": ""
  349. }, {
  350. "id": 3,
  351. "name": "办税服务",
  352. "image": "fbsfwt.png",
  353. "dictType": "bsfwts"
  354. }, {
  355. "id": 4,
  356. "name": "市场监管",
  357. "image": "fscjd.png",
  358. "dictType": "scjdgljs"
  359. }],
  360. [{
  361. "id": 1,
  362. "name": "住房保障",
  363. "image": "fgzf.png",
  364. "dictType": "fwglzxs"
  365. }, {
  366. "id": 2,
  367. "name": "不动产登记",
  368. "image": "fbdcdj.png",
  369. "dictType": "bdcdjzxbsdts"
  370. }, {
  371. "id": 3,
  372. "name": "住房公积金",
  373. "image": "fgjj.png",
  374. "dictType": "gjjs"
  375. }, {
  376. "id": 4,
  377. "name": "文体旅游",
  378. "image": "fwtly.png",
  379. "dictType": ""
  380. }],
  381. [{
  382. "id": 1,
  383. "name": "司法服务",
  384. "image": "fsffw.png",
  385. "dictType": ""
  386. }, {
  387. "id": 2,
  388. "name": "助疾服务",
  389. "image": "fcjr.png",
  390. "dictType": ""
  391. }, {
  392. "id": 3,
  393. "name": "产业园区",
  394. "image": "fcyy.png",
  395. "dictType": "cyys"
  396. }, {
  397. "id": 4,
  398. "name": "商业服务",
  399. "image": "fbmfw.png",
  400. "dictType": ""
  401. }],
  402. [{
  403. "id": 1,
  404. "name": "便民公厕",
  405. "image": "fgc.png",
  406. "dictType": "gcs"
  407. }, {
  408. "id": 2,
  409. "name": "停车泊车",
  410. "image": "ftc.png",
  411. "dictType": "tcs"
  412. }, {
  413. "id": 3,
  414. "name": "直饮水点",
  415. "image": "zysd.png",
  416. "dictType": "zysd"
  417. }, {
  418. "id": 4,
  419. "name": "劳动者港湾",
  420. "image": "ldzgw.png",
  421. "dictType": "ldzgw"
  422. }]
  423. ],
  424. circle: [],
  425. popData: [{
  426. "popName": "",
  427. "data": []
  428. }],
  429. showIndex: false,
  430. showSearch: true,
  431. showTraffic: true,
  432. height: 0,
  433. searchVal: '',
  434. loadValue: '',
  435. trafficStart: '',
  436. trafficEnd: '',
  437. index: 0,
  438. isList: true,
  439. showSet: false,
  440. trafficType: 0,
  441. page: 0,
  442. limit: 15,
  443. marksInfo: [],
  444. marksView: [],
  445. marksNum: 0,
  446. searchInfo: {
  447. navType: 0,
  448. isShow: false
  449. },
  450. matterEventInfo: {
  451. data: [],
  452. isShow: false,
  453. search: false
  454. },
  455. itemInfo: {
  456. page: 1,
  457. limit: 6,
  458. navType: 0,
  459. deptNow: '',
  460. pageNext: true,
  461. pagePrev: false,
  462. matterStatus: true,
  463. matterList: [{
  464. itemName: '',
  465. matterUrl: ''
  466. }],
  467. '重庆市南岸区政务服务中心(江南新城中心)': ['重庆市南岸区残联', '重庆市南岸区财政局', '重庆市南岸区文化和旅游发展委员会', '重庆市南岸区档案馆', '重庆市南岸区卫生健康委员会', '重庆市南岸区交通局', '重庆市南岸区规划自然资源局', '重庆市南岸区住房和城乡建设委员会', '重庆市南岸区生态环境局', '重庆市南岸区农业农村委员会', '重庆市南岸区发展和改革委员会', '重庆市南岸区消防救援支队', '重庆市南岸区城市管理局', '重庆市公安局南岸分局'],
  468. '重庆市南岸区政务服务中心(南坪中心)': ['重庆市南岸区市场监管局', '重庆市公安局南岸分局'],
  469. },
  470. jnxc: ['重庆市南岸区残联', '重庆市南岸区财政局', '重庆市南岸区文化和旅游发展委员会', '重庆市南岸区档案馆', '重庆市南岸区卫生健康委员会', '重庆市南岸区交通局', '重庆市南岸区规划自然资源局', '重庆市南岸区住房和城乡建设委员会', '重庆市南岸区生态环境局', '重庆市南岸区农业农村委员会', '重庆市南岸区发展和改革委员会', '重庆市南岸区消防救援支队', '重庆市南岸区城市管理局', '重庆市公安局南岸分局'],
  471. npzx: ['重庆市南岸区市场监管局', '重庆市公安局南岸分局'],
  472. toType: ''
  473. },
  474. onLoad: function (options) {
  475. this.setData({
  476. height: wx.getSystemInfoSync().windowHeight,
  477. })
  478. if (options.type && options.type == 'tdcr') {
  479. this.setData({
  480. toType: options.type,
  481. dataIndex: options.dataIndex
  482. })
  483. }
  484. // console.log(options);
  485. if (options.se) {
  486. this.setData({
  487. loadValue: options.se,
  488. showTraffic: false
  489. });
  490. } else {
  491. this.setData({
  492. showTraffic: true
  493. })
  494. }
  495. // searchVal
  496. },
  497. onReady: function () {
  498. // debugger
  499. const that = this
  500. this.loadItem();
  501. getMapDataAll().then((res) => {
  502. let arr = []
  503. console.log(res.data);
  504. for (const key in res.data) {
  505. // console.log(res.data[key]);
  506. Array.prototype.push.apply(arr, res.data[key])
  507. }
  508. // Array.prototype.push.apply(arr, res.data.xzfwzxs);
  509. // Array.prototype.push.apply(arr, res.data.ggfwzxs);
  510. for (let j = 0; j < arr.length; j++) {
  511. if (arr[j].tel && !(arr[j].tel instanceof Array)) {
  512. arr[j].tel = arr[j].tel.split(";")
  513. }
  514. }
  515. that.setData({
  516. xzfwzxs: res.data.xzfwzxs,
  517. marksInfo: arr
  518. })
  519. this.setMap();
  520. });
  521. // this.setMap();
  522. },
  523. async setMap() {
  524. var that = this;
  525. BMap = await new QQMapWX({
  526. key: 'KN3BZ-KUDND-PGH4Y-POVRP-43KF3-RNF4K'
  527. });
  528. wx.getLocation({
  529. type: 'gcj02', //返回可以用于wx.openLocation的经纬度
  530. success(res) {
  531. console.log(res)
  532. const latitude = res.latitude
  533. const longitude = res.longitude
  534. initMapDataAll(that, latitude, longitude)
  535. if (!(that.data.toType && that.data.toType == 'tdcr')) {
  536. that.setData({
  537. latitude: latitude,
  538. longitude: longitude,
  539. })
  540. } else {
  541. wx.request({
  542. url: imgUrl + 'tdcr/details/data.json',
  543. success: (res) => {
  544. // 解析中心点
  545. BMap.reverseGeocoder({
  546. location: {
  547. longitude: res.data[that.data.dataIndex].longitude,
  548. latitude: res.data[that.data.dataIndex].latitude,
  549. },
  550. success: res => {
  551. // console.log(res)
  552. that.setData({
  553. trafficEnd: res.result.formatted_addresses?.recommend
  554. })
  555. }
  556. })
  557. let polygons = []
  558. res.data[that.data.dataIndex].polygon.forEach(item => {
  559. polygons.push({
  560. dashArray: [10, 10],
  561. strokeColor: '#ffe20063',
  562. fillColor: '#ffe20063',
  563. points: item
  564. })
  565. })
  566. that.setData({
  567. polygons,
  568. longitude: res.data[that.data.dataIndex].longitude,
  569. latitude: res.data[that.data.dataIndex].latitude,
  570. })
  571. }
  572. })
  573. }
  574. that.setData({
  575. trafficStart: "我的位置",
  576. circle: [{
  577. latitude: res.latitude,
  578. longitude: res.longitude,
  579. radius: that.data.custGap + 500,
  580. fillColor: '#c4d2ec6a',
  581. color: '#c4d2ec'
  582. }],
  583. markers: [{
  584. latitude: latitude,
  585. longitude: longitude,
  586. iconPath: imgUrl + "/location.png",
  587. width: '30px',
  588. height: '30px',
  589. rotate: 0,
  590. alpha: 1
  591. }]
  592. });
  593. }
  594. });
  595. },
  596. popview(e) {
  597. let x = e.currentTarget.dataset.index;
  598. let y = e.currentTarget.dataset.id;
  599. let pop = popType[x][y - 1]
  600. if (pop.length > 0) {
  601. // this.setTypeDateToPop2(pop)
  602. this.setData({
  603. popData: pop,
  604. showIndex: true
  605. });
  606. } else {
  607. let pop = this.data.type[x][y - 1]
  608. // console.log(pop);
  609. this.setDateToPop(pop)
  610. this.setData({
  611. showTraffic: false,
  612. showIndex: false
  613. })
  614. }
  615. },
  616. setTypeDateToPop2: function (pop) {
  617. let arr = [];
  618. pop.forEach(e => {
  619. arr.push({
  620. "popName": e.name
  621. })
  622. })
  623. this.setData({
  624. popData: arr
  625. })
  626. },
  627. setDateToPop: function (pop) {
  628. let arr = [];
  629. let params = {
  630. "dictType": pop.dictType,
  631. "type": "",
  632. "title": "",
  633. };
  634. wx.showToast({
  635. title: '加载中...',
  636. icon: 'loading'
  637. });
  638. getMapDataType(params).then((res) => {
  639. console.log(res.data[0].tel);
  640. let data = []
  641. res.data.forEach((item) => {
  642. if (item.tel != null && item.tel != "" && !(item.tel instanceof Array)) {
  643. item.tel = item.tel.split(";")
  644. }
  645. data.push(item)
  646. });
  647. this.setData({
  648. popData: data,
  649. })
  650. wx.hideToast({
  651. success: (res) => {},
  652. });
  653. });
  654. },
  655. closePopup() {
  656. this.setData({
  657. showIndex: false
  658. })
  659. },
  660. changeInfo(e) {
  661. // console.log(e.currentTarget.dataset.data);
  662. let searchInfo = this.data.searchInfo
  663. searchInfo.isShow = false
  664. this.setData({
  665. searchInfo: searchInfo
  666. })
  667. let dataitem = e.currentTarget.dataset.data;
  668. console.log(dataitem);
  669. let params = {
  670. "dictType": dataitem.dictType,
  671. "type": "",
  672. "title": "",
  673. };
  674. wx.showToast({
  675. title: '加载中...',
  676. icon: 'loading'
  677. });
  678. getMapDataType(params).then((res) => {
  679. let data = []
  680. switch (dataitem.name) {
  681. case "小学":
  682. case "特殊教育学校":
  683. res.data.forEach((item) => {
  684. if (item.type == dataitem.name) {
  685. data.push(item)
  686. }
  687. });
  688. break;
  689. case "中学":
  690. res.data.forEach((item) => {
  691. if (item.type == dataitem.name || item.specialtype == dataitem.name) {
  692. data.push(item)
  693. }
  694. });
  695. break;
  696. default:
  697. data = res.data;
  698. break;
  699. }
  700. let renderData = []
  701. data.forEach((item) => {
  702. if (item.tel != null && item.tel != "" && !(item.tel instanceof Array)) {
  703. item.tel = item.tel.split(";")
  704. }
  705. renderData.push(item)
  706. });
  707. this.setData({
  708. popData: renderData,
  709. showTraffic: false,
  710. showIndex: false
  711. })
  712. wx.hideToast({
  713. success: (res) => {},
  714. });
  715. });
  716. },
  717. /**
  718. * 拨打电话
  719. * @param {*} e
  720. */
  721. callNumber(e) {
  722. let phoneNumber = e.currentTarget.dataset.value;
  723. wx.makePhoneCall({
  724. phoneNumber: phoneNumber,
  725. });
  726. },
  727. /**
  728. * list跳转info
  729. *
  730. */
  731. changeItem(e) {
  732. let that = this;
  733. console.info(e)
  734. let value = e.currentTarget.dataset.value;
  735. if (value === "none") {
  736. let searchInfo = that.data.searchInfo
  737. searchInfo.isShow = false
  738. that.setData({
  739. isList: false,
  740. showSearch: false,
  741. showSet: false,
  742. searchInfo: searchInfo
  743. });
  744. } else {
  745. // 控制公交自驾选中状态
  746. let type = e.currentTarget.dataset.type;
  747. if (type == 0) {
  748. if (e.detail.value == 0) {
  749. changeValue = "transit";
  750. } else {
  751. changeValue = "driving";
  752. }
  753. }
  754. that.setData({
  755. trafficType: type,
  756. showSet: false
  757. });
  758. that.setData({
  759. isList: false,
  760. showSearch: false,
  761. showSet: true
  762. });
  763. }
  764. // 详情赋值
  765. let index = e.currentTarget.dataset.index;
  766. let item = that.data.popData[index];
  767. console.info(item);
  768. let address = '';
  769. if (item.address.search("重庆") == -1) {
  770. address = "重庆" + item.address;
  771. } else {
  772. address = item.address;
  773. }
  774. console.log(item.time);
  775. let itemInfo = that.data.itemInfo
  776. if (itemInfo[item.dep]) {
  777. let arr = []
  778. for (let i = 0; i < itemInfo[item.dep].length; i++) {
  779. arr.push(itemInfo[item.dep][i].replace('重庆市', '').replace('南岸', ''))
  780. }
  781. itemInfo.deptList = arr
  782. itemInfo.oldDeptList = itemInfo[item.dep]
  783. }
  784. itemInfo.deptShow = itemInfo[item.dep] ? true : false
  785. itemInfo.navType = 0
  786. itemInfo.page = 1
  787. itemInfo.deptNow = ''
  788. let params = {
  789. page: 1,
  790. limit: itemInfo.limit,
  791. type: itemInfo.navType,
  792. }
  793. if (itemInfo.deptShow) {
  794. params.matterDept = itemInfo.oldDeptList.join(',')
  795. } else {
  796. params.matterDept = item.dep.replace('政府', '').replace('便民服务中心', '')
  797. }
  798. const _this = this
  799. getHandMatterPage(params).then((res) => {
  800. if (!(res && res.count > 0)) {
  801. itemInfo.matterStatus = false
  802. _this.setData({
  803. itemInfo: itemInfo
  804. })
  805. return
  806. }
  807. itemInfo.matterStatus = true
  808. itemInfo.pagePrev = itemInfo.page == 1
  809. itemInfo.pageNext = itemInfo.page * itemInfo.limit >= res.count
  810. itemInfo.matterList = res.data
  811. _this.setData({
  812. itemInfo: itemInfo
  813. })
  814. });
  815. that.setData({
  816. detail_dep: item.dep,
  817. detail_content: item.content,
  818. detail_img: item.img,
  819. detail_address: item.address,
  820. detail_time: item.time,
  821. detail_tel: item.tel,
  822. detail_index: index,
  823. trafficEnd: address,
  824. itemInfo: itemInfo
  825. });
  826. BMap.geocoder({
  827. address: address,
  828. success: function (data) {
  829. var res = data.result
  830. that.setData({
  831. latitude: res.location.lat,
  832. longitude: res.location.lng,
  833. markers: [{
  834. latitude: res.location.lat,
  835. longitude: res.location.lng,
  836. iconPath: imgUrl + "/location.png",
  837. width: '30px',
  838. height: '30px',
  839. rotate: 0,
  840. alpha: 1
  841. }]
  842. });
  843. }
  844. });
  845. },
  846. /**
  847. * 打开全景地图
  848. * @param {*} e
  849. */
  850. openVR(e) {
  851. wx.navigateTo({
  852. url: '../map-vr/map-vr',
  853. });
  854. },
  855. getSearchVal(e) {
  856. this.setData({
  857. searchVal: e.detail.value
  858. });
  859. },
  860. loadItem() {
  861. let searchVal = this.data.loadValue;
  862. let datatype = this.data.type;
  863. if (!searchVal) {
  864. return;
  865. }
  866. wx.showToast({
  867. title: '加载中...',
  868. icon: 'loading'
  869. });
  870. let x = -1
  871. let y = -1
  872. for (let i = 0; i < datatype.length; i++) {
  873. for (let j = 0; j < datatype[i].length; j++) {
  874. if (datatype[i][j].name == searchVal) {
  875. x = i
  876. y = j
  877. break;
  878. }
  879. }
  880. if (x != -1) {
  881. break;
  882. }
  883. }
  884. let searcharr = ""
  885. if (datatype[x][y].dictType != "") {
  886. searcharr = datatype[x][y].dictType
  887. } else {
  888. let arr = popType[x][y]
  889. arr.forEach((item) => {
  890. searcharr += item.dictType + ","
  891. })
  892. searcharr = searcharr.substring(0, searcharr.length - 1)
  893. }
  894. let params = {
  895. "dictType": searcharr,
  896. "type": "",
  897. "title": "",
  898. };
  899. getMapDataType(params).then((res) => {
  900. let data = []
  901. res.data.forEach((item) => {
  902. if (item.tel != null && item.tel != "" && !(item.tel instanceof Array)) {
  903. item.tel = item.tel.split(";")
  904. }
  905. data.push(item)
  906. });
  907. this.setData({
  908. // showTraffic: false,
  909. popData: data,
  910. })
  911. wx.hideToast({
  912. success: (res) => {},
  913. });
  914. });
  915. // 搜索结果
  916. },
  917. /**
  918. * 顶部搜索点击事件
  919. * @param {*} e
  920. */
  921. searchTap(e) {
  922. let searchInfo = this.data.searchInfo
  923. searchInfo.isShow = true
  924. searchInfo.navType = 0
  925. this.setData({
  926. searchInfo: searchInfo
  927. })
  928. let searchVal = this.data.searchVal;
  929. wx.showToast({
  930. title: '加载中...',
  931. icon: 'loading'
  932. });
  933. let params = {
  934. "dictType": "",
  935. "type": "",
  936. "title": searchVal,
  937. };
  938. this.setData({
  939. showTraffic: false
  940. })
  941. getMapDataType(params).then((res) => {
  942. let data = []
  943. res.data.forEach((item) => {
  944. if (item.tel != null && item.tel != "" && !(item.tel instanceof Array)) {
  945. item.tel = item.tel.split(";")
  946. }
  947. data.push(item)
  948. });
  949. this.setData({
  950. showTraffic: false,
  951. popData: data,
  952. })
  953. wx.hideToast({
  954. success: (res) => {},
  955. });
  956. });
  957. // 搜索结果
  958. wx.hideToast({
  959. success: (res) => {},
  960. });
  961. },
  962. getTrafficStart(e) {
  963. this.setData({
  964. trafficStart: e.detail.value
  965. });
  966. },
  967. getTrafficEnd(e) {
  968. this.setData({
  969. trafficEnd: e.detail.value
  970. });
  971. },
  972. /**
  973. * 搜索进行交通路线规划
  974. * @param {*} e
  975. */
  976. searchTrafficTap(e) {
  977. const that = this;
  978. // console.log(that.data.trafficType);
  979. let trafficType = that.data.trafficType;
  980. if (trafficType == 0) {
  981. changeValue = "transit";
  982. } else {
  983. changeValue = "driving";
  984. }
  985. let trafficStart = that.data.trafficStart;
  986. let trafficEnd = that.data.trafficEnd;
  987. if (!trafficStart || !trafficEnd) {
  988. wx.showToast({
  989. title: '请输入起点和终点',
  990. icon: 'none'
  991. });
  992. return;
  993. }
  994. console.info(trafficStart, trafficEnd);
  995. BMap.geocoder({
  996. address: trafficEnd,
  997. success: function (data) {
  998. console.log(data);
  999. var res = data.result
  1000. // console.log(res);
  1001. let key = 'KN3BZ-KUDND-PGH4Y-POVRP-43KF3-RNF4K'; //使用在腾讯位置服务申请的key
  1002. let referer = '掌上南岸'; //调用插件的app的名称
  1003. // 终点
  1004. let endPoint = JSON.stringify({
  1005. 'name': trafficEnd,
  1006. 'latitude': res.location.lat,
  1007. 'longitude': res.location.lng
  1008. });
  1009. wx.openLocation({
  1010. name: trafficEnd,
  1011. latitude: res.location.lat,
  1012. longitude: res.location.lng
  1013. })
  1014. // wx.navigateTo({
  1015. // url: 'plugin://routePlan/index?key=' + key + '&referer=' + referer + '&endPoint=' + endPoint + "&mode=" + changeValue
  1016. // });
  1017. },
  1018. });
  1019. },
  1020. backSearch() {
  1021. let that = this
  1022. let searchInfo = that.data.searchInfo
  1023. searchInfo.isShow = that.data.searchVal ? true : false
  1024. that.setData({
  1025. searchInfo: searchInfo
  1026. })
  1027. let matterEventInfo = that.data.matterEventInfo
  1028. console.log(matterEventInfo)
  1029. if (!that.data.isList) {
  1030. if (that.data.issy) {
  1031. that.setData({
  1032. showTraffic: true,
  1033. showSearch: true,
  1034. searchVal: ''
  1035. });
  1036. this.setMap();
  1037. return
  1038. }
  1039. matterEventInfo.isShow = searchInfo.navType != 1
  1040. this.setData({
  1041. isList: true,
  1042. showSearch: true,
  1043. showSet: false,
  1044. matterEventInfo: matterEventInfo
  1045. });
  1046. } else if (!matterEventInfo.isShow && matterEventInfo.search) {
  1047. matterEventInfo.isShow = true
  1048. this.setData({
  1049. isList: true,
  1050. showSearch: true,
  1051. showSet: false,
  1052. matterEventInfo: matterEventInfo
  1053. });
  1054. // this.setMap();
  1055. } else {
  1056. matterEventInfo.isShow = false
  1057. matterEventInfo.search = false
  1058. that.setData({
  1059. matterEventInfo: matterEventInfo
  1060. })
  1061. if (!that.data.showTraffic) {
  1062. that.setData({
  1063. showTraffic: true,
  1064. showSearch: true,
  1065. searchVal: ''
  1066. });
  1067. }
  1068. this.setMap();
  1069. }
  1070. wx.getLocation({
  1071. type: 'gcj02', //返回可以用于wx.openLocation的经纬度
  1072. success(res) {
  1073. const latitude = res.latitude
  1074. const longitude = res.longitude
  1075. that.setData({
  1076. latitude: latitude,
  1077. longitude: longitude,
  1078. trafficStart: "我的位置",
  1079. markers: [{
  1080. latitude: latitude,
  1081. longitude: longitude,
  1082. iconPath: imgUrl + "/location.png",
  1083. width: '34px',
  1084. height: '34px',
  1085. rotate: 0,
  1086. alpha: 1
  1087. }]
  1088. });
  1089. }
  1090. })
  1091. changeValue = "transit";
  1092. },
  1093. matterTab(e) {
  1094. let itemInfo = this.data.itemInfo
  1095. itemInfo.navType = e.currentTarget.dataset?.type
  1096. let params = {
  1097. page: 1,
  1098. limit: itemInfo.limit,
  1099. type: itemInfo.navType,
  1100. }
  1101. if (itemInfo.deptShow) {
  1102. if (itemInfo.deptList && itemInfo.deptList.indexOf(itemInfo.deptNow) > -1) {
  1103. params.matterDept = itemInfo.deptNow.replace('政府', '').replace('便民服务中心', '')
  1104. } else {
  1105. params.matterDept = itemInfo.oldDeptList.join(',')
  1106. }
  1107. } else {
  1108. params.matterDept = this.data.detail_dep.replace('政府', '').replace('便民服务中心', '')
  1109. }
  1110. const _this = this
  1111. getHandMatterPage(params).then((res) => {
  1112. if (!(res && res.count > 0)) {
  1113. itemInfo.matterStatus = false
  1114. _this.setData({
  1115. itemInfo: itemInfo
  1116. })
  1117. return
  1118. }
  1119. itemInfo.matterStatus = true
  1120. itemInfo.page = 1
  1121. itemInfo.pagePrev = itemInfo.page == 1
  1122. itemInfo.pageNext = itemInfo.page * itemInfo.limit >= res.count
  1123. itemInfo.matterList = res.data
  1124. _this.setData({
  1125. itemInfo: itemInfo
  1126. })
  1127. });
  1128. },
  1129. clickDept(e) {
  1130. console.log(e)
  1131. let itemInfo = this.data.itemInfo
  1132. itemInfo.deptNow = e.currentTarget.dataset.dept
  1133. itemInfo.page = 1
  1134. this.setData({
  1135. itemInfo: itemInfo
  1136. })
  1137. let params = {
  1138. page: itemInfo.page,
  1139. limit: itemInfo.limit,
  1140. type: itemInfo.navType,
  1141. }
  1142. if (itemInfo.deptShow) {
  1143. if (itemInfo.deptList && itemInfo.deptList.indexOf(itemInfo.deptNow) > -1) {
  1144. params.matterDept = itemInfo.deptNow
  1145. } else {
  1146. params.matterDept = itemInfo.oldDeptList.join(',')
  1147. }
  1148. } else {
  1149. params.matterDept = this.data.detail_dep
  1150. }
  1151. const _this = this
  1152. getHandMatterPage(params).then((res) => {
  1153. if (!(res && res.count > 0)) {
  1154. itemInfo.matterStatus = false
  1155. _this.setData({
  1156. itemInfo: itemInfo
  1157. })
  1158. return
  1159. }
  1160. itemInfo.pagePrev = itemInfo.page == 1
  1161. itemInfo.pageNext = itemInfo.page * itemInfo.limit >= res.count
  1162. itemInfo.matterList = res.data
  1163. _this.setData({
  1164. itemInfo: itemInfo
  1165. })
  1166. });
  1167. },
  1168. clickPageTo(e) {
  1169. let itemInfo = this.data.itemInfo
  1170. let page = 1
  1171. if (e.currentTarget.dataset.type == 0) {
  1172. // 上一页
  1173. if (itemInfo.pagePrev) return
  1174. page = itemInfo.page - 1
  1175. } else {
  1176. if (itemInfo.pageNext) return
  1177. page = itemInfo.page + 1
  1178. }
  1179. let params = {
  1180. page: page,
  1181. limit: itemInfo.limit,
  1182. type: itemInfo.navType,
  1183. }
  1184. if (itemInfo.deptShow) {
  1185. if (itemInfo.deptList && itemInfo.deptList.indexOf(itemInfo.deptNow) > -1) {
  1186. params.matterDept = itemInfo.deptNow.replace('政府', '').replace('便民服务中心', '')
  1187. } else {
  1188. params.matterDept = itemInfo.oldDeptList.join(',')
  1189. }
  1190. } else {
  1191. params.matterDept = this.data.detail_dep.replace('政府', '').replace('便民服务中心', '')
  1192. }
  1193. const _this = this
  1194. getHandMatterPage(params).then((res) => {
  1195. if (!(res && res.count > 0)) {
  1196. itemInfo.matterStatus = false
  1197. _this.setData({
  1198. itemInfo: itemInfo
  1199. })
  1200. return
  1201. }
  1202. itemInfo.matterStatus = true
  1203. itemInfo.page = page
  1204. itemInfo.pagePrev = itemInfo.page == 1
  1205. itemInfo.pageNext = itemInfo.page * itemInfo.limit >= res.count
  1206. itemInfo.matterList = res.data
  1207. _this.setData({
  1208. itemInfo: itemInfo
  1209. })
  1210. });
  1211. },
  1212. searchTab(e) {
  1213. let searchInfo = this.data.searchInfo
  1214. searchInfo.navType = e.currentTarget.dataset.type
  1215. this.setData({
  1216. searchInfo: searchInfo
  1217. })
  1218. const _this = this
  1219. let matterEventInfo = _this.data.matterEventInfo
  1220. if (searchInfo.navType == 0) {
  1221. matterEventInfo.isShow = false
  1222. let params = {
  1223. "title": _this.data.searchVal,
  1224. };
  1225. getMapDataType(params).then((res) => {
  1226. let data = []
  1227. res.data.forEach((item) => {
  1228. if (item.tel != null && item.tel != "" && !(item.tel instanceof Array)) {
  1229. item.tel = item.tel.split(";")
  1230. }
  1231. data.push(item)
  1232. });
  1233. this.setData({
  1234. showTraffic: false,
  1235. popData: data,
  1236. })
  1237. });
  1238. } else {
  1239. matterEventInfo.search = true
  1240. searchHandMatterByValFun(_this)
  1241. // searchHandMatter(_this)
  1242. }
  1243. _this.setData({
  1244. matterEventInfo: matterEventInfo
  1245. })
  1246. },
  1247. clickMatterEvent(e) {
  1248. const _this = this
  1249. let matterEventInfo = _this.data.matterEventInfo
  1250. matterEventInfo.isShow = false
  1251. _this.setData({
  1252. matterEventInfo: matterEventInfo
  1253. })
  1254. console.log(_this.data)
  1255. searchHandMatter(_this, e.currentTarget.dataset.depts)
  1256. },
  1257. markClick(e) {
  1258. if (!e.markerId) {
  1259. return
  1260. }
  1261. const arr = this.data.marksInfo
  1262. const that = this
  1263. this.setData({
  1264. popData: arr
  1265. })
  1266. for (let i = 0; i < arr.length; i++) {
  1267. if (arr[i].id == e.markerId) {
  1268. let searchInfo = that.data.searchInfo
  1269. searchInfo.isShow = false
  1270. that.setData({
  1271. isList: false,
  1272. showSearch: false,
  1273. showSet: false,
  1274. showTraffic: false,
  1275. searchInfo: searchInfo,
  1276. issy:true
  1277. });
  1278. let item = arr[i];
  1279. console.info(item);
  1280. if (item.tel && !(item.tel instanceof Array)) {
  1281. item.tel = item.tel.split(";")
  1282. }
  1283. let address = item.address
  1284. console.log(item.time);
  1285. let itemInfo = that.data.itemInfo
  1286. if (itemInfo[item.dep]) {
  1287. let arr = []
  1288. for (let i = 0; i < itemInfo[item.dep].length; i++) {
  1289. arr.push(itemInfo[item.dep][i].replace('重庆市', '').replace('南岸', ''))
  1290. }
  1291. itemInfo.deptList = arr
  1292. itemInfo.oldDeptList = itemInfo[item.dep]
  1293. }
  1294. itemInfo.deptShow = itemInfo[item.dep] ? true : false
  1295. itemInfo.navType = 0
  1296. itemInfo.page = 1
  1297. itemInfo.deptNow = ''
  1298. let params = {
  1299. page: 1,
  1300. limit: itemInfo.limit,
  1301. type: itemInfo.navType,
  1302. }
  1303. if (itemInfo.deptShow) {
  1304. params.matterDept = itemInfo.oldDeptList.join(',')
  1305. } else {
  1306. params.matterDept = item.dep.replace('政府', '').replace('便民服务中心', '')
  1307. }
  1308. console.log(params)
  1309. const _this = this
  1310. getHandMatterPage(params).then((res) => {
  1311. if (!(res && res.count > 0)) {
  1312. itemInfo.matterStatus = false
  1313. _this.setData({
  1314. itemInfo: itemInfo
  1315. })
  1316. return
  1317. }
  1318. itemInfo.matterStatus = true
  1319. itemInfo.pagePrev = itemInfo.page == 1
  1320. itemInfo.pageNext = itemInfo.page * itemInfo.limit >= res.count
  1321. itemInfo.matterList = res.data
  1322. _this.setData({
  1323. itemInfo: itemInfo
  1324. })
  1325. });
  1326. that.setData({
  1327. detail_dep: item.dep,
  1328. detail_content: item.content,
  1329. detail_img: item.img,
  1330. detail_address: item.address,
  1331. detail_time: item.time,
  1332. detail_tel: item.tel,
  1333. detail_index: i,
  1334. trafficEnd: address,
  1335. itemInfo: itemInfo
  1336. });
  1337. break;
  1338. }
  1339. }
  1340. },
  1341. aroundEvent(e) {
  1342. const _this = this
  1343. this.setData({
  1344. isList: true,
  1345. showSearch: false,
  1346. showSet: false,
  1347. showTraffic: false,
  1348. popData: _this.data.marksView
  1349. })
  1350. },
  1351. toDetailWeb(e) {
  1352. console.log(e.currentTarget.dataset.url)
  1353. // wx.navigateTo({
  1354. // url: '/pages/web/web?gzUrl=' + e.currentTarget.dataset.url,
  1355. // })
  1356. },
  1357. onchange(e) {
  1358. let that = this;
  1359. if (e.detail.value == 0) {
  1360. that.setData({
  1361. trafficType: 0
  1362. });
  1363. changeValue = "transit";
  1364. } else {
  1365. that.setData({
  1366. trafficType: 1
  1367. });
  1368. changeValue = "driving";
  1369. }
  1370. },
  1371. /**
  1372. * 用户点击右上角分享
  1373. */
  1374. onShareAppMessage() {
  1375. return {
  1376. title: '地图服务'
  1377. }
  1378. },
  1379. onShareTimeline() {
  1380. return {
  1381. title: '地图服务'
  1382. }
  1383. },
  1384. openShq() {
  1385. wx.navigateTo({
  1386. url: '/pages/map-shq/map-shq',
  1387. })
  1388. }
  1389. });
  1390. let changeValue = "transit";
  1391. function searchHandMatter(that, queryVal) {
  1392. // getHandMatterBySearch(queryVal).then((res) => {
  1393. // if (res.data && res.data.length) {
  1394. // searchDepVal(that, res.data.join(','), res.data)
  1395. // }
  1396. // });
  1397. searchDepVal(that, queryVal, queryVal.split(","))
  1398. }
  1399. function searchDepVal(that, queryVal, deptArr) {
  1400. let params = {
  1401. title: queryVal
  1402. }
  1403. wx.showToast({
  1404. title: '加载中...',
  1405. icon: 'loading'
  1406. });
  1407. getMapDataType(params).then((res) => {
  1408. let data = []
  1409. let st = true,
  1410. st2 = true
  1411. deptArr.forEach((item) => {
  1412. if (that.data.jnxc.indexOf(item) > -1 && st) {
  1413. st = false
  1414. let ite = that.data.xzfwzxs[0]
  1415. if (ite.tel && !(ite.tel instanceof Array)) {
  1416. ite.tel = ite.tel.split(";")
  1417. }
  1418. data.push(ite)
  1419. }
  1420. if (that.data.npzx.indexOf(item) > -1 && st2) {
  1421. st2 = false
  1422. let ite = that.data.xzfwzxs[1]
  1423. if (ite.tel && !(ite.tel instanceof Array)) {
  1424. ite.tel = ite.tel.split(";")
  1425. }
  1426. data.push(ite)
  1427. }
  1428. })
  1429. res.data.forEach((item) => {
  1430. if (item.tel != null && item.tel != "" && !(item.tel instanceof Array)) {
  1431. item.tel = item.tel.split(";")
  1432. }
  1433. data.push(item)
  1434. });
  1435. that.setData({
  1436. showTraffic: false,
  1437. popData: data,
  1438. })
  1439. wx.hideLoading()
  1440. });
  1441. wx.hideLoading()
  1442. }
  1443. function initMapDataAll(that, lat, lng) {
  1444. let arr = that.data.marksInfo
  1445. console.log(arr)
  1446. let index = 0;
  1447. let addrArr = []
  1448. let marksView = []
  1449. let task = setInterval(function () {
  1450. if (index >= arr.length) {
  1451. addrArr.push({
  1452. latitude: lat,
  1453. longitude: lng,
  1454. iconPath: imgUrl + "/location.png",
  1455. width: '30px',
  1456. height: '30px',
  1457. rotate: 0,
  1458. alpha: 1,
  1459. label: {
  1460. anchorX: 10,
  1461. anchorY: -22,
  1462. bgColor: '#fff',
  1463. borderRadius: 5,
  1464. padding: 5,
  1465. content: "我的位置",
  1466. color: '#333'
  1467. }
  1468. })
  1469. console.log(addrArr)
  1470. that.setData({
  1471. markers: addrArr,
  1472. marksView: marksView,
  1473. marksNum: addrArr.length - 1
  1474. })
  1475. clearInterval(task)
  1476. return
  1477. }
  1478. const address = arr[index]
  1479. index++
  1480. const jl = getDistances(lat, lng, address.latitude, address.longitude)
  1481. if (jl.m <= that.data.custGap) {
  1482. marksView.push(address)
  1483. addrArr.push({
  1484. id: address.id,
  1485. latitude: address.latitude,
  1486. longitude: address.longitude,
  1487. iconPath: imgUrl + "/location.png",
  1488. width: '34px',
  1489. height: '34px',
  1490. rotate: 0,
  1491. alpha: 1,
  1492. label: {
  1493. anchorX: 10,
  1494. anchorY: -22,
  1495. bgColor: '#fff',
  1496. borderRadius: 5,
  1497. padding: 5,
  1498. content: address.dep,
  1499. color: '#333'
  1500. }
  1501. })
  1502. }
  1503. // BMap.geocoder({
  1504. // address: address.address,
  1505. // success: (addr) => {
  1506. // BMap.calculateDistance({
  1507. // mode: 'straight',
  1508. // from: {
  1509. // latitude: lat,
  1510. // longitude: lng
  1511. // },
  1512. // to: [{
  1513. // latitude: addr.result.location.lat,
  1514. // longitude: addr.result.location.lng
  1515. // }],
  1516. // success: (json) => {
  1517. // console.log(getDistances(lat, lng, addr.result.location.lat, addr.result.location.lng))
  1518. // console.log(json)
  1519. // const jl = parseInt(json.result.elements[0].distance)
  1520. // if (jl <= 1000) {
  1521. // marksView.push(address)
  1522. // addrArr.push({
  1523. // id: address.id,
  1524. // latitude: json.result.elements[0].to.lat,
  1525. // longitude: json.result.elements[0].to.lng,
  1526. // iconPath: imgUrl+"/location.png",
  1527. // width: '34px',
  1528. // height: '34px',
  1529. // rotate: 0,
  1530. // alpha: 1
  1531. // })
  1532. // }
  1533. // }
  1534. // })
  1535. // }
  1536. // })
  1537. }, 10);
  1538. }
  1539. function searchHandMatterByValFun(that) {
  1540. searchHandMatterByVal(that.data.searchVal).then((res) => {
  1541. res.data.forEach((item) => {
  1542. const dept = item.depts.split(',')
  1543. let formtDept = item.fomartDept
  1544. const arr = dept.filter(value => that.data.jnxc.includes(value));
  1545. if (arr && arr.length) {
  1546. formtDept += ",区政务服务中心(江南新城中心)"
  1547. }
  1548. const arr2 = dept.filter(value => that.data.npzx.includes(value));
  1549. if (arr2 && arr2.length) {
  1550. formtDept += ",区政务服务中心(南坪中心)"
  1551. }
  1552. item.fomartDept = formtDept
  1553. })
  1554. let matterEventInfo = that.data.matterEventInfo
  1555. matterEventInfo.isShow = true
  1556. matterEventInfo.data = res.data
  1557. that.setData({
  1558. matterEventInfo: matterEventInfo
  1559. })
  1560. });
  1561. }
  1562. // 根据经纬度计算距离,参数分别为第一点的纬度,经度;第二点的纬度,经度
  1563. function getDistances(lat1, lng1, lat2, lng2) {
  1564. let EARTH_RADIUS = 6378.137; // 地球半径
  1565. let radLat1 = lat1 * Math.PI / 180.0; //lat1 * Math.PI / 180.0=>弧度计算
  1566. let radLat2 = lat2 * Math.PI / 180.0;
  1567. let a = radLat1 - radLat2;
  1568. let b = lng1 * Math.PI / 180.0 - lng2 * Math.PI / 180.0;
  1569. let 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)));
  1570. s = s * EARTH_RADIUS;
  1571. s = Math.round(s * 10000) / 10000; // 输出为公里
  1572. return {
  1573. m: s * 1000,
  1574. km: Number(s.toFixed(2))
  1575. }
  1576. }