map.js 38 KB

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