Sfoglia il codice sorgente

Merge branch 'master' of http://118.195.146.34:3000/ygtx/ygoa_miniapp

wangpx 1 anno fa
parent
commit
32c5d16392

+ 3 - 3
pages.json

@@ -112,14 +112,14 @@
 			"path" : "pages/mine/checkIn/checkIn",
 			"style" : 
 			{
-				"navigationBarTitleText" : ""
+				"navigationBarTitleText" : "我的考勤"
 			}
 		},
 		{
-			"path" : "pages/mine/test/test",
+			"path" : "pages/mine/clockIn/clockIn",
 			"style" : 
 			{
-				"navigationBarTitleText" : ""
+				"navigationBarTitleText" : "打卡签到"
 			}
 		}
 	],

+ 142 - 44
pages/mine/test/test.vue → pages/mine/clockIn/clockIn.vue

@@ -16,20 +16,21 @@
 				<text class="title">下班</text>
 				<text class="time">{{ signOutTime ||'未打卡'}}</text>
 			</view>
+			<view class="record-item" @click="getAddress">
+				<image :src="locationImg" class="icon"></image>
+				<text class="title">当前位置</text>
+				<text class="time">{{ address ||'点击获取定位'}}</text>
+			</view>
 		</view>
-		<!-- <map id="myMap" class="map" :latitude="latitude" :longitude="longitude" :markers="covers"> -->
-		<!-- </map> -->
-		<!-- <map id="myMap" class="map" :longitude="longitude" :latitude="latitude" show-location></map> -->
-		<atl-map :mapKey="mapKey" :mapType="mapType">
-		            <template v-slot:content>
-		                <view style="position: absolute; bottom: 0; width: 100%; height: 24px; background-color: white">
-		                    <view style="display: flex; align-items: center; justify-content: center">
-		                        <image style="width: 24px; height: 24px" :src="imageSrc"></image>
-		                        <text>内容插槽</text>
-		                    </view>
-		                </view>
-		            </template>
-		        </atl-map>
+		<atl-map :mapKey="mapKey" :mapType="mapType" @confirm="confirm" :marker="marker" :polygons="polygons"
+			:isPolygons="true">
+			<template v-slot:content>
+				<view style="position: absolute; bottom: 0; width: 100%; height: 24px; background-color: white">
+					<view style="display: flex; align-items: center; justify-content: center">
+					</view>
+				</view>
+			</template>
+		</atl-map>
 		<view class="footer">
 			<button type="primary" @click="signIn">上班签到</button>
 			<button type="default" @click="signOut">下班签退</button>
@@ -38,17 +39,28 @@
 </template>
 
 
-<script setup lang="ts">
-	import { onMounted, reactive, ref } from 'vue';
+<script setup>
+	import {
+		onMounted,
+		reactive,
+		ref
+	} from 'vue';
 
 	import goToWorkImg from "/static/images/mine/goToWork.png";
 	import afterWorkImg from "/static/images/mine/afterWork.png";
 	import locationImg from "/static/images/mine/location.png";
+
+	import booleanPointInPolygon from "@turf/boolean-point-in-polygon";
+	import {
+		point,
+		polygon
+	} from "@turf/helpers";
 	// const UniMap = require('@/uni_modules/uni-map-common/uniCloud/cloudfunctions/common/uni-map-common');
-    const disable=ref(true);
-	const show=ref(true);
-	const mapKey=ref('KJBBZ-5JCLZ-3NLXD-742CK-Y26UZ-X7BJN');
-	const mapType=ref('tmap');
+
+	const mapKey = ref('KJBBZ-5JCLZ-3NLXD-742CK-Y26UZ-X7BJN');
+	const mapType = ref('tmap');
+	const address = ref('');
+
 	const currentDate = ref('2023-04-01');
 	const currentDay = ref('星期三');
 	const clockInStatus = ref('');
@@ -56,21 +68,50 @@
 	const signInTime = ref('09:00');
 	const signOutTime = ref('');
 
-	const longitude = ref(119.22069399999998);
-	const latitude = ref(25.955783999999984);
-	const covers = reactive([{
+	const longitude = ref(0);
+	const latitude = ref(0);
+	const marker = reactive({
 		id: 1,
-		longitude: longitude.value,
-		latitude: latitude.value,
-		iconPath: locationImg,
+		latitude: 25.958812,
+		longitude: 119.213036,
+		// iconPath: locationImg,
 		width: 50, // 标记的宽度
-		height: 50 // 标记的高度
-	}])
+		height: 50, // 标记的高度
+		title: '宇光同行'
+	})
+	const polygons = reactive([{
+		points: [{
+				latitude: 25.9591401,
+				longitude: 119.21292356
+			},
+			{
+				latitude: 25.95828592,
+				longitude: 119.21261955
+			},
+			{
+				latitude: 25.9576709,
+				longitude: 119.21458294
+			},
+			{
+				latitude: 25.95845106,
+				longitude: 119.21486162
+			},
+			{
+				latitude: 25.9591401,
+				longitude: 119.21292356
+			}
+
+		],
+		strokeWidth: 1,
+		strokeColor: "#ff000066",
+		fillColor: "#ff000016",
+	}, ])
 
 
 
 	onMounted(() => {
 		dateInit();
+		getlocation();
 	});
 
 
@@ -89,32 +130,34 @@
 	}
 
 	function signIn() {
-		// let uniMap = new UniMap({
-		// 	provider: "qqmap", // 指定使用哪家地图供应商
-		// 	key: "KJBBZ-5JCLZ-3NLXD-742CK-Y26UZ-X7BJN"
-		// });
-		// // 调用API
-		// let result = uniMap.ip2location({
-		// 	ip: "111.206.145.41"
-		// });
-		// console.log("result", result);
 		getlocation();
+		tranAddress();
+		clockIn();
 	};
 
 	function signOut() {
-		console.log('下班签退');
+		getlocation();
+		tranAddress();
+		const flag= clockIn();	
+		if(flag){
+			var now = new Date();
+			var hours = now.getHours();
+			var minutes = now.getMinutes();
+			signOutTime.value=hours+':'+minutes;
+		}
 	};
 
+
+	//获取当前定位经纬度
 	function getlocation() {
-		uni.getLocation({
-			type: 'wgs84',
+		wx.getLocation({
+			type: 'gcj02',
 			success: (res) => {
+				console.log(res);
 				console.log('当前位置的经度:' + res.longitude);
 				console.log('当前位置的纬度:' + res.latitude);
-				this.longitude = res.longitude
-				this.latitude = res.latitude
-				// 调用后端接口根据得到的经纬度获取地址
-				console.log(res, "根据经纬度获取地址");
+				longitude.value=res.longitude;
+				latitude.value=res.latitude;
 			},
 			// 若用户点击拒绝获取位置则弹出提示
 			fail: (err) => {
@@ -156,7 +199,62 @@
 					}
 				})
 			},
-		})
+		});
+		
+	}
+
+	//获取当前精确地址
+    async function getAddress() {
+		getlocation();
+		// console.log(latitude.value)
+		tranAddress();
+	}
+	
+	//经纬度转地址
+	function tranAddress(){
+		let locationStr = latitude.value+','+longitude.value
+		uni.request({
+			url: 'https://apis.map.qq.com/ws/geocoder/v1/?location=' + locationStr + '&key=' + mapKey.value +
+				'&get_poi=1',
+			method: 'GET',
+			data: {
+				// 这里可以添加一些GET请求的参数
+			},
+			success: function(res) {
+				console.log('请求成功', res.data);
+				address.value = res.data.result.address;
+			},
+			fail: function(err) {
+				console.error('请求失败', err);
+			}
+		});
+	}
+
+	//打卡
+	function clockIn() {
+		const _polygons = polygons.map((polygon) => {
+			return polygon.points.map((i) => [
+				Number(i.longitude),
+				Number(i.latitude),
+			]);
+		});
+		const _point = point([longitude.value, latitude.value]);
+		const _polygon = polygon(_polygons);
+		// 根据电子围栏判断否禁用
+		const f = booleanPointInPolygon(_point, _polygon);
+		// console.log(f);
+		if (f) {
+			uni.showToast({
+				title: "打卡成功",
+				icon: 'none'
+			});
+			return true;
+		} else {
+			uni.showToast({
+				title: "未在指定范围,打卡失败",
+				icon: 'none'
+			})
+		}
 	}
 </script>
 

+ 10 - 2
pages/mine/index.vue

@@ -45,6 +45,11 @@
 				<text class="title">应用设置</text>
 				<text class="desc">></text>
 			</view>
+			<view class="function-item" @click="handleButtonClick5">
+				<image :src="waitWork" class="icon"></image>
+				<text class="title">打卡</text>
+				<text class="desc">></text>
+			</view>
 		</view>
 
 
@@ -93,16 +98,19 @@
 	function handleButtonClick1() {
 		$tab.navigateTo('/pages/mine/edit/edit')
 	};
+	
 	function handleButtonClick2(){
-		$tab.navigateTo('/pages/mine/test/test')
+		$tab.navigateTo('/pages/mine/waitWork/waitWork')
 	}
 	function handleButtonClick3(){
 		$tab.navigateTo('/pages/mine/checkIn/checkIn')
 	}
-
 	function handleButtonClick4() {
 		$tab.navigateTo('/pages/mine/setting/setting')
 	};
+	function handleButtonClick5() {
+		$tab.navigateTo('/pages/mine/clockIn/clockIn')
+	};
 </script>
 
 

+ 9 - 7
uni_modules/atl-map/components/tmap/tmap.vue

@@ -7,21 +7,21 @@
 				top: top + 'px',
 			},
 		]">
-		<view class="top">
+		<!-- <view class="top">
 			<view class="cancel" @click="closeMap">取消</view>
 			<view class="address-text">
 				{{ currentAd.title || '' }}
 			</view>
 			<view class="confirm" @click="submit"
 				:style="{ backgroundColor: disable ? 'rgba(0, 0, 0, 0.2)' : '#42b983' }">确定</view>
-		</view>
+		</view> -->
 		<map id="map" class="map" :longitude="long" :latitude="lat" show-location @tap="onTap" :markers="markers"
 			:polygons="isPolygons?polygons:[]" enable-poi @poitap="poitap">
 			<cover-view>
 				<slot name="content"></slot>
 			</cover-view>
 		</map>
-		<view class="search">
+		<!-- <view class="search">
 			<view class="search-input">
 				<input placeholder="搜索附近" v-model="search" type="text" maxlength="64" @input="gosearch" />
 			</view>
@@ -40,7 +40,7 @@
 				</view>
 				<view class="empty" v-if="poiList.length == 0">暂无数据, 请更检查key是否有效或者更换关键词</view>
 			</view>
-		</view>
+		</view> -->
 	</view>
 </template>
 <script>
@@ -403,6 +403,7 @@
 					location = {};
 				}
 			}
+			console.log('location',location);
 			return location;
 		},
 
@@ -917,6 +918,7 @@
 				output: 'json',
 				key: that.key
 			};
+			// console.log('地址',options.address)
 
 			//城市限定
 			if (options.region) {
@@ -1289,8 +1291,8 @@
 			changeMarkers() {
 				this.markers[0] = {
 					...this.$props?.marker,
-					longitude: this.long,
-					latitude: this.lat
+					// longitude: this.long,
+					// latitude: this.lat
 				};
 			},
 			//当前位址信息
@@ -1388,7 +1390,7 @@
 </script>
 <style lang="scss" scoped>
 	.map-content {
-		position: fixed;
+		// position: fixed;
 		top: 0;
 		left: 0;
 		bottom: 0;