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: { imgUrl: imgUrl, newImgUrl: newImgUrl, markers: [INIT_MARKER], latitude: '', longitude: '', 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"}] ], 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 () { const that = this this.loadItem(); getMapDataAll().then((res) => { let arr = [] 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: "我的位置", // markers: [{ // latitude: latitude, // longitude: longitude, // iconPath: "/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: "/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.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) { 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 }); } else { matterEventInfo.isShow = false matterEventInfo.search = false that.setData({ matterEventInfo: matterEventInfo }) if (!that.data.showTraffic) { that.setData({ showTraffic: true, showSearch: true, searchVal: '' }); } } 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 }); 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: "/location.png", width: '30px', height: '30px', rotate: 0, alpha: 1 }) 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) console.log(jl) if (jl.m <= 1000) { 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 }) } // 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)) } }