Initial commit of akmon project
This commit is contained in:
151
pages/sport/student/location-test.uvue
Normal file
151
pages/sport/student/location-test.uvue
Normal file
@@ -0,0 +1,151 @@
|
||||
<!-- 手环位置功能测试页面 -->
|
||||
<template>
|
||||
<view class="test-page">
|
||||
<text class="test-title">手环位置功能测试</text>
|
||||
|
||||
<view class="test-section">
|
||||
<text class="section-title">基本功能测试</text>
|
||||
<button class="test-btn" @click="testGetCurrentLocation">测试获取当前位置</button>
|
||||
<button class="test-btn" @click="testGetBaseStations">测试获取基站列表</button>
|
||||
<button class="test-btn" @click="testGetFences">测试获取围栏列表</button>
|
||||
<button class="test-btn" @click="testGetLocationHistory">测试获取位置历史</button>
|
||||
<button class="test-btn" @click="testGetFenceEvents">测试获取围栏事件</button>
|
||||
</view>
|
||||
|
||||
<view class="test-results">
|
||||
<text class="results-title">测试结果:</text>
|
||||
<scroll-view class="results-scroll" scroll-y="true">
|
||||
<text class="result-text">{{ testResults }}</text>
|
||||
</scroll-view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup lang="uts">
|
||||
import { ref } from 'vue'
|
||||
import { LocationService } from '@/utils/locationService.uts'
|
||||
|
||||
const testResults = ref<string>('等待测试...\n')
|
||||
|
||||
const addResult = (text: string) => {
|
||||
const now = new Date()
|
||||
const h = now.getHours().toString().padStart(2, '0')
|
||||
const m = now.getMinutes().toString().padStart(2, '0')
|
||||
const s = now.getSeconds().toString().padStart(2, '0')
|
||||
const timestamp = `${h}:${m}:${s}`
|
||||
testResults.value += `[${timestamp}] ${text}\n`
|
||||
}
|
||||
|
||||
const testGetCurrentLocation = async () => {
|
||||
addResult('开始测试获取当前位置...')
|
||||
try {
|
||||
const result = await LocationService.getCurrentLocation('device_test')
|
||||
addResult(`获取位置结果: ${JSON.stringify(result, null, 2)}`)
|
||||
} catch (error) {
|
||||
addResult(`获取位置失败: ${error}`)
|
||||
}
|
||||
}
|
||||
|
||||
const testGetBaseStations = async () => {
|
||||
addResult('开始测试获取基站列表...')
|
||||
try {
|
||||
const result = await LocationService.getBaseStations()
|
||||
addResult(`获取基站结果: ${JSON.stringify(result, null, 2)}`)
|
||||
} catch (error) {
|
||||
addResult(`获取基站失败: ${error}`)
|
||||
}
|
||||
}
|
||||
|
||||
const testGetFences = async () => {
|
||||
addResult('开始测试获取围栏列表...')
|
||||
try {
|
||||
const result = await LocationService.getFences('device_test')
|
||||
addResult(`获取围栏结果: ${JSON.stringify(result, null, 2)}`)
|
||||
} catch (error) {
|
||||
addResult(`获取围栏失败: ${error}`)
|
||||
}
|
||||
}
|
||||
|
||||
const testGetLocationHistory = async () => {
|
||||
addResult('开始测试获取位置历史...')
|
||||
try {
|
||||
const endDate = new Date().toISOString()
|
||||
const startDate = new Date(Date.now() - 7 * 24 * 60 * 60 * 1000).toISOString()
|
||||
const result = await LocationService.getLocationHistory('device_test', startDate, endDate)
|
||||
addResult(`获取历史结果: ${JSON.stringify(result, null, 2)}`)
|
||||
} catch (error) {
|
||||
addResult(`获取历史失败: ${error}`)
|
||||
}
|
||||
}
|
||||
|
||||
const testGetFenceEvents = async () => {
|
||||
addResult('开始测试获取围栏事件...')
|
||||
try {
|
||||
const result = await LocationService.getFenceEvents('device_test', 10)
|
||||
addResult(`获取事件结果: ${JSON.stringify(result, null, 2)}`)
|
||||
} catch (error) {
|
||||
addResult(`获取事件失败: ${error}`)
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.test-page {
|
||||
padding: 32rpx;
|
||||
}
|
||||
|
||||
.test-title {
|
||||
font-size: 48rpx;
|
||||
font-weight: bold;
|
||||
color: #333333;
|
||||
margin-bottom: 32rpx;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.test-section {
|
||||
margin-bottom: 32rpx;
|
||||
}
|
||||
|
||||
.section-title {
|
||||
font-size: 32rpx;
|
||||
font-weight: bold;
|
||||
color: #333333;
|
||||
margin-bottom: 24rpx;
|
||||
}
|
||||
|
||||
.test-btn {
|
||||
width: 100%;
|
||||
height: 80rpx;
|
||||
background: #007aff;
|
||||
color: #ffffff;
|
||||
border: none;
|
||||
border-radius: 12rpx;
|
||||
margin-bottom: 16rpx;
|
||||
font-size: 28rpx;
|
||||
}
|
||||
|
||||
.test-results {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.results-title {
|
||||
font-size: 28rpx;
|
||||
font-weight: bold;
|
||||
color: #333333;
|
||||
margin-bottom: 16rpx;
|
||||
}
|
||||
|
||||
.results-scroll {
|
||||
height: 400rpx;
|
||||
background: #f5f5f5;
|
||||
border-radius: 12rpx;
|
||||
padding: 16rpx;
|
||||
}
|
||||
|
||||
.result-text {
|
||||
font-size: 24rpx;
|
||||
color: #666666;
|
||||
line-height: 1.5;
|
||||
white-space: pre-wrap;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user