12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571 |
- import {
- imgUrl,
- newImgUrl
- } from "../api/request"
- import {
- getMapDataType,
- getHandMatterPage,
- getHandMatterBySearch,
- getMapDataAll,
- searchHandMatterByVal
- } from "../api/yxna-api"
- var QQMapWX = require('../../libs/qqmap-wx-jssdk.min.js');
- const popType = [
- [
- [{
- "name": "受理场所",
- "dictType": "jzs,bms",
- "type": ""
- }, {
- "name": "查阅场所",
- "dictType": "cycsbms,slcsjzs",
- "type": ""
- }, ],
- [{
- "name": "区级政务服务中心",
- "dictType": "xzfwzxs",
- "type": ""
- }, {
- "name": "镇(街道)便民服务中心",
- "dictType": "ggfwzxs",
- "type": ""
- }, {
- "name": "村(社区)便民服务站",
- "dictType": "bmfwzxs",
- "type": ""
- }, {
- "name": "生源地助学贷款办理点",
- "dictType": "dkblds",
- "type": ""
- }],
- [{
- "name": "党群服务中心",
- "dictType": "dqfwzxs",
- "type": ""
- }],
- [{
- "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"
- }]
- ],
- [
- [{
- "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": ""
- }],
- [{
- "name": "派出所",
- "dictType": "pcss",
- "type": ""
- }, {
- "name": "出入境业务办理机构",
- "dictType": "crjywbljgs",
- "type": ""
- }],
- [{
- "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": ""
- }],
- [{
- "name": "就业和人才中心",
- "dictType": "jyhrczxs",
- "type": ""
- }, {
- "name": "社会保险事务中心",
- "dictType": "shbxswzxs",
- "type": ""
- }]
- ],
- [
- [{
- "name": "养老机构",
- "dictType": "ylfwjgs",
- "type": ""
- }],
- [{
- "name": "婚姻登记机构",
- "dictType": "hydjcs",
- "type": ""
- }, {
- "name": "殡仪服务机构",
- "dictType": "byfwjgs",
- "type": ""
- }],
- [],
- []
- ],
- [
- [],
- [],
- [],
- [{
- "name": "图书馆",
- "dictType": "tsgs",
- "type": ""
- }, {
- "name": "文化馆",
- "dictType": "whgs",
- "type": ""
- }, {
- "name": "文管所",
- "dictType": "wgss",
- "type": ""
- }, {
- "name": "公共体育馆",
- "dictType": "ggtys",
- "type": ""
- }, {
- "name": "旅游景点",
- "dictType": "jqs",
- "type": ""
- }, {
- "name": "公园",
- "dictType": "gys",
- "type": ""
- }]
- ],
- [
- [{
- "name": "公证处",
- "dictType": "gzcs",
- "type": ""
- }, {
- "name": "司法鉴定机构",
- "dictType": "sfjdjgs",
- "type": ""
- }, {
- "name": "基层司法所",
- "dictType": "jcfwfwss",
- "type": ""
- }, {
- "name": "法律援助机构",
- "dictType": "flyzzxs",
- "type": ""
- }, {
- "name": "矫正中心",
- "dictType": "jzzxs",
- "type": ""
- }],
- [{
- "name": "残疾人服务中心",
- "dictType": "cjrfwzxs",
- "type": ""
- }, {
- "name": "定点残疾人服务机构",
- "dictType": "qtcjrfwzxs",
- "type": ""
- }],
- [],
- [{
- "name": "商圈",
- "dictType": "sqs",
- "type": ""
- }, {
- "name": "购物中心",
- "dictType": "gwzxs",
- "type": ""
- }, {
- "name": "酒店",
- "dictType": "jds",
- "type": ""
- }]
- ],
- [
- [],
- [],
- [],
- []
- ]
- ]
- let BMap = {};
- let x = null;
- let y = null;
- const INIT_MARKER = {
- latitude: 0,
- longitude: 0,
- iconPath: imgUrl + "/location.png",
- width: '34px',
- height: '34px',
- rotate: 0,
- alpha: 1
- };
- Page({
- data: {
- issy:false,
- imgUrl: imgUrl,
- newImgUrl: newImgUrl,
- markers: [INIT_MARKER],
- latitude: '',
- longitude: '',
- custGap: 1000,
- type: [
- [{
- "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": ""
- }],
- [{
- "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": ""
- }],
- [{
- "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"
- }],
- [{
- "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": ""
- }],
- [{
- "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": ""
- }],
- [{
- "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"
- }]
- ],
- circle: [],
- popData: [{
- "popName": "",
- "data": []
- }],
- showIndex: false,
- showSearch: true,
- showTraffic: true,
- height: 0,
- searchVal: '',
- loadValue: '',
- trafficStart: '',
- trafficEnd: '',
- index: 0,
- isList: true,
- showSet: false,
- trafficType: 0,
- page: 0,
- limit: 15,
- marksInfo: [],
- marksView: [],
- marksNum: 0,
- searchInfo: {
- navType: 0,
- isShow: false
- },
- matterEventInfo: {
- data: [],
- isShow: false,
- search: false
- },
- itemInfo: {
- page: 1,
- limit: 6,
- navType: 0,
- deptNow: '',
- pageNext: true,
- pagePrev: false,
- matterStatus: true,
- matterList: [{
- itemName: '',
- matterUrl: ''
- }],
- '重庆市南岸区政务服务中心(江南新城中心)': ['重庆市南岸区残联', '重庆市南岸区财政局', '重庆市南岸区文化和旅游发展委员会', '重庆市南岸区档案馆', '重庆市南岸区卫生健康委员会', '重庆市南岸区交通局', '重庆市南岸区规划自然资源局', '重庆市南岸区住房和城乡建设委员会', '重庆市南岸区生态环境局', '重庆市南岸区农业农村委员会', '重庆市南岸区发展和改革委员会', '重庆市南岸区消防救援支队', '重庆市南岸区城市管理局', '重庆市公安局南岸分局'],
- '重庆市南岸区政务服务中心(南坪中心)': ['重庆市南岸区市场监管局', '重庆市公安局南岸分局'],
- },
- jnxc: ['重庆市南岸区残联', '重庆市南岸区财政局', '重庆市南岸区文化和旅游发展委员会', '重庆市南岸区档案馆', '重庆市南岸区卫生健康委员会', '重庆市南岸区交通局', '重庆市南岸区规划自然资源局', '重庆市南岸区住房和城乡建设委员会', '重庆市南岸区生态环境局', '重庆市南岸区农业农村委员会', '重庆市南岸区发展和改革委员会', '重庆市南岸区消防救援支队', '重庆市南岸区城市管理局', '重庆市公安局南岸分局'],
- npzx: ['重庆市南岸区市场监管局', '重庆市公安局南岸分局'],
- },
- onLoad: function (options) {
- this.setData({
- height: wx.getSystemInfoSync().windowHeight
- })
- // console.log(options);
- if (options.se) {
- this.setData({
- loadValue: options.se,
- showTraffic: false
- });
- } else {
- this.setData({
- showTraffic: true
- })
- }
- // searchVal
- },
- onReady: function () {
- // debugger
- const that = this
- this.loadItem();
- getMapDataAll().then((res) => {
- let arr = []
- console.log(res.data);
- for (const key in res.data) {
- // console.log(res.data[key]);
- Array.prototype.push.apply(arr, res.data[key])
- }
- // Array.prototype.push.apply(arr, res.data.xzfwzxs);
- // Array.prototype.push.apply(arr, res.data.ggfwzxs);
- for (let j = 0; j < arr.length; j++) {
- if (arr[j].tel && !(arr[j].tel instanceof Array)) {
- arr[j].tel = arr[j].tel.split(";")
- }
- }
- that.setData({
- xzfwzxs: res.data.xzfwzxs,
- marksInfo: arr
- })
- this.setMap();
- });
- // this.setMap();
- },
- async setMap() {
- var that = this;
- BMap = await new QQMapWX({
- key: 'KN3BZ-KUDND-PGH4Y-POVRP-43KF3-RNF4K'
- });
- wx.getLocation({
- type: 'gcj02', //返回可以用于wx.openLocation的经纬度
- success(res) {
- console.log(res)
- const latitude = res.latitude
- const longitude = res.longitude
- initMapDataAll(that, latitude, longitude)
- that.setData({
- latitude: latitude,
- longitude: longitude,
- trafficStart: "我的位置",
- circle: [{
- latitude: res.latitude,
- longitude: res.longitude,
- radius: that.data.custGap + 500,
- fillColor: '#c4d2ec6a',
- color: '#c4d2ec'
- }],
- markers: [{
- latitude: latitude,
- longitude: longitude,
- iconPath: imgUrl + "/location.png",
- width: '30px',
- height: '30px',
- rotate: 0,
- alpha: 1
- }]
- });
- }
- });
- },
- popview(e) {
- let x = e.currentTarget.dataset.index;
- let y = e.currentTarget.dataset.id;
- let pop = popType[x][y - 1]
- if (pop.length > 0) {
- // this.setTypeDateToPop2(pop)
- this.setData({
- popData: pop,
- showIndex: true
- });
- } else {
- let pop = this.data.type[x][y - 1]
- // console.log(pop);
- this.setDateToPop(pop)
- this.setData({
- showTraffic: false,
- showIndex: false
- })
- }
- },
- setTypeDateToPop2: function (pop) {
- let arr = [];
- pop.forEach(e => {
- arr.push({
- "popName": e.name
- })
- })
- this.setData({
- popData: arr
- })
- },
- setDateToPop: function (pop) {
- let arr = [];
- let params = {
- "dictType": pop.dictType,
- "type": "",
- "title": "",
- };
- wx.showToast({
- title: '加载中...',
- icon: 'loading'
- });
- getMapDataType(params).then((res) => {
- console.log(res.data[0].tel);
- let data = []
- res.data.forEach((item) => {
- if (item.tel != null && item.tel != "" && !(item.tel instanceof Array)) {
- item.tel = item.tel.split(";")
- }
- data.push(item)
- });
- this.setData({
- popData: data,
- })
- wx.hideToast({
- success: (res) => {},
- });
- });
- },
- closePopup() {
- this.setData({
- showIndex: false
- })
- },
- changeInfo(e) {
- // console.log(e.currentTarget.dataset.data);
- let searchInfo = this.data.searchInfo
- searchInfo.isShow = false
- this.setData({
- searchInfo: searchInfo
- })
- let dataitem = e.currentTarget.dataset.data;
- console.log(dataitem);
- let params = {
- "dictType": dataitem.dictType,
- "type": "",
- "title": "",
- };
- wx.showToast({
- title: '加载中...',
- icon: 'loading'
- });
- getMapDataType(params).then((res) => {
- let data = []
- switch (dataitem.name) {
- case "小学":
- case "特殊教育学校":
- res.data.forEach((item) => {
- if (item.type == dataitem.name) {
- data.push(item)
- }
- });
- break;
- case "中学":
- res.data.forEach((item) => {
- if (item.type == dataitem.name || item.specialtype == dataitem.name) {
- data.push(item)
- }
- });
- break;
- default:
- data = res.data;
- break;
- }
- let renderData = []
- data.forEach((item) => {
- if (item.tel != null && item.tel != "" && !(item.tel instanceof Array)) {
- item.tel = item.tel.split(";")
- }
- renderData.push(item)
- });
- this.setData({
- popData: renderData,
- showTraffic: false,
- showIndex: false
- })
- wx.hideToast({
- success: (res) => {},
- });
- });
- },
- /**
- * 拨打电话
- * @param {*} e
- */
- callNumber(e) {
- let phoneNumber = e.currentTarget.dataset.value;
- wx.makePhoneCall({
- phoneNumber: phoneNumber,
- });
- },
- /**
- * list跳转info
- *
- */
- changeItem(e) {
- let that = this;
- console.info(e)
- let value = e.currentTarget.dataset.value;
- if (value === "none") {
- let searchInfo = that.data.searchInfo
- searchInfo.isShow = false
- that.setData({
- isList: false,
- showSearch: false,
- showSet: false,
- searchInfo: searchInfo
- });
- } else {
- // 控制公交自驾选中状态
- let type = e.currentTarget.dataset.type;
- if (type == 0) {
- if (e.detail.value == 0) {
- changeValue = "transit";
- } else {
- changeValue = "driving";
- }
- }
- that.setData({
- trafficType: type,
- showSet: false
- });
- that.setData({
- isList: false,
- showSearch: false,
- showSet: true
- });
- }
- // 详情赋值
- let index = e.currentTarget.dataset.index;
- let item = that.data.popData[index];
- console.info(item);
- let address = '';
- if (item.address.search("重庆") == -1) {
- address = "重庆" + item.address;
- } else {
- address = item.address;
- }
- console.log(item.time);
- let itemInfo = that.data.itemInfo
- if (itemInfo[item.dep]) {
- let arr = []
- for (let i = 0; i < itemInfo[item.dep].length; i++) {
- arr.push(itemInfo[item.dep][i].replace('重庆市', '').replace('南岸', ''))
- }
- itemInfo.deptList = arr
- itemInfo.oldDeptList = itemInfo[item.dep]
- }
- itemInfo.deptShow = itemInfo[item.dep] ? true : false
- itemInfo.navType = 0
- itemInfo.page = 1
- itemInfo.deptNow = ''
- let params = {
- page: 1,
- limit: itemInfo.limit,
- type: itemInfo.navType,
- }
- if (itemInfo.deptShow) {
- params.matterDept = itemInfo.oldDeptList.join(',')
- } else {
- params.matterDept = item.dep.replace('政府', '').replace('便民服务中心', '')
- }
- const _this = this
- getHandMatterPage(params).then((res) => {
- if (!(res && res.count > 0)) {
- itemInfo.matterStatus = false
- _this.setData({
- itemInfo: itemInfo
- })
- return
- }
- itemInfo.matterStatus = true
- itemInfo.pagePrev = itemInfo.page == 1
- itemInfo.pageNext = itemInfo.page * itemInfo.limit >= res.count
- itemInfo.matterList = res.data
- _this.setData({
- itemInfo: itemInfo
- })
- });
- that.setData({
- detail_dep: item.dep,
- detail_content: item.content,
- detail_img: item.img,
- detail_address: item.address,
- detail_time: item.time,
- detail_tel: item.tel,
- detail_index: index,
- trafficEnd: address,
- itemInfo: itemInfo
- });
- BMap.geocoder({
- address: address,
- success: function (data) {
- var res = data.result
- that.setData({
- latitude: res.location.lat,
- longitude: res.location.lng,
- markers: [{
- latitude: res.location.lat,
- longitude: res.location.lng,
- iconPath: imgUrl + "/location.png",
- width: '30px',
- height: '30px',
- rotate: 0,
- alpha: 1
- }]
- });
- }
- });
- },
- /**
- * 打开全景地图
- * @param {*} e
- */
- openVR(e) {
- wx.navigateTo({
- url: '../map-vr/map-vr',
- });
- },
- getSearchVal(e) {
- this.setData({
- searchVal: e.detail.value
- });
- },
- loadItem() {
- let searchVal = this.data.loadValue;
- let datatype = this.data.type;
- if (!searchVal) {
- return;
- }
- wx.showToast({
- title: '加载中...',
- icon: 'loading'
- });
- let x = -1
- let y = -1
- for (let i = 0; i < datatype.length; i++) {
- for (let j = 0; j < datatype[i].length; j++) {
- if (datatype[i][j].name == searchVal) {
- x = i
- y = j
- break;
- }
- }
- if (x != -1) {
- break;
- }
- }
- let searcharr = ""
- if (datatype[x][y].dictType != "") {
- searcharr = datatype[x][y].dictType
- } else {
- let arr = popType[x][y]
- arr.forEach((item) => {
- searcharr += item.dictType + ","
- })
- searcharr = searcharr.substring(0, searcharr.length - 1)
- }
- let params = {
- "dictType": searcharr,
- "type": "",
- "title": "",
- };
- getMapDataType(params).then((res) => {
- let data = []
- res.data.forEach((item) => {
- if (item.tel != null && item.tel != "" && !(item.tel instanceof Array)) {
- item.tel = item.tel.split(";")
- }
- data.push(item)
- });
- this.setData({
- // showTraffic: false,
- popData: data,
- })
- wx.hideToast({
- success: (res) => {},
- });
- });
- // 搜索结果
- },
- /**
- * 顶部搜索点击事件
- * @param {*} e
- */
- searchTap(e) {
- let searchInfo = this.data.searchInfo
- searchInfo.isShow = true
- searchInfo.navType = 0
- this.setData({
- searchInfo: searchInfo
- })
- let searchVal = this.data.searchVal;
- wx.showToast({
- title: '加载中...',
- icon: 'loading'
- });
- let params = {
- "dictType": "",
- "type": "",
- "title": searchVal,
- };
- this.setData({
- showTraffic: false
- })
- getMapDataType(params).then((res) => {
- let data = []
- res.data.forEach((item) => {
- if (item.tel != null && item.tel != "" && !(item.tel instanceof Array)) {
- item.tel = item.tel.split(";")
- }
- data.push(item)
- });
- this.setData({
- showTraffic: false,
- popData: data,
- })
- wx.hideToast({
- success: (res) => {},
- });
- });
- // 搜索结果
- wx.hideToast({
- success: (res) => {},
- });
- },
- getTrafficStart(e) {
- this.setData({
- trafficStart: e.detail.value
- });
- },
- getTrafficEnd(e) {
- this.setData({
- trafficEnd: e.detail.value
- });
- },
- /**
- * 搜索进行交通路线规划
- * @param {*} e
- */
- searchTrafficTap(e) {
- const that = this;
- // console.log(that.data.trafficType);
- let trafficType = that.data.trafficType;
- if (trafficType == 0) {
- changeValue = "transit";
- } else {
- changeValue = "driving";
- }
- let trafficStart = that.data.trafficStart;
- let trafficEnd = that.data.trafficEnd;
- if (!trafficStart || !trafficEnd) {
- wx.showToast({
- title: '请输入起点和终点',
- icon: 'none'
- });
- return;
- }
- console.info(trafficStart, trafficEnd);
- BMap.geocoder({
- address: trafficEnd,
- success: function (data) {
- console.log(data);
- var res = data.result
- // console.log(res);
- let key = 'KN3BZ-KUDND-PGH4Y-POVRP-43KF3-RNF4K'; //使用在腾讯位置服务申请的key
- let referer = '掌上南岸'; //调用插件的app的名称
- // 终点
- let endPoint = JSON.stringify({
- 'name': trafficEnd,
- 'latitude': res.location.lat,
- 'longitude': res.location.lng
- });
- wx.openLocation({
- name: trafficEnd,
- latitude: res.location.lat,
- longitude: res.location.lng
- })
- // wx.navigateTo({
- // url: 'plugin://routePlan/index?key=' + key + '&referer=' + referer + '&endPoint=' + endPoint + "&mode=" + changeValue
- // });
- },
- });
- },
- backSearch() {
- let that = this
- let searchInfo = that.data.searchInfo
- searchInfo.isShow = that.data.searchVal ? true : false
- that.setData({
- searchInfo: searchInfo
- })
- let matterEventInfo = that.data.matterEventInfo
- console.log(matterEventInfo)
- if (!that.data.isList) {
- if (that.data.issy) {
- that.setData({
- showTraffic: true,
- showSearch: true,
- searchVal: ''
- });
- this.setMap();
- return
- }
- matterEventInfo.isShow = searchInfo.navType != 1
- this.setData({
- isList: true,
- showSearch: true,
- showSet: false,
- matterEventInfo: matterEventInfo
- });
- } else if (!matterEventInfo.isShow && matterEventInfo.search) {
- matterEventInfo.isShow = true
- this.setData({
- isList: true,
- showSearch: true,
- showSet: false,
- matterEventInfo: matterEventInfo
- });
- // this.setMap();
- } else {
- matterEventInfo.isShow = false
- matterEventInfo.search = false
- that.setData({
- matterEventInfo: matterEventInfo
- })
- if (!that.data.showTraffic) {
- that.setData({
- showTraffic: true,
- showSearch: true,
- searchVal: ''
- });
- }
- this.setMap();
- }
- wx.getLocation({
- type: 'gcj02', //返回可以用于wx.openLocation的经纬度
- success(res) {
- const latitude = res.latitude
- const longitude = res.longitude
- that.setData({
- latitude: latitude,
- longitude: longitude,
- trafficStart: "我的位置",
- markers: [{
- latitude: latitude,
- longitude: longitude,
- iconPath: imgUrl + "/location.png",
- width: '34px',
- height: '34px',
- rotate: 0,
- alpha: 1
- }]
- });
- }
- })
- changeValue = "transit";
- },
- matterTab(e) {
- let itemInfo = this.data.itemInfo
- itemInfo.navType = e.currentTarget.dataset?.type
- let params = {
- page: 1,
- limit: itemInfo.limit,
- type: itemInfo.navType,
- }
- if (itemInfo.deptShow) {
- if (itemInfo.deptList && itemInfo.deptList.indexOf(itemInfo.deptNow) > -1) {
- params.matterDept = itemInfo.deptNow.replace('政府', '').replace('便民服务中心', '')
- } else {
- params.matterDept = itemInfo.oldDeptList.join(',')
- }
- } else {
- params.matterDept = this.data.detail_dep.replace('政府', '').replace('便民服务中心', '')
- }
- const _this = this
- getHandMatterPage(params).then((res) => {
- if (!(res && res.count > 0)) {
- itemInfo.matterStatus = false
- _this.setData({
- itemInfo: itemInfo
- })
- return
- }
- itemInfo.matterStatus = true
- itemInfo.page = 1
- itemInfo.pagePrev = itemInfo.page == 1
- itemInfo.pageNext = itemInfo.page * itemInfo.limit >= res.count
- itemInfo.matterList = res.data
- _this.setData({
- itemInfo: itemInfo
- })
- });
- },
- clickDept(e) {
- console.log(e)
- let itemInfo = this.data.itemInfo
- itemInfo.deptNow = e.currentTarget.dataset.dept
- itemInfo.page = 1
- this.setData({
- itemInfo: itemInfo
- })
- let params = {
- page: itemInfo.page,
- limit: itemInfo.limit,
- type: itemInfo.navType,
- }
- if (itemInfo.deptShow) {
- if (itemInfo.deptList && itemInfo.deptList.indexOf(itemInfo.deptNow) > -1) {
- params.matterDept = itemInfo.deptNow
- } else {
- params.matterDept = itemInfo.oldDeptList.join(',')
- }
- } else {
- params.matterDept = this.data.detail_dep
- }
- const _this = this
- getHandMatterPage(params).then((res) => {
- if (!(res && res.count > 0)) {
- itemInfo.matterStatus = false
- _this.setData({
- itemInfo: itemInfo
- })
- return
- }
- itemInfo.pagePrev = itemInfo.page == 1
- itemInfo.pageNext = itemInfo.page * itemInfo.limit >= res.count
- itemInfo.matterList = res.data
- _this.setData({
- itemInfo: itemInfo
- })
- });
- },
- clickPageTo(e) {
- let itemInfo = this.data.itemInfo
- let page = 1
- if (e.currentTarget.dataset.type == 0) {
- // 上一页
- if (itemInfo.pagePrev) return
- page = itemInfo.page - 1
- } else {
- if (itemInfo.pageNext) return
- page = itemInfo.page + 1
- }
- let params = {
- page: page,
- limit: itemInfo.limit,
- type: itemInfo.navType,
- }
- if (itemInfo.deptShow) {
- if (itemInfo.deptList && itemInfo.deptList.indexOf(itemInfo.deptNow) > -1) {
- params.matterDept = itemInfo.deptNow.replace('政府', '').replace('便民服务中心', '')
- } else {
- params.matterDept = itemInfo.oldDeptList.join(',')
- }
- } else {
- params.matterDept = this.data.detail_dep.replace('政府', '').replace('便民服务中心', '')
- }
- const _this = this
- getHandMatterPage(params).then((res) => {
- if (!(res && res.count > 0)) {
- itemInfo.matterStatus = false
- _this.setData({
- itemInfo: itemInfo
- })
- return
- }
- itemInfo.matterStatus = true
- itemInfo.page = page
- itemInfo.pagePrev = itemInfo.page == 1
- itemInfo.pageNext = itemInfo.page * itemInfo.limit >= res.count
- itemInfo.matterList = res.data
- _this.setData({
- itemInfo: itemInfo
- })
- });
- },
- searchTab(e) {
- let searchInfo = this.data.searchInfo
- searchInfo.navType = e.currentTarget.dataset.type
- this.setData({
- searchInfo: searchInfo
- })
- const _this = this
- if (searchInfo.navType == 0) {
- let params = {
- "title": _this.data.searchVal,
- };
- getMapDataType(params).then((res) => {
- let data = []
- res.data.forEach((item) => {
- if (item.tel != null && item.tel != "" && !(item.tel instanceof Array)) {
- item.tel = item.tel.split(";")
- }
- data.push(item)
- });
- this.setData({
- showTraffic: false,
- popData: data,
- })
- });
- } else {
- let matterEventInfo = _this.data.matterEventInfo
- matterEventInfo.search = true
- _this.setData({
- matterEventInfo: matterEventInfo
- })
- searchHandMatterByValFun(_this)
- // searchHandMatter(_this)
- }
- },
- clickMatterEvent(e) {
- const _this = this
- let matterEventInfo = _this.data.matterEventInfo
- matterEventInfo.isShow = false
- _this.setData({
- matterEventInfo: matterEventInfo
- })
- console.log(_this.data)
- searchHandMatter(_this, e.currentTarget.dataset.depts)
- },
- markClick(e) {
- if (!e.markerId) {
- return
- }
- const arr = this.data.marksInfo
- const that = this
- this.setData({
- popData: arr
- })
- for (let i = 0; i < arr.length; i++) {
- if (arr[i].id == e.markerId) {
- let searchInfo = that.data.searchInfo
- searchInfo.isShow = false
- that.setData({
- isList: false,
- showSearch: false,
- showSet: false,
- showTraffic: false,
- searchInfo: searchInfo,
- issy:true
- });
- let item = arr[i];
- console.info(item);
- if (item.tel && !(item.tel instanceof Array)) {
- item.tel = item.tel.split(";")
- }
- let address = item.address
- console.log(item.time);
- let itemInfo = that.data.itemInfo
- if (itemInfo[item.dep]) {
- let arr = []
- for (let i = 0; i < itemInfo[item.dep].length; i++) {
- arr.push(itemInfo[item.dep][i].replace('重庆市', '').replace('南岸', ''))
- }
- itemInfo.deptList = arr
- itemInfo.oldDeptList = itemInfo[item.dep]
- }
- itemInfo.deptShow = itemInfo[item.dep] ? true : false
- itemInfo.navType = 0
- itemInfo.page = 1
- itemInfo.deptNow = ''
- let params = {
- page: 1,
- limit: itemInfo.limit,
- type: itemInfo.navType,
- }
- if (itemInfo.deptShow) {
- params.matterDept = itemInfo.oldDeptList.join(',')
- } else {
- params.matterDept = item.dep.replace('政府', '').replace('便民服务中心', '')
- }
- console.log(params)
- const _this = this
- getHandMatterPage(params).then((res) => {
- if (!(res && res.count > 0)) {
- itemInfo.matterStatus = false
- _this.setData({
- itemInfo: itemInfo
- })
- return
- }
- itemInfo.matterStatus = true
- itemInfo.pagePrev = itemInfo.page == 1
- itemInfo.pageNext = itemInfo.page * itemInfo.limit >= res.count
- itemInfo.matterList = res.data
- _this.setData({
- itemInfo: itemInfo
- })
- });
- that.setData({
- detail_dep: item.dep,
- detail_content: item.content,
- detail_img: item.img,
- detail_address: item.address,
- detail_time: item.time,
- detail_tel: item.tel,
- detail_index: i,
- trafficEnd: address,
- itemInfo: itemInfo
- });
- break;
- }
- }
- },
- aroundEvent(e) {
- const _this = this
- this.setData({
- isList: true,
- showSearch: false,
- showSet: false,
- showTraffic: false,
- popData: _this.data.marksView
- })
- },
- toDetailWeb(e) {
- console.log(e.currentTarget.dataset.url)
- // wx.navigateTo({
- // url: '/pages/web/web?gzUrl=' + e.currentTarget.dataset.url,
- // })
- },
- onchange(e) {
- let that = this;
- if (e.detail.value == 0) {
- that.setData({
- trafficType: 0
- });
- changeValue = "transit";
- } else {
- that.setData({
- trafficType: 1
- });
- changeValue = "driving";
- }
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage() {
- return {
- title: '地图服务'
- }
- },
- onShareTimeline() {
- return {
- title: '地图服务'
- }
- },
- openShq() {
- wx.navigateTo({
- url: '/pages/map-shq/map-shq',
- })
- }
- });
- let changeValue = "transit";
- function searchHandMatter(that, queryVal) {
- // getHandMatterBySearch(queryVal).then((res) => {
- // if (res.data && res.data.length) {
- // searchDepVal(that, res.data.join(','), res.data)
- // }
- // });
- searchDepVal(that, queryVal, queryVal.split(","))
- }
- function searchDepVal(that, queryVal, deptArr) {
- let params = {
- title: queryVal
- }
- wx.showToast({
- title: '加载中...',
- icon: 'loading'
- });
- getMapDataType(params).then((res) => {
- let data = []
- let st = true,
- st2 = true
- deptArr.forEach((item) => {
- if (that.data.jnxc.indexOf(item) > -1 && st) {
- st = false
- let ite = that.data.xzfwzxs[0]
- if (ite.tel && !(ite.tel instanceof Array)) {
- ite.tel = ite.tel.split(";")
- }
- data.push(ite)
- }
- if (that.data.npzx.indexOf(item) > -1 && st2) {
- st2 = false
- let ite = that.data.xzfwzxs[1]
- if (ite.tel && !(ite.tel instanceof Array)) {
- ite.tel = ite.tel.split(";")
- }
- data.push(ite)
- }
- })
- res.data.forEach((item) => {
- if (item.tel != null && item.tel != "" && !(item.tel instanceof Array)) {
- item.tel = item.tel.split(";")
- }
- data.push(item)
- });
- that.setData({
- showTraffic: false,
- popData: data,
- })
- wx.hideLoading()
- });
- wx.hideLoading()
- }
- function initMapDataAll(that, lat, lng) {
- let arr = that.data.marksInfo
- console.log(arr)
- let index = 0;
- let addrArr = []
- let marksView = []
- let task = setInterval(function () {
- if (index >= arr.length) {
- addrArr.push({
- latitude: lat,
- longitude: lng,
- iconPath: imgUrl + "/location.png",
- width: '30px',
- height: '30px',
- rotate: 0,
- alpha: 1,
- label: {
- anchorX: 10,
- anchorY: -22,
- bgColor: '#fff',
- borderRadius: 5,
- padding: 5,
- content: "我的位置",
- color: '#333'
- }
- })
- console.log(addrArr)
- that.setData({
- markers: addrArr,
- marksView: marksView,
- marksNum: addrArr.length - 1
- })
- clearInterval(task)
- return
- }
- const address = arr[index]
- index++
- const jl = getDistances(lat, lng, address.latitude, address.longitude)
- if (jl.m <= that.data.custGap) {
- marksView.push(address)
- addrArr.push({
- id: address.id,
- latitude: address.latitude,
- longitude: address.longitude,
- iconPath: imgUrl + "/location.png",
- width: '34px',
- height: '34px',
- rotate: 0,
- alpha: 1,
- label: {
- anchorX: 10,
- anchorY: -22,
- bgColor: '#fff',
- borderRadius: 5,
- padding: 5,
- content: address.dep,
- color: '#333'
- }
- })
- }
- // BMap.geocoder({
- // address: address.address,
- // success: (addr) => {
- // BMap.calculateDistance({
- // mode: 'straight',
- // from: {
- // latitude: lat,
- // longitude: lng
- // },
- // to: [{
- // latitude: addr.result.location.lat,
- // longitude: addr.result.location.lng
- // }],
- // success: (json) => {
- // console.log(getDistances(lat, lng, addr.result.location.lat, addr.result.location.lng))
- // console.log(json)
- // const jl = parseInt(json.result.elements[0].distance)
- // if (jl <= 1000) {
- // marksView.push(address)
- // addrArr.push({
- // id: address.id,
- // latitude: json.result.elements[0].to.lat,
- // longitude: json.result.elements[0].to.lng,
- // iconPath: imgUrl+"/location.png",
- // width: '34px',
- // height: '34px',
- // rotate: 0,
- // alpha: 1
- // })
- // }
- // }
- // })
- // }
- // })
- }, 10);
- }
- function searchHandMatterByValFun(that) {
- searchHandMatterByVal(that.data.searchVal).then((res) => {
- res.data.forEach((item) => {
- const dept = item.depts.split(',')
- let formtDept = item.fomartDept
- const arr = dept.filter(value => that.data.jnxc.includes(value));
- if (arr && arr.length) {
- formtDept += ",区政务服务中心(江南新城中心)"
- }
- const arr2 = dept.filter(value => that.data.npzx.includes(value));
- if (arr2 && arr2.length) {
- formtDept += ",区政务服务中心(南坪中心)"
- }
- item.fomartDept = formtDept
- })
- let matterEventInfo = that.data.matterEventInfo
- matterEventInfo.isShow = true
- matterEventInfo.data = res.data
- that.setData({
- matterEventInfo: matterEventInfo
- })
- });
- }
- // 根据经纬度计算距离,参数分别为第一点的纬度,经度;第二点的纬度,经度
- function getDistances(lat1, lng1, lat2, lng2) {
- let EARTH_RADIUS = 6378.137; // 地球半径
- let radLat1 = lat1 * Math.PI / 180.0; //lat1 * Math.PI / 180.0=>弧度计算
- let radLat2 = lat2 * Math.PI / 180.0;
- let a = radLat1 - radLat2;
- let b = lng1 * Math.PI / 180.0 - lng2 * Math.PI / 180.0;
- 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)));
- s = s * EARTH_RADIUS;
- s = Math.round(s * 10000) / 10000; // 输出为公里
- return {
- m: s * 1000,
- km: Number(s.toFixed(2))
- }
- }
|