map.js 38 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162
  1. import {
  2. imgUrl
  3. } from "../api/request"
  4. import{
  5. getMapDataType,
  6. getHandMatterPage,
  7. getHandMatterBySearch,
  8. getMapDataAll,
  9. searchHandMatterByVal
  10. } from "../api/yxna-api"
  11. var QQMapWX = require('../../libs/qqmap-wx-jssdk.min.js');
  12. const popType = [
  13. [
  14. [{"name":"受理场所","dictType":"jzs,bms","type":""}, {"name":"查阅场所","dictType":"cycsbms,slcsjzs","type":""},],
  15. [{"name":"区级政务服务中心","dictType":"xzfwzxs","type":""}, {"name":"镇(街道)便民服务中心","dictType":"ggfwzxs","type":""}, {"name":"村(社区)便民服务站","dictType":"bmfwzxs","type":""}, {"name":"生源地助学贷款办理点","dictType":"dkblds","type":""}],
  16. [{"name":"党群服务中心","dictType":"dqfwzxs","type":""}],
  17. [{"name":"职业教育学校","dictType":"zyyxs","type":""}, {"name":"特殊教育学校","dictType":"xxs","type":""}, {"name":"高等院校","dictType":"dxs","type":""}, {"name":"小学","dictType":"xxs","type":"小学"}, {"name":"中学","dictType":"xxs","type":""}, {"name":"幼儿园","dictType":"yeys","type":""}, {"name":"教育考试中心","dictType":"","type":"jykszxs"}]
  18. ],
  19. [
  20. [{"name":"村卫生室","dictType":"","type":"cwsss"}, {"name":"社区卫生服务站","dictType":"","type":"sqwsfwzs"}, {"name":"儿科诊疗服务机构","dictType":"ekzlfwjgs","type":""}, {"name":"狂犬病,破伤风处置门诊","dictType":"kqbpsfczmzs","type":""}, {"name":"免疫规划预防接种门诊","dictType":"myghyfjzmzs","type":""}, {"name":"二级医疗机构","dictType":"ejyljgs","type":""}, {"name":"三级医疗机构","dictType":"sjyljgs","type":""}, {"name":"社区卫生服务机构","dictType":"sqwsfwjgs","type":""}, {"name":"职业病诊断机构","dictType":"zybzdjgs","type":""}, {"name":"助产医疗机构","dictType":"zcyljg","type":""}, {"name":"产科门诊服务机构","dictType":"ckmzfwjgs","type":""}, {"name":"医疗保障事务中心","dictType":"ybs","type":""}],
  21. [{"name":"派出所","dictType":"pcss","type":""}, {"name":"出入境业务办理机构","dictType":"crjywbljgs","type":""}],
  22. [{"name":"交通支大队","dictType":"jtxljcdds","type":""}, {"name":"交通违法处理机构","dictType":"jtwfcljgs","type":""}, {"name":"交通事故处理机构","dictType":"jtsgcljgs","type":""}, {"name":"车管所","dictType":"cgss","type":""}, {"name":"机动车检测场所","dictType":"jdcjccss","type":""}, {"name":"驾驶人体检医院","dictType":"jsrtjzs","type":""}, {"name":"车驾管社会服务站","dictType":"cjgshfwzs","type":""}],
  23. [{"name":"就业和人才中心","dictType":"jyhrczxs","type":""}, {"name":"社会保险事务中心","dictType":"shbxswzxs","type":""}]
  24. ],
  25. [
  26. [{"name":"养老机构","dictType":"ylfwjgs","type":""}],
  27. [{"name":"婚姻登记机构","dictType":"hydjcs","type":""}, {"name":"殡仪服务机构","dictType":"byfwjgs","type":""}],
  28. [],
  29. []
  30. ],
  31. [
  32. [],
  33. [],
  34. [],
  35. [{"name":"图书馆","dictType":"tsgs","type":""}, {"name":"文化馆","dictType":"whgs","type":""}, {"name":"文管所","dictType":"wgss","type":""}, {"name":"公共体育馆","dictType":"ggtys","type":""}, {"name":"旅游景点","dictType":"jqs","type":""}, {"name":"公园","dictType":"gys","type":""}]
  36. ],
  37. [
  38. [{"name":"公证处","dictType":"gzcs","type":""}, {"name":"司法鉴定机构","dictType":"sfjdjgs","type":""}, {"name":"基层司法所","dictType":"jcfwfwss","type":""}, {"name":"法律援助机构","dictType":"flyzzxs","type":""}, {"name":"矫正中心","dictType":"jzzxs","type":""}],
  39. [{"name":"残疾人服务中心","dictType":"cjrfwzxs","type":""}, {"name":"定点残疾人服务机构","dictType":"qtcjrfwzxs","type":""}],
  40. [],
  41. [{"name":"商圈","dictType":"sqs","type":""}, {"name":"购物中心","dictType":"gwzxs","type":""}, {"name":"酒店","dictType":"jds","type":""}]
  42. ],
  43. [
  44. [],
  45. [],
  46. []
  47. ]
  48. ]
  49. let BMap = {};
  50. let x = null;
  51. let y = null;
  52. const INIT_MARKER = {
  53. latitude: 0,
  54. longitude: 0,
  55. iconPath: imgUrl+"/location.png",
  56. width: '34px',
  57. height: '34px',
  58. rotate: 0,
  59. alpha: 1
  60. };
  61. Page({
  62. data: {
  63. imgUrl: imgUrl,
  64. markers: [INIT_MARKER],
  65. latitude: '',
  66. longitude: '',
  67. type: [
  68. [{ "id": 1, "name": "政务公开", "image": "fgk.png","dictType":"" }, { "id": 2, "name": "政务服务", "image": "fzwfw.png" ,"dictType":""}, { "id": 3, "name": "党群服务", "image": "fdqfwzx.png" ,"dictType":""},{ "id": 4, "name": "教育资源", "image": "fjy.png","dictType":"" }],
  69. [{ "id": 1, "name": "医疗卫生", "image": "fyl.png" ,"dictType":""}, { "id": 2, "name": "户籍管理", "image": "fhjgl.png" ,"dictType":""}, { "id": 3, "name": "交通服务", "image": "fjtfw.png" ,"dictType":""},{ "id": 4, "name": "社会保障", "image": "fshbz.png","dictType":"" }],
  70. [{ "id": 1, "name": "养老服务", "image": "fylfw.png" ,"dictType":""}, { "id": 2, "name": "民政服务", "image": "fmzfw.png" ,"dictType":""}, { "id": 3, "name": "办税服务", "image": "fbsfwt.png" ,"dictType":"bsfwts"},{ "id": 4, "name": "市场监管", "image": "fscjd.png","dictType":"scjdgljs" }],
  71. [{ "id": 1, "name": "住房保障", "image": "fgzf.png","dictType":"fwglzxs" }, { "id": 2, "name": "不动产登记", "image": "fbdcdj.png" ,"dictType":"bdcdjzxbsdts"}, { "id": 3, "name": "住房公积金", "image": "fgjj.png" ,"dictType":"gjjs"},{ "id": 4, "name": "文体旅游", "image": "fwtly.png","dictType":"" }],
  72. [{ "id": 1, "name": "司法服务", "image": "fsffw.png" ,"dictType":""}, { "id": 2, "name": "助疾服务", "image": "fcjr.png" ,"dictType":""}, { "id": 3, "name": "产业园区", "image": "fcyy.png" ,"dictType":"cyys"},{ "id": 4, "name": "商业服务", "image": "fbmfw.png","dictType":"" }],
  73. [{ "id": 1, "name": "便民公厕", "image": "fgc.png" ,"dictType":"gcs"}, { "id": 2, "name": "停车泊车", "image": "ftc.png" ,"dictType":"tcs"}, { "id": 3, "name": "直饮水点", "image": "zysd.png" ,"dictType":"zysd"}]
  74. ],
  75. popData: [{ "popName": "", "data": [] }],
  76. showIndex: false,
  77. showSearch: true,
  78. showTraffic: true,
  79. height: 0,
  80. searchVal: '',
  81. loadValue: '',
  82. trafficStart: '',
  83. trafficEnd: '',
  84. index: 0,
  85. isList: true,
  86. showSet: false,
  87. trafficType: 0,
  88. page:0,
  89. limit:15,
  90. marksInfo: [],
  91. marksView: [],
  92. marksNum: 0,
  93. searchInfo: {
  94. navType: 0,
  95. isShow: false
  96. },
  97. matterEventInfo: {
  98. data: [],
  99. isShow: false,
  100. search: false
  101. },
  102. itemInfo: {
  103. page: 1,
  104. limit: 6,
  105. navType: 0,
  106. deptNow: '',
  107. pageNext: true,
  108. pagePrev: false,
  109. matterStatus: true,
  110. matterList: [{
  111. itemName: '',
  112. matterUrl: ''
  113. }],
  114. '重庆市南岸区政务服务中心(江南新城中心)': ['重庆市南岸区残联', '重庆市南岸区财政局', '重庆市南岸区文化和旅游发展委员会', '重庆市南岸区档案馆', '重庆市南岸区卫生健康委员会', '重庆市南岸区交通局', '重庆市南岸区规划自然资源局', '重庆市南岸区住房和城乡建设委员会', '重庆市南岸区生态环境局', '重庆市南岸区农业农村委员会', '重庆市南岸区发展和改革委员会', '重庆市南岸区消防救援支队', '重庆市南岸区城市管理局', '重庆市公安局南岸分局'],
  115. '重庆市南岸区政务服务中心(南坪中心)': ['重庆市南岸区市场监管局', '重庆市公安局南岸分局'],
  116. },
  117. jnxc: ['重庆市南岸区残联', '重庆市南岸区财政局', '重庆市南岸区文化和旅游发展委员会', '重庆市南岸区档案馆', '重庆市南岸区卫生健康委员会', '重庆市南岸区交通局', '重庆市南岸区规划自然资源局', '重庆市南岸区住房和城乡建设委员会', '重庆市南岸区生态环境局', '重庆市南岸区农业农村委员会', '重庆市南岸区发展和改革委员会', '重庆市南岸区消防救援支队', '重庆市南岸区城市管理局', '重庆市公安局南岸分局'],
  118. npzx: ['重庆市南岸区市场监管局', '重庆市公安局南岸分局'],
  119. },
  120. onLoad: function (options) {
  121. this.setData({
  122. height: wx.getSystemInfoSync().windowHeight
  123. })
  124. console.log(options);
  125. if (options.se) {
  126. this.setData({
  127. loadValue: options.se,
  128. showTraffic: false
  129. });
  130. }else{
  131. this.setData({
  132. showTraffic: true
  133. })
  134. }
  135. // searchVal
  136. },
  137. onReady:function () {
  138. const that = this
  139. this.loadItem();
  140. getMapDataAll().then((res) => {
  141. let arr = []
  142. Array.prototype.push.apply(arr, res.data.xzfwzxs);
  143. Array.prototype.push.apply(arr, res.data.ggfwzxs);
  144. for (let j = 0; j < arr.length; j++) {
  145. if(arr[j].tel && !(arr[j].tel instanceof Array)){
  146. arr[j].tel = arr[j].tel.split(";")
  147. }
  148. }
  149. that.setData({
  150. xzfwzxs: res.data.xzfwzxs,
  151. marksInfo: arr
  152. })
  153. this.setMap();
  154. });
  155. // this.setMap();
  156. },
  157. async setMap(){
  158. var that = this;
  159. BMap = await new QQMapWX({
  160. key: 'KN3BZ-KUDND-PGH4Y-POVRP-43KF3-RNF4K'
  161. });
  162. wx.getLocation({
  163. type: 'gcj02', //返回可以用于wx.openLocation的经纬度
  164. success(res) {
  165. console.log(res)
  166. const latitude = res.latitude
  167. const longitude = res.longitude
  168. initMapDataAll(that, latitude, longitude)
  169. that.setData({
  170. latitude: latitude,
  171. longitude: longitude,
  172. trafficStart: "我的位置",
  173. // markers: [{
  174. // latitude: latitude,
  175. // longitude: longitude,
  176. // iconPath: "/location.png",
  177. // width: '30px',
  178. // height: '30px',
  179. // rotate: 0,
  180. // alpha: 1
  181. // }]
  182. });
  183. }
  184. });
  185. },
  186. popview(e) {
  187. let x = e.currentTarget.dataset.index;
  188. let y = e.currentTarget.dataset.id;
  189. let pop = popType[x][y - 1]
  190. if (pop.length > 0) {
  191. // this.setTypeDateToPop2(pop)
  192. this.setData({
  193. popData: pop,
  194. showIndex: true
  195. });
  196. } else {
  197. let pop = this.data.type[x][y - 1]
  198. // console.log(pop);
  199. this.setDateToPop(pop)
  200. this.setData({
  201. showTraffic: false,
  202. showIndex: false
  203. })
  204. }
  205. },
  206. setTypeDateToPop2: function (pop) {
  207. let arr = [];
  208. pop.forEach(e => {
  209. arr.push({
  210. "popName": e.name
  211. })
  212. })
  213. this.setData({
  214. popData: arr
  215. })
  216. },
  217. setDateToPop: function (pop) {
  218. let arr = [];
  219. let params ={
  220. "dictType": pop.dictType,
  221. "type": "",
  222. "title": "",
  223. } ;
  224. wx.showToast({
  225. title: '加载中...',
  226. icon: 'loading'
  227. });
  228. getMapDataType(params).then((res) => {
  229. console.log(res.data[0].tel);
  230. let data = []
  231. res.data.forEach((item) => {
  232. if(item.tel!=null && item.tel!="" && !(item.tel instanceof Array)){
  233. item.tel = item.tel.split(";")
  234. }
  235. data.push(item)
  236. });
  237. this.setData({
  238. popData: data,
  239. })
  240. wx.hideToast({
  241. success: (res) => {},
  242. });
  243. });
  244. },
  245. closePopup() {
  246. this.setData({
  247. showIndex: false
  248. })
  249. },
  250. changeInfo(e) {
  251. // console.log(e.currentTarget.dataset.data);
  252. let searchInfo = this.data.searchInfo
  253. searchInfo.isShow = false
  254. this.setData({
  255. searchInfo: searchInfo
  256. })
  257. let dataitem = e.currentTarget.dataset.data;
  258. console.log(dataitem);
  259. let params ={
  260. "dictType":dataitem.dictType,
  261. "type": "",
  262. "title": "",
  263. };
  264. wx.showToast({
  265. title: '加载中...',
  266. icon: 'loading'
  267. });
  268. getMapDataType(params).then((res) => {
  269. let data = []
  270. switch (dataitem.name) {
  271. case "小学":
  272. case "特殊教育学校":
  273. res.data.forEach((item) => {
  274. if (item.type == dataitem.name) {
  275. data.push(item)
  276. }
  277. });
  278. break;
  279. case "中学":
  280. res.data.forEach((item) => {
  281. if (item.type == dataitem.name||item.specialtype == dataitem.name) {
  282. data.push(item)
  283. }
  284. });
  285. break;
  286. default:
  287. data = res.data;
  288. break;
  289. }
  290. let renderData = []
  291. data.forEach((item) => {
  292. if(item.tel!=null && item.tel!="" && !(item.tel instanceof Array)){
  293. item.tel = item.tel.split(";")
  294. }
  295. renderData.push(item)
  296. });
  297. this.setData({
  298. popData: renderData,
  299. showTraffic: false,
  300. showIndex: false
  301. })
  302. wx.hideToast({
  303. success: (res) => {},
  304. });
  305. });
  306. },
  307. /**
  308. * 拨打电话
  309. * @param {*} e
  310. */
  311. callNumber(e) {
  312. let phoneNumber = e.currentTarget.dataset.value;
  313. wx.makePhoneCall({
  314. phoneNumber: phoneNumber,
  315. });
  316. },
  317. /**
  318. * list跳转info
  319. *
  320. */
  321. changeItem(e) {
  322. let that = this;
  323. console.info(e)
  324. let value = e.currentTarget.dataset.value;
  325. if (value === "none") {
  326. let searchInfo = that.data.searchInfo
  327. searchInfo.isShow = false
  328. that.setData({
  329. isList: false,
  330. showSearch: false,
  331. showSet: false,
  332. searchInfo: searchInfo
  333. });
  334. } else {
  335. // 控制公交自驾选中状态
  336. let type = e.currentTarget.dataset.type;
  337. if (type==0){
  338. if(e.detail.value==0){
  339. changeValue = "transit";
  340. }else{
  341. changeValue = "driving";
  342. }
  343. }
  344. that.setData({
  345. trafficType: type,
  346. showSet: false
  347. });
  348. that.setData({
  349. isList: false,
  350. showSearch: false,
  351. showSet: true
  352. });
  353. }
  354. // 详情赋值
  355. let index = e.currentTarget.dataset.index;
  356. let item = that.data.popData[index];
  357. console.info(item);
  358. let address='';
  359. if (item.address.search("重庆")==-1) {
  360. address = "重庆" + item.address;
  361. }else{
  362. address = item.address;
  363. }
  364. console.log(item.time);
  365. let itemInfo = that.data.itemInfo
  366. if (itemInfo[item.dep]) {
  367. let arr = []
  368. for (let i = 0; i < itemInfo[item.dep].length; i++) {
  369. arr.push(itemInfo[item.dep][i].replace('重庆市', '').replace('南岸', ''))
  370. }
  371. itemInfo.deptList = arr
  372. itemInfo.oldDeptList = itemInfo[item.dep]
  373. }
  374. itemInfo.deptShow = itemInfo[item.dep] ? true : false
  375. itemInfo.navType = 0
  376. itemInfo.page = 1
  377. itemInfo.deptNow = ''
  378. let params = {
  379. page: 1,
  380. limit: itemInfo.limit,
  381. type: itemInfo.navType,
  382. }
  383. if (itemInfo.deptShow) {
  384. params.matterDept = itemInfo.oldDeptList.join(',')
  385. } else {
  386. params.matterDept = item.dep.replace('政府', '').replace('便民服务中心', '')
  387. }
  388. const _this = this
  389. getHandMatterPage(params).then((res) => {
  390. if (!(res && res.count > 0)) {
  391. itemInfo.matterStatus = false
  392. _this.setData({
  393. itemInfo: itemInfo
  394. })
  395. return
  396. }
  397. itemInfo.matterStatus = true
  398. itemInfo.pagePrev = itemInfo.page == 1
  399. itemInfo.pageNext = itemInfo.page * itemInfo.limit >= res.count
  400. itemInfo.matterList = res.data
  401. _this.setData({
  402. itemInfo: itemInfo
  403. })
  404. });
  405. that.setData({
  406. detail_dep: item.dep,
  407. detail_content: item.content,
  408. detail_img: item.img,
  409. detail_address: item.address,
  410. detail_time: item.time,
  411. detail_tel: item.tel,
  412. detail_index: index,
  413. trafficEnd: address,
  414. itemInfo: itemInfo
  415. });
  416. BMap.geocoder({
  417. address: address,
  418. success: function (data) {
  419. var res = data.result
  420. that.setData({
  421. latitude: res.location.lat,
  422. longitude: res.location.lng,
  423. markers: [{
  424. latitude: res.location.lat,
  425. longitude: res.location.lng,
  426. iconPath: "/location.png",
  427. width: '30px',
  428. height: '30px',
  429. rotate: 0,
  430. alpha: 1
  431. }]
  432. });
  433. }
  434. });
  435. },
  436. /**
  437. * 打开全景地图
  438. * @param {*} e
  439. */
  440. openVR(e) {
  441. wx.navigateTo({
  442. url: '../map-vr/map-vr',
  443. });
  444. },
  445. getSearchVal(e) {
  446. this.setData({
  447. searchVal: e.detail.value
  448. });
  449. },
  450. loadItem() {
  451. let searchVal = this.data.loadValue;
  452. let datatype = this.data.type;
  453. if (!searchVal) {
  454. return;
  455. }
  456. wx.showToast({
  457. title: '加载中...',
  458. icon: 'loading'
  459. });
  460. let x =-1
  461. let y =-1
  462. for (let i = 0; i < datatype.length; i++) {
  463. for (let j = 0; j < datatype[i].length; j++) {
  464. if (datatype[i][j].name == searchVal) {
  465. x = i
  466. y = j
  467. break;
  468. }
  469. }
  470. if(x!=-1){
  471. break;
  472. }
  473. }
  474. let searcharr = ""
  475. if (datatype[x][y].dictType != "") {
  476. searcharr = datatype[x][y].dictType
  477. } else {
  478. let arr = popType[x][y]
  479. arr.forEach((item) => {
  480. searcharr += item.dictType + ","
  481. })
  482. searcharr = searcharr.substring(0, searcharr.length - 1)
  483. }
  484. let params ={
  485. "dictType": searcharr,
  486. "type": "",
  487. "title": "",
  488. } ;
  489. getMapDataType(params).then((res) => {
  490. let data = []
  491. res.data.forEach((item) => {
  492. if(item.tel!=null && item.tel!="" && !(item.tel instanceof Array)){
  493. item.tel = item.tel.split(";")
  494. }
  495. data.push(item)
  496. });
  497. this.setData({
  498. // showTraffic: false,
  499. popData: data,
  500. })
  501. wx.hideToast({
  502. success: (res) => {},
  503. });
  504. });
  505. // 搜索结果
  506. },
  507. /**
  508. * 顶部搜索点击事件
  509. * @param {*} e
  510. */
  511. searchTap(e) {
  512. let searchInfo = this.data.searchInfo
  513. searchInfo.isShow = true
  514. searchInfo.navType = 0
  515. this.setData({
  516. searchInfo: searchInfo
  517. })
  518. let searchVal = this.data.searchVal;
  519. wx.showToast({
  520. title: '加载中...',
  521. icon: 'loading'
  522. });
  523. let params ={
  524. "dictType": "",
  525. "type": "",
  526. "title": searchVal,
  527. };
  528. this.setData({
  529. showTraffic: false
  530. })
  531. getMapDataType(params).then((res) => {
  532. let data = []
  533. res.data.forEach((item) => {
  534. if(item.tel!=null && item.tel!="" && !(item.tel instanceof Array)){
  535. item.tel = item.tel.split(";")
  536. }
  537. data.push(item)
  538. });
  539. this.setData({
  540. showTraffic: false,
  541. popData: data,
  542. })
  543. wx.hideToast({
  544. success: (res) => {},
  545. });
  546. });
  547. // 搜索结果
  548. wx.hideToast({
  549. success: (res) => {},
  550. });
  551. },
  552. getTrafficStart(e) {
  553. this.setData({
  554. trafficStart: e.detail.value
  555. });
  556. },
  557. getTrafficEnd(e) {
  558. this.setData({
  559. trafficEnd: e.detail.value
  560. });
  561. },
  562. /**
  563. * 搜索进行交通路线规划
  564. * @param {*} e
  565. */
  566. searchTrafficTap(e) {
  567. const that = this;
  568. // console.log(that.data.trafficType);
  569. let trafficType = that.data.trafficType;
  570. if (trafficType == 0) {
  571. changeValue = "transit";
  572. } else {
  573. changeValue = "driving";
  574. }
  575. let trafficStart = that.data.trafficStart;
  576. let trafficEnd = that.data.trafficEnd;
  577. if (!trafficStart || !trafficEnd) {
  578. wx.showToast({
  579. title: '请输入起点和终点',
  580. icon: 'none'
  581. });
  582. return;
  583. }
  584. console.info(trafficStart, trafficEnd);
  585. BMap.geocoder({
  586. address: trafficEnd,
  587. success: function (data) {
  588. console.log(data);
  589. var res = data.result
  590. // console.log(res);
  591. let key = 'KN3BZ-KUDND-PGH4Y-POVRP-43KF3-RNF4K'; //使用在腾讯位置服务申请的key
  592. let referer = '掌上南岸'; //调用插件的app的名称
  593. // 终点
  594. let endPoint = JSON.stringify({
  595. 'name': trafficEnd,
  596. 'latitude': res.location.lat,
  597. 'longitude': res.location.lng
  598. });
  599. wx.navigateTo({
  600. url: 'plugin://routePlan/index?key=' + key + '&referer=' + referer + '&endPoint=' + endPoint + "&mode=" + changeValue
  601. });
  602. },
  603. });
  604. },
  605. backSearch() {
  606. let that =this
  607. let searchInfo = that.data.searchInfo
  608. searchInfo.isShow = that.data.searchVal ? true : false
  609. that.setData({
  610. searchInfo: searchInfo
  611. })
  612. let matterEventInfo = that.data.matterEventInfo
  613. console.log(matterEventInfo)
  614. if (!that.data.isList) {
  615. matterEventInfo.isShow = searchInfo.navType != 1
  616. this.setData({
  617. isList: true,
  618. showSearch: true,
  619. showSet: false,
  620. matterEventInfo: matterEventInfo
  621. });
  622. } else if(!matterEventInfo.isShow && matterEventInfo.search) {
  623. matterEventInfo.isShow = true
  624. this.setData({
  625. isList: true,
  626. showSearch: true,
  627. showSet: false,
  628. matterEventInfo: matterEventInfo
  629. });
  630. } else {
  631. matterEventInfo.isShow = false
  632. matterEventInfo.search = false
  633. that.setData({
  634. matterEventInfo: matterEventInfo
  635. })
  636. if (!that.data.showTraffic) {
  637. that.setData({
  638. showTraffic: true,
  639. showSearch: true,
  640. searchVal: ''
  641. });
  642. }
  643. }
  644. wx.getLocation({
  645. type: 'gcj02', //返回可以用于wx.openLocation的经纬度
  646. success (res) {
  647. const latitude = res.latitude
  648. const longitude = res.longitude
  649. that.setData({
  650. latitude: latitude,
  651. longitude:longitude,
  652. trafficStart:"我的位置",
  653. markers:[{
  654. latitude: latitude,
  655. longitude: longitude,
  656. iconPath: imgUrl+"/location.png",
  657. width: '34px',
  658. height: '34px',
  659. rotate: 0,
  660. alpha: 1
  661. }]
  662. });
  663. }
  664. })
  665. changeValue = "transit";
  666. },
  667. matterTab(e) {
  668. let itemInfo = this.data.itemInfo
  669. itemInfo.navType = e.currentTarget.dataset?.type
  670. let params = {
  671. page: 1,
  672. limit: itemInfo.limit,
  673. type: itemInfo.navType,
  674. }
  675. if (itemInfo.deptShow) {
  676. if (itemInfo.deptList && itemInfo.deptList.indexOf(itemInfo.deptNow) > -1) {
  677. params.matterDept = itemInfo.deptNow.replace('政府', '').replace('便民服务中心', '')
  678. } else {
  679. params.matterDept = itemInfo.oldDeptList.join(',')
  680. }
  681. } else {
  682. params.matterDept = this.data.detail_dep.replace('政府', '').replace('便民服务中心', '')
  683. }
  684. const _this = this
  685. getHandMatterPage(params).then((res) => {
  686. if (!(res && res.count > 0)) {
  687. itemInfo.matterStatus = false
  688. _this.setData({
  689. itemInfo: itemInfo
  690. })
  691. return
  692. }
  693. itemInfo.matterStatus = true
  694. itemInfo.page = 1
  695. itemInfo.pagePrev = itemInfo.page == 1
  696. itemInfo.pageNext = itemInfo.page * itemInfo.limit >= res.count
  697. itemInfo.matterList = res.data
  698. _this.setData({
  699. itemInfo: itemInfo
  700. })
  701. });
  702. },
  703. clickDept(e) {
  704. console.log(e)
  705. let itemInfo = this.data.itemInfo
  706. itemInfo.deptNow = e.currentTarget.dataset.dept
  707. itemInfo.page = 1
  708. this.setData({
  709. itemInfo: itemInfo
  710. })
  711. let params = {
  712. page: itemInfo.page,
  713. limit: itemInfo.limit,
  714. type: itemInfo.navType,
  715. }
  716. if (itemInfo.deptShow) {
  717. if (itemInfo.deptList && itemInfo.deptList.indexOf(itemInfo.deptNow) > -1) {
  718. params.matterDept = itemInfo.deptNow
  719. } else {
  720. params.matterDept = itemInfo.oldDeptList.join(',')
  721. }
  722. } else {
  723. params.matterDept = this.data.detail_dep
  724. }
  725. const _this = this
  726. getHandMatterPage(params).then((res) => {
  727. if (!(res && res.count > 0)) {
  728. itemInfo.matterStatus = false
  729. _this.setData({
  730. itemInfo: itemInfo
  731. })
  732. return
  733. }
  734. itemInfo.pagePrev = itemInfo.page == 1
  735. itemInfo.pageNext = itemInfo.page * itemInfo.limit >= res.count
  736. itemInfo.matterList = res.data
  737. _this.setData({
  738. itemInfo: itemInfo
  739. })
  740. });
  741. },
  742. clickPageTo(e) {
  743. let itemInfo = this.data.itemInfo
  744. let page = 1
  745. if (e.currentTarget.dataset.type == 0) {
  746. // 上一页
  747. if (itemInfo.pagePrev) return
  748. page = itemInfo.page - 1
  749. } else {
  750. if (itemInfo.pageNext) return
  751. page = itemInfo.page + 1
  752. }
  753. let params = {
  754. page: page,
  755. limit: itemInfo.limit,
  756. type: itemInfo.navType,
  757. }
  758. if (itemInfo.deptShow) {
  759. if (itemInfo.deptList && itemInfo.deptList.indexOf(itemInfo.deptNow) > -1) {
  760. params.matterDept = itemInfo.deptNow.replace('政府', '').replace('便民服务中心', '')
  761. } else {
  762. params.matterDept = itemInfo.oldDeptList.join(',')
  763. }
  764. } else {
  765. params.matterDept = this.data.detail_dep.replace('政府', '').replace('便民服务中心', '')
  766. }
  767. const _this = this
  768. getHandMatterPage(params).then((res) => {
  769. if (!(res && res.count > 0)) {
  770. itemInfo.matterStatus = false
  771. _this.setData({
  772. itemInfo: itemInfo
  773. })
  774. return
  775. }
  776. itemInfo.matterStatus = true
  777. itemInfo.page = page
  778. itemInfo.pagePrev = itemInfo.page == 1
  779. itemInfo.pageNext = itemInfo.page * itemInfo.limit >= res.count
  780. itemInfo.matterList = res.data
  781. _this.setData({
  782. itemInfo: itemInfo
  783. })
  784. });
  785. },
  786. searchTab(e) {
  787. let searchInfo = this.data.searchInfo
  788. searchInfo.navType = e.currentTarget.dataset.type
  789. this.setData({
  790. searchInfo: searchInfo
  791. })
  792. const _this = this
  793. if (searchInfo.navType == 0) {
  794. let params ={
  795. "title": _this.data.searchVal,
  796. };
  797. getMapDataType(params).then((res) => {
  798. let data = []
  799. res.data.forEach((item) => {
  800. if(item.tel!=null && item.tel!="" && !(item.tel instanceof Array)){
  801. item.tel = item.tel.split(";")
  802. }
  803. data.push(item)
  804. });
  805. this.setData({
  806. showTraffic: false,
  807. popData: data,
  808. })
  809. });
  810. } else {
  811. let matterEventInfo = _this.data.matterEventInfo
  812. matterEventInfo.search = true
  813. _this.setData({
  814. matterEventInfo: matterEventInfo
  815. })
  816. searchHandMatterByValFun(_this)
  817. // searchHandMatter(_this)
  818. }
  819. },
  820. clickMatterEvent(e) {
  821. const _this = this
  822. let matterEventInfo = _this.data.matterEventInfo
  823. matterEventInfo.isShow = false
  824. _this.setData({
  825. matterEventInfo: matterEventInfo
  826. })
  827. console.log(_this.data)
  828. searchHandMatter(_this, e.currentTarget.dataset.depts)
  829. },
  830. markClick(e) {
  831. if(!e.markerId) {
  832. return
  833. }
  834. const arr = this.data.marksInfo
  835. const that = this
  836. this.setData({
  837. popData: arr
  838. })
  839. for (let i = 0; i < arr.length; i++) {
  840. if (arr[i].id == e.markerId) {
  841. let searchInfo = that.data.searchInfo
  842. searchInfo.isShow = false
  843. that.setData({
  844. isList: false,
  845. showSearch: false,
  846. showSet: false,
  847. showTraffic: false,
  848. searchInfo: searchInfo
  849. });
  850. let item = arr[i];
  851. console.info(item);
  852. if(item.tel && !(item.tel instanceof Array)){
  853. item.tel = item.tel.split(";")
  854. }
  855. let address = item.address
  856. console.log(item.time);
  857. let itemInfo = that.data.itemInfo
  858. if (itemInfo[item.dep]) {
  859. let arr = []
  860. for (let i = 0; i < itemInfo[item.dep].length; i++) {
  861. arr.push(itemInfo[item.dep][i].replace('重庆市', '').replace('南岸', ''))
  862. }
  863. itemInfo.deptList = arr
  864. itemInfo.oldDeptList = itemInfo[item.dep]
  865. }
  866. itemInfo.deptShow = itemInfo[item.dep] ? true : false
  867. itemInfo.navType = 0
  868. itemInfo.page = 1
  869. itemInfo.deptNow = ''
  870. let params = {
  871. page: 1,
  872. limit: itemInfo.limit,
  873. type: itemInfo.navType,
  874. }
  875. if (itemInfo.deptShow) {
  876. params.matterDept = itemInfo.oldDeptList.join(',')
  877. } else {
  878. params.matterDept = item.dep.replace('政府', '').replace('便民服务中心', '')
  879. }
  880. console.log(params)
  881. const _this = this
  882. getHandMatterPage(params).then((res) => {
  883. if (!(res && res.count > 0)) {
  884. itemInfo.matterStatus = false
  885. _this.setData({
  886. itemInfo: itemInfo
  887. })
  888. return
  889. }
  890. itemInfo.matterStatus = true
  891. itemInfo.pagePrev = itemInfo.page == 1
  892. itemInfo.pageNext = itemInfo.page * itemInfo.limit >= res.count
  893. itemInfo.matterList = res.data
  894. _this.setData({
  895. itemInfo: itemInfo
  896. })
  897. });
  898. that.setData({
  899. detail_dep: item.dep,
  900. detail_content: item.content,
  901. detail_img: item.img,
  902. detail_address: item.address,
  903. detail_time: item.time,
  904. detail_tel: item.tel,
  905. detail_index: i,
  906. trafficEnd: address,
  907. itemInfo: itemInfo
  908. });
  909. break;
  910. }
  911. }
  912. },
  913. aroundEvent(e) {
  914. const _this = this
  915. this.setData({
  916. isList: true,
  917. showSearch: false,
  918. showSet: false,
  919. showTraffic: false,
  920. popData: _this.data.marksView
  921. })
  922. },
  923. toDetailWeb(e) {
  924. console.log(e.currentTarget.dataset.url)
  925. // wx.navigateTo({
  926. // url: '/pages/web/web?gzUrl=' + e.currentTarget.dataset.url,
  927. // })
  928. },
  929. onchange(e) {
  930. let that = this;
  931. if (e.detail.value == 0) {
  932. that.setData({
  933. trafficType: 0
  934. });
  935. changeValue = "transit";
  936. } else {
  937. that.setData({
  938. trafficType: 1
  939. });
  940. changeValue = "driving";
  941. }
  942. },
  943. /**
  944. * 用户点击右上角分享
  945. */
  946. onShareAppMessage() {
  947. return {
  948. title: '地图服务'
  949. }
  950. },
  951. onShareTimeline(){
  952. return {
  953. title: '地图服务'
  954. }
  955. }
  956. });
  957. let changeValue = "transit";
  958. function searchHandMatter(that, queryVal) {
  959. // getHandMatterBySearch(queryVal).then((res) => {
  960. // if (res.data && res.data.length) {
  961. // searchDepVal(that, res.data.join(','), res.data)
  962. // }
  963. // });
  964. searchDepVal(that, queryVal, queryVal.split(","))
  965. }
  966. function searchDepVal(that, queryVal, deptArr) {
  967. let params = {
  968. title: queryVal
  969. }
  970. wx.showToast({
  971. title: '加载中...',
  972. icon: 'loading'
  973. });
  974. getMapDataType(params).then((res) => {
  975. let data = []
  976. let st = true, st2 = true
  977. deptArr.forEach((item) => {
  978. if (that.data.jnxc.indexOf(item) > -1 && st) {
  979. st = false
  980. let ite = that.data.xzfwzxs[0]
  981. if(ite.tel && !(ite.tel instanceof Array)){
  982. ite.tel = ite.tel.split(";")
  983. }
  984. data.push(ite)
  985. }
  986. if (that.data.npzx.indexOf(item) > -1 && st2) {
  987. st2 = false
  988. let ite = that.data.xzfwzxs[1]
  989. if(ite.tel && !(ite.tel instanceof Array)){
  990. ite.tel = ite.tel.split(";")
  991. }
  992. data.push(ite)
  993. }
  994. })
  995. res.data.forEach((item) => {
  996. if(item.tel!=null && item.tel!="" && !(item.tel instanceof Array)){
  997. item.tel = item.tel.split(";")
  998. }
  999. data.push(item)
  1000. });
  1001. that.setData({
  1002. showTraffic: false,
  1003. popData: data,
  1004. })
  1005. wx.hideLoading()
  1006. });
  1007. wx.hideLoading()
  1008. }
  1009. function initMapDataAll(that, lat, lng) {
  1010. let arr = that.data.marksInfo
  1011. console.log(arr)
  1012. let index = 0;
  1013. let addrArr = []
  1014. let marksView = []
  1015. let task = setInterval(function() {
  1016. if (index >= arr.length) {
  1017. addrArr.push({
  1018. latitude: lat,
  1019. longitude: lng,
  1020. iconPath: "/location.png",
  1021. width: '30px',
  1022. height: '30px',
  1023. rotate: 0,
  1024. alpha: 1
  1025. })
  1026. console.log(addrArr)
  1027. that.setData({
  1028. markers: addrArr,
  1029. marksView: marksView,
  1030. marksNum: addrArr.length - 1
  1031. })
  1032. clearInterval(task)
  1033. return
  1034. }
  1035. const address = arr[index]
  1036. index++
  1037. const jl = getDistances(lat, lng, address.latitude, address.longitude)
  1038. console.log(jl)
  1039. if (jl.m <= 1000) {
  1040. marksView.push(address)
  1041. addrArr.push({
  1042. id: address.id,
  1043. latitude: address.latitude,
  1044. longitude: address.longitude,
  1045. iconPath: imgUrl+"/location.png",
  1046. width: '34px',
  1047. height: '34px',
  1048. rotate: 0,
  1049. alpha: 1
  1050. })
  1051. }
  1052. // BMap.geocoder({
  1053. // address: address.address,
  1054. // success: (addr) => {
  1055. // BMap.calculateDistance({
  1056. // mode: 'straight',
  1057. // from: {
  1058. // latitude: lat,
  1059. // longitude: lng
  1060. // },
  1061. // to: [{
  1062. // latitude: addr.result.location.lat,
  1063. // longitude: addr.result.location.lng
  1064. // }],
  1065. // success: (json) => {
  1066. // console.log(getDistances(lat, lng, addr.result.location.lat, addr.result.location.lng))
  1067. // console.log(json)
  1068. // const jl = parseInt(json.result.elements[0].distance)
  1069. // if (jl <= 1000) {
  1070. // marksView.push(address)
  1071. // addrArr.push({
  1072. // id: address.id,
  1073. // latitude: json.result.elements[0].to.lat,
  1074. // longitude: json.result.elements[0].to.lng,
  1075. // iconPath: imgUrl+"/location.png",
  1076. // width: '34px',
  1077. // height: '34px',
  1078. // rotate: 0,
  1079. // alpha: 1
  1080. // })
  1081. // }
  1082. // }
  1083. // })
  1084. // }
  1085. // })
  1086. }, 10);
  1087. }
  1088. function searchHandMatterByValFun(that) {
  1089. searchHandMatterByVal(that.data.searchVal).then((res) => {
  1090. res.data.forEach((item) => {
  1091. const dept = item.depts.split(',')
  1092. let formtDept = item.fomartDept
  1093. const arr = dept.filter(value => that.data.jnxc.includes(value));
  1094. if (arr && arr.length) {
  1095. formtDept += ",区政务服务中心(江南新城中心)"
  1096. }
  1097. const arr2 = dept.filter(value => that.data.npzx.includes(value));
  1098. if (arr2 && arr2.length) {
  1099. formtDept += ",区政务服务中心(南坪中心)"
  1100. }
  1101. item.fomartDept = formtDept
  1102. })
  1103. let matterEventInfo = that.data.matterEventInfo
  1104. matterEventInfo.isShow = true
  1105. matterEventInfo.data = res.data
  1106. that.setData({
  1107. matterEventInfo: matterEventInfo
  1108. })
  1109. });
  1110. }
  1111. // 根据经纬度计算距离,参数分别为第一点的纬度,经度;第二点的纬度,经度
  1112. function getDistances(lat1, lng1, lat2, lng2) {
  1113. let EARTH_RADIUS = 6378.137;// 地球半径
  1114. let radLat1 = lat1 * Math.PI / 180.0; //lat1 * Math.PI / 180.0=>弧度计算
  1115. let radLat2 = lat2 * Math.PI / 180.0;
  1116. let a = radLat1 - radLat2;
  1117. let b = lng1 * Math.PI / 180.0 - lng2 * Math.PI / 180.0;
  1118. 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)));
  1119. s = s * EARTH_RADIUS;
  1120. s = Math.round(s * 10000) / 10000;// 输出为公里
  1121. return { m: s * 1000, km: Number(s.toFixed(2)) }
  1122. }