Browse Source

打卡项目优化

MS-CIAZDCOIXVRW\Administrator 3 years ago
parent
commit
e3c0dd760a

+ 1 - 1
pagesClockIn/addLocation/addLocation.vue

@@ -83,7 +83,7 @@
 			// 实例化API核心类
 			qqmapsdk = new QQMapWX({
 				// 申请的key
-				key: 'R43BZ-2XROX-L7T45-T5OQI-IBDFT-GNBOI'
+				key: 'X57BZ-ZISE3-KTN3O-3P45H-C3J7Q-D5B67'
 			});
 			this.getLocationData()
 		},

+ 34 - 3
pagesClockIn/addRules/addRules.vue

@@ -104,6 +104,26 @@
 			</view>
 		</view>
 
+		<view class="box">
+			<view class="name">
+				是否需要拍摄场景照片:
+			</view>
+			<view class="val2">
+				<switch style="transform:scale(0.8)" color="#3396FB" :checked="takePicture"
+					@change="switchChange_takePicture" />
+			</view>
+		</view>
+
+		<view class="box">
+			<view class="name">
+				是否需要人脸识别:
+			</view>
+			<view class="val2">
+				<switch style="transform:scale(0.8)" color="#3396FB" :checked="faceRecognition"
+					@change="switchChange_faceRecognition" />
+			</view>
+		</view>
+
 		<!-- 确认按钮区域 -->
 		<view class="button" @click="handleConfirm">
 			确认
@@ -136,6 +156,10 @@
 				locations: [],
 				// 是否同步节假日
 				holiday: false,
+				// 是否需要拍摄场景照片
+				takePicture: false,
+				// 是否需要人脸识别
+				faceRecognition: false,
 				// 星期映射数组
 				arr: ["", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六", "星期天"]
 			};
@@ -243,11 +267,12 @@
 								method: "post",
 								header: {
 									'Authorization': uni.getStorageSync("token"),
-									'platform': 2
+									'platform': 2,
+									'Accept-Language': 'zh-CN,zh;q=0.9'
 								},
 								data: {
 									// 是否需要人脸识别
-									faceRecognition: true,
+									faceRecognition: this.faceRecognition,
 									// 考勤组ID列表
 									groupIds: this.groupIds,
 									// 是否同步节假日
@@ -259,7 +284,7 @@
 									// 提前通知时间
 									noticeTime: this.value,
 									// 是否需要场景拍照
-									takePicture: true,
+									takePicture: this.takePicture,
 									// 打卡地点列表
 									locations: this.locations,
 									// 打卡时间列表
@@ -294,6 +319,12 @@
 				this.holiday = e.detail.value
 				// console.log(this.holiday);
 			},
+			switchChange_takePicture(e) {
+				this.takePicture = e.detail.value
+			},
+			switchChange_faceRecognition(e) {
+				this.faceRecognition = e.detail.value
+			},
 			// 点击规则名称跳转回调
 			goPageRuleName() {
 				uni.navigateTo({

+ 15 - 6
pagesClockIn/authentication/authentication.vue

@@ -65,11 +65,12 @@
 				// 姓名
 				name: "",
 				// 身份证号
-				cardNumber: ""
+				cardNumber: "",
+				// 是否需要场景照片,值为1时是不需要
+				flag: ""
 			};
 		},
 		onLoad(options) {
-			this.initData()
 			let userInfo = uni.getStorageSync("userInfo")
 			if (userInfo) {
 				this.name = userInfo.name
@@ -79,7 +80,13 @@
 			this.lat = options.latitude
 			this.lng = options.longitude
 			this.location = options.address
-			this.sceneImage = options.imgUrl
+			if (options.imgUrl) {
+				this.sceneImage = options.imgUrl
+			}
+			if (options.flag) {
+				this.flag = options.flag
+			}
+			this.initData()
 		},
 		methods: {
 			// 初始化相机引擎
@@ -190,7 +197,8 @@
 						filePath: url,
 						name: 'file',
 						header: {
-							'platform': 2
+							'platform': 2,
+							'Accept-Language': 'zh-CN,zh;q=0.9'
 						},
 						success: (uploadFileRes) => {
 							let imgUrl = JSON.parse(uploadFileRes.data)
@@ -212,7 +220,8 @@
 					method: "put",
 					header: {
 						'Authorization': uni.getStorageSync("token"),
-						'platform': 2
+						'platform': 2,
+						'Accept-Language': 'zh-CN,zh;q=0.9'
 					},
 					data: {
 						id: this.id,
@@ -220,7 +229,7 @@
 						lng: this.lng,
 						location: this.location,
 						matchFaceImage: imgUrl,
-						sceneImage: this.sceneImage,
+						sceneImage: this.flag == 1 ? "" : this.sceneImage,
 					}
 				})
 				// console.log(res);

+ 36 - 1
pagesClockIn/editRules/editRules.vue

@@ -105,6 +105,26 @@
 			</view>
 		</view>
 
+		<view class="box">
+			<view class="name">
+				是否需要拍摄场景照片:
+			</view>
+			<view class="val2">
+				<switch style="transform:scale(0.8)" color="#3396FB" :checked="takePicture"
+					@change="switchChange_takePicture" />
+			</view>
+		</view>
+
+		<view class="box">
+			<view class="name">
+				是否需要人脸识别:
+			</view>
+			<view class="val2">
+				<switch style="transform:scale(0.8)" color="#3396FB" :checked="faceRecognition"
+					@change="switchChange_faceRecognition" />
+			</view>
+		</view>
+
 		<!-- 确认按钮区域 -->
 		<view class="button" @click="handleConfirm">
 			确认
@@ -144,6 +164,10 @@
 				locations: [],
 				// 是否同步节假日
 				holiday: false,
+				// 是否需要拍摄场景照片
+				takePicture: false,
+				// 是否需要人脸识别
+				faceRecognition: false,
 				// 星期映射数组
 				arr: ["", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六", "星期天"]
 			};
@@ -228,6 +252,10 @@
 
 					// 法定节假日
 					this.holiday = res.data.holiday
+					// 人脸识别
+					this.faceRecognition = res.data.faceRecognition
+					// 场景照片
+					this.takePicture = res.data.takePicture
 				}
 			},
 			// 点击确认按钮回调
@@ -281,7 +309,8 @@
 								method: "put",
 								header: {
 									'Authorization': uni.getStorageSync("token"),
-									'platform': 2
+									'platform': 2,
+									'Accept-Language': 'zh-CN,zh;q=0.9'
 								},
 								data: {
 									// 编辑的规则id
@@ -362,6 +391,12 @@
 				this.holiday = e.detail.value
 				// console.log(this.holiday);
 			},
+			switchChange_takePicture(e) {
+				this.takePicture = e.detail.value
+			},
+			switchChange_faceRecognition(e) {
+				this.faceRecognition = e.detail.value
+			},
 			// 点击规则名称跳转回调
 			goPageRuleName() {
 				uni.navigateTo({

+ 2 - 1
pagesClockIn/group/group.vue

@@ -267,7 +267,8 @@
 					method: "post",
 					header: {
 						'Authorization': uni.getStorageSync("token"),
-						'platform': 2
+						'platform': 2,
+						'Accept-Language': 'zh-CN,zh;q=0.9'
 					},
 					data: {
 						name: this.group_name,

+ 138 - 29
pagesClockIn/home/home.vue

@@ -102,6 +102,26 @@
 				</view>
 			</navigator>
 		</view>
+
+		<!-- 认证结果弹窗 -->
+		<uni-popup ref="popup" :is-mask-click="false">
+			<view class="popup-content">
+				<view class="title">
+					<view class="icon">
+						<img src="./imgs/success2.png">
+					</view>
+					<view class="title_info">
+						打卡成功
+					</view>
+				</view>
+				<view class="time">
+					{{nowTime_pop}}
+				</view>
+				<view class="popup_button" @click="handleGoHome">
+					我知道了
+				</view>
+			</view>
+		</uni-popup>
 	</view>
 </template>
 
@@ -117,6 +137,8 @@
 				list: [],
 				// 当前时间
 				nowTime: "",
+				// 弹窗当前时间
+				nowTime_pop: "",
 				// 当前定位位置信息
 				address: "",
 				// 定时器标识
@@ -146,7 +168,11 @@
 				// 当前页面的路由地址
 				pageUrl: "",
 				// 是否显示底部 我的 导航栏
-				showTab: false
+				showTab: false,
+				// 是否需要人脸识别
+				faceRecognition: true,
+				// 是否需要拍摄场景照片
+				takePicture: true
 			};
 		},
 		onLoad() {
@@ -155,7 +181,7 @@
 			// 实例化API核心类
 			qqmapsdk = new QQMapWX({
 				// 申请的key
-				key: 'R43BZ-2XROX-L7T45-T5OQI-IBDFT-GNBOI'
+				key: 'X57BZ-ZISE3-KTN3O-3P45H-C3J7Q-D5B67'
 			});
 			// 获取当前系统时间
 			this.getNowTime()
@@ -178,7 +204,7 @@
 			uni.removeStorageSync("sub-administrator")
 			qqmapsdk = new QQMapWX({
 				// 申请的key
-				key: 'R43BZ-2XROX-L7T45-T5OQI-IBDFT-GNBOI'
+				key: 'X57BZ-ZISE3-KTN3O-3P45H-C3J7Q-D5B67'
 			});
 			this.getNowTime()
 			this.getTimestamp()
@@ -304,8 +330,10 @@
 						this.notes = "无打卡任务无需打卡"
 					} else {
 						this.flags = true
-						this.list = res.data.reverse()
+						this.list = res.data
 						this.activeid = this.list[0].id
+						this.faceRecognition = this.list[0].faceRecognition
+						this.takePicture = this.list[0].takePicture
 						this.contrastObj = this.list[0]
 						this.changeType()
 					}
@@ -365,39 +393,75 @@
 				this.getTimestamp()
 				this.contrastObj = item
 				this.activeid = item.id
+				this.faceRecognition = item.faceRecognition
+				this.takePicture = item.takePicture
 				this.changeType()
 			},
 			// 点击打卡按钮回调
 			handlePunch(info) {
 				if (this.flags) {
 					let obj = JSON.stringify(info)
-
-					// 获取用户位置权限
-					uni.authorize({
-						scope: 'scope.userLocation',
-						success() {
-							uni.navigateTo({
-								url: `/pagesClockIn/location/location?obj=${obj}`
-							})
-						},
-						fail() {
-							uni.showModal({
-								title: '提示',
-								content: '请先开启定位权限,否则将无法使用定位功能',
-								cancelText: '不授权',
-								confirmText: '授权',
-								success: function(res) {
-									if (res.confirm) {
-										uni.openSetting({
-											success(res) {}
-										})
-									}
-								}
-							});
-						}
-					})
+					// 如果场景照片和人脸识别都需要
+					if (this.faceRecognition && this.takePicture) {
+						uni.navigateTo({
+							url: `/pagesClockIn/location/location?obj=${obj}`
+						})
+					}
+					// 如果都不需要
+					else if (!this.faceRecognition && !this.takePicture) {
+						this.handleUploading()
+					}
+					// 如果只需要场景照片
+					else if (this.takePicture) {
+						uni.navigateTo({
+							url: `/pagesClockIn/location/location?obj=${obj}&flag=1`
+						})
+					}
+					// 如果只需要人脸识别
+					else if (this.faceRecognition) {
+						uni.navigateTo({
+							url: `/pagesClockIn/authentication/authentication?id=${this.contrastObj.id}&address=${this.address}&latitude=${this.myLat}&longitude=${this.myLng}&flag=1`
+						})
+					}
 				}
 			},
+			// 打卡请求
+			async handleUploading() {
+				let res = await this.$myRequest_clockIn({
+					url: "/attendance/api/sign/check/in/update",
+					method: "put",
+					header: {
+						'Authorization': uni.getStorageSync("token"),
+						'platform': 2,
+						'Accept-Language': 'zh-CN,zh;q=0.9'
+					},
+					data: {
+						id: this.contrastObj.id,
+						lat: this.myLat,
+						lng: this.myLng,
+						location: this.address,
+					}
+				})
+				// console.log(res);
+				if (res.code == 200) {
+					this.getNowTimePop()
+					this.$refs.popup.open()
+				}
+			},
+			// 点击 我知道了按钮 跳回首页
+			handleGoHome() {
+				this.$refs.popup.close()
+				uni.reLaunch({
+					url: "/pagesClockIn/home/home"
+				})
+			},
+			getNowTimePop() {
+				let date = new Date()
+				let hours = date.getHours() < 10 ? '0' + date.getHours() : date.getHours()
+				let minutes = date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()
+				let seconds = date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds()
+				this.nowTime_pop = hours + ':' + minutes + ':' + seconds
+			},
 			// 格式化时间
 			format_time(timestamp) {
 				//时间戳为10位需*1000,时间戳为13位的话不需乘1000
@@ -646,5 +710,50 @@
 				}
 			}
 		}
+
+		.popup-content {
+			display: flex;
+			flex-direction: column;
+			justify-content: space-around;
+			align-items: center;
+			width: 630rpx;
+			height: 376rpx;
+			border-radius: 33rpx;
+			background-color: #fff;
+
+			.title {
+				display: flex;
+				justify-content: center;
+				align-items: center;
+
+				.icon {
+					width: 40rpx;
+					height: 40rpx;
+
+					img {
+						width: 100%;
+						height: 100%;
+					}
+				}
+
+				.title_info {
+					margin-left: 8rpx;
+					font-size: 36rpx;
+					font-weight: 800;
+					color: #0082FC;
+				}
+			}
+
+			.time {
+				font-size: 32rpx;
+			}
+
+			.popup_button {
+				width: 50%;
+				text-align: center;
+				font-size: 32rpx;
+				color: #0082FC;
+			}
+		}
 	}
 </style>

BIN
pagesClockIn/home/imgs/success2.png


+ 2 - 1
pagesClockIn/index/index.vue

@@ -97,7 +97,8 @@
 					method: "post",
 					header:{
 						'content-type': 'application/json',
-						'platform': 2
+						'platform': 2,
+						'Accept-Language': 'zh-CN,zh;q=0.9'
 					},
 					data: {
 						redirect_uri: `mnp://${this.appid}`,

BIN
pagesClockIn/location/imgs/success2.png


+ 123 - 6
pagesClockIn/location/location.vue

@@ -38,6 +38,26 @@
 				</view>
 			</view>
 		</view>
+		
+		<!-- 认证结果弹窗 -->
+		<uni-popup ref="popup" :is-mask-click="false">
+			<view class="popup-content">
+				<view class="title">
+					<view class="icon">
+						<img src="./imgs/success2.png">
+					</view>
+					<view class="title_info">
+						打卡成功
+					</view>
+				</view>
+				<view class="time">
+					{{nowTime_pop}}
+				</view>
+				<view class="popup_button" @click="handleGoHome">
+					我知道了
+				</view>
+			</view>
+		</uni-popup>
 	</view>
 </template>
 
@@ -66,17 +86,24 @@
 				// 时间段信息
 				timeRange: "",
 				// 规则id
-				id: ""
+				id: "",
+				// 是否需要人脸识别,值为1时是不需要
+				flag: "",
+				// 弹窗当前时间
+				nowTime_pop:""
 			};
 		},
 		onLoad(options) {
+			if (options.flag) {
+				this.flag = options.flag
+			}
 			let obj = JSON.parse(options.obj)
 			this.timeRange = obj.timeRange
 			this.id = obj.id
 			// 实例化API核心类
 			qqmapsdk = new QQMapWX({
 				// 申请的key
-				key: 'R43BZ-2XROX-L7T45-T5OQI-IBDFT-GNBOI'
+				key: 'X57BZ-ZISE3-KTN3O-3P45H-C3J7Q-D5B67'
 			});
 			this.getLocationData()
 		},
@@ -131,14 +158,19 @@
 									filePath: res.tempFilePaths[0],
 									name: 'file',
 									header: {
-										'platform': 2
+										'platform': 2,
+										'Accept-Language': 'zh-CN,zh;q=0.9'
 									},
 									success: (uploadFileRes) => {
 										let imgUrl = JSON.parse(uploadFileRes.data)
 											.data
-										uni.navigateTo({
-											url: `/pagesClockIn/authentication/authentication?imgUrl=${imgUrl}&id=${this.id}&address=${this.address}&latitude=${this.latitude}&longitude=${this.longitude}`
-										})
+										if (this.flag == 1) {
+											this.handleUploading(imgUrl)
+										} else {
+											uni.redirectTo({
+												url: `/pagesClockIn/authentication/authentication?imgUrl=${imgUrl}&id=${this.id}&address=${this.address}&latitude=${this.latitude}&longitude=${this.longitude}`
+											})
+										}
 									},
 									fail: () => {
 										uni.showToast({
@@ -167,6 +199,46 @@
 					}
 				})
 			},
+			
+			// 打卡请求
+			async handleUploading(imgUrl) {
+				let res = await this.$myRequest_clockIn({
+					url: "/attendance/api/sign/check/in/update",
+					method: "put",
+					header: {
+						'Authorization': uni.getStorageSync("token"),
+						'platform': 2,
+						'Accept-Language': 'zh-CN,zh;q=0.9'
+					},
+					data: {
+						id: this.id,
+						lat: this.latitude,
+						lng: this.longitude,
+						location: this.address,
+						sceneImage: imgUrl,
+					}
+				})
+				// console.log(res);
+				if (res.code == 200) {
+					this.getNowTimePop()
+					this.$refs.popup.open()
+				}
+			},
+			getNowTimePop() {
+				let date = new Date()
+				let hours = date.getHours() < 10 ? '0' + date.getHours() : date.getHours()
+				let minutes = date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()
+				let seconds = date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds()
+				this.nowTime_pop = hours + ':' + minutes + ':' + seconds
+			},
+			
+			// 点击 我知道了按钮 跳回首页
+			handleGoHome() {
+				this.$refs.popup.close()
+				uni.reLaunch({
+					url: "/pagesClockIn/home/home"
+				})
+			},
 		}
 	}
 </script>
@@ -275,5 +347,50 @@
 				}
 			}
 		}
+		
+		.popup-content {
+			display: flex;
+			flex-direction: column;
+			justify-content: space-around;
+			align-items: center;
+			width: 630rpx;
+			height: 376rpx;
+			border-radius: 33rpx;
+			background-color: #fff;
+		
+			.title {
+				display: flex;
+				justify-content: center;
+				align-items: center;
+		
+				.icon {
+					width: 40rpx;
+					height: 40rpx;
+		
+					img {
+						width: 100%;
+						height: 100%;
+					}
+				}
+		
+				.title_info {
+					margin-left: 8rpx;
+					font-size: 36rpx;
+					font-weight: 800;
+					color: #0082FC;
+				}
+			}
+		
+			.time {
+				font-size: 32rpx;
+			}
+		
+			.popup_button {
+				width: 50%;
+				text-align: center;
+				font-size: 32rpx;
+				color: #0082FC;
+			}
+		}
 	}
 </style>

+ 4 - 2
pagesClockIn/powerSet/powerSet.vue

@@ -130,7 +130,8 @@
 								method: "put",
 								header: {
 									'Authorization': uni.getStorageSync("token"),
-									'platform': 2
+									'platform': 2,
+									'Accept-Language': 'zh-CN,zh;q=0.9'
 								},
 								data: {
 									id: this.roleId,
@@ -180,7 +181,8 @@
 									method: "put",
 									header: {
 										'Authorization': uni.getStorageSync("token"),
-										'platform': 2
+										'platform': 2,
+										'Accept-Language': 'zh-CN,zh;q=0.9'
 									},
 									data: {
 										id: this.roleId,

+ 2 - 1
pagesClockIn/stat/stat.vue

@@ -455,7 +455,8 @@
 									data,
 									header: {
 										'Authorization': uni.getStorageSync("token"),
-										'platform': 2
+										'platform': 2,
+										'Accept-Language': 'zh-CN,zh;q=0.9'
 									}
 								})
 								// console.log(res);

+ 2 - 1
pagesClockIn/util/api.js

@@ -15,7 +15,8 @@ export const myRequest_clockIn = (options) => {
 			header: options.header || {
 				'content-type': 'application/x-www-form-urlencoded',
 				'Authorization': uni.getStorageSync("token"),
-				'platform': 2
+				'platform': 2,
+				'Accept-Language': 'zh-CN,zh;q=0.9'
 			},
 			success: (res) => {
 				uni.hideLoading();