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
douaojie
2024-04-23 14:57:18 +0800
Browse Files
Options
Browse Files
Download
Plain Diff
Commit
de9c871b5611d383f6ebf62d72cf8e2433753964
de9c871b
2 parents
5bc1358a
f8d02143
Merge remote-tracking branch 'origin/main'
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
24 deletions
sight_harmony/commons/wdConstant/src/main/ets/constants/SpConstants.ets
sight_harmony/commons/wdNetwork/src/main/ets/http/HttpUrlUtils.ets
sight_harmony/features/wdHwAbility/src/main/ets/location/HWLocationUtils.ets
sight_harmony/commons/wdConstant/src/main/ets/constants/SpConstants.ets
View file @
de9c871
...
...
@@ -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/commons/wdNetwork/src/main/ets/http/HttpUrlUtils.ets
View file @
de9c871
...
...
@@ -324,8 +324,9 @@ export class HttpUrlUtils {
headers.set('EagleEye-TraceID', 'D539562E48554A60977AF4BECB6D6C7A')
headers.set('imei', HttpUrlUtils.getImei())
headers.set('Accept-Language', 'zh')
headers.set('city', HttpUrlUtils.getCity())
headers.set('city_dode', HttpUrlUtils.getCityCode())
// headers.set('city', HttpUrlUtils.getCity())
// headers.set('city_dode', HttpUrlUtils.getCityCode())
HttpUrlUtils.setLocationHeader(headers)
// TODO 判断是否登录
headers.set('userId', HttpUrlUtils.getUserId())
headers.set('userType', HttpUrlUtils.getUserType())
...
...
@@ -368,6 +369,17 @@ export class HttpUrlUtils {
}
}
static setLocationHeader(headers: HashMap<string, string>){
let cityName= SPHelper.default.getSync(SpConstants.LOCATION_CITY_NAME,'') as string
if(StringUtils.isNotEmpty(cityName)){
headers.set('city', encodeURI(cityName))
}
let cityCode= SPHelper.default.getSync(SpConstants.LOCATION_CITY_CODE,'') as string
if(StringUtils.isNotEmpty(cityCode)){
headers.set('city_dode', encodeURI(cityCode))
}
}
static getHost() {
return HttpUrlUtils._hostUrl;
}
...
...
sight_harmony/features/wdHwAbility/src/main/ets/location/HWLocationUtils.ets
View file @
de9c871
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