Browse Source

bug修改

heikabujianai 5 years ago
parent
commit
924f232915
3 changed files with 106 additions and 80 deletions
  1. 94 72
      pages/clock/clock.js
  2. 1 1
      pages/clock/clock.wxml
  3. 11 7
      pages/clock/clock.wxss

+ 94 - 72
pages/clock/clock.js

@@ -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: '请勿重复点击',
+      })
+    }
   },
   /**
    * 生命周期函数--监听页面加载

+ 1 - 1
pages/clock/clock.wxml

@@ -45,7 +45,7 @@
         <view class="time">
           <view>本周工时</view>
           <view>
-            <text class="number">{{clock.toFixed(sumDuration)}}</text>
+            <text class="number">{{sumDuration}}</text>
             <text class="unit">小时</text>
           </view>
         </view>

+ 11 - 7
pages/clock/clock.wxss

@@ -187,14 +187,12 @@ page {
   box-shadow: 0px 10rpx 10rpx 0rpx rgba(0, 0, 0, 0.06);
   border-radius: 32rpx;
   margin-top: 20rpx;
-  padding: 30rpx;
+  padding: 30rpx 27rpx;
   box-sizing: border-box;
-  display: flex;
-  align-items: center;
-  flex-direction: column;
 }
 
 .status {
+  width: 100%;
   display: flex;
   align-items: center;
   justify-content: space-between;
@@ -209,6 +207,8 @@ page {
   font-weight: 400;
   color: #000000;
   background: #F5F5F5;
+  box-sizing: border-box;
+  padding-left: 30rpx;
   border-radius: 10rpx;
   display: flex;
   flex-direction: column;
@@ -240,7 +240,7 @@ page {
   font-weight: 400;
   color: #999999;
   margin-top: 20rpx;
-  margin-bottom: 100rpx;
+  padding-bottom: 100rpx;
 }
 
 .image {
@@ -249,6 +249,7 @@ page {
   display: flex;
   align-items: center;
   justify-content: center;
+  margin: 0 auto;
 }
 
 .image image {
@@ -261,7 +262,7 @@ page {
   font-family: PingFangSC-Regular, PingFang SC;
   font-weight: 400;
   color: #666666;
-  margin-top: 70rpx;
+  padding-top: 70rpx;
   display: flex;
   align-items: center;
   justify-content: center;
@@ -278,7 +279,10 @@ page {
   font-family: PingFangSC-Semibold, PingFang SC;
   font-weight: 600;
   color: #007AFF;
-  margin-top: 40rpx;
+  padding-top: 40rpx;
+  display: flex;
+  justify-content: center;
+  align-items: center;
 }
 
 .reload-location image {