|
@@ -17,29 +17,31 @@
|
|
|
<div class="cw_pre">
|
|
|
<p>上班08:30</p>
|
|
|
<div class="cwp_time">
|
|
|
- <image :src="imgBase+'clockingin/checked_active.png'"></image>
|
|
|
+ <image :src="imgBase+'clockingin/checked_active.png'" v-if="sbClockTime"></image>
|
|
|
+ <image :src="imgBase+'clockingin/checked_inactive.png'" v-else></image>
|
|
|
<span>打卡{{sbClockTime||'- -'}}</span>
|
|
|
</div>
|
|
|
- <div class="cwp_status active">已打卡</div>
|
|
|
+ <div class="cwp_status" :class="{'active':sbClockTime,'inactive':!sbClockTime}">{{sbClockTime?'已打卡':'未打卡'}}</div>
|
|
|
</div>
|
|
|
<div class="cw_pre">
|
|
|
<p>下班20:00</p>
|
|
|
<div class="cwp_time">
|
|
|
- <image :src="imgBase+'clockingin/checked_inactive.png'"></image>
|
|
|
+ <image :src="imgBase+'clockingin/checked_active.png'" v-if="xbClockTime"></image>
|
|
|
+ <image :src="imgBase+'clockingin/checked_inactive.png'" v-else></image>
|
|
|
<span>{{xbClockTime||'- -'}}</span>
|
|
|
</div>
|
|
|
- <div class="cwp_status inactive">未打卡</div>
|
|
|
+ <div class="cwp_status" :class="{'active':xbClockTime,'inactive':!xbClockTime}">{{xbClockTime?'已打卡':'未打卡'}}</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="c_clock">
|
|
|
- <div class="cc_box" :style="{'background-image':'url('+imgBase+'clockingin/clock_active_bg.png)'}" @tap="clock">
|
|
|
+ <div class="cc_box" :style="{'background-image':'url('+imgBase+(canClock?'clockingin/clock_active_bg.png':'clockingin/clock_inactive_bg.png')+')'}" @tap="clock">
|
|
|
<p>{{isSW?'上班':'下班'}}打卡</p>
|
|
|
<p class="time">{{currentSFM}}</p>
|
|
|
</div>
|
|
|
<div class="cc_location">
|
|
|
- <image :src="imgBase+'clockingin/location_active.png'"></image>
|
|
|
- <span>已进入考勤范围:谷锐特设备自动化有限公司</span>
|
|
|
- <!-- <span>当前定位不在考勤范围内</span> -->
|
|
|
+ <image :src="imgBase+(canClock?'clockingin/location_active.png':'clockingin/location_inactive.png')"></image>
|
|
|
+ <span v-if="canClock">已进入考勤范围:谷锐特设备自动化有限公司</span>
|
|
|
+ <span v-else>当前定位不在考勤范围内</span>
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
@@ -69,33 +71,49 @@
|
|
|
components:{ Tabbar },
|
|
|
data(){
|
|
|
return {
|
|
|
- username:'王勇毅',
|
|
|
+ username:'',
|
|
|
dateweek:'',
|
|
|
- sbClockTime:'08::24',
|
|
|
+ sbClockTime:'',
|
|
|
xbClockTime:'',
|
|
|
- isSW:true,//是否是上午,12点前是上午,12点后是下午
|
|
|
+ isSW:true,//是否是上午,12点前是上午/12点前上午打过卡就是下午了,12点后是下午
|
|
|
currentSFM:new Date().Format('hh:mm:ss'),
|
|
|
show:false,
|
|
|
+ canClock:false,
|
|
|
clockTime:'',
|
|
|
distance: null,
|
|
|
targetLocation: { //谷锐特 31.962084,117.020446 /跨境电商大厦 31.865786,117.15297
|
|
|
latitude: 31.865786,
|
|
|
longitude: 117.15297
|
|
|
- }
|
|
|
+ },
|
|
|
+ userInfo:null
|
|
|
}
|
|
|
},
|
|
|
created() {
|
|
|
this.getDateWeek();
|
|
|
this.getCurrentSFM();
|
|
|
this.getCurrentHour();
|
|
|
+ if(uni.getStorageSync('userInfo')){
|
|
|
+ this.userInfo = JSON.parse(uni.getStorageSync('userInfo'));
|
|
|
+ this.username = this.userInfo.realName;
|
|
|
+ }
|
|
|
},
|
|
|
onUnload() {
|
|
|
clearInterval(timer)
|
|
|
},
|
|
|
mounted() {
|
|
|
this.getCurrentLocation();
|
|
|
+ this.getUserInfo();
|
|
|
},
|
|
|
methods:{
|
|
|
+ getUserInfo(){
|
|
|
+ this.$api.get('/wms/outsourced/attendance/getAttendanceByUserId/'+this.userInfo?.id).then(res=>{
|
|
|
+ if(res.data.code!==0) return this.$showToast(res.data.msg)
|
|
|
+ this.sbClockTime = res.data.data?.checkInTime;
|
|
|
+ this.xbClockTime = res.data.data?.clockOutTime;
|
|
|
+ if(new Date().getHours()<12&&!this.sbClockTime) this.isSW = true
|
|
|
+ else this.isSW = false;
|
|
|
+ })
|
|
|
+ },
|
|
|
getDateWeek(){
|
|
|
let date = new Date().Format('yyyy年MM月dd日');
|
|
|
let cfg = {0:'天',1:'一',2:'二',3:'三',4:'四',5:'五',6:'六'};
|
|
@@ -111,11 +129,19 @@
|
|
|
this.isSW = new Date().getHours()>12?false:true;
|
|
|
},
|
|
|
clock(){
|
|
|
- this.clockTime = new Date().Format('hh:mm');
|
|
|
- this.show = true;
|
|
|
+ if(!this.canClock) return
|
|
|
+ let url = this.isSW?'/wms/outsourced/attendance/checkIn':'/wms/outsourced/attendance/clockOut';
|
|
|
+ let params = {outUserId:this.userInfo?.id};
|
|
|
+ params[this.isSW?'checkInTime':'clockOutTime'] = new Date().Format('hh:mm');
|
|
|
+ this.$api.post(url,params).then(res=>{
|
|
|
+ if(res.data.code!==0) return this.$showToast(res.data.msg);
|
|
|
+ this.clockTime = new Date().Format('hh:mm');
|
|
|
+ this.show = true;
|
|
|
+ })
|
|
|
},
|
|
|
close(){
|
|
|
this.show = false;
|
|
|
+ this.getUserInfo();
|
|
|
},
|
|
|
// 获取当前位置
|
|
|
async getCurrentLocation() {
|
|
@@ -124,7 +150,6 @@
|
|
|
type: 'gcj02 ', // 腾讯地图使用GCJ-02坐标系/
|
|
|
isHighAccuracy: true
|
|
|
});
|
|
|
- console.log(res);
|
|
|
this.calculateDistance(
|
|
|
res[1].latitude,
|
|
|
res[1].longitude,
|
|
@@ -132,6 +157,7 @@
|
|
|
this.targetLocation.longitude
|
|
|
);
|
|
|
console.log(this.distance,'distance');
|
|
|
+ this.canClock = this.distance<=10;
|
|
|
} catch (err) {
|
|
|
uni.showToast({
|
|
|
title: '获取位置失败,请检查权限设置',
|