|
@@ -385,29 +385,22 @@ export default {
|
|
|
});
|
|
|
},
|
|
|
getIpAddress() {
|
|
|
- let year = new Date().getFullYear();
|
|
|
- fetch(`https://${year}.ip138.com/`)
|
|
|
- .then((x) => x.text())
|
|
|
- .then((h) => {
|
|
|
- let domParser = new DOMParser();
|
|
|
- let doc = domParser.parseFromString(h, "text/html");
|
|
|
- let text = doc?.querySelector("p")?.innerText?.trim();
|
|
|
- // document.getElementById('content1').innerText = text;
|
|
|
- // let ipAddress = {ip: "", location: "", type: ""}
|
|
|
- // try {
|
|
|
- // let ip = text.substring(text.indexOf("[")+1,text.indexOf("]")).trim();
|
|
|
- // ipAddress.ip = ip;
|
|
|
- // let other = text.substring(text.indexOf("来自:")+3).trim();
|
|
|
- // let arr = other.split(" ");
|
|
|
- // ipAddress.location = arr[0];
|
|
|
- // ipAddress.type = arr[1];
|
|
|
- // }catch (e) {
|
|
|
- // console.error(e)
|
|
|
- // }
|
|
|
- let ip = text
|
|
|
- .substring(text.indexOf("[") + 1, text.indexOf("]"))
|
|
|
- .trim();
|
|
|
- this.editForm.ip = ip;
|
|
|
+ // let year = new Date().getFullYear();
|
|
|
+ // fetch(`https://${year}.ip138.com/`)
|
|
|
+ // .then((x) => x.text())
|
|
|
+ // .then((h) => {
|
|
|
+ // let domParser = new DOMParser();
|
|
|
+ // let doc = domParser.parseFromString(h, "text/html");
|
|
|
+ // let text = doc?.querySelector("p")?.innerText?.trim();
|
|
|
+ // let ip = text
|
|
|
+ // .substring(text.indexOf("[") + 1, text.indexOf("]"))
|
|
|
+ // .trim();
|
|
|
+ // this.editForm.ip = ip;
|
|
|
+ // });
|
|
|
+ fetch("https://qifu-api.baidubce.com/ip/local/geo/v1/district")
|
|
|
+ .then((res) => res.json())
|
|
|
+ .then((res) => {
|
|
|
+ this.editForm.ip = res?.ip || "";
|
|
|
});
|
|
|
},
|
|
|
editSubmit() {
|