|
|
@@ -7,6 +7,8 @@ import {
|
|
|
imgServerUrl
|
|
|
} from '../../config/config.js'
|
|
|
import { transformFromWGSToGCJ } from '../../utils/util'
|
|
|
+let clickStatus = true
|
|
|
+let locationStatus = true
|
|
|
Page({
|
|
|
|
|
|
/**
|
|
|
@@ -138,22 +140,32 @@ Page({
|
|
|
}
|
|
|
},
|
|
|
clock(longitude, latitude) {
|
|
|
- savePunchClock({ longitude, latitude, clockType: this.data.clockType, wsPunchClockId: this.data.wsPunchClockId }).then(data => {
|
|
|
- wx.showToast({
|
|
|
- title: '打卡成功',
|
|
|
- success: () => {
|
|
|
- wx.navigateTo({
|
|
|
- url: `./clock-success/clock-success?clockType=${this.data.clockType}&&sumMoney=${data.data.sumMoney}&&duration=${data.data.duration}&&todayMoney=${data.data.todayMoney}`
|
|
|
- })
|
|
|
- }
|
|
|
+ if (clickStatus) {
|
|
|
+ clickStatus = false
|
|
|
+ savePunchClock({ longitude, latitude, clockType: this.data.clockType, wsPunchClockId: this.data.wsPunchClockId }).then(data => {
|
|
|
+ wx.showToast({
|
|
|
+ title: '打卡成功',
|
|
|
+ success: () => {
|
|
|
+ clickStatus = true
|
|
|
+ wx.navigateTo({
|
|
|
+ url: `./clock-success/clock-success?clockType=${this.data.clockType}&&sumMoney=${data.data.sumMoney}&&duration=${data.data.duration}&&todayMoney=${data.data.todayMoney}`
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }).catch(data => {
|
|
|
+ clickStatus = true
|
|
|
+ wx.showModal({
|
|
|
+ title: '提示',
|
|
|
+ content: data.errmsg,
|
|
|
+ showCancel: false,
|
|
|
+ })
|
|
|
})
|
|
|
- }).catch(data => {
|
|
|
- wx.showModal({
|
|
|
- title: '提示',
|
|
|
- content: data.errmsg,
|
|
|
- showCancel: false,
|
|
|
+ } else {
|
|
|
+ wx.showToast({
|
|
|
+ icon: 'none',
|
|
|
+ title: '请勿重复点击',
|
|
|
})
|
|
|
- })
|
|
|
+ }
|
|
|
},
|
|
|
navigator(e) {
|
|
|
const { index } = e.currentTarget.dataset
|
|
|
@@ -182,66 +194,76 @@ Page({
|
|
|
})
|
|
|
},
|
|
|
async load() {
|
|
|
- const data = await this.location()
|
|
|
- console.log(data)
|
|
|
- punchClockNeedInfo({ longitude: data.longitude, latitude: data.latitude }).then(data => {
|
|
|
- // punchClockNeedInfo({ longitude: 120.353312, latitude: 31.535582 }).then(data => {
|
|
|
- let {
|
|
|
- authenticationStatus,
|
|
|
- startPunch,
|
|
|
- endPunch,
|
|
|
- todayMoney,
|
|
|
- clockType, // 1:上班打卡 2:下班打卡 3:超出范围 4:已完成
|
|
|
- sumDuration,
|
|
|
- sumMoney,
|
|
|
- wsPunchClockId,
|
|
|
- dailyAvailableMinHour
|
|
|
- } = data.data
|
|
|
- this.setData({
|
|
|
- approveStatus: authenticationStatus, // 认证状态(0:未认证 1:等待认证 2:未通过 3:已认证) ,
|
|
|
- startPunch,
|
|
|
- endPunch,
|
|
|
- todayMoney,
|
|
|
- clockType,
|
|
|
- sumDuration,
|
|
|
- sumMoney,
|
|
|
- wsPunchClockId
|
|
|
- })
|
|
|
- if (clockType === 1 && !wsPunchClockId) {
|
|
|
- this.setData({
|
|
|
- statusImage: `${imgServerUrl}/images/clock/clock-in.png`,
|
|
|
- statusIcon: `${imgServerUrl}/images/clock/clock-can.png`,
|
|
|
- })
|
|
|
- }
|
|
|
- if (clockType === 1 && wsPunchClockId) {
|
|
|
- this.setData({
|
|
|
- statusImage: `${imgServerUrl}/images/clock/clock-out-disabled.png`,
|
|
|
- statusIcon: `${imgServerUrl}/images/clock/clock-waring.png`,
|
|
|
- statusMessage: `上班${dailyAvailableMinHour}小时候才能进行下班打卡`,
|
|
|
- })
|
|
|
- }
|
|
|
- if (clockType === 2 && wsPunchClockId) {
|
|
|
+ if (locationStatus) {
|
|
|
+ locationStatus = false
|
|
|
+ const data = await this.location()
|
|
|
+ punchClockNeedInfo({ longitude: data.longitude, latitude: data.latitude }).then(data => {
|
|
|
+ // punchClockNeedInfo({ longitude: 120.353312, latitude: 31.535582 }).then(data => {
|
|
|
+ locationStatus = true
|
|
|
+ let {
|
|
|
+ authenticationStatus,
|
|
|
+ startPunch,
|
|
|
+ endPunch,
|
|
|
+ todayMoney,
|
|
|
+ clockType, // 1:上班打卡 2:下班打卡 3:超出范围 4:已完成
|
|
|
+ sumDuration,
|
|
|
+ sumMoney,
|
|
|
+ wsPunchClockId,
|
|
|
+ dailyAvailableMinHour
|
|
|
+ } = data.data
|
|
|
this.setData({
|
|
|
- statusImage: `${imgServerUrl}/images/clock/clock-out.png`,
|
|
|
- statusIcon: `${imgServerUrl}/images/clock/clock-can.png`,
|
|
|
- statusMessage: `已进入考勤打卡范围`,
|
|
|
+ approveStatus: authenticationStatus, // 认证状态(0:未认证 1:等待认证 2:未通过 3:已认证) ,
|
|
|
+ startPunch,
|
|
|
+ endPunch,
|
|
|
+ todayMoney,
|
|
|
+ clockType,
|
|
|
+ sumDuration,
|
|
|
+ sumMoney,
|
|
|
+ wsPunchClockId
|
|
|
})
|
|
|
- }
|
|
|
- if (clockType === 3) {
|
|
|
- this.setData({
|
|
|
- statusImage: `${imgServerUrl}/images/clock/clock-beyond.png`,
|
|
|
- statusIcon: `${imgServerUrl}/images/clock/clock-waring.png`,
|
|
|
- statusMessage: `请进入企业后再进行打卡`,
|
|
|
- })
|
|
|
- }
|
|
|
- if (clockType === 4) {
|
|
|
- this.setData({
|
|
|
- statusImage: `${imgServerUrl}/images/clock/clock-done.png`,
|
|
|
- statusIcon: `${imgServerUrl}/images/clock/clock-can.png`,
|
|
|
- statusMessage: `今日打卡已完成`,
|
|
|
- })
|
|
|
- }
|
|
|
- })
|
|
|
+ if (clockType === 1 && !wsPunchClockId) {
|
|
|
+ this.setData({
|
|
|
+ statusImage: `${imgServerUrl}/images/clock/clock-in.png`,
|
|
|
+ statusIcon: `${imgServerUrl}/images/clock/clock-can.png`,
|
|
|
+ })
|
|
|
+ }
|
|
|
+ if (clockType === 1 && wsPunchClockId) {
|
|
|
+ this.setData({
|
|
|
+ statusImage: `${imgServerUrl}/images/clock/clock-out-disabled.png`,
|
|
|
+ statusIcon: `${imgServerUrl}/images/clock/clock-waring.png`,
|
|
|
+ statusMessage: `上班${dailyAvailableMinHour}小时候才能进行下班打卡`,
|
|
|
+ })
|
|
|
+ }
|
|
|
+ if (clockType === 2 && wsPunchClockId) {
|
|
|
+ this.setData({
|
|
|
+ statusImage: `${imgServerUrl}/images/clock/clock-out.png`,
|
|
|
+ statusIcon: `${imgServerUrl}/images/clock/clock-can.png`,
|
|
|
+ statusMessage: `已进入考勤打卡范围`,
|
|
|
+ })
|
|
|
+ }
|
|
|
+ if (clockType === 3) {
|
|
|
+ this.setData({
|
|
|
+ statusImage: `${imgServerUrl}/images/clock/clock-beyond.png`,
|
|
|
+ statusIcon: `${imgServerUrl}/images/clock/clock-waring.png`,
|
|
|
+ statusMessage: `请进入企业后再进行打卡`,
|
|
|
+ })
|
|
|
+ }
|
|
|
+ if (clockType === 4) {
|
|
|
+ this.setData({
|
|
|
+ statusImage: `${imgServerUrl}/images/clock/clock-done.png`,
|
|
|
+ statusIcon: `${imgServerUrl}/images/clock/clock-can.png`,
|
|
|
+ statusMessage: `今日打卡已完成`,
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }).catch(data => {
|
|
|
+ locationStatus = true
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ wx.showToast({
|
|
|
+ icon: 'none',
|
|
|
+ title: '请勿重复点击',
|
|
|
+ })
|
|
|
+ }
|
|
|
},
|
|
|
/**
|
|
|
* 生命周期函数--监听页面加载
|