map.js 38 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571
  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. },
  473. onLoad: function (options) {
  474. this.setData({
  475. height: wx.getSystemInfoSync().windowHeight
  476. })
  477. // console.log(options);
  478. if (options.se) {
  479. this.setData({
  480. loadValue: options.se,
  481. showTraffic: false
  482. });
  483. } else {
  484. this.setData({
  485. showTraffic: true
  486. })
  487. }
  488. // searchVal
  489. },
  490. onReady: function () {
  491. // debugger
  492. const that = this
  493. this.loadItem();
  494. getMapDataAll().then((res) => {
  495. let arr = []
  496. console.log(res.data);
  497. for (const key in res.data) {
  498. // console.log(res.data[key]);
  499. Array.prototype.push.apply(arr, res.data[key])
  500. }
  501. // Array.prototype.push.apply(arr, res.data.xzfwzxs);
  502. // Array.prototype.push.apply(arr, res.data.ggfwzxs);
  503. for (let j = 0; j < arr.length; j++) {
  504. if (arr[j].tel && !(arr[j].tel instanceof Array)) {
  505. arr[j].tel = arr[j].tel.split(";")
  506. }
  507. }
  508. that.setData({
  509. xzfwzxs: res.data.xzfwzxs,
  510. marksInfo: arr
  511. })
  512. this.setMap();
  513. });
  514. // this.setMap();
  515. },
  516. async setMap() {
  517. var that = this;
  518. BMap = await new QQMapWX({
  519. key: 'KN3BZ-KUDND-PGH4Y-POVRP-43KF3-RNF4K'
  520. });
  521. wx.getLocation({
  522. type: 'gcj02', //返回可以用于wx.openLocation的经纬度
  523. success(res) {
  524. console.log(res)
  525. const latitude = res.latitude
  526. const longitude = res.longitude
  527. initMapDataAll(that, latitude, longitude)
  528. that.setData({
  529. latitude: latitude,
  530. longitude: longitude,
  531. trafficStart: "我的位置",
  532. circle: [{
  533. latitude: res.latitude,
  534. longitude: res.longitude,
  535. radius: that.data.custGap + 500,
  536. fillColor: '#c4d2ec6a',
  537. color: '#c4d2ec'
  538. }],
  539. markers: [{
  540. latitude: latitude,
  541. longitude: longitude,
  542. iconPath: imgUrl + "/location.png",
  543. width: '30px',
  544. height: '30px',
  545. rotate: 0,
  546. alpha: 1
  547. }]
  548. });
  549. }
  550. });
  551. },
  552. popview(e) {
  553. let x = e.currentTarget.dataset.index;
  554. let y = e.currentTarget.dataset.id;
  555. let pop = popType[x][y - 1]
  556. if (pop.length > 0) {
  557. // this.setTypeDateToPop2(pop)
  558. this.setData({
  559. popData: pop,
  560. showIndex: true
  561. });
  562. } else {
  563. let pop = this.data.type[x][y - 1]
  564. // console.log(pop);
  565. this.setDateToPop(pop)
  566. this.setData({
  567. showTraffic: false,
  568. showIndex: false
  569. })
  570. }
  571. },
  572. setTypeDateToPop2: function (pop) {
  573. let arr = [];
  574. pop.forEach(e => {
  575. arr.push({
  576. "popName": e.name
  577. })
  578. })
  579. this.setData({
  580. popData: arr
  581. })
  582. },
  583. setDateToPop: function (pop) {
  584. let arr = [];
  585. let params = {
  586. "dictType": pop.dictType,
  587. "type": "",
  588. "title": "",
  589. };
  590. wx.showToast({
  591. title: '加载中...',
  592. icon: 'loading'
  593. });
  594. getMapDataType(params).then((res) => {
  595. console.log(res.data[0].tel);
  596. let data = []
  597. res.data.forEach((item) => {
  598. if (item.tel != null && item.tel != "" && !(item.tel instanceof Array)) {
  599. item.tel = item.tel.split(";")
  600. }
  601. data.push(item)
  602. });
  603. this.setData({
  604. popData: data,
  605. })
  606. wx.hideToast({
  607. success: (res) => {},
  608. });
  609. });
  610. },
  611. closePopup() {
  612. this.setData({
  613. showIndex: false
  614. })
  615. },
  616. changeInfo(e) {
  617. // console.log(e.currentTarget.dataset.data);
  618. let searchInfo = this.data.searchInfo
  619. searchInfo.isShow = false
  620. this.setData({
  621. searchInfo: searchInfo
  622. })
  623. let dataitem = e.currentTarget.dataset.data;
  624. console.log(dataitem);
  625. let params = {
  626. "dictType": dataitem.dictType,
  627. "type": "",
  628. "title": "",
  629. };
  630. wx.showToast({
  631. title: '加载中...',
  632. icon: 'loading'
  633. });
  634. getMapDataType(params).then((res) => {
  635. let data = []
  636. switch (dataitem.name) {
  637. case "小学":
  638. case "特殊教育学校":
  639. res.data.forEach((item) => {
  640. if (item.type == dataitem.name) {
  641. data.push(item)
  642. }
  643. });
  644. break;
  645. case "中学":
  646. res.data.forEach((item) => {
  647. if (item.type == dataitem.name || item.specialtype == dataitem.name) {
  648. data.push(item)
  649. }
  650. });
  651. break;
  652. default:
  653. data = res.data;
  654. break;
  655. }
  656. let renderData = []
  657. data.forEach((item) => {
  658. if (item.tel != null && item.tel != "" && !(item.tel instanceof Array)) {
  659. item.tel = item.tel.split(";")
  660. }
  661. renderData.push(item)
  662. });
  663. this.setData({
  664. popData: renderData,
  665. showTraffic: false,
  666. showIndex: false
  667. })
  668. wx.hideToast({
  669. success: (res) => {},
  670. });
  671. });
  672. },
  673. /**
  674. * 拨打电话
  675. * @param {*} e
  676. */
  677. callNumber(e) {
  678. let phoneNumber = e.currentTarget.dataset.value;
  679. wx.makePhoneCall({
  680. phoneNumber: phoneNumber,
  681. });
  682. },
  683. /**
  684. * list跳转info
  685. *
  686. */
  687. changeItem(e) {
  688. let that = this;
  689. console.info(e)
  690. let value = e.currentTarget.dataset.value;
  691. if (value === "none") {
  692. let searchInfo = that.data.searchInfo
  693. searchInfo.isShow = false
  694. that.setData({
  695. isList: false,
  696. showSearch: false,
  697. showSet: false,
  698. searchInfo: searchInfo
  699. });
  700. } else {
  701. // 控制公交自驾选中状态
  702. let type = e.currentTarget.dataset.type;
  703. if (type == 0) {
  704. if (e.detail.value == 0) {
  705. changeValue = "transit";
  706. } else {
  707. changeValue = "driving";
  708. }
  709. }
  710. that.setData({
  711. trafficType: type,
  712. showSet: false
  713. });
  714. that.setData({
  715. isList: false,
  716. showSearch: false,
  717. showSet: true
  718. });
  719. }
  720. // 详情赋值
  721. let index = e.currentTarget.dataset.index;
  722. let item = that.data.popData[index];
  723. console.info(item);
  724. let address = '';
  725. if (item.address.search("重庆") == -1) {
  726. address = "重庆" + item.address;
  727. } else {
  728. address = item.address;
  729. }
  730. console.log(item.time);
  731. let itemInfo = that.data.itemInfo
  732. if (itemInfo[item.dep]) {
  733. let arr = []
  734. for (let i = 0; i < itemInfo[item.dep].length; i++) {
  735. arr.push(itemInfo[item.dep][i].replace('重庆市', '').replace('南岸', ''))
  736. }
  737. itemInfo.deptList = arr
  738. itemInfo.oldDeptList = itemInfo[item.dep]
  739. }
  740. itemInfo.deptShow = itemInfo[item.dep] ? true : false
  741. itemInfo.navType = 0
  742. itemInfo.page = 1
  743. itemInfo.deptNow = ''
  744. let params = {
  745. page: 1,
  746. limit: itemInfo.limit,
  747. type: itemInfo.navType,
  748. }
  749. if (itemInfo.deptShow) {
  750. params.matterDept = itemInfo.oldDeptList.join(',')
  751. } else {
  752. params.matterDept = item.dep.replace('政府', '').replace('便民服务中心', '')
  753. }
  754. const _this = this
  755. getHandMatterPage(params).then((res) => {
  756. if (!(res && res.count > 0)) {
  757. itemInfo.matterStatus = false
  758. _this.setData({
  759. itemInfo: itemInfo
  760. })
  761. return
  762. }
  763. itemInfo.matterStatus = true
  764. itemInfo.pagePrev = itemInfo.page == 1
  765. itemInfo.pageNext = itemInfo.page * itemInfo.limit >= res.count
  766. itemInfo.matterList = res.data
  767. _this.setData({
  768. itemInfo: itemInfo
  769. })
  770. });
  771. that.setData({
  772. detail_dep: item.dep,
  773. detail_content: item.content,
  774. detail_img: item.img,
  775. detail_address: item.address,
  776. detail_time: item.time,
  777. detail_tel: item.tel,
  778. detail_index: index,
  779. trafficEnd: address,
  780. itemInfo: itemInfo
  781. });
  782. BMap.geocoder({
  783. address: address,
  784. success: function (data) {
  785. var res = data.result
  786. that.setData({
  787. latitude: res.location.lat,
  788. longitude: res.location.lng,
  789. markers: [{
  790. latitude: res.location.lat,
  791. longitude: res.location.lng,
  792. iconPath: imgUrl + "/location.png",
  793. width: '30px',
  794. height: '30px',
  795. rotate: 0,
  796. alpha: 1
  797. }]
  798. });
  799. }
  800. });
  801. },
  802. /**
  803. * 打开全景地图
  804. * @param {*} e
  805. */
  806. openVR(e) {
  807. wx.navigateTo({
  808. url: '../map-vr/map-vr',
  809. });
  810. },
  811. getSearchVal(e) {
  812. this.setData({
  813. searchVal: e.detail.value
  814. });
  815. },
  816. loadItem() {
  817. let searchVal = this.data.loadValue;
  818. let datatype = this.data.type;
  819. if (!searchVal) {
  820. return;
  821. }
  822. wx.showToast({
  823. title: '加载中...',
  824. icon: 'loading'
  825. });
  826. let x = -1
  827. let y = -1
  828. for (let i = 0; i < datatype.length; i++) {
  829. for (let j = 0; j < datatype[i].length; j++) {
  830. if (datatype[i][j].name == searchVal) {
  831. x = i
  832. y = j
  833. break;
  834. }
  835. }
  836. if (x != -1) {
  837. break;
  838. }
  839. }
  840. let searcharr = ""
  841. if (datatype[x][y].dictType != "") {
  842. searcharr = datatype[x][y].dictType
  843. } else {
  844. let arr = popType[x][y]
  845. arr.forEach((item) => {
  846. searcharr += item.dictType + ","
  847. })
  848. searcharr = searcharr.substring(0, searcharr.length - 1)
  849. }
  850. let params = {
  851. "dictType": searcharr,
  852. "type": "",
  853. "title": "",
  854. };
  855. getMapDataType(params).then((res) => {
  856. let data = []
  857. res.data.forEach((item) => {
  858. if (item.tel != null && item.tel != "" && !(item.tel instanceof Array)) {
  859. item.tel = item.tel.split(";")
  860. }
  861. data.push(item)
  862. });
  863. this.setData({
  864. // showTraffic: false,
  865. popData: data,
  866. })
  867. wx.hideToast({
  868. success: (res) => {},
  869. });
  870. });
  871. // 搜索结果
  872. },
  873. /**
  874. * 顶部搜索点击事件
  875. * @param {*} e
  876. */
  877. searchTap(e) {
  878. let searchInfo = this.data.searchInfo
  879. searchInfo.isShow = true
  880. searchInfo.navType = 0
  881. this.setData({
  882. searchInfo: searchInfo
  883. })
  884. let searchVal = this.data.searchVal;
  885. wx.showToast({
  886. title: '加载中...',
  887. icon: 'loading'
  888. });
  889. let params = {
  890. "dictType": "",
  891. "type": "",
  892. "title": searchVal,
  893. };
  894. this.setData({
  895. showTraffic: false
  896. })
  897. getMapDataType(params).then((res) => {
  898. let data = []
  899. res.data.forEach((item) => {
  900. if (item.tel != null && item.tel != "" && !(item.tel instanceof Array)) {
  901. item.tel = item.tel.split(";")
  902. }
  903. data.push(item)
  904. });
  905. this.setData({
  906. showTraffic: false,
  907. popData: data,
  908. })
  909. wx.hideToast({
  910. success: (res) => {},
  911. });
  912. });
  913. // 搜索结果
  914. wx.hideToast({
  915. success: (res) => {},
  916. });
  917. },
  918. getTrafficStart(e) {
  919. this.setData({
  920. trafficStart: e.detail.value
  921. });
  922. },
  923. getTrafficEnd(e) {
  924. this.setData({
  925. trafficEnd: e.detail.value
  926. });
  927. },
  928. /**
  929. * 搜索进行交通路线规划
  930. * @param {*} e
  931. */
  932. searchTrafficTap(e) {
  933. const that = this;
  934. // console.log(that.data.trafficType);
  935. let trafficType = that.data.trafficType;
  936. if (trafficType == 0) {
  937. changeValue = "transit";
  938. } else {
  939. changeValue = "driving";
  940. }
  941. let trafficStart = that.data.trafficStart;
  942. let trafficEnd = that.data.trafficEnd;
  943. if (!trafficStart || !trafficEnd) {
  944. wx.showToast({
  945. title: '请输入起点和终点',
  946. icon: 'none'
  947. });
  948. return;
  949. }
  950. console.info(trafficStart, trafficEnd);
  951. BMap.geocoder({
  952. address: trafficEnd,
  953. success: function (data) {
  954. console.log(data);
  955. var res = data.result
  956. // console.log(res);
  957. let key = 'KN3BZ-KUDND-PGH4Y-POVRP-43KF3-RNF4K'; //使用在腾讯位置服务申请的key
  958. let referer = '掌上南岸'; //调用插件的app的名称
  959. // 终点
  960. let endPoint = JSON.stringify({
  961. 'name': trafficEnd,
  962. 'latitude': res.location.lat,
  963. 'longitude': res.location.lng
  964. });
  965. wx.openLocation({
  966. name: trafficEnd,
  967. latitude: res.location.lat,
  968. longitude: res.location.lng
  969. })
  970. // wx.navigateTo({
  971. // url: 'plugin://routePlan/index?key=' + key + '&referer=' + referer + '&endPoint=' + endPoint + "&mode=" + changeValue
  972. // });
  973. },
  974. });
  975. },
  976. backSearch() {
  977. let that = this
  978. let searchInfo = that.data.searchInfo
  979. searchInfo.isShow = that.data.searchVal ? true : false
  980. that.setData({
  981. searchInfo: searchInfo
  982. })
  983. let matterEventInfo = that.data.matterEventInfo
  984. console.log(matterEventInfo)
  985. if (!that.data.isList) {
  986. if (that.data.issy) {
  987. that.setData({
  988. showTraffic: true,
  989. showSearch: true,
  990. searchVal: ''
  991. });
  992. this.setMap();
  993. return
  994. }
  995. matterEventInfo.isShow = searchInfo.navType != 1
  996. this.setData({
  997. isList: true,
  998. showSearch: true,
  999. showSet: false,
  1000. matterEventInfo: matterEventInfo
  1001. });
  1002. } else if (!matterEventInfo.isShow && matterEventInfo.search) {
  1003. matterEventInfo.isShow = true
  1004. this.setData({
  1005. isList: true,
  1006. showSearch: true,
  1007. showSet: false,
  1008. matterEventInfo: matterEventInfo
  1009. });
  1010. // this.setMap();
  1011. } else {
  1012. matterEventInfo.isShow = false
  1013. matterEventInfo.search = false
  1014. that.setData({
  1015. matterEventInfo: matterEventInfo
  1016. })
  1017. if (!that.data.showTraffic) {
  1018. that.setData({
  1019. showTraffic: true,
  1020. showSearch: true,
  1021. searchVal: ''
  1022. });
  1023. }
  1024. this.setMap();
  1025. }
  1026. wx.getLocation({
  1027. type: 'gcj02', //返回可以用于wx.openLocation的经纬度
  1028. success(res) {
  1029. const latitude = res.latitude
  1030. const longitude = res.longitude
  1031. that.setData({
  1032. latitude: latitude,
  1033. longitude: longitude,
  1034. trafficStart: "我的位置",
  1035. markers: [{
  1036. latitude: latitude,
  1037. longitude: longitude,
  1038. iconPath: imgUrl + "/location.png",
  1039. width: '34px',
  1040. height: '34px',
  1041. rotate: 0,
  1042. alpha: 1
  1043. }]
  1044. });
  1045. }
  1046. })
  1047. changeValue = "transit";
  1048. },
  1049. matterTab(e) {
  1050. let itemInfo = this.data.itemInfo
  1051. itemInfo.navType = e.currentTarget.dataset?.type
  1052. let params = {
  1053. page: 1,
  1054. limit: itemInfo.limit,
  1055. type: itemInfo.navType,
  1056. }
  1057. if (itemInfo.deptShow) {
  1058. if (itemInfo.deptList && itemInfo.deptList.indexOf(itemInfo.deptNow) > -1) {
  1059. params.matterDept = itemInfo.deptNow.replace('政府', '').replace('便民服务中心', '')
  1060. } else {
  1061. params.matterDept = itemInfo.oldDeptList.join(',')
  1062. }
  1063. } else {
  1064. params.matterDept = this.data.detail_dep.replace('政府', '').replace('便民服务中心', '')
  1065. }
  1066. const _this = this
  1067. getHandMatterPage(params).then((res) => {
  1068. if (!(res && res.count > 0)) {
  1069. itemInfo.matterStatus = false
  1070. _this.setData({
  1071. itemInfo: itemInfo
  1072. })
  1073. return
  1074. }
  1075. itemInfo.matterStatus = true
  1076. itemInfo.page = 1
  1077. itemInfo.pagePrev = itemInfo.page == 1
  1078. itemInfo.pageNext = itemInfo.page * itemInfo.limit >= res.count
  1079. itemInfo.matterList = res.data
  1080. _this.setData({
  1081. itemInfo: itemInfo
  1082. })
  1083. });
  1084. },
  1085. clickDept(e) {
  1086. console.log(e)
  1087. let itemInfo = this.data.itemInfo
  1088. itemInfo.deptNow = e.currentTarget.dataset.dept
  1089. itemInfo.page = 1
  1090. this.setData({
  1091. itemInfo: itemInfo
  1092. })
  1093. let params = {
  1094. page: itemInfo.page,
  1095. limit: itemInfo.limit,
  1096. type: itemInfo.navType,
  1097. }
  1098. if (itemInfo.deptShow) {
  1099. if (itemInfo.deptList && itemInfo.deptList.indexOf(itemInfo.deptNow) > -1) {
  1100. params.matterDept = itemInfo.deptNow
  1101. } else {
  1102. params.matterDept = itemInfo.oldDeptList.join(',')
  1103. }
  1104. } else {
  1105. params.matterDept = this.data.detail_dep
  1106. }
  1107. const _this = this
  1108. getHandMatterPage(params).then((res) => {
  1109. if (!(res && res.count > 0)) {
  1110. itemInfo.matterStatus = false
  1111. _this.setData({
  1112. itemInfo: itemInfo
  1113. })
  1114. return
  1115. }
  1116. itemInfo.pagePrev = itemInfo.page == 1
  1117. itemInfo.pageNext = itemInfo.page * itemInfo.limit >= res.count
  1118. itemInfo.matterList = res.data
  1119. _this.setData({
  1120. itemInfo: itemInfo
  1121. })
  1122. });
  1123. },
  1124. clickPageTo(e) {
  1125. let itemInfo = this.data.itemInfo
  1126. let page = 1
  1127. if (e.currentTarget.dataset.type == 0) {
  1128. // 上一页
  1129. if (itemInfo.pagePrev) return
  1130. page = itemInfo.page - 1
  1131. } else {
  1132. if (itemInfo.pageNext) return
  1133. page = itemInfo.page + 1
  1134. }
  1135. let params = {
  1136. page: page,
  1137. limit: itemInfo.limit,
  1138. type: itemInfo.navType,
  1139. }
  1140. if (itemInfo.deptShow) {
  1141. if (itemInfo.deptList && itemInfo.deptList.indexOf(itemInfo.deptNow) > -1) {
  1142. params.matterDept = itemInfo.deptNow.replace('政府', '').replace('便民服务中心', '')
  1143. } else {
  1144. params.matterDept = itemInfo.oldDeptList.join(',')
  1145. }
  1146. } else {
  1147. params.matterDept = this.data.detail_dep.replace('政府', '').replace('便民服务中心', '')
  1148. }
  1149. const _this = this
  1150. getHandMatterPage(params).then((res) => {
  1151. if (!(res && res.count > 0)) {
  1152. itemInfo.matterStatus = false
  1153. _this.setData({
  1154. itemInfo: itemInfo
  1155. })
  1156. return
  1157. }
  1158. itemInfo.matterStatus = true
  1159. itemInfo.page = page
  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. searchTab(e) {
  1169. let searchInfo = this.data.searchInfo
  1170. searchInfo.navType = e.currentTarget.dataset.type
  1171. this.setData({
  1172. searchInfo: searchInfo
  1173. })
  1174. const _this = this
  1175. if (searchInfo.navType == 0) {
  1176. let params = {
  1177. "title": _this.data.searchVal,
  1178. };
  1179. getMapDataType(params).then((res) => {
  1180. let data = []
  1181. res.data.forEach((item) => {
  1182. if (item.tel != null && item.tel != "" && !(item.tel instanceof Array)) {
  1183. item.tel = item.tel.split(";")
  1184. }
  1185. data.push(item)
  1186. });
  1187. this.setData({
  1188. showTraffic: false,
  1189. popData: data,
  1190. })
  1191. });
  1192. } else {
  1193. let matterEventInfo = _this.data.matterEventInfo
  1194. matterEventInfo.search = true
  1195. _this.setData({
  1196. matterEventInfo: matterEventInfo
  1197. })
  1198. searchHandMatterByValFun(_this)
  1199. // searchHandMatter(_this)
  1200. }
  1201. },
  1202. clickMatterEvent(e) {
  1203. const _this = this
  1204. let matterEventInfo = _this.data.matterEventInfo
  1205. matterEventInfo.isShow = false
  1206. _this.setData({
  1207. matterEventInfo: matterEventInfo
  1208. })
  1209. console.log(_this.data)
  1210. searchHandMatter(_this, e.currentTarget.dataset.depts)
  1211. },
  1212. markClick(e) {
  1213. if (!e.markerId) {
  1214. return
  1215. }
  1216. const arr = this.data.marksInfo
  1217. const that = this
  1218. this.setData({
  1219. popData: arr
  1220. })
  1221. for (let i = 0; i < arr.length; i++) {
  1222. if (arr[i].id == e.markerId) {
  1223. let searchInfo = that.data.searchInfo
  1224. searchInfo.isShow = false
  1225. that.setData({
  1226. isList: false,
  1227. showSearch: false,
  1228. showSet: false,
  1229. showTraffic: false,
  1230. searchInfo: searchInfo,
  1231. issy:true
  1232. });
  1233. let item = arr[i];
  1234. console.info(item);
  1235. if (item.tel && !(item.tel instanceof Array)) {
  1236. item.tel = item.tel.split(";")
  1237. }
  1238. let address = item.address
  1239. console.log(item.time);
  1240. let itemInfo = that.data.itemInfo
  1241. if (itemInfo[item.dep]) {
  1242. let arr = []
  1243. for (let i = 0; i < itemInfo[item.dep].length; i++) {
  1244. arr.push(itemInfo[item.dep][i].replace('重庆市', '').replace('南岸', ''))
  1245. }
  1246. itemInfo.deptList = arr
  1247. itemInfo.oldDeptList = itemInfo[item.dep]
  1248. }
  1249. itemInfo.deptShow = itemInfo[item.dep] ? true : false
  1250. itemInfo.navType = 0
  1251. itemInfo.page = 1
  1252. itemInfo.deptNow = ''
  1253. let params = {
  1254. page: 1,
  1255. limit: itemInfo.limit,
  1256. type: itemInfo.navType,
  1257. }
  1258. if (itemInfo.deptShow) {
  1259. params.matterDept = itemInfo.oldDeptList.join(',')
  1260. } else {
  1261. params.matterDept = item.dep.replace('政府', '').replace('便民服务中心', '')
  1262. }
  1263. console.log(params)
  1264. const _this = this
  1265. getHandMatterPage(params).then((res) => {
  1266. if (!(res && res.count > 0)) {
  1267. itemInfo.matterStatus = false
  1268. _this.setData({
  1269. itemInfo: itemInfo
  1270. })
  1271. return
  1272. }
  1273. itemInfo.matterStatus = true
  1274. itemInfo.pagePrev = itemInfo.page == 1
  1275. itemInfo.pageNext = itemInfo.page * itemInfo.limit >= res.count
  1276. itemInfo.matterList = res.data
  1277. _this.setData({
  1278. itemInfo: itemInfo
  1279. })
  1280. });
  1281. that.setData({
  1282. detail_dep: item.dep,
  1283. detail_content: item.content,
  1284. detail_img: item.img,
  1285. detail_address: item.address,
  1286. detail_time: item.time,
  1287. detail_tel: item.tel,
  1288. detail_index: i,
  1289. trafficEnd: address,
  1290. itemInfo: itemInfo
  1291. });
  1292. break;
  1293. }
  1294. }
  1295. },
  1296. aroundEvent(e) {
  1297. const _this = this
  1298. this.setData({
  1299. isList: true,
  1300. showSearch: false,
  1301. showSet: false,
  1302. showTraffic: false,
  1303. popData: _this.data.marksView
  1304. })
  1305. },
  1306. toDetailWeb(e) {
  1307. console.log(e.currentTarget.dataset.url)
  1308. // wx.navigateTo({
  1309. // url: '/pages/web/web?gzUrl=' + e.currentTarget.dataset.url,
  1310. // })
  1311. },
  1312. onchange(e) {
  1313. let that = this;
  1314. if (e.detail.value == 0) {
  1315. that.setData({
  1316. trafficType: 0
  1317. });
  1318. changeValue = "transit";
  1319. } else {
  1320. that.setData({
  1321. trafficType: 1
  1322. });
  1323. changeValue = "driving";
  1324. }
  1325. },
  1326. /**
  1327. * 用户点击右上角分享
  1328. */
  1329. onShareAppMessage() {
  1330. return {
  1331. title: '地图服务'
  1332. }
  1333. },
  1334. onShareTimeline() {
  1335. return {
  1336. title: '地图服务'
  1337. }
  1338. },
  1339. openShq() {
  1340. wx.navigateTo({
  1341. url: '/pages/map-shq/map-shq',
  1342. })
  1343. }
  1344. });
  1345. let changeValue = "transit";
  1346. function searchHandMatter(that, queryVal) {
  1347. // getHandMatterBySearch(queryVal).then((res) => {
  1348. // if (res.data && res.data.length) {
  1349. // searchDepVal(that, res.data.join(','), res.data)
  1350. // }
  1351. // });
  1352. searchDepVal(that, queryVal, queryVal.split(","))
  1353. }
  1354. function searchDepVal(that, queryVal, deptArr) {
  1355. let params = {
  1356. title: queryVal
  1357. }
  1358. wx.showToast({
  1359. title: '加载中...',
  1360. icon: 'loading'
  1361. });
  1362. getMapDataType(params).then((res) => {
  1363. let data = []
  1364. let st = true,
  1365. st2 = true
  1366. deptArr.forEach((item) => {
  1367. if (that.data.jnxc.indexOf(item) > -1 && st) {
  1368. st = false
  1369. let ite = that.data.xzfwzxs[0]
  1370. if (ite.tel && !(ite.tel instanceof Array)) {
  1371. ite.tel = ite.tel.split(";")
  1372. }
  1373. data.push(ite)
  1374. }
  1375. if (that.data.npzx.indexOf(item) > -1 && st2) {
  1376. st2 = false
  1377. let ite = that.data.xzfwzxs[1]
  1378. if (ite.tel && !(ite.tel instanceof Array)) {
  1379. ite.tel = ite.tel.split(";")
  1380. }
  1381. data.push(ite)
  1382. }
  1383. })
  1384. res.data.forEach((item) => {
  1385. if (item.tel != null && item.tel != "" && !(item.tel instanceof Array)) {
  1386. item.tel = item.tel.split(";")
  1387. }
  1388. data.push(item)
  1389. });
  1390. that.setData({
  1391. showTraffic: false,
  1392. popData: data,
  1393. })
  1394. wx.hideLoading()
  1395. });
  1396. wx.hideLoading()
  1397. }
  1398. function initMapDataAll(that, lat, lng) {
  1399. let arr = that.data.marksInfo
  1400. console.log(arr)
  1401. let index = 0;
  1402. let addrArr = []
  1403. let marksView = []
  1404. let task = setInterval(function () {
  1405. if (index >= arr.length) {
  1406. addrArr.push({
  1407. latitude: lat,
  1408. longitude: lng,
  1409. iconPath: imgUrl + "/location.png",
  1410. width: '30px',
  1411. height: '30px',
  1412. rotate: 0,
  1413. alpha: 1,
  1414. label: {
  1415. anchorX: 10,
  1416. anchorY: -22,
  1417. bgColor: '#fff',
  1418. borderRadius: 5,
  1419. padding: 5,
  1420. content: "我的位置",
  1421. color: '#333'
  1422. }
  1423. })
  1424. console.log(addrArr)
  1425. that.setData({
  1426. markers: addrArr,
  1427. marksView: marksView,
  1428. marksNum: addrArr.length - 1
  1429. })
  1430. clearInterval(task)
  1431. return
  1432. }
  1433. const address = arr[index]
  1434. index++
  1435. const jl = getDistances(lat, lng, address.latitude, address.longitude)
  1436. if (jl.m <= that.data.custGap) {
  1437. marksView.push(address)
  1438. addrArr.push({
  1439. id: address.id,
  1440. latitude: address.latitude,
  1441. longitude: address.longitude,
  1442. iconPath: imgUrl + "/location.png",
  1443. width: '34px',
  1444. height: '34px',
  1445. rotate: 0,
  1446. alpha: 1,
  1447. label: {
  1448. anchorX: 10,
  1449. anchorY: -22,
  1450. bgColor: '#fff',
  1451. borderRadius: 5,
  1452. padding: 5,
  1453. content: address.dep,
  1454. color: '#333'
  1455. }
  1456. })
  1457. }
  1458. // BMap.geocoder({
  1459. // address: address.address,
  1460. // success: (addr) => {
  1461. // BMap.calculateDistance({
  1462. // mode: 'straight',
  1463. // from: {
  1464. // latitude: lat,
  1465. // longitude: lng
  1466. // },
  1467. // to: [{
  1468. // latitude: addr.result.location.lat,
  1469. // longitude: addr.result.location.lng
  1470. // }],
  1471. // success: (json) => {
  1472. // console.log(getDistances(lat, lng, addr.result.location.lat, addr.result.location.lng))
  1473. // console.log(json)
  1474. // const jl = parseInt(json.result.elements[0].distance)
  1475. // if (jl <= 1000) {
  1476. // marksView.push(address)
  1477. // addrArr.push({
  1478. // id: address.id,
  1479. // latitude: json.result.elements[0].to.lat,
  1480. // longitude: json.result.elements[0].to.lng,
  1481. // iconPath: imgUrl+"/location.png",
  1482. // width: '34px',
  1483. // height: '34px',
  1484. // rotate: 0,
  1485. // alpha: 1
  1486. // })
  1487. // }
  1488. // }
  1489. // })
  1490. // }
  1491. // })
  1492. }, 10);
  1493. }
  1494. function searchHandMatterByValFun(that) {
  1495. searchHandMatterByVal(that.data.searchVal).then((res) => {
  1496. res.data.forEach((item) => {
  1497. const dept = item.depts.split(',')
  1498. let formtDept = item.fomartDept
  1499. const arr = dept.filter(value => that.data.jnxc.includes(value));
  1500. if (arr && arr.length) {
  1501. formtDept += ",区政务服务中心(江南新城中心)"
  1502. }
  1503. const arr2 = dept.filter(value => that.data.npzx.includes(value));
  1504. if (arr2 && arr2.length) {
  1505. formtDept += ",区政务服务中心(南坪中心)"
  1506. }
  1507. item.fomartDept = formtDept
  1508. })
  1509. let matterEventInfo = that.data.matterEventInfo
  1510. matterEventInfo.isShow = true
  1511. matterEventInfo.data = res.data
  1512. that.setData({
  1513. matterEventInfo: matterEventInfo
  1514. })
  1515. });
  1516. }
  1517. // 根据经纬度计算距离,参数分别为第一点的纬度,经度;第二点的纬度,经度
  1518. function getDistances(lat1, lng1, lat2, lng2) {
  1519. let EARTH_RADIUS = 6378.137; // 地球半径
  1520. let radLat1 = lat1 * Math.PI / 180.0; //lat1 * Math.PI / 180.0=>弧度计算
  1521. let radLat2 = lat2 * Math.PI / 180.0;
  1522. let a = radLat1 - radLat2;
  1523. let b = lng1 * Math.PI / 180.0 - lng2 * Math.PI / 180.0;
  1524. 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)));
  1525. s = s * EARTH_RADIUS;
  1526. s = Math.round(s * 10000) / 10000; // 输出为公里
  1527. return {
  1528. m: s * 1000,
  1529. km: Number(s.toFixed(2))
  1530. }
  1531. }