Compare commits
No commits in common. "627f7fde609f1e74a9284b8c07db344e74e5cf69" and "09dc7a61193dfb5c817301c20aced7d497473368" have entirely different histories.
627f7fde60
...
09dc7a6119
@ -1,24 +1,14 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="zh-CN">
|
<html lang="zh-CN">
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8" />
|
<meta charset="UTF-8" />
|
||||||
<meta name="viewport"
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0, viewport-fit=cover" />
|
||||||
content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0, viewport-fit=cover" />
|
|
||||||
<meta name="apple-mobile-web-app-capable" content="yes" />
|
<meta name="apple-mobile-web-app-capable" content="yes" />
|
||||||
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
|
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
|
||||||
<title>H5移动端</title>
|
<title>H5移动端</title>
|
||||||
<script>
|
|
||||||
window._AMapSecurityConfig = {
|
|
||||||
securityJsCode: "08c037da44c78afd7338203268c2d2a5"
|
|
||||||
};
|
|
||||||
</script>
|
|
||||||
<script src="https://webapi.amap.com/loader.js"></script>
|
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<div id="app"></div>
|
<div id="app"></div>
|
||||||
<script type="module" src="/src/main.js"></script>
|
<script type="module" src="/src/main.js"></script>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
@ -211,7 +211,6 @@ import { ref, onMounted, reactive, toRaw, watch } from "vue";
|
|||||||
import { useRouter, useRoute } from "vue-router";
|
import { useRouter, useRoute } from "vue-router";
|
||||||
import { showToast, showLoadingToast } from "vant";
|
import { showToast, showLoadingToast } from "vant";
|
||||||
import { request } from "../../../../shared/utils/request";
|
import { request } from "../../../../shared/utils/request";
|
||||||
import { loadAMap } from "../../../../shared/utils/amap";
|
|
||||||
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
@ -219,7 +218,7 @@ const searchValue = ref(""); // 搜索框输入值
|
|||||||
const showPopup = ref(false); // 控制弹出层显示隐藏
|
const showPopup = ref(false); // 控制弹出层显示隐藏
|
||||||
const yhzDetail = ref({}); // 养护站详情数据
|
const yhzDetail = ref({}); // 养护站详情数据
|
||||||
const materialList = ref([]); // 物资列表数据
|
const materialList = ref([]); // 物资列表数据
|
||||||
const getInitForm = () => ({
|
const INIT_FORM = {
|
||||||
material: {
|
material: {
|
||||||
jd: "", // 物资经度
|
jd: "", // 物资经度
|
||||||
wd: "", // 物资纬度
|
wd: "", // 物资纬度
|
||||||
@ -239,8 +238,8 @@ const getInitForm = () => ({
|
|||||||
remark: "", // 备注
|
remark: "", // 备注
|
||||||
},
|
},
|
||||||
photos: [],
|
photos: [],
|
||||||
});
|
};
|
||||||
const form = reactive(getInitForm());
|
const form = reactive({ ...INIT_FORM }); // 表单
|
||||||
|
|
||||||
// 根据养护站rid获取物资列表
|
// 根据养护站rid获取物资列表
|
||||||
const getMaterialList = async (wzmc) => {
|
const getMaterialList = async (wzmc) => {
|
||||||
@ -282,6 +281,15 @@ onMounted(() => {
|
|||||||
|
|
||||||
// 购置日期相关
|
// 购置日期相关
|
||||||
const showTimePicker = ref(false);
|
const showTimePicker = ref(false);
|
||||||
|
const currentDate = ref([
|
||||||
|
new Date().getFullYear(),
|
||||||
|
new Date().getMonth() + 1,
|
||||||
|
new Date().getDate(),
|
||||||
|
]);
|
||||||
|
const onDateConfirm = ({ selectedValues }) => {
|
||||||
|
form.rkrq = selectedValues.join("-");
|
||||||
|
showTimePicker.value = false;
|
||||||
|
};
|
||||||
|
|
||||||
// 选择单位相关
|
// 选择单位相关
|
||||||
const dwField = ref(null);
|
const dwField = ref(null);
|
||||||
@ -330,6 +338,7 @@ const handleSubmit = async () => {
|
|||||||
message: "新增成功",
|
message: "新增成功",
|
||||||
});
|
});
|
||||||
onPopupClose();
|
onPopupClose();
|
||||||
|
Object.assign(form, { ...INIT_FORM });
|
||||||
getMaterialList(searchValue.value);
|
getMaterialList(searchValue.value);
|
||||||
} else {
|
} else {
|
||||||
throw new Error(res.message);
|
throw new Error(res.message);
|
||||||
@ -414,38 +423,37 @@ const afterRead = async (file) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// 获取经纬度
|
// 获取经纬度
|
||||||
const handleGetLocation = async () => {
|
const handleGetLocation = () => {
|
||||||
// 确保AMap完成加载
|
if (!navigator.geolocation) {
|
||||||
if (!window.AMap) {
|
showToast("您的浏览器不支持地理位置获取");
|
||||||
await loadAMap();
|
return;
|
||||||
}
|
}
|
||||||
const loadingToast = showLoadingToast({
|
|
||||||
message: "正在获取位置",
|
showLoadingToast({
|
||||||
|
message: "定位中...",
|
||||||
forbidClick: true,
|
forbidClick: true,
|
||||||
duration: 0, // 设置为0表示不会自动关闭
|
|
||||||
zIndex: 9999,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
AMap.plugin("AMap.Geolocation", () => {
|
navigator.geolocation.getCurrentPosition(
|
||||||
const geolocation = new AMap.Geolocation({
|
(position) => {
|
||||||
enableHighAccuracy: true,
|
form.material.jd = position.coords.longitude.toFixed(6);
|
||||||
timeout: 5000,
|
form.material.wd = position.coords.latitude.toFixed(6);
|
||||||
showMarker: false,
|
},
|
||||||
zoomToAccuracy: true,
|
(error) => {
|
||||||
});
|
const errorMessage =
|
||||||
|
{
|
||||||
geolocation.getCurrentPosition((status, result) => {
|
1: "位置服务被拒绝",
|
||||||
if (status === "complete") {
|
2: "暂时无法获取位置",
|
||||||
form.material.jd = result.position.lng.toFixed(6);
|
3: "定位超时",
|
||||||
form.material.wd = result.position.lat.toFixed(6);
|
}[error.code] || "定位失败";
|
||||||
loadingToast.close();
|
showToast(errorMessage);
|
||||||
} else {
|
},
|
||||||
loadingToast.close();
|
{
|
||||||
showToast("定位失败 请检查网络情况后重试");
|
enableHighAccuracy: true, // 高精度模式
|
||||||
console.log("result", result);
|
timeout: 5000, // 超时时间
|
||||||
|
maximumAge: 0, // 不缓存位置
|
||||||
}
|
}
|
||||||
});
|
);
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
@ -497,9 +505,6 @@ const handleAdd = async () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const onPopupClose = () => {
|
const onPopupClose = () => {
|
||||||
Object.assign(form, getInitForm());
|
|
||||||
fileList.value = [];
|
|
||||||
[showDwPicker, showFzrPicker].forEach((v) => (v.value = false));
|
|
||||||
showPopup.value = false;
|
showPopup.value = false;
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@ -1,24 +0,0 @@
|
|||||||
export function loadAMap() {
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
if (window.AMap) return resolve();
|
|
||||||
|
|
||||||
// 确保AMapLoader存在
|
|
||||||
if (!window.AMapLoader) {
|
|
||||||
return reject(new Error("AMapLoader未正确加载"));
|
|
||||||
}
|
|
||||||
|
|
||||||
window.AMapLoader.load({
|
|
||||||
key: "848ab05db2a57a7782c153119f50dcef",
|
|
||||||
version: "2.0",
|
|
||||||
})
|
|
||||||
.then((AMap) => {
|
|
||||||
window.AMap = AMap;
|
|
||||||
console.log("AMap初始化完成", AMap);
|
|
||||||
resolve();
|
|
||||||
})
|
|
||||||
.catch((err) => {
|
|
||||||
console.error("AMap加载失败:", err);
|
|
||||||
reject(new Error("地图加载失败,请检查网络连接"));
|
|
||||||
});
|
|
||||||
});
|
|
||||||
};
|
|
||||||
Loading…
x
Reference in New Issue
Block a user