douaojie

Merge remote-tracking branch 'origin/main'

@@ -26,4 +26,8 @@ export class SpConstants{ @@ -26,4 +26,8 @@ export class SpConstants{
26 26
27 //未登录保存兴趣标签 27 //未登录保存兴趣标签
28 static PUBLICVISUTORMODE_INTERESTTAGS = 'PublicVisitorMode_InterestTags' 28 static PUBLICVISUTORMODE_INTERESTTAGS = 'PublicVisitorMode_InterestTags'
  29 +
  30 + //定位相关
  31 + static LOCATION_CITY_NAME = "location_city_name" //定位
  32 + static LOCATION_CITY_CODE = "location_city_code" //定位
29 } 33 }
@@ -324,8 +324,9 @@ export class HttpUrlUtils { @@ -324,8 +324,9 @@ export class HttpUrlUtils {
324 headers.set('EagleEye-TraceID', 'D539562E48554A60977AF4BECB6D6C7A') 324 headers.set('EagleEye-TraceID', 'D539562E48554A60977AF4BECB6D6C7A')
325 headers.set('imei', HttpUrlUtils.getImei()) 325 headers.set('imei', HttpUrlUtils.getImei())
326 headers.set('Accept-Language', 'zh') 326 headers.set('Accept-Language', 'zh')
327 - headers.set('city', HttpUrlUtils.getCity())  
328 - headers.set('city_dode', HttpUrlUtils.getCityCode()) 327 + // headers.set('city', HttpUrlUtils.getCity())
  328 + // headers.set('city_dode', HttpUrlUtils.getCityCode())
  329 + HttpUrlUtils.setLocationHeader(headers)
329 // TODO 判断是否登录 330 // TODO 判断是否登录
330 headers.set('userId', HttpUrlUtils.getUserId()) 331 headers.set('userId', HttpUrlUtils.getUserId())
331 headers.set('userType', HttpUrlUtils.getUserType()) 332 headers.set('userType', HttpUrlUtils.getUserType())
@@ -368,6 +369,17 @@ export class HttpUrlUtils { @@ -368,6 +369,17 @@ export class HttpUrlUtils {
368 } 369 }
369 } 370 }
370 371
  372 + static setLocationHeader(headers: HashMap<string, string>){
  373 + let cityName= SPHelper.default.getSync(SpConstants.LOCATION_CITY_NAME,'') as string
  374 + if(StringUtils.isNotEmpty(cityName)){
  375 + headers.set('city', encodeURI(cityName))
  376 + }
  377 + let cityCode= SPHelper.default.getSync(SpConstants.LOCATION_CITY_CODE,'') as string
  378 + if(StringUtils.isNotEmpty(cityCode)){
  379 + headers.set('city_dode', encodeURI(cityCode))
  380 + }
  381 + }
  382 +
371 static getHost() { 383 static getHost() {
372 return HttpUrlUtils._hostUrl; 384 return HttpUrlUtils._hostUrl;
373 } 385 }
1 import { abilityAccessCtrl, bundleManager, Permissions } from '@kit.AbilityKit'; 1 import { abilityAccessCtrl, bundleManager, Permissions } from '@kit.AbilityKit';
2 import { BusinessError } from '@kit.BasicServicesKit'; 2 import { BusinessError } from '@kit.BasicServicesKit';
3 import { geoLocationManager } from '@kit.LocationKit'; 3 import { geoLocationManager } from '@kit.LocationKit';
  4 +import { SpConstants } from 'wdConstant/Index';
4 import { Logger, PermissionUtils, ResourcesUtils, SPHelper } from 'wdKit/Index'; 5 import { Logger, PermissionUtils, ResourcesUtils, SPHelper } from 'wdKit/Index';
  6 +import { ResponseDTO } from 'wdNetwork/Index';
5 7
6 /** 8 /**
7 * 系统定位服务实现 9 * 系统定位服务实现
8 * */ 10 * */
9 export class HWLocationUtils { 11 export class HWLocationUtils {
10 - //d定位相关  
11 - static LOCATION_CITY_NAME = "location_city_name" //定位  
12 - static LOCATION_CITY_CODE = "location_city_code" //定位  
13 12
14 13
15 static LOCATION: Permissions = 'ohos.permission.LOCATION' 14 static LOCATION: Permissions = 'ohos.permission.LOCATION'
@@ -107,10 +106,14 @@ export class HWLocationUtils { @@ -107,10 +106,14 @@ export class HWLocationUtils {
107 Logger.debug('location :' + JSON.stringify(data)) 106 Logger.debug('location :' + JSON.stringify(data))
108 if (data[0] && data[0].administrativeArea && data[0].subAdministrativeArea) { 107 if (data[0] && data[0].administrativeArea && data[0].subAdministrativeArea) {
109 let cityName = data[0].subAdministrativeArea; 108 let cityName = data[0].subAdministrativeArea;
  109 + let name = await SPHelper.default.get(SpConstants.LOCATION_CITY_NAME, '') as string
  110 + if (cityName == name) {
  111 + return
  112 + }
110 let code = await HWLocationUtils.getCityCode(data[0].administrativeArea, data[0].subAdministrativeArea) 113 let code = await HWLocationUtils.getCityCode(data[0].administrativeArea, data[0].subAdministrativeArea)
111 if (code) { 114 if (code) {
112 - SPHelper.default.save(HWLocationUtils.LOCATION_CITY_NAME, cityName)  
113 - SPHelper.default.save(HWLocationUtils.LOCATION_CITY_CODE, code) 115 + SPHelper.default.save(SpConstants.LOCATION_CITY_NAME, cityName)
  116 + SPHelper.default.save(SpConstants.LOCATION_CITY_CODE, code)
114 } 117 }
115 } 118 }
116 } 119 }
@@ -151,23 +154,6 @@ export class HWLocationUtils { @@ -151,23 +154,6 @@ export class HWLocationUtils {
151 } 154 }
152 } 155 }
153 156
154 -interface ResponseDTO<T> {  
155 - success: boolean;  
156 -  
157 - // 服务请求响应值/微服务响应状态码”  
158 - code: number;  
159 -  
160 - // 服务请求响应说明  
161 - message: string;  
162 -  
163 - // 响应结果  
164 - data?: T;  
165 - totalCount?: number;  
166 -  
167 - // 请求响应时间戳(unix格式)  
168 - timestamp?: number;  
169 -}  
170 -  
171 interface LocalData { 157 interface LocalData {
172 "code": string, 158 "code": string,
173 "id": string, 159 "id": string,