修改
This commit is contained in:
@@ -48,13 +48,6 @@
|
||||
required
|
||||
:rules="[{ required: true }]"
|
||||
/>
|
||||
<!-- <van-field
|
||||
v-model="formData.clockTime"
|
||||
label="打卡时间"
|
||||
input-align="right"
|
||||
placeholder="请输入"
|
||||
readonly
|
||||
/> -->
|
||||
<van-field
|
||||
v-model="formData.remark"
|
||||
label="备注"
|
||||
@@ -75,6 +68,14 @@
|
||||
</div>
|
||||
<div class="pic">
|
||||
<Uploader
|
||||
ref="uploaderRef"
|
||||
type="text1"
|
||||
:value="text1"
|
||||
:deletable="showSubmit"
|
||||
@afterRead="afterRead"
|
||||
@delImg="delImg"
|
||||
@onUpload="onUpload" />
|
||||
<!-- <Uploader
|
||||
ref="uploaderRef"
|
||||
type="text1"
|
||||
:value="text1"
|
||||
@@ -83,7 +84,7 @@
|
||||
@afterRead="afterRead"
|
||||
@delImg="delImg"
|
||||
@onUpload="onUpload"
|
||||
/>
|
||||
/> -->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -102,7 +103,6 @@ import {
|
||||
getPosition,
|
||||
// chooseAlbumAndTakePhoto,
|
||||
} from '@/utils/dsbridge'
|
||||
import { format } from '@/utils/timeUtil.js'
|
||||
import { insertPositionData, getPositionData } from '@/api/api.js'
|
||||
import { downloadUrl } from '@/settings'
|
||||
export default {
|
||||
@@ -128,7 +128,6 @@ export default {
|
||||
showSubmit: false,
|
||||
taskId: '',
|
||||
customerId: '',
|
||||
animation: null
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
@@ -162,54 +161,62 @@ export default {
|
||||
}else{
|
||||
this.showSubmit = true
|
||||
this.getLocation()
|
||||
this.getAddress()
|
||||
}
|
||||
})
|
||||
},
|
||||
// 获取当前位置
|
||||
getLocation() {
|
||||
console.log('-------------------------getLocation');
|
||||
if (process.env.NODE_ENV === 'development') {
|
||||
this.formData.lgitude = 31.560001
|
||||
this.formData.ltitude = 118.708980
|
||||
this.formData.lgitude = 118.708980
|
||||
this.formData.ltitude = 31.560001
|
||||
this.formData.addressName = '江苏省南京市江宁区'
|
||||
}
|
||||
try {
|
||||
// this.formData.clockTime = format(new Date().getTime())
|
||||
} catch (error) {}
|
||||
const that = this
|
||||
getPosition((data) => {
|
||||
console.log('-------------------------位置信息', data, typeof(data));
|
||||
if (data) {
|
||||
console.log(data, '位置信息')
|
||||
this.formData.lgitude = data.longitude
|
||||
this.formData.ltitude = data.latitude
|
||||
console.log(data.longitude, 'lgitude位置信息')
|
||||
if(typeof(data) == 'string'){
|
||||
let dataArr = data.split(',')
|
||||
that.$set(that.formData, 'lgitude', dataArr[0].match(/\d+\.\d{2}/)[0])
|
||||
that.$set(that.formData, 'ltitude', dataArr[1].match(/\d+\.\d{2}/)[0])
|
||||
}else{
|
||||
that.$set(that.formData, 'lgitude', (data.longitude+'').match(/\d+\.\d{2}/)[0])
|
||||
that.$set(that.formData, 'ltitude', (data.latitude+'').match(/\d+\.\d{2}/)[0])
|
||||
}
|
||||
} else {
|
||||
Notify({ type: 'warning', message: '未获取到位置信息' })
|
||||
}
|
||||
})
|
||||
},
|
||||
getAddress(){
|
||||
const that = this
|
||||
getLocationMessage((data) => {
|
||||
console.log('-------------------------getLocationMessage', data);
|
||||
if (data) {
|
||||
this.formData.addressName = data
|
||||
that.$set(that.formData, 'addressName', data)
|
||||
} else {
|
||||
Notify({ type: 'warning', message: '未获取到定位信息' })
|
||||
}
|
||||
})
|
||||
this.animation = requestAnimationFrame(this.getLocation)
|
||||
},
|
||||
/**
|
||||
* 图片方法
|
||||
*/
|
||||
//浏览器 ios 会走这个方法
|
||||
afterRead(data, type) {
|
||||
this[type].push({
|
||||
fileName: data.original_name,
|
||||
fileId: data.attach_id,
|
||||
url: `${downloadUrl}${data.attach_id}`
|
||||
})
|
||||
|
||||
console.log('-------------------------afterRead', data, type);
|
||||
this[type] = [data.attach_id]
|
||||
this.formData.fileName = data.original_name
|
||||
this.formData.fileId = data.attach_id
|
||||
},
|
||||
//安卓会调用的方法
|
||||
onUpload(data, type) {
|
||||
this[type].push(data[0])
|
||||
console.log('-------------------------onUpload', data, type);
|
||||
// this[type].push(data[0])
|
||||
this[type] = [data[0].url]
|
||||
this.formData.fileName = data[0].fileName
|
||||
this.formData.fileId = data[0].fileId
|
||||
},
|
||||
@@ -270,12 +277,6 @@ export default {
|
||||
})
|
||||
},
|
||||
},
|
||||
beforeDestroy(){
|
||||
if(this.animation){
|
||||
cancelAnimationFrame(this.animation)
|
||||
this.animation = null
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<style lang="less" scoped>
|
||||
|
||||
Reference in New Issue
Block a user