付延余
2023-03-23 1cb780b1762c62751c7f5f26132f3a7aa4ef3e2f
pages/driver-page/driver-index/bill-of-lading-details/punchTheClock/punchTheClock.vue
@@ -3,8 +3,8 @@
   <view class="punchTheClock">
      <!-- 打卡按钮 -->
      <view class="punchTheClock_container">
         <view class="punchTheClock_btn">
            <view class="">
         <view class="punchTheClock_btn" @click="arrive">
            <view>
               <p>签到/打卡</p>
               <p>{{ nowTime }}</p>
            </view>
@@ -20,31 +20,84 @@
<script>
import { todayDate } from '@/utils/util.js';
export default {
   onLoad(params){
      if(params.orderPlanId){
         this.orderPlanId = params.orderPlanId
   onLoad(params) {
      if (params.orderPlanId) {
         this.punchTheClockObj.id = params.orderPlanId;
      }
   },
   data() {
      return {
         nowTime: '',
         orderPlanId:null
         punchTheClockObj: {
            latitude: null,
            longitude: null,
            id: null
         }
      };
   },
   onShow() {
      this.todayDate();
      // 获取权限信息
      wx.getSetting({
         success(res) {
            if (!res.authSetting['scope.userFuzzyLocation']) {
               wx.authorize({
                  scope: 'scope.userFuzzyLocation',
                  success(res) {
                     console.log(res);
                     if (res.errMsg == 'authorize:ok') {
                        // 获取位置信息
                        this.getFuzzyLocation();
                     }
                  }
               });
            } else {
               this.getFuzzyLocation();
            }
         },
         fail() {
            console.log('获取失败');
         }
      });
   },
   methods: {
      getFuzzyLocation() {
         wx.getFuzzyLocation({
            type: 'wgs84',
            success(res) {
               console.log(res, '获取位置');
               this.punchTheClockObj.latitude = res.latitude;
               this.punchTheClockObj.longitude = res.longitude;
            }
         });
      },
      todayDate() {
         setInterval(() => {
            this.nowTime = todayDate('hms');
         }, 1000);
      },
      // 签到
      arrive(){
         this.$reqPost('arrive', { id: this.orderPlanId }, 'params').then(res => {
            console.log(res, '签到');
         });
      arrive() {
         if (this.punchTheClockObj.latitude && this.punchTheClockObj.longitude) {
            this.$reqPost('arrive', this.punchTheClockObj, 'params').then(res => {
               console.log(res, '签到');
               if (res.code == 0) {
                  this.$u.toast('签到成功');
                  setTimeout(() => {
                     uni.navigateBack(
                        {
                           delta: 1
                        },
                        500
                     );
                  });
               } else {
                  this.$u.toast(res.data ? res.data : '签到失败');
               }
            });
         } else {
            this.$u.toast('暂获取不到到当前位置');
         }
      }
   }
};
@@ -69,12 +122,12 @@
         align-items: center;
      }
      .punchTheClock_text {
         display:flex;
         display: flex;
         justify-content: center;
         margin-top: vww(20);
         color: #b8b8b8;
         .text{
            margin-left:vww(5);
         .text {
            margin-left: vww(5);
         }
      }
   }