Toggle navigation
Toggle navigation
This project
Loading...
Sign in
developOne
/
harmonyPool
Go to a project
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
shishuangxi
2024-04-23 14:46:23 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
60a05b3666c6a56644a83a2794e3c54f881e2dc3
60a05b36
1 parent
ba1e83b6
定位数据保存
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
22 deletions
sight_harmony/commons/wdConstant/src/main/ets/constants/SpConstants.ets
sight_harmony/features/wdHwAbility/src/main/ets/location/HWLocationUtils.ets
sight_harmony/commons/wdConstant/src/main/ets/constants/SpConstants.ets
View file @
60a05b3
...
...
@@ -26,4 +26,8 @@ export class SpConstants{
//未登录保存兴趣标签
static PUBLICVISUTORMODE_INTERESTTAGS = 'PublicVisitorMode_InterestTags'
//定位相关
static LOCATION_CITY_NAME = "location_city_name" //定位
static LOCATION_CITY_CODE = "location_city_code" //定位
}
\ No newline at end of file
...
...
sight_harmony/features/wdHwAbility/src/main/ets/location/HWLocationUtils.ets
View file @
60a05b3
import { abilityAccessCtrl, bundleManager, Permissions } from '@kit.AbilityKit';
import { BusinessError } from '@kit.BasicServicesKit';
import { geoLocationManager } from '@kit.LocationKit';
import { SpConstants } from 'wdConstant/Index';
import { Logger, PermissionUtils, ResourcesUtils, SPHelper } from 'wdKit/Index';
import { ResponseDTO } from 'wdNetwork/Index';
/**
* 系统定位服务实现
* */
export class HWLocationUtils {
//d定位相关
static LOCATION_CITY_NAME = "location_city_name" //定位
static LOCATION_CITY_CODE = "location_city_code" //定位
static LOCATION: Permissions = 'ohos.permission.LOCATION'
...
...
@@ -107,10 +106,14 @@ export class HWLocationUtils {
Logger.debug('location :' + JSON.stringify(data))
if (data[0] && data[0].administrativeArea && data[0].subAdministrativeArea) {
let cityName = data[0].subAdministrativeArea;
let name = await SPHelper.default.get(SpConstants.LOCATION_CITY_NAME, '') as string
if (cityName == name) {
return
}
let code = await HWLocationUtils.getCityCode(data[0].administrativeArea, data[0].subAdministrativeArea)
if (code) {
SPHelper.default.save(HWLocationUtils.LOCATION_CITY_NAME, cityName)
SPHelper.default.save(HWLocationUtils.LOCATION_CITY_CODE, code)
SPHelper.default.save(SpConstants.LOCATION_CITY_NAME, cityName)
SPHelper.default.save(SpConstants.LOCATION_CITY_CODE, code)
}
}
}
...
...
@@ -151,23 +154,6 @@ export class HWLocationUtils {
}
}
interface ResponseDTO<T> {
success: boolean;
// 服务请求响应值/微服务响应状态码”
code: number;
// 服务请求响应说明
message: string;
// 响应结果
data?: T;
totalCount?: number;
// 请求响应时间戳(unix格式)
timestamp?: number;
}
interface LocalData {
"code": string,
"id": string,
...
...
Please
register
or
login
to post a comment