feat: 出差打卡
This commit is contained in:
@@ -10,6 +10,14 @@ export function addStartMap(data) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//出差打卡接口
|
||||||
|
export function businessTripClockIn(data) {
|
||||||
|
return request.post({
|
||||||
|
url: '/crm/app/appVisistMap/businessTripClockIn',
|
||||||
|
data
|
||||||
|
},{isTransformResponse:false});
|
||||||
|
}
|
||||||
|
|
||||||
//新增地图开始打卡接口
|
//新增地图开始打卡接口
|
||||||
export function addStartMapForClockIn(data) {
|
export function addStartMapForClockIn(data) {
|
||||||
return request.post({
|
return request.post({
|
||||||
|
|||||||
22
src/constants/mapApiConstants.js
Normal file
22
src/constants/mapApiConstants.js
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
/**
|
||||||
|
* @description 定位API的配置
|
||||||
|
* @type {{URL: string, token: string}}
|
||||||
|
*/
|
||||||
|
export const MapApiConfig = {
|
||||||
|
/**
|
||||||
|
* @description API接口地址
|
||||||
|
*/
|
||||||
|
URL: 'https://tiles.geovisearth.com/geo/v1/geocode/regeo',
|
||||||
|
/**
|
||||||
|
* @description 接口鉴权Token
|
||||||
|
*/
|
||||||
|
token: '66c87c897f0251295afdc794e4fbf73046a070338a726fe04f06cece6cb1ffdf',
|
||||||
|
/**
|
||||||
|
* @description 打卡类型:西安办事处
|
||||||
|
*/
|
||||||
|
XI_AN_BAN: {latitude: 34.1360, longitude: 108.9126, typeName: '西安办事处位置打卡'},
|
||||||
|
/**
|
||||||
|
* @description 打卡类型:第三方维护
|
||||||
|
*/
|
||||||
|
OTHER: {typeName: '第三方维护打卡'}
|
||||||
|
}
|
||||||
@@ -9,14 +9,29 @@
|
|||||||
|
|
||||||
<!-- 正文内容 -->
|
<!-- 正文内容 -->
|
||||||
<view class="white-bg">
|
<view class="white-bg">
|
||||||
<image src="../../../../static/images/business/btn-qd.png" class="btn-image" @click="handleCheckIn" />
|
<image src="../../../../static/images/business/btn-qd.png" class="btn-image" @click="handleCheckIn"/>
|
||||||
<image src="../../../../static/images/business/btn-dk.png" class="btn-image" @click="handleClockIn" />
|
<!-- <image src="../../../../static/images/business/btn-dk.png" class="btn-image" @click="handleClockIn"/>-->
|
||||||
|
<image src="../../../../static/images/business/btn-dk.png" class="btn-image" @click="handleClick"/>
|
||||||
<view class="check-desc">
|
<view class="check-desc">
|
||||||
业务人员可通过<text class="font-orange">签到</text>或<text
|
业务人员可通过
|
||||||
class="font-blue">打卡</text>进行行为记录,该时间会和走访报告中的时间进行关联,便于查看。
|
<text class="font-orange">签到</text>
|
||||||
|
或
|
||||||
|
<text
|
||||||
|
class="font-blue">打卡
|
||||||
|
</text>
|
||||||
|
进行行为记录,该时间会和走访报告中的时间进行关联,便于查看。
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
<closeable-modal v-model="modalVisible"
|
||||||
|
title="确认在此处打卡?"
|
||||||
|
:content="form.addressForStart"
|
||||||
|
closeTip="轻触空白处关闭"
|
||||||
|
cancelText="出差"
|
||||||
|
confirmText="打卡"
|
||||||
|
contentAlign="center"
|
||||||
|
@confirm="handleConfirm"
|
||||||
|
@cancel="handleCancel"/>
|
||||||
|
|
||||||
<!-- 打卡遮罩层 -->
|
<!-- 打卡遮罩层 -->
|
||||||
<!-- <view class="check-con" v-if="checkFlag">
|
<!-- <view class="check-con" v-if="checkFlag">
|
||||||
@@ -38,9 +53,11 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref, onMounted, reactive } from 'vue'
|
import {ref, onMounted, reactive} from 'vue'
|
||||||
import customHeader from '@/components/customHeader.vue'
|
import customHeader from '@/components/customHeader.vue'
|
||||||
import { addStartMapForClockIn } from '../../../../api/crm/activity/map';
|
import {addStartMapForClockIn, businessTripClockIn} from '../../../../api/crm/activity/map';
|
||||||
|
import CloseableModal from "@/components/closeableModal.vue";
|
||||||
|
import {MapApiConfig} from "../../../../constants/mapApiConstants";
|
||||||
|
|
||||||
let form = reactive({
|
let form = reactive({
|
||||||
addressForStart: null,
|
addressForStart: null,
|
||||||
@@ -49,6 +66,7 @@ let form = reactive({
|
|||||||
staffName: null,
|
staffName: null,
|
||||||
visistCode: null,
|
visistCode: null,
|
||||||
visistId: null,
|
visistId: null,
|
||||||
|
remark: null,
|
||||||
mapId: null
|
mapId: null
|
||||||
})
|
})
|
||||||
// 签到
|
// 签到
|
||||||
@@ -58,25 +76,87 @@ let handleCheckIn = () => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
// 打卡
|
// 打卡
|
||||||
let handleClockIn = () => {
|
// let handleClockIn = () => {
|
||||||
|
// uni.getLocation({
|
||||||
|
// type: 'wgs84',
|
||||||
|
// success: (res) => {
|
||||||
|
// const latiude = res.latitude;
|
||||||
|
// const longitude = res.longitude;
|
||||||
|
// //进行解析
|
||||||
|
// inverseGeocoding(latiude, longitude);
|
||||||
|
// },
|
||||||
|
// fail: function (err) {
|
||||||
|
// console.log("获取地址失败" + err)
|
||||||
|
// }
|
||||||
|
// })
|
||||||
|
// }
|
||||||
|
let modalVisible = ref(false);
|
||||||
|
let handleClick = () => {
|
||||||
uni.getLocation({
|
uni.getLocation({
|
||||||
type: 'wgs84',
|
type: 'wgs84',
|
||||||
success: (res) => {
|
success: (res) => {
|
||||||
const latiude = res.latitude;
|
const latitude = res.latitude;
|
||||||
const longitude = res.longitude;
|
const longitude = res.longitude;
|
||||||
//进行解析
|
console.log('纬度:',latitude,',经度:', longitude);
|
||||||
inverseGeocoding(latiude, longitude);
|
inverseGeocoding(latitude, longitude);
|
||||||
},
|
},
|
||||||
fail: function (err) {
|
fail: function (err) {
|
||||||
console.log("获取地址失败" + err)
|
console.log("获取地址失败" + err)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
// 反馈提示
|
||||||
|
const feedback = (res, callback)=>{
|
||||||
|
if(res.code===200){
|
||||||
|
if(callback) callback();
|
||||||
|
uni.showToast({
|
||||||
|
title: MapApiConfig.OTHER.typeName === form.addressForStart ? MapApiConfig.OTHER.typeName : res.msg,
|
||||||
|
icon: 'success'
|
||||||
|
})
|
||||||
|
setTimeout(()=>{
|
||||||
|
uni.navigateBack(1);
|
||||||
|
}, 500)
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
uni.showToast({
|
||||||
|
icon: 'none',
|
||||||
|
title: res.msg
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 出差
|
||||||
|
const handleCancel = () => {
|
||||||
|
businessTripClockIn(form).then(res=>{
|
||||||
|
feedback(res,()=>console.log('出差打卡成功'));
|
||||||
|
}).catch(e=>{
|
||||||
|
uni.showToast({
|
||||||
|
icon: 'none',
|
||||||
|
title: e
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
// 打卡
|
||||||
|
let handleConfirm = () => {
|
||||||
|
addStartMapForClockIn(form).then(res=>{
|
||||||
|
feedback(res, ()=>console.log('打卡成功'));
|
||||||
|
}).catch(e=>{
|
||||||
|
uni.showToast({
|
||||||
|
icon: 'none',
|
||||||
|
title: e
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 判定是否在范围内
|
||||||
function isWithinRange(lat, lon, centerLat, centerLon, rangeKm) {
|
function isWithinRange(lat, lon, centerLat, centerLon, rangeKm) {
|
||||||
const distance = haversineDistance(centerLat, centerLon, lat, lon);
|
const distance = haversineDistance(centerLat, centerLon, lat, lon);
|
||||||
return distance <= rangeKm;
|
return distance <= rangeKm;
|
||||||
}
|
}
|
||||||
|
|
||||||
function haversineDistance(lat1, lon1, lat2, lon2, radius = 6371) {
|
function haversineDistance(lat1, lon1, lat2, lon2, radius = 6371) {
|
||||||
const dLat = degToRad(lat2 - lat1);
|
const dLat = degToRad(lat2 - lat1);
|
||||||
const dLon = degToRad(lon2 - lon1);
|
const dLon = degToRad(lon2 - lon1);
|
||||||
@@ -87,23 +167,25 @@ function haversineDistance(lat1, lon1, lat2, lon2, radius = 6371) {
|
|||||||
const c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
|
const c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
|
||||||
return radius * c; // 距离,单位:公里
|
return radius * c; // 距离,单位:公里
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 角度转弧度
|
||||||
function degToRad(deg) {
|
function degToRad(deg) {
|
||||||
return deg * (Math.PI / 180);
|
return deg * (Math.PI / 180);
|
||||||
}
|
}
|
||||||
|
|
||||||
//解析地址
|
//解析地址
|
||||||
function inverseGeocoding(latiude, longitude) {
|
function inverseGeocoding(latitude, longitude) {
|
||||||
let points = longitude + ',' + latiude
|
uni.showLoading();
|
||||||
const apiURL = 'https://tiles.geovisearth.com/geo/v1/geocode/regeo';
|
const apiURL = MapApiConfig.URL;
|
||||||
const params = {
|
const params = {
|
||||||
lat: latiude,
|
lat: latitude,
|
||||||
lng: longitude,
|
lng: longitude,
|
||||||
radius: 1000,
|
radius: 1000,
|
||||||
pageSize: 1,
|
pageSize: 1,
|
||||||
currentPage: 1,
|
currentPage: 1,
|
||||||
//classify: 220100
|
//classify: 220100
|
||||||
};
|
};
|
||||||
const token = '66c87c897f0251295afdc794e4fbf73046a070338a726fe04f06cece6cb1ffdf';
|
const token = MapApiConfig.token;
|
||||||
uni.request({
|
uni.request({
|
||||||
url: apiURL,
|
url: apiURL,
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
@@ -112,124 +194,31 @@ function inverseGeocoding(latiude, longitude) {
|
|||||||
'Authorization': 'Bearer ' + token
|
'Authorization': 'Bearer ' + token
|
||||||
},
|
},
|
||||||
success: (res) => {
|
success: (res) => {
|
||||||
console.log(res, "----")
|
modalVisible.value=true;
|
||||||
if (res.statusCode == 200 && res.data.status == 200) {
|
console.log(res, "经纬度解析成功")
|
||||||
|
if (res.statusCode === 200 && res.data.status === 200) {
|
||||||
let resdata = res.data.data.rows[0].address
|
let resdata = res.data.data.rows[0].address
|
||||||
if (resdata == null) {
|
if (resdata == null) {
|
||||||
console.log(resdata.srcLat)
|
console.log(resdata.srcLat)
|
||||||
const latiude1 = 34.1360;
|
if (isWithinRange(latitude1, longitude1, latiude, longitude, 1)) {
|
||||||
const longitude1 = 108.9126;
|
form.addressForStart = MapApiConfig.XI_AN_BAN.typeName;
|
||||||
if (isWithinRange(latiude1, longitude1, latiude, longitude, 1)) {
|
form.path = MapApiConfig.XI_AN_BAN.longitude + ',' + MapApiConfig.XI_AN_BAN.latitude ;
|
||||||
form.addressForStart = "西安办事处位置打卡"
|
|
||||||
uni.showModal({
|
|
||||||
title: '确定要在此处打卡吗',
|
|
||||||
content: form.addressForStart,
|
|
||||||
success: function (res) {
|
|
||||||
if (res.confirm) {
|
|
||||||
var data = {
|
|
||||||
mapId: form.mapId,
|
|
||||||
addressForStart: form.addressForStart,
|
|
||||||
cusName: form.cusName,
|
|
||||||
cusId: form.cusId,
|
|
||||||
remark: form.remark,
|
|
||||||
path: longitude1 + "," + latiude1
|
|
||||||
}
|
|
||||||
addStartMapForClockIn(data).then(res => {
|
|
||||||
if (res.code == 200) {
|
|
||||||
uni.showToast({
|
|
||||||
icon: 'success',
|
|
||||||
title: res.msg,
|
|
||||||
duration: 1500,
|
|
||||||
});
|
|
||||||
setTimeout(() => {
|
|
||||||
uni.navigateBack(1)
|
|
||||||
}, 500)
|
|
||||||
} else {
|
|
||||||
uni.showToast({
|
|
||||||
icon: 'none',
|
|
||||||
title: res.msg,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
})
|
|
||||||
} else if (res.cancel) {
|
|
||||||
console.log('用户点击取消');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
else {
|
||||||
}
|
|
||||||
} else {
|
|
||||||
form.addressForStart = resdata;
|
form.addressForStart = resdata;
|
||||||
uni.showModal({
|
form.path = longitude + ',' + latitude; // 经度,纬度
|
||||||
title: '确定要在此处打卡吗',
|
|
||||||
content: form.addressForStart,
|
|
||||||
success: function (res) {
|
|
||||||
if (res.confirm) {
|
|
||||||
var data = {
|
|
||||||
mapId: form.mapId,
|
|
||||||
addressForStart: form.addressForStart,
|
|
||||||
cusName: form.cusName,
|
|
||||||
cusId: form.cusId,
|
|
||||||
path: points
|
|
||||||
}
|
|
||||||
addStartMapForClockIn(data).then(res => {
|
|
||||||
if (res.code == 200) {
|
|
||||||
uni.showToast({
|
|
||||||
icon: 'success',
|
|
||||||
title: res.msg,
|
|
||||||
duration: 1500,
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
uni.showToast({
|
|
||||||
icon: 'none',
|
|
||||||
title: res.msg,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
})
|
|
||||||
} else if (res.cancel) {
|
|
||||||
console.log('用户点击取消');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
form.addressForStart = "第三方维护打卡"
|
form.addressForStart = MapApiConfig.OTHER.typeName;
|
||||||
uni.showModal({
|
form.path = longitude + ',' + latitude; // 经度,纬度
|
||||||
title: '确定要在此处打卡吗',
|
|
||||||
content: form.addressForStart,
|
|
||||||
success: function (res) {
|
|
||||||
if (res.confirm) {
|
|
||||||
var data = {
|
|
||||||
mapId: form.mapId,
|
|
||||||
addressForStart: form.addressForStart,
|
|
||||||
cusName: form.cusName,
|
|
||||||
cusId: form.cusId,
|
|
||||||
path: points
|
|
||||||
}
|
}
|
||||||
addStartMapForClockIn(data).then(res => {
|
uni.hideLoading();
|
||||||
if (res.code == 200) {
|
|
||||||
uni.showToast({
|
|
||||||
icon: 'success',
|
|
||||||
title: '第三方维护打卡',
|
|
||||||
duration: 1500,
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
uni.showToast({
|
|
||||||
icon: 'none',
|
|
||||||
title: res.msg,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
})
|
|
||||||
} else if (res.cancel) {
|
|
||||||
console.log('用户点击取消');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
},
|
},
|
||||||
fail(e) {
|
fail(e) {
|
||||||
console.log("获取位置失败", e)
|
console.log("获取位置失败", e)
|
||||||
}
|
uni.hideLoading();
|
||||||
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user