map.js 39 KB

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