import { imgUrl } from "../api/request" import{ getMapDataType } 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, 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"}] ], 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 }, 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 () { this.loadItem(); 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) { const latitude = res.latitude const longitude = res.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 = 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 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 = 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") { that.setData({ isList: false, showSearch: false, showSet: false, }); } 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); 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 }); 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 = item.tel.split(";") } data.push(item) }); this.setData({ // showTraffic: false, popData: data, }) wx.hideToast({ success: (res) => {}, }); }); // 搜索结果 }, /** * 顶部搜索点击事件 * @param {*} e */ searchTap(e) { 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 = 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) { 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 if (!that.data.isList) { this.setData({ isList: true, showSearch: true, showSet: false }); } else { 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"; }, 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: '地图服务' } } }); let changeValue = "transit";