Swanky 2 years ago
parent 6148e287ee
commit 8019beddea
  1. 30
      App.vue
  2. 16
      pages.json
  3. 22
      pages/bdsjgl/bdsjgl.vue
  4. 98
      pages/lssjgl/lssjgl.vue
  5. 241
      pages/sjsb/sjsb.vue
  6. 16
      pages/workbench/workbench.vue

@ -1,9 +1,9 @@
<script>
import helper from 'common/helper.js'
export default {
globalData: {
globalData: {
map: null
},
},
onLaunch: function() {
/* #ifndef H5 */
const getInfo = (token) => {
@ -11,7 +11,7 @@
url: `${helper.serverUrl}/user/getInfo`,
header: {
Authorization: `Bearer ${token}`
},
},
success(resp) {
console.log('success', resp);
if (resp?.data?.code !== 200) {
@ -38,12 +38,24 @@
},
fail(err) {
console.log('error', err);
uni.reLaunch({
url: '/pages/login/login',
success() {
plus.navigator.closeSplashscreen();
}
})
if (token) {
uni.reLaunch({
url: '/pages/index/index',
success() {
plus.navigator.closeSplashscreen();
},
fail(err) {
console.log('reLaunch', err);
}
})
} else {
uni.reLaunch({
url: '/pages/login/login',
success() {
plus.navigator.closeSplashscreen();
}
})
}
}
})

@ -79,6 +79,22 @@
}
}
}
},
{
"path": "pages/bdsjgl/bdsjgl",
"style": {
"navigationBarTitleText": "",
"enablePullDownRefresh": false
}
},
{
"path": "pages/lssjgl/lssjgl",
"style": {
"navigationBarTitleText": "临时数据管理",
"enablePullDownRefresh": false,
"navigationBarBackgroundColor": "#01D393",
"navigationBarTextStyle": "white"
}
}
],
"globalStyle": {

@ -0,0 +1,22 @@
<template>
<view>
</view>
</template>
<script>
export default {
data() {
return {
}
},
methods: {
}
}
</script>
<style>
</style>

@ -0,0 +1,98 @@
<template>
<view class="sjgl">
<view v-for="(item,i) in datas">
<uni-card style="padding: 0;">
<view style="padding: 10px;">
<custom-attr label="上报时间" :value="item.saveTime"></custom-attr>
<custom-attr label="上报内容" :value="item.reason"></custom-attr>
<custom-attr label="上报位置" :value="item.geom"></custom-attr>
</view>
<view style="margin-top: 10px;">
<uni-row>
<uni-col :span="24">
<button style="color: #e64340;" @click="delItem(i)">
移除
</button>
</uni-col>
</uni-row>
</view>
</uni-card>
</view>
<button class="submit-btn" type="primary" @click="submit" :loading="submiting">上报所有数据</button>
</view>
</template>
<script>
import helper from '../../common/helper'
export default {
data() {
return {
datas: [],
submiting: false
}
},
onLoad() {},
onShow(e) {
console.log('onshow', e)
uni.getStorage({
key: 'sbsjTemp',
success: (resp) => {
this.datas = resp.data;
},
fail(err) {},
complete: () => {}
})
},
methods: {
submit() {
},
delItem(index) {
uni.showModal({
title: '提示',
content: '确定删除该条数据?',
success: (e) => {
if (e.confirm) {
this.datas.splice(index, 1);
uni.setStorage({
data: this.datas,
key: 'sbsjTemp'
})
}
}
})
}
}
}
</script>
<style scoped>
.submit-btn {
height: 64px;
background: linear-gradient(-90deg, #01C4B4, #01DC7F);
border-radius: 47px;
font-weight: 400;
font-size: 30px;
color: #FFFFFF;
margin-top: 36px;
line-height: 64px;
margin: 16px;
margin-top: 36px;
}
.img-btn {
width: 16px;
height: 16px;
margin-right: 2px;
}
.sjgl>>>.uni-card__content {
padding: 0 !important;
}
.sjgl>>>.uni-card {
padding: 0 !important;
}
</style>

@ -1,11 +1,14 @@
<template>
<view class="form-root">
<uni-notice-bar v-if="networkType==='none'" text="当前无法连接网络,上报后的数据将存储在临时数据管理中" />
<view class="form-group">
<view class="uni-form-item form-item uni-column">
<view class="form-control border-btm">
<text class="form-label">当前经度</text>
<view class="form-input">
<input class="uni-input" name="jd" :disabled="true" :value="jd" />
<input v-if="!locationLoading" class="uni-input" name="jd" :disabled="true" :value="jd" />
<input v-if="locationLoading" class="uni-input" value="位置获取中..."></input>
</view>
</view>
</view>
@ -13,7 +16,8 @@
<view class="form-control">
<text class="form-label">当前纬度</text>
<view class="form-input">
<input class="uni-input" name="wd" :disabled="true" :value="wd" />
<input v-if="!locationLoading" class="uni-input" name="wd" :disabled="true" :value="wd" />
<input v-if="locationLoading" class="uni-input" value="位置获取中..."></input>
</view>
</view>
</view>
@ -26,7 +30,7 @@
</text>
</view>
<view class="form-input imgs">
<view v-for="(img,index) in imgStrs" style="position: relative;" @click="preview(index)">
<view v-for="(img,index) in imgs" style="position: relative;" @click="preview(index)">
<image :src="img" class="upload-img"></image>
<image @click.stop="delImg(index)" src="../../static/remove.png"
style="position: absolute;width:20px;height:20px;top: -10px;right: 0px;background-color: #fff;">
@ -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() {

@ -12,7 +12,7 @@
<view class="panel">
<view class="action">
<view class="title2">草原核查数据</view>
<view class="flex" style="margin-top: 36px;">
<view class="flex" style="margin-top: 24px;">
<view class="action-btn fill flex" style="margin-right: 12px;" @click="toSjsb">
<image src="/static/sjsb.png" class="action-img"></image>
<text class="action-text">数据上报</text>
@ -24,6 +24,13 @@
<image src="/static/jr.png" class="action-arrow"></image>
</view>
</view>
<view class="flex">
<view class="action-btn fill flex" style="align-items: center;justify-content: flex-start;" @click="toLssjgl">
<image src="/static/sjgl.png" class="action-img"></image>
<text class="action-text">临时数据管理</text>
<image src="/static/jr.png" class="action-arrow"></image>
</view>
</view>
</view>
</view>
</view>
@ -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;

Loading…
Cancel
Save