From 626003e9beb59cf711f59f3b48087300070f121e Mon Sep 17 00:00:00 2001 From: lixuliang <lixuliang_hd@126.com> Date: 星期五, 15 三月 2024 09:49:31 +0800 Subject: [PATCH] 优化 --- src/components/leftMenu/sousuo.vue | 431 +++++++++++++++++++++++++++-------------------------- 1 files changed, 220 insertions(+), 211 deletions(-) diff --git a/src/components/leftMenu/sousuo.vue b/src/components/leftMenu/sousuo.vue index a7740c9..07aeca6 100644 --- a/src/components/leftMenu/sousuo.vue +++ b/src/components/leftMenu/sousuo.vue @@ -282,6 +282,100 @@ rectangle.maxy > 31.182515322 && (rectangle.maxy = 31.182515322); return `RECT(${rectangle.minx} ${rectangle.miny},${rectangle.maxx} ${rectangle.maxy})`; }, + getGdPoi() { + axios + .get(common.poiserve, { + params: { + request: "GdPoi", + keywords: this.poi_text, + output: "json", + coord: "cgcs2000", + offset: 20, + page: 1, + }, + }) + .then((res) => { + // 楂樺痉 + if (res.data.status == 1) { + res.data.pois && + res.data.pois + .filter((item) => { + var reg = new RegExp("[\\u4E00-\\u9FFF]+", "g"); + return ( + item.pname.includes("鍖椾含") && + item.name.includes(this.poi_text) && + !reg.test(item.typecode) + ); + }) + .forEach((val) => { + let poiarr = val.location.split(","); + let poi = { + lon: parseFloat(poiarr[0]), + lat: parseFloat(poiarr[1]), + }; + let obj = { + adcode: val.adcode, + address: val.address, + adname: val.area, + citycode: val.citycode, + cityname: val.cityname, + id: val.uid, + lat: poi.lat, + lng: poi.lon, + name: val.name, + pcode: val.pcode, + pname: val.province, + type: val.type, + typecode: val.typecode, + }; + Allresults.push(obj); + }); + } + this.total = Allresults.length; + this.poiList = Allresults; + this.showList = true; + }); + }, + getData() { + axios + .post(common.poiserve2, { + adcode: "110115", + address: { + name: "", + type: "", + }, + adname: "澶у叴鍖�", + cityname: "鍖椾含甯�", + name: { + name: this.poi_text, + type: "", + }, + page: 1, + perPageCount: 20, + pcode: "110000", + pname: "", + resType: "", + }) + .then((res) => { + if (res.status == 200) { + res.data.data.res && + res.data.data.res + .filter((item) => { + // 鍒ゆ柇鍦板潡鏄惁鏈夋眽瀛� + var reg = new RegExp("[\\u4E00-\\u9FFF]+", "g"); + return ( + item.name.includes(this.poi_text) && reg.test(item.typecode) + ); + }) + .forEach((val) => { + Allresults.push(val); + }); + } + this.total = Allresults.length; + this.poiList = Allresults; + this.showList = true; + }); + }, search() { if (this.poi_text === "") { this.poiList = []; @@ -292,221 +386,136 @@ this.poiList = []; switch (this.select) { case "鍏ㄩ儴": - axios - .all([ - // 115鎺ュ彛锛堝彲鏌ュ湴鍧楀悕锛� - axios.post(common.poiserve2, { - adcode: "110115", - address: { - name: "", - type: "", - }, - adname: "澶у叴鍖�", - cityname: "鍖椾含甯�", - name: { - name: this.poi_text, - type: "", - }, - page: 1, - perPageCount: 20, - pcode: "110000", - pname: "", - resType: "", - }), - // // 甯傜骇骞冲彴锛堢櫨搴︼細浼氭煡鍒板鍦帮級 - // axios.get(common.poiserve, { - // params: { - // request: "bdPoi", - // query: this.poi_text, - // output: "json", - // coord: "cgcs2000", - // page_num: 0, - // page_size: 20, - // }, - // }), - // 甯傜骇骞冲彴锛堥珮寰凤級 - axios.get(common.poiserve, { - params: { - request: "GdPoi", - keywords: this.poi_text, - output: "json", - coord: "cgcs2000", - offset: 20, - page: 1, - }, - }), - ]) - .then( - (data) => { - // this.total = data.data.pois.length; - // this.poiList = - // data.data && data.data.pois; - //115鎺ュ彛 - if (data[0].status == 200) { - data[0].data.data.res && - data[0].data.data.res - .filter((item) => { - return item.name.includes(this.poi_text); - }) - .forEach((val) => { - Allresults.push(val); - }); - } - // 甯傜骇骞冲彴 - // // 鐧惧害 - // if (data[1].data.status == 0) { - // data[1].data.results.forEach((val) => { - // let obj = { - // address: val.address, - // adname: val.area, - // cityname: val.city, - // id: val.uid, - // lat: val.location.lat, - // lng: val.location.lng, - // name: val.name, - // pname: val.province, - // }; - // Allresults.push(obj); - // }); - // } - // 楂樺痉 - if (data[1].data.status == 1) { - data[1].data.pois && - data[1].data.pois - .filter((item) => { - return ( - item.pname.includes("鍖椾含") && - item.name.includes(this.poi_text) - ); - }) - .forEach((val) => { - let poiarr = val.location.split(","); - let poi = { - lon: parseFloat(poiarr[0]), - lat: parseFloat(poiarr[1]), - }; - let obj = { - adcode: val.adcode, - address: val.address, - adname: val.area, - citycode: val.citycode, - cityname: val.cityname, - id: val.uid, - lat: poi.lat, - lng: poi.lon, - name: val.name, - pcode: val.pcode, - pname: val.province, - type: val.type, - typecode: val.typecode, - }; - Allresults.push(obj); - }); - } - this.total = Allresults.length; - this.poiList = Allresults; - this.showList = true; - console.log(Allresults); - }, - (response) => { - console.log("error"); - } - ); + this.getGdPoi(); + this.getData(); + // axios + // .all([ + // // 115鎺ュ彛锛堝彲鏌ュ湴鍧楀悕锛� + // axios.post(common.poiserve2, { + // adcode: "110115", + // address: { + // name: "", + // type: "", + // }, + // adname: "澶у叴鍖�", + // cityname: "鍖椾含甯�", + // name: { + // name: this.poi_text, + // type: "", + // }, + // page: 1, + // perPageCount: 20, + // pcode: "110000", + // pname: "", + // resType: "", + // }), + // // // 甯傜骇骞冲彴锛堢櫨搴︼細浼氭煡鍒板鍦帮級 + // // axios.get(common.poiserve, { + // // params: { + // // request: "bdPoi", + // // query: this.poi_text, + // // output: "json", + // // coord: "cgcs2000", + // // page_num: 0, + // // page_size: 20, + // // }, + // // }), + // // 甯傜骇骞冲彴锛堥珮寰凤級 + // axios.get(common.poiserve, { + // params: { + // request: "GdPoi", + // keywords: this.poi_text, + // output: "json", + // coord: "cgcs2000", + // offset: 20, + // page: 1, + // }, + // }), + // ]) + // .then( + // (data) => { + // // this.total = data.data.pois.length; + // // this.poiList = + // // data.data && data.data.pois; + // //115鎺ュ彛 + // if (data[0].status == 200) { + // data[0].data.data.res && + // data[0].data.data.res + // .filter((item) => { + // return item.name.includes(this.poi_text); + // }) + // .forEach((val) => { + // Allresults.push(val); + // }); + // } + // // 甯傜骇骞冲彴 + // // // 鐧惧害 + // // if (data[1].data.status == 0) { + // // data[1].data.results.forEach((val) => { + // // let obj = { + // // address: val.address, + // // adname: val.area, + // // cityname: val.city, + // // id: val.uid, + // // lat: val.location.lat, + // // lng: val.location.lng, + // // name: val.name, + // // pname: val.province, + // // }; + // // Allresults.push(obj); + // // }); + // // } + // // 楂樺痉 + + // console.log(data, "鏁版嵁"); + // if (data[0].data.status == 1) { + // data[0].data.pois && + // data[0].data.pois + // .filter((item) => { + // return ( + // item.pname.includes("鍖椾含") && + // item.name.includes(this.poi_text) + // ); + // }) + // .forEach((val) => { + // let poiarr = val.location.split(","); + // let poi = { + // lon: parseFloat(poiarr[0]), + // lat: parseFloat(poiarr[1]), + // }; + // let obj = { + // adcode: val.adcode, + // address: val.address, + // adname: val.area, + // citycode: val.citycode, + // cityname: val.cityname, + // id: val.uid, + // lat: poi.lat, + // lng: poi.lon, + // name: val.name, + // pcode: val.pcode, + // pname: val.province, + // type: val.type, + // typecode: val.typecode, + // }; + // Allresults.push(obj); + // }); + // } + // this.total = Allresults.length; + // this.poiList = Allresults; + // this.showList = true; + // console.log(Allresults); + // }, + // (response) => { + // console.log("error"); + // } + // ); break; case "POI": - axios - .get(common.poiserve, { - params: { - request: "GdPoi", - keywords: this.poi_text, - output: "json", - coord: "cgcs2000", - offset: 20, - page: 1, - }, - }) - .then((res) => { - // 楂樺痉 - if (res.data.status == 1) { - res.data.pois && - res.data.pois - .filter((item) => { - var reg = new RegExp("[\\u4E00-\\u9FFF]+", "g"); - return ( - item.pname.includes("鍖椾含") && - item.name.includes(this.poi_text) && - !reg.test(item.typecode) - ); - }) - .forEach((val) => { - let poiarr = val.location.split(","); - let poi = { - lon: parseFloat(poiarr[0]), - lat: parseFloat(poiarr[1]), - }; - let obj = { - adcode: val.adcode, - address: val.address, - adname: val.area, - citycode: val.citycode, - cityname: val.cityname, - id: val.uid, - lat: poi.lat, - lng: poi.lon, - name: val.name, - pcode: val.pcode, - pname: val.province, - type: val.type, - typecode: val.typecode, - }; - Allresults.push(obj); - }); - } - this.total = Allresults.length; - this.poiList = Allresults; - this.showList = true; - }); + this.getGdPoi(); break; case "鍦板潡": - axios - .post(common.poiserve2, { - adcode: "110115", - address: { - name: "", - type: "", - }, - adname: "澶у叴鍖�", - cityname: "鍖椾含甯�", - name: { - name: this.poi_text, - type: "", - }, - page: 1, - perPageCount: 20, - pcode: "110000", - pname: "", - resType: "", - }) - .then((res) => { - if (res.status == 200) { - res.data.data.res && - res.data.data.res - .filter((item) => { - // 鍒ゆ柇鍦板潡鏄惁鏈夋眽瀛� - var reg = new RegExp("[\\u4E00-\\u9FFF]+", "g"); - return ( - item.name.includes(this.poi_text) && - reg.test(item.typecode) - ); - }) - .forEach((val) => { - Allresults.push(val); - }); - } - this.total = Allresults.length; - this.poiList = Allresults; - this.showList = true; - }); + this.getData(); break; } } -- Gitblit v1.9.3