map.js 39 KB

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