map.js 39 KB

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