This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2026-01-19 15:01:13 +07:00
parent 8b26530d52
commit 112e6911ad
3 changed files with 50 additions and 34 deletions

View file

@ -1,5 +1,5 @@
<script setup lang="ts">
import { ref, computed } from 'vue'
import { ref, computed, nextTick } from 'vue'
import { useQuasar } from 'quasar'
import http from '@/plugins/http'
import config from '@/app.config'
@ -53,6 +53,7 @@ const privacyContent = {
},
}
const scrollContainer = ref<HTMLElement | null>(null)
const hasScrolledToBottom = ref(false)
const acceptPrivacy = ref(false)
const showDetails = ref(false)
@ -60,6 +61,7 @@ const isAcceptDisabled = computed(() => !acceptPrivacy.value)
const handleScroll = (event: Event) => {
const target = event.target as HTMLElement
if (!target) return
const { scrollTop, scrollHeight, clientHeight } = target
@ -82,6 +84,20 @@ const handleAccept = async () => {
const toggleDetails = () => {
showDetails.value = !showDetails.value
checkIfScrollable()
}
const checkIfScrollable = () => {
nextTick(() => {
const container = scrollContainer.value?.$el || scrollContainer.value
if (container) {
const { scrollHeight, clientHeight } = container
if (scrollHeight <= clientHeight + 20) {
hasScrolledToBottom.value = true
}
}
})
}
</script>

View file

@ -5,34 +5,35 @@ export function usePermissions() {
const $q = useQuasar()
const privacyStore = usePrivacyStore()
const checkCameraPermission = (): boolean => {
if (!privacyStore.isAccepted) {
privacyStore.modalPrivacy = true
$q.notify({
type: 'warning',
message: 'กรุณายอมรับนโยบายคุ้มครองข้อมูลส่วนบุคคลก่อนใช้งานกล้อง',
position: 'top',
})
return false
}
return true
}
// const checkCameraPermission = (): boolean => {
// if (!privacyStore.isAccepted) {
// privacyStore.modalPrivacy = true
// $q.notify({
// type: 'warning',
// message: 'กรุณายอมรับนโยบายคุ้มครองข้อมูลส่วนบุคคลก่อนใช้งานกล้อง',
// position: 'top',
// })
// return false
// }
// return true
// }
const checkLocationPermission = (): boolean => {
if (!privacyStore.isAccepted) {
privacyStore.modalPrivacy = true
$q.notify({
type: 'warning',
message: 'กรุณายอมรับนโยบายคุ้มครองข้อมูลส่วนบุคคลก่อนใช้งานแผนที่',
position: 'top',
})
return false
}
return true
}
// const checkLocationPermission = (): boolean => {
// if (!privacyStore.isAccepted) {
// privacyStore.modalPrivacy = true
// $q.notify({
// type: 'warning',
// message: 'กรุณายอมรับนโยบายคุ้มครองข้อมูลส่วนบุคคลก่อนใช้งานแผนที่',
// position: 'top',
// })
// return false
// }
// return true
// }
const checkPrivacyAccepted = (): boolean => {
if (!privacyStore.isAccepted) {
privacyStore.modalPrivacy = true
$q.notify({
type: 'warning',
message: 'กรุณายอมรับนโยบายคุ้มครองข้อมูลส่วนบุคคลก่อนใช้งาน',
@ -44,8 +45,8 @@ export function usePermissions() {
}
return {
checkCameraPermission,
checkLocationPermission,
// checkCameraPermission,
// checkLocationPermission,
checkPrivacyAccepted,
}
}

View file

@ -17,7 +17,7 @@ import MapCheck from '@/components/AscGISMap.vue'
const mixin = useCounterMixin()
const { date2Thai, showLoader, hideLoader, messageError, dialogConfirm } = mixin
const $q = useQuasar()
const { checkCameraPermission, checkLocationPermission } = usePermissions()
const { checkPrivacyAccepted } = usePermissions()
const privacyStore = usePrivacyStore()
const modalTime = ref<boolean>(false) // Dailog
@ -266,11 +266,10 @@ async function stopChecking() {
/** function เปิดกล้อง*/
async function openCamera() {
// privacy
if (!checkCameraPermission()) {
if (!checkPrivacyAccepted()) {
return
}
// change camera device
if (cameraIsOn.value) {
await camera.value?.stop()
@ -347,10 +346,10 @@ const timeChickin = ref<string>('') //เวลาเข้างาน,เว
/** function ยืนยันการลงเวลาเข้า - ออก*/
async function confirm() {
// privacy
if (!checkLocationPermission() || !checkCameraPermission()) {
if (!checkPrivacyAccepted()) {
return
}
if (!formLocation.POI || !formLocation.lat || !formLocation.lng) {
mapRef.value?.requestLocationPermission()
return
@ -488,7 +487,7 @@ onMounted(async () => {
isLoadingCheckTime.value = true
updateClock()
startChecking() // status #1
// privacy
if (privacyStore.isAccepted) {
mapRef.value?.requestLocationPermission()