zhenghy
Showing 24 changed files with 357 additions and 21 deletions
@@ -217,6 +217,18 @@ @@ -217,6 +217,18 @@
217 ] 217 ]
218 } 218 }
219 ] 219 ]
  220 + },
  221 + {
  222 + "name": "wdHwAbility",
  223 + "srcPath": "./features/wdHwAbility",
  224 + "targets": [
  225 + {
  226 + "name": "default",
  227 + "applyToProducts": [
  228 + "default"
  229 + ]
  230 + }
  231 + ]
220 } 232 }
221 ] 233 ]
222 } 234 }
@@ -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'  
@@ -5,6 +5,7 @@ import axios, { @@ -5,6 +5,7 @@ import axios, {
5 HttpStatusCode, 5 HttpStatusCode,
6 InternalAxiosRequestConfig 6 InternalAxiosRequestConfig
7 } from '@ohos/axios'; 7 } from '@ohos/axios';
  8 +import { Logger } from 'wdKit/Index';
8 9
9 // import type ResponseDTO from '../models/ResponseDTO'; 10 // import type ResponseDTO from '../models/ResponseDTO';
10 11
@@ -84,6 +85,9 @@ instance.interceptors.response.use(// 响应拦截器response类型就是Axios.r @@ -84,6 +85,9 @@ instance.interceptors.response.use(// 响应拦截器response类型就是Axios.r
84 // return Promise.reject(new Error(message)) 85 // return Promise.reject(new Error(message))
85 // } 86 // }
86 // const data: ResponseBean<any> = response.data 87 // const data: ResponseBean<any> = response.data
  88 + Logger.debug('HttpRequest', 'response ======start======= ')
  89 + Logger.debug('HttpRequest', 'response: ' + JSON.stringify(response.data))
  90 + Logger.debug('HttpRequest', 'response ======end======= ')
87 // 改造返回的数据,即将AxiosResponse的data返回,服务端返回的数据 91 // 改造返回的数据,即将AxiosResponse的data返回,服务端返回的数据
88 return response.data; 92 return response.data;
89 } else { 93 } else {
  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 + "meta": {
  3 + "stableOrder": true
  4 + },
  5 + "lockfileVersion": 3,
  6 + "ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.",
  7 + "specifiers": {
  8 + "@ohos/axios@^2.1.1": "@ohos/axios@2.2.0",
  9 + "wdBean@../wdBean": "wdBean@../wdBean",
  10 + "wdConstant@../../commons/wdConstant": "wdConstant@../../commons/wdConstant",
  11 + "wdJsBridge@../../commons/wdJsBridge": "wdJsBridge@../../commons/wdJsBridge",
  12 + "wdKit@../../commons/wdKit": "wdKit@../../commons/wdKit",
  13 + "wdLogin@../wdLogin": "wdLogin@../wdLogin",
  14 + "wdNetwork@../../commons/wdNetwork": "wdNetwork@../../commons/wdNetwork",
  15 + "wdRouter@../../commons/wdRouter": "wdRouter@../../commons/wdRouter",
  16 + "wdWebComponent@../../commons/wdWebComponent": "wdWebComponent@../../commons/wdWebComponent"
  17 + },
  18 + "packages": {
  19 + "@ohos/axios@2.2.0": {
  20 + "name": "@ohos/axios",
  21 + "integrity": "sha512-v1QBWk6DfcN8wUW3D0ieFbHTR1taSI5cOgxp5l6B5cegXuNYhSc8ggKlAIXe6h/14LsfM+NW0ZGfSXcNEIM5yA==",
  22 + "resolved": "https://repo.harmonyos.com/ohpm/@ohos/axios/-/axios-2.2.0.har",
  23 + "registryType": "ohpm"
  24 + },
  25 + "wdBean@../wdBean": {
  26 + "name": "wdbean",
  27 + "resolved": "../wdBean",
  28 + "registryType": "local"
  29 + },
  30 + "wdConstant@../../commons/wdConstant": {
  31 + "name": "wdconstant",
  32 + "resolved": "../../commons/wdConstant",
  33 + "registryType": "local"
  34 + },
  35 + "wdJsBridge@../../commons/wdJsBridge": {
  36 + "name": "wdjsbridge",
  37 + "resolved": "../../commons/wdJsBridge",
  38 + "registryType": "local"
  39 + },
  40 + "wdKit@../../commons/wdKit": {
  41 + "name": "wdkit",
  42 + "resolved": "../../commons/wdKit",
  43 + "registryType": "local"
  44 + },
  45 + "wdLogin@../wdLogin": {
  46 + "name": "wdlogin",
  47 + "resolved": "../wdLogin",
  48 + "registryType": "local",
  49 + "dependencies": {
  50 + "wdConstant": "file:../../commons/wdConstant",
  51 + "wdKit": "file:../../commons/wdKit",
  52 + "wdWebComponent": "file:../../commons/wdWebComponent",
  53 + "wdBean": "file:../../features/wdBean",
  54 + "wdRouter": "file:../../commons/wdRouter",
  55 + "wdNetwork": "file:../../commons/wdNetwork"
  56 + }
  57 + },
  58 + "wdNetwork@../../commons/wdNetwork": {
  59 + "name": "wdnetwork",
  60 + "resolved": "../../commons/wdNetwork",
  61 + "registryType": "local",
  62 + "dependencies": {
  63 + "wdConstant": "file:../wdConstant",
  64 + "wdKit": "file:../wdKit",
  65 + "@ohos/axios": "^2.1.1"
  66 + }
  67 + },
  68 + "wdRouter@../../commons/wdRouter": {
  69 + "name": "wdrouter",
  70 + "resolved": "../../commons/wdRouter",
  71 + "registryType": "local",
  72 + "dependencies": {
  73 + "wdKit": "file:../wdKit",
  74 + "wdBean": "file:../../features/wdBean",
  75 + "wdNetwork": "file:../../commons/wdNetwork",
  76 + "wdConstant": "file:../../commons/wdConstant"
  77 + }
  78 + },
  79 + "wdWebComponent@../../commons/wdWebComponent": {
  80 + "name": "wdwebcomponent",
  81 + "resolved": "../../commons/wdWebComponent",
  82 + "registryType": "local",
  83 + "dependencies": {
  84 + "wdConstant": "file:../wdConstant",
  85 + "wdKit": "file:../wdKit",
  86 + "wdJsBridge": "file:../wdJsBridge",
  87 + "wdBean": "file:../../features/wdBean",
  88 + "wdRouter": "file:../wdRouter"
  89 + }
  90 + }
  91 + }
  92 +}
  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 + "wdConstant": "file:../../commons/wdConstant",
  11 + "wdLogin": "file:../../features/wdLogin",
  12 + "wdKit": "file:../../commons/wdKit",
  13 + "wdBean": "file:../../features/wdBean",
  14 + "wdNetwork": "file:../../commons/wdNetwork"
  15 + }
  16 +}
1 -import { Logger } from './Logger';  
2 -import { PermissionUtils } from './PermissionUtils';  
3 import { abilityAccessCtrl, bundleManager, Permissions } from '@kit.AbilityKit'; 1 import { abilityAccessCtrl, bundleManager, Permissions } from '@kit.AbilityKit';
4 import { BusinessError } from '@kit.BasicServicesKit'; 2 import { BusinessError } from '@kit.BasicServicesKit';
5 import { geoLocationManager } from '@kit.LocationKit'; 3 import { geoLocationManager } from '@kit.LocationKit';
6 -import { SPHelper } from './SPHelper'; 4 +import { Logger, PermissionUtils, ResourcesUtils, SPHelper } from 'wdKit/Index';
7 5
8 /** 6 /**
9 * 系统定位服务实现 7 * 系统定位服务实现
@@ -101,23 +99,18 @@ export class HWLocationUtils { @@ -101,23 +99,18 @@ export class HWLocationUtils {
101 "longitude": longitude, 99 "longitude": longitude,
102 "maxItems": 2 100 "maxItems": 2
103 }; 101 };
104 - geoLocationManager.getAddressesFromLocation(requestInfo, (error, data) => { 102 + geoLocationManager.getAddressesFromLocation(requestInfo, async (error, data) => {
105 if (error) { 103 if (error) {
106 Logger.debug('location :' + JSON.stringify(error)) 104 Logger.debug('location :' + JSON.stringify(error))
107 } 105 }
108 if (data) { 106 if (data) {
109 Logger.debug('location :' + JSON.stringify(data)) 107 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)  
114 - let cityName = data[0].subAdministrativeArea;  
115 - if (cityName) {  
116 - SPHelper.default.save(HWLocationUtils.LOCATION_CITY_NAME, cityName)  
117 - }  
118 - if (cityCode) {  
119 - SPHelper.default.save(HWLocationUtils.LOCATION_CITY_NAME, cityCode)  
120 - } 108 + if (data[0] && data[0].administrativeArea && data[0].subAdministrativeArea) {
  109 + let cityName = data[0].subAdministrativeArea;
  110 + let code = await HWLocationUtils.getCityCode(data[0].administrativeArea, data[0].subAdministrativeArea)
  111 + if (code) {
  112 + SPHelper.default.save(HWLocationUtils.LOCATION_CITY_NAME, cityName)
  113 + SPHelper.default.save(HWLocationUtils.LOCATION_CITY_CODE, code)
121 } 114 }
122 } 115 }
123 } 116 }
@@ -135,4 +128,55 @@ export class HWLocationUtils { @@ -135,4 +128,55 @@ export class HWLocationUtils {
135 }) 128 })
136 }) 129 })
137 } 130 }
  131 +
  132 + private static async getCityCode(administrativeArea: string, cityName: string) {
  133 + let bean = await ResourcesUtils.getResourcesJson<ResponseDTO<Array<LocalData>>>(getContext(), 'areaList_data.json');
  134 + if (bean) {
  135 + if (bean.code == 0 && bean.data) {
  136 + for (let i = 0; i < bean.data.length; i++) {
  137 + if (bean.data[i].label == administrativeArea) {
  138 + for (let j = 0; j < bean.data[i].children.length; j++) {
  139 + if (bean.data[i].children[j].label == cityName) {
  140 + Logger.debug("huaw" + bean.data[i].children[j].code)
  141 + return bean.data[i].children[j].code
  142 + }
  143 + }
  144 + }
  145 +
  146 + }
  147 +
  148 + }
  149 + }
  150 + return ''
  151 + }
  152 +}
  153 +
  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 {
  172 + "code": string,
  173 + "id": string,
  174 + "label": string,
  175 + "children": Array<ChildrenData>
  176 +}
  177 +
  178 +interface ChildrenData {
  179 + "code": string,
  180 + "id": string,
  181 + "label": string,
138 } 182 }
  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 +}
@@ -52,7 +52,7 @@ export struct LoginInputComponent { @@ -52,7 +52,7 @@ export struct LoginInputComponent {
52 .margin({ top: 36 }) 52 .margin({ top: 36 })
53 .backgroundColor("#F5F5F5") 53 .backgroundColor("#F5F5F5")
54 .borderRadius(4) 54 .borderRadius(4)
55 - .type(InputType.PhoneNumber) 55 + .type(InputType.Number)
56 .onChange((content) => { 56 .onChange((content) => {
57 this.phoneContent = content 57 this.phoneContent = content
58 this.isSubmit = (this.phoneContent.length >= 11 && this.codeContent.length >= 6) 58 this.isSubmit = (this.phoneContent.length >= 11 && this.codeContent.length >= 6)
@@ -12,6 +12,7 @@ @@ -12,6 +12,7 @@
12 "wdConstant@../../commons/wdConstant": "wdConstant@../../commons/wdConstant", 12 "wdConstant@../../commons/wdConstant": "wdConstant@../../commons/wdConstant",
13 "wdDetailPlayApi@../../features/wdDetailPlayApi": "wdDetailPlayApi@../../features/wdDetailPlayApi", 13 "wdDetailPlayApi@../../features/wdDetailPlayApi": "wdDetailPlayApi@../../features/wdDetailPlayApi",
14 "wdDetailPlayShortVideo@../../features/wdDetailPlayShortVideo": "wdDetailPlayShortVideo@../../features/wdDetailPlayShortVideo", 14 "wdDetailPlayShortVideo@../../features/wdDetailPlayShortVideo": "wdDetailPlayShortVideo@../../features/wdDetailPlayShortVideo",
  15 + "wdHwAbility@../../features/wdHwAbility": "wdHwAbility@../../features/wdHwAbility",
15 "wdJsBridge@../../commons/wdJsBridge": "wdJsBridge@../../commons/wdJsBridge", 16 "wdJsBridge@../../commons/wdJsBridge": "wdJsBridge@../../commons/wdJsBridge",
16 "wdKit@../../commons/wdKit": "wdKit@../../commons/wdKit", 17 "wdKit@../../commons/wdKit": "wdKit@../../commons/wdKit",
17 "wdLogin@../../features/wdLogin": "wdLogin@../../features/wdLogin", 18 "wdLogin@../../features/wdLogin": "wdLogin@../../features/wdLogin",
@@ -87,6 +88,19 @@ @@ -87,6 +88,19 @@
87 "wdDetailPlayApi": "file:../../features/wdDetailPlayApi" 88 "wdDetailPlayApi": "file:../../features/wdDetailPlayApi"
88 } 89 }
89 }, 90 },
  91 + "wdHwAbility@../../features/wdHwAbility": {
  92 + "name": "wdhwability",
  93 + "resolved": "../../features/wdHwAbility",
  94 + "registryType": "local",
  95 + "dependencies": {
  96 + "wdConstant": "file:../../commons/wdConstant",
  97 + "wdLogin": "file:../../features/wdLogin",
  98 + "wdKit": "file:../../commons/wdKit",
  99 + "wdBean": "file:../../features/wdBean",
  100 + "wdNetwork": "file:../../commons/wdNetwork"
  101 + },
  102 + "packageType": "InterfaceHar"
  103 + },
90 "wdJsBridge@../../commons/wdJsBridge": { 104 "wdJsBridge@../../commons/wdJsBridge": {
91 "name": "wdjsbridge", 105 "name": "wdjsbridge",
92 "resolved": "../../commons/wdJsBridge", 106 "resolved": "../../commons/wdJsBridge",
@@ -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';
@@ -88,7 +88,6 @@ struct LaunchPage { @@ -88,7 +88,6 @@ struct LaunchPage {
88 // let isJumpPrivacy: boolean = globalThis.isJumpPrivacy ?? false; 88 // let isJumpPrivacy: boolean = globalThis.isJumpPrivacy ?? false;
89 // let isJumpPrivacy: boolean = (GlobalContext.getContext().getObject('isJumpPrivacy') as boolean) ?? false; 89 // let isJumpPrivacy: boolean = (GlobalContext.getContext().getObject('isJumpPrivacy') as boolean) ?? false;
90 //if (!isJumpPrivacy) { 90 //if (!isJumpPrivacy) {
91 - this.requestAgreement()  
92 this.dialogController.open(); 91 this.dialogController.open();
93 // } 92 // }
94 } else { 93 } else {
@@ -165,5 +164,9 @@ struct LaunchPage { @@ -165,5 +164,9 @@ struct LaunchPage {
165 164
166 } 165 }
167 166
  167 + aboutToAppear(): void {
  168 + this.requestAgreement()
  169 + }
  170 +
168 171
169 } 172 }