From e193d75257a21568a15f99b27a2a48bd7fd815f9 Mon Sep 17 00:00:00 2001
From: 付延余 <f-yanyu@outlook.com>
Date: 星期三, 22 三月 2023 17:59:06 +0800
Subject: [PATCH] 1.磅房详情(完成) 2.入场申请报错(完成) 3.签到(完成) 4.日志(完成) 5.发运计划详情(完成)

---
 pages/driver-page/driver-index/bill-of-lading-details/punchTheClock/punchTheClock.vue |   79 +++++++++++++++++++++++++++++++++------
 1 files changed, 66 insertions(+), 13 deletions(-)

diff --git a/pages/driver-page/driver-index/bill-of-lading-details/punchTheClock/punchTheClock.vue b/pages/driver-page/driver-index/bill-of-lading-details/punchTheClock/punchTheClock.vue
index 843f75a..38d397c 100644
--- a/pages/driver-page/driver-index/bill-of-lading-details/punchTheClock/punchTheClock.vue
+++ b/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);
 			}
 		}
 	}

--
Gitblit v1.9.1