diff --git a/App.vue b/App.vue
index 1ff0af7..996d61e 100644
--- a/App.vue
+++ b/App.vue
@@ -1,9 +1,9 @@
+
+
diff --git a/pages/lssjgl/lssjgl.vue b/pages/lssjgl/lssjgl.vue
new file mode 100644
index 0000000..3e82084
--- /dev/null
+++ b/pages/lssjgl/lssjgl.vue
@@ -0,0 +1,98 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/pages/sjsb/sjsb.vue b/pages/sjsb/sjsb.vue
index 69ee160..a56bcc8 100644
--- a/pages/sjsb/sjsb.vue
+++ b/pages/sjsb/sjsb.vue
@@ -1,11 +1,14 @@
+
+
当前经度
-
+
+
@@ -13,7 +16,8 @@
当前纬度
-
+
+
@@ -26,7 +30,7 @@
-
+
@@ -66,7 +70,10 @@
submiting: false,
token: '',
id: null,
- submitText: ''
+ submitText: '',
+ imgPaths: [],
+ locationLoading: false,
+ networkType: ''
}
},
onLoad(e) {
@@ -75,18 +82,42 @@
} else {
this.submitText = '上报'
}
+ uni.getNetworkType({
+ success: (res) => {
+ console.log(res.networkType);
+ this.networkType = res.networkType;
+ }
+ });
uni.getStorage({
key: 'token',
success: (token) => {
this.token = token.data;
if (!e.id) {
- uni.getLocation({
- type: 'wgs84',
- success: (res) => {
- this.jd = res.longitude;
- this.wd = res.latitude;
- }
+ // uni.getLocation({
+ // type: 'wgs84',
+ // success: (res) => {
+ // this.jd = res.longitude;
+ // this.wd = res.latitude;
+ // }
+ // });
+ this.locationLoading = true
+ plus.geolocation.getCurrentPosition((res) => {
+ this.jd = res.coords.longitude;
+ this.wd = res.coords.latitude;
+ this.locationLoading = false
+ // resolve({
+ // lat: res.coords.latitude,
+ // lng: res.coords.longitude
+ // });
+ }, (error) => {
+ this.locationLoading = false
+ // uni.showToast({
+ // title: error.message,
+ // duration: 3000,
+ // icon: 'icon'
+ // });
+ // reject();
});
} else {
this.id = e.id
@@ -100,6 +131,8 @@
methods: {
delImg(index) {
this.imgStrs.splice(index, 1);
+ this.imgPaths.splice(index, 1);
+ this.imgs.splice(index, 1);
},
preview(index) {
uni.previewImage({
@@ -137,14 +170,13 @@
})
return;
}
- if (this.imgStrs?.length <= 0) {
+ if (this.imgStrs?.length <= 0 && this.imgs?.length <= 0) {
uni.showToast({
icon: 'error',
title: '请上传现场照片'
})
return;
}
- this.submiting = true;
if (this.id) {
uni.request({
url: `${helper.serverUrl}/ffzy/ffzy`,
@@ -180,39 +212,87 @@
})
} else {
- uni.request({
- url: `${helper.serverUrl}/ffzy/ffzy`,
- method: 'POST',
- data: {
+ // const data =
+ if (this.networkType !== 'none') {
+ this.submiting = true;
+ uni.request({
+ url: `${helper.serverUrl}/ffzy/ffzy`,
+ method: 'POST',
+ data: {
+ geom: `POINT(${this.jd} ${this.wd})`,
+ img: this.imgStrs.join(','),
+ reason: this.reason
+ },
+ header: {
+ Authorization: `Bearer ${this.token}`
+ },
+ success: (resp) => {
+ if (resp.data.code === 200) {
+ uni.showToast({
+ mask: true,
+ icon: 'success',
+ title: '上报成功'
+ });
+ setTimeout(() => {
+ uni.navigateBack()
+ }, 1500)
+ }
+ console.log(resp)
+ },
+ fail: () => {
+ console.log(resp)
+ uni.showToast({
+ title: '上报失败'
+ })
+ },
+ complete: () => {
+ this.submiting = false;
+ }
+ })
+ } else {
+ const date = new Date();
+ this.saveTemp({
geom: `POINT(${this.jd} ${this.wd})`,
- img: this.imgStrs.join(','),
- reason: this.reason
- },
- header: {
- Authorization: `Bearer ${this.token}`
- },
- success: (resp) => {
- if (resp.data.code === 200) {
+ imgPaths: this.imgPaths,
+ reason: this.reason,
+ saveTime: `${date.getFullYear()}-${date.getMonth()+1}-${date.getDate()} ${date.getHours()}:${date.getMinutes()}:${date.getSeconds()}`
+ });
+ }
+ }
+ },
+ saveTemp(data) {
+ uni.getStorage({
+ key: 'sbsjTemp',
+ success: (resp) => {
+ console.log(resp);
+ uni.setStorage({
+ key: 'sbsjTemp',
+ data: [...resp.data || [], data],
+ success: () => {
uni.showToast({
- mask: true,
- icon: 'success',
- title: '上报成功'
- });
+ title: '已保存到临时数据管理'
+ })
setTimeout(() => {
- uni.navigateBack()
+ uni.navigateBack();
}, 1500)
}
- console.log(resp)
- },
- fail: () => {
- console.log(resp)
- },
- complete: () => {
- this.submiting = false;
- }
- })
-
- }
+ })
+ },
+ fail: () => {
+ uni.setStorage({
+ key: 'sbsjTemp',
+ data: [data],
+ success: () => {
+ uni.showToast({
+ title: '已保存到临时数据管理'
+ })
+ setTimeout(() => {
+ uni.navigateBack();
+ }, 1500)
+ }
+ })
+ }
+ })
},
chooseImg() {
uni.chooseImage({
@@ -223,50 +303,55 @@
}) => {
console.log(tempFilePaths, tempFiles)
const strs = [];
- // tempFilePaths.forEach(path => {
- // pathToBase64(path).then(r => {
- // this.imgs = this.imgs.concat(r);
- // }).catch(err => {
- // console.log(err)
- // });
- // })
+ tempFilePaths.forEach(path => {
+ pathToBase64(path).then(r => {
+ this.imgs = this.imgs.concat(r);
+ }).catch(err => {
+ console.log(err)
+ });
+ })
const file = tempFiles?.[0];
const filePath = tempFilePaths?.[0];
if (filePath) {
// const formData = new FormData();
// formData.append('file', file);
- this.uploading = true
- uni.uploadFile({
- url: `${helper.serverUrl}/system/oss/upload`,
- method: 'POST',
- header: {
- Authorization: `Bearer ${this.token}`
- },
- files: tempFilePaths.map(path => {
- return {
- uri: path
- }
- }),
- // name: 'file',
- success: (resp) => {
- console.log(resp.data)
- let data = resp.data;
- if (typeof(resp.data) === 'string') {
- data = JSON.parse(resp.data);
+ this.imgPaths.push(filePath);
+
+ if (this.networkType !== 'none') {
+ this.uploading = true
+ uni.uploadFile({
+ url: `${helper.serverUrl}/system/oss/upload`,
+ method: 'POST',
+ header: {
+ Authorization: `Bearer ${this.token}`
+ },
+ files: tempFilePaths.map(path => {
+ return {
+ uri: path
+ }
+ }),
+ // name: 'file',
+ success: (resp) => {
+ console.log(resp.data)
+ let data = resp.data;
+ if (typeof(resp.data) === 'string') {
+ data = JSON.parse(resp.data);
+ }
+ console.log(data.data.url)
+ this.imgStrs = [...this.imgStrs, data.data
+ .url
+ ]
+ },
+ fail(resp) {
+ console.log(resp)
+ },
+ complete: () => {
+ console.log(111)
+ this.uploading = false
}
- console.log(data.data.url)
- this.imgStrs = [...this.imgStrs, data.data
- .url
- ]
- },
- fail(resp) {
- console.log(resp)
- },
- complete: () => {
- console.log(111)
- this.uploading = false
- }
- })
+ })
+
+ }
}
},
fail() {
diff --git a/pages/workbench/workbench.vue b/pages/workbench/workbench.vue
index c16771c..ad65a47 100644
--- a/pages/workbench/workbench.vue
+++ b/pages/workbench/workbench.vue
@@ -12,7 +12,7 @@
草原核查数据
-
+
数据上报
@@ -24,6 +24,13 @@
+
+
+
+ 临时数据管理
+
+
+
@@ -43,6 +50,11 @@
url: '/pages/sjsb/sjsb'
})
},
+ toLssjgl(){
+ uni.navigateTo({
+ url: '/pages/lssjgl/lssjgl'
+ })
+ },
toSjgl() {
uni.navigateTo({
url: '/pages/sjgl/sjgl'
@@ -130,7 +142,7 @@
}
.action {
- height: 160px;
+ height: 230px;
background: #FFFFFF;
box-shadow: 0px 0px 1px 0px rgba(0, 0, 0, 0.1);
border-radius: 20px;