shishuangxi

新增组件

@@ -43,5 +43,3 @@ export { ErrorToastUtils } from './src/main/ets/utils/ErrorToastUtils' @@ -43,5 +43,3 @@ export { ErrorToastUtils } from './src/main/ets/utils/ErrorToastUtils'
43 export { EmitterUtils } from './src/main/ets/utils/EmitterUtils' 43 export { EmitterUtils } from './src/main/ets/utils/EmitterUtils'
44 44
45 export { EmitterEventId } from './src/main/ets/utils/EmitterEventId' 45 export { EmitterEventId } from './src/main/ets/utils/EmitterEventId'
46 -  
47 -export { HWLocationUtils } from './src/main/ets/utils/HWLocationUtils'  
  1 +/node_modules
  2 +/oh_modules
  3 +/.preview
  4 +/build
  5 +/.cxx
  6 +/.test
  1 +export { add } from "./src/main/ets/utils/Calc"
  2 +
  3 +export { HWLocationUtils } from './src/main/ets/location/HWLocationUtils'
  1 +{
  2 + "apiType": "stageMode",
  3 + "buildOption": {
  4 + },
  5 + "buildOptionSet": [
  6 + {
  7 + "name": "release",
  8 + "arkOptions": {
  9 + "obfuscation": {
  10 + "ruleOptions": {
  11 + "enable": true,
  12 + "files": [
  13 + "./obfuscation-rules.txt"
  14 + ]
  15 + }
  16 + }
  17 + },
  18 + },
  19 + ],
  20 + "targets": [
  21 + {
  22 + "name": "default"
  23 + }
  24 + ]
  25 +}
  1 +import { hspTasks } from '@ohos/hvigor-ohos-plugin';
  2 +
  3 +export default {
  4 + system: hspTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
  5 + plugins:[] /* Custom plugin to extend the functionality of Hvigor. */
  6 +}
  1 +# Define project specific obfuscation rules here.
  2 +# You can include the obfuscation configuration files in the current module's build-profile.json5.
  3 +#
  4 +# For more details, see
  5 +# https://gitee.com/openharmony/arkcompiler_ets_frontend/blob/master/arkguard/README.md
  6 +
  7 +# Obfuscation options:
  8 +# -disable-obfuscation: disable all obfuscations
  9 +# -enable-property-obfuscation: obfuscate the property names
  10 +# -enable-toplevel-obfuscation: obfuscate the names in the global scope
  11 +# -compact: remove unnecessary blank spaces and all line feeds
  12 +# -remove-log: remove all console.* statements
  13 +# -print-namecache: print the name cache that contains the mapping from the old names to new names
  14 +# -apply-namecache: reuse the given cache file
  15 +
  16 +# Keep options:
  17 +# -keep-property-name: specifies property names that you want to keep
  18 +# -keep-global-name: specifies names that you want to keep in the global scope
  1 +{
  2 + "name": "wdhwability",
  3 + "version": "1.0.0",
  4 + "description": "Please describe the basic information.",
  5 + "main": "Index.ets",
  6 + "author": "",
  7 + "license": "Apache-2.0",
  8 + "packageType": "InterfaceHar",
  9 + "dependencies": {
  10 + }
  11 +}
1 -import { Logger } from './Logger';  
2 -import { PermissionUtils } from './PermissionUtils'; 1 +import { Logger } from '../../../../../../commons/wdKit/src/main/ets/utils/Logger';
  2 +import { PermissionUtils } from '../../../../../../commons/wdKit/src/main/ets/utils/PermissionUtils';
3 import { abilityAccessCtrl, bundleManager, Permissions } from '@kit.AbilityKit'; 3 import { abilityAccessCtrl, bundleManager, Permissions } from '@kit.AbilityKit';
4 import { BusinessError } from '@kit.BasicServicesKit'; 4 import { BusinessError } from '@kit.BasicServicesKit';
5 import { geoLocationManager } from '@kit.LocationKit'; 5 import { geoLocationManager } from '@kit.LocationKit';
6 -import { SPHelper } from './SPHelper'; 6 +import { SPHelper } from '../../../../../../commons/wdKit/src/main/ets/utils/SPHelper';
  7 +import { ResourcesUtils } from '../../../../../../commons/wdKit/src/main/ets/utils/ResourcesUtils';
7 8
8 /** 9 /**
9 * 系统定位服务实现 10 * 系统定位服务实现
@@ -101,23 +102,18 @@ export class HWLocationUtils { @@ -101,23 +102,18 @@ export class HWLocationUtils {
101 "longitude": longitude, 102 "longitude": longitude,
102 "maxItems": 2 103 "maxItems": 2
103 }; 104 };
104 - geoLocationManager.getAddressesFromLocation(requestInfo, (error, data) => { 105 + geoLocationManager.getAddressesFromLocation(requestInfo, async (error, data) => {
105 if (error) { 106 if (error) {
106 Logger.debug('location :' + JSON.stringify(error)) 107 Logger.debug('location :' + JSON.stringify(error))
107 } 108 }
108 if (data) { 109 if (data) {
109 Logger.debug('location :' + JSON.stringify(data)) 110 Logger.debug('location :' + JSON.stringify(data))
110 - if (data[0] && data[0].countryName) {  
111 - if (data[0].descriptionsSize && data[0].descriptions) {  
112 - let code = data[0].descriptions[1]  
113 - let cityCode = code.substring(0, 6) 111 + if (data[0] && data[0].administrativeArea && data[0].subAdministrativeArea) {
114 let cityName = data[0].subAdministrativeArea; 112 let cityName = data[0].subAdministrativeArea;
115 - if (cityName) { 113 + let code = await HWLocationUtils.getCityCode(data[0].administrativeArea, data[0].subAdministrativeArea)
  114 + if (code) {
116 SPHelper.default.save(HWLocationUtils.LOCATION_CITY_NAME, cityName) 115 SPHelper.default.save(HWLocationUtils.LOCATION_CITY_NAME, cityName)
117 - }  
118 - if (cityCode) {  
119 - SPHelper.default.save(HWLocationUtils.LOCATION_CITY_NAME, cityCode)  
120 - } 116 + SPHelper.default.save(HWLocationUtils.LOCATION_CITY_CODE, code)
121 } 117 }
122 } 118 }
123 } 119 }
@@ -135,4 +131,55 @@ export class HWLocationUtils { @@ -135,4 +131,55 @@ export class HWLocationUtils {
135 }) 131 })
136 }) 132 })
137 } 133 }
  134 +
  135 + private static async getCityCode(administrativeArea: string, cityName: string) {
  136 + let bean = await ResourcesUtils.getResourcesJson<ResponseDTO<Array<LocalData>>>(getContext(), 'areaList_data.json');
  137 + if (bean) {
  138 + if (bean.code == 0 && bean.data) {
  139 + for (let i = 0; i < bean.data.length; i++) {
  140 + if (bean.data[i].label == administrativeArea) {
  141 + for (let j = 0; j < bean.data[i].children.length; j++) {
  142 + if (bean.data[i].children[j].label == cityName) {
  143 + Logger.debug("huaw" + bean.data[i].children[j].code)
  144 + return bean.data[i].children[j].code
  145 + }
  146 + }
  147 + }
  148 +
  149 + }
  150 +
  151 + }
  152 + }
  153 + return ''
  154 + }
  155 +}
  156 +
  157 +interface ResponseDTO<T> {
  158 + success: boolean;
  159 +
  160 + // 服务请求响应值/微服务响应状态码”
  161 + code: number;
  162 +
  163 + // 服务请求响应说明
  164 + message: string;
  165 +
  166 + // 响应结果
  167 + data?: T;
  168 + totalCount?: number;
  169 +
  170 + // 请求响应时间戳(unix格式)
  171 + timestamp?: number;
  172 +}
  173 +
  174 +interface LocalData {
  175 + "code": string,
  176 + "id": string,
  177 + "label": string,
  178 + "children": Array<ChildrenData>
  179 +}
  180 +
  181 +interface ChildrenData {
  182 + "code": string,
  183 + "id": string,
  184 + "label": string,
138 } 185 }
  1 +@Entry
  2 +@Component
  3 +struct Index {
  4 + @State message: string = 'Hello World';
  5 +
  6 + build() {
  7 + Row() {
  8 + Column() {
  9 + Text(this.message)
  10 + .fontSize(50)
  11 + .fontWeight(FontWeight.Bold)
  12 + }
  13 + .width('100%')
  14 + }
  15 + .height('100%')
  16 + }
  17 +}
  1 +export function add(a:number, b:number) {
  2 + return a + b;
  3 +}
  1 +{
  2 + "module": {
  3 + "name": "wdHwAbility",
  4 + "type": "shared",
  5 + "description": "$string:shared_desc",
  6 + "deviceTypes": [
  7 + "phone",
  8 + "tablet",
  9 + "2in1"
  10 + ],
  11 + "deliveryWithInstall": true,
  12 + "pages": "$profile:main_pages"
  13 + }
  14 +}
  1 +{
  2 + "color": [
  3 + {
  4 + "name": "white",
  5 + "value": "#FFFFFF"
  6 + }
  7 + ]
  8 +}
  1 +{
  2 + "string": [
  3 + {
  4 + "name": "shared_desc",
  5 + "value": "description"
  6 + }
  7 + ]
  8 +}
  1 +import localUnitTest from './LocalUnit.test';
  2 +
  3 +export default function testsuite() {
  4 + localUnitTest();
  5 +}
  1 +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium';
  2 +
  3 +export default function localUnitTest() {
  4 + describe('localUnitTest',() => {
  5 + // Defines a test suite. Two parameters are supported: test suite name and test suite function.
  6 + beforeAll(() => {
  7 + // Presets an action, which is performed only once before all test cases of the test suite start.
  8 + // This API supports only one parameter: preset action function.
  9 + });
  10 + beforeEach(() => {
  11 + // Presets an action, which is performed before each unit test case starts.
  12 + // The number of execution times is the same as the number of test cases defined by **it**.
  13 + // This API supports only one parameter: preset action function.
  14 + });
  15 + afterEach(() => {
  16 + // Presets a clear action, which is performed after each unit test case ends.
  17 + // The number of execution times is the same as the number of test cases defined by **it**.
  18 + // This API supports only one parameter: clear action function.
  19 + });
  20 + afterAll(() => {
  21 + // Presets a clear action, which is performed after all test cases of the test suite end.
  22 + // This API supports only one parameter: clear action function.
  23 + });
  24 + it('assertContain', 0, () => {
  25 + // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function.
  26 + let a = 'abc';
  27 + let b = 'b';
  28 + // Defines a variety of assertion methods, which are used to declare expected boolean conditions.
  29 + expect(a).assertContain(b);
  30 + expect(a).assertEqual(a);
  31 + });
  32 + });
  33 +}
@@ -14,6 +14,7 @@ @@ -14,6 +14,7 @@
14 "wdBean": "file:../../features/wdBean", 14 "wdBean": "file:../../features/wdBean",
15 "wdDetailPlayShortVideo": "file:../../features/wdDetailPlayShortVideo", 15 "wdDetailPlayShortVideo": "file:../../features/wdDetailPlayShortVideo",
16 "wdRouter": "file:../../commons/wdRouter", 16 "wdRouter": "file:../../commons/wdRouter",
17 - "wdNetwork": "file:../../commons/wdNetwork" 17 + "wdNetwork": "file:../../commons/wdNetwork",
  18 + "wdHwAbility": "file:../../features/wdHwAbility"
18 } 19 }
19 } 20 }
1 import { BottomNavigationComponent, LogoutViewModel} from 'wdComponent'; 1 import { BottomNavigationComponent, LogoutViewModel} from 'wdComponent';
2 import { BreakpointConstants } from 'wdConstant'; 2 import { BreakpointConstants } from 'wdConstant';
3 3
4 -import { BreakpointSystem, EmitterEventId, EmitterUtils, HWLocationUtils, Logger } from 'wdKit'; 4 +import { BreakpointSystem, EmitterEventId, EmitterUtils, Logger } from 'wdKit';
5 import router from '@ohos.router'; 5 import router from '@ohos.router';
6 import { promptAction } from '@kit.ArkUI'; 6 import { promptAction } from '@kit.ArkUI';
  7 +import { HWLocationUtils } from 'wdHwAbility/Index';
7 8
8 9
9 const TAG = 'MainPage'; 10 const TAG = 'MainPage';