qingyiay
2023-03-28 e7b0b34176549cfec809c6b89c4cab0999e488b9
pages/driver-page/driver-index/bill-of-lading-details/punchTheClock/punchTheClock.vue
@@ -5,7 +5,7 @@
      <view class="punchTheClock_container">
         <view class="punchTheClock_btn" @click="arrive">
            <view>
               <p>签到/打卡</p>
               <p>{{ coalStatus == 2 ? '已签到' : '签到/打卡' }}</p>
               <p>{{ nowTime }}</p>
            </view>
         </view>
@@ -21,53 +21,54 @@
import { todayDate } from '@/utils/util.js';
export default {
   onLoad(params) {
      if (params.orderPlanId) {
         this.punchTheClockObj.id = params.orderPlanId;
      }
      this.punchTheClockObj.tmcoa = params.tmId.toString();
      this.coalStatus = params.coalStatus;
   },
   data() {
      return {
         nowTime: '',
         coalStatus: 0,
         punchTheClockObj: {
            latitude: null,
            longitude: null,
            id: null
            tmcoa: null,
            latA: null,
            latB: 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('获取失败');
         }
      });
      this.getSetting(); //获取授权
      this.getFuzzyLocation(); //获取位置
      this.todayDate(); //当前时间
   },
   methods: {
      getSetting() {
         // 获取权限信息
         wx.getSetting({
            success(res) {
               if (!res.authSetting['scope.userFuzzyLocation']) {
                  wx.authorize({
                     scope: 'scope.userFuzzyLocation',
                     success(res) {
                        uni.showToast({
                           title: '授权成功!'
                        });
                     }
                  });
               }
            },
            fail() {
               console.log('获取失败');
            }
         });
      },
      getFuzzyLocation() {
         let that = this;
         wx.getFuzzyLocation({
            type: 'wgs84',
            success(res) {
               console.log(res, '获取位置');
               this.punchTheClockObj.latitude = res.latitude;
               this.punchTheClockObj.longitude = res.longitude;
               console.log(res, '获取位置', that);
               that.punchTheClockObj.latB = res.latitude;
               that.punchTheClockObj.latA = res.longitude;
            }
         });
      },
@@ -78,7 +79,8 @@
      },
      // 签到
      arrive() {
         if (this.punchTheClockObj.latitude && this.punchTheClockObj.longitude) {
         if (this.punchTheClockObj.latA && this.punchTheClockObj.latB) {
            console.log(this.punchTheClockObj);
            this.$reqPost('arrive', this.punchTheClockObj, 'params').then(res => {
               console.log(res, '签到');
               if (res.code == 0) {
@@ -92,7 +94,7 @@
                     );
                  });
               } else {
                  this.$u.toast(res.data ? res.data : '签到失败');
                  this.$u.toast(res.msg ? res.msg : '签到失败');
               }
            });
         } else {
@@ -120,6 +122,9 @@
         display: flex;
         justify-content: center;
         align-items: center;
         p {
            text-align: center;
         }
      }
      .punchTheClock_text {
         display: flex;