map.js 35 KB

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