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
yuzhilin
2024-04-25 16:02:22 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
12cb576f0b12a15dbb8ebfb595dde954ece73ed1
12cb576f
1 parent
b862df6b
H5调用App接口
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
38 additions
and
14 deletions
sight_harmony/commons/wdJsBridge/src/main/ets/bean/Message.ets
sight_harmony/commons/wdWebComponent/oh-package.json5
sight_harmony/commons/wdWebComponent/src/main/ets/pages/H5CallNativeType.ets
sight_harmony/commons/wdWebComponent/src/main/ets/pages/JsBridgeBiz.ets
sight_harmony/features/wdComponent/src/main/ets/components/ImageAndTextWebComponent.ets
sight_harmony/products/phone/src/main/ets/pages/launchPage/LaunchInterestsHobbiesPage.ets
sight_harmony/commons/wdJsBridge/src/main/ets/bean/Message.ets
View file @
12cb576
import { Action } from './Action';
interface dataObject {
// dataSource:
// 1、图文详情数据
...
...
@@ -17,7 +18,11 @@ interface dataObject {
webViewHeight?: string
dataJson?: string
appInnerLink?: string
method?: string
url?: string
parameters?: object
}
/**
* 消息Message
*/
...
...
sight_harmony/commons/wdWebComponent/oh-package.json5
View file @
12cb576
...
...
@@ -11,6 +11,7 @@
"wdKit"
:
"file:../wdKit"
,
"wdJsBridge"
:
"file:../wdJsBridge"
,
"wdBean"
:
"file:../../features/wdBean"
,
"wdRouter"
:
"file:../wdRouter"
"wdRouter"
:
"file:../wdRouter"
,
"wdNetwork"
:
"file:../wdNetwork"
}
}
...
...
sight_harmony/commons/wdWebComponent/src/main/ets/pages/H5CallNativeType.ets
View file @
12cb576
...
...
@@ -10,6 +10,7 @@ export class H5CallNativeType {
static jsCall_callAppService = 'jsCall_callAppService'
static jsCall_appInnerLinkMethod = 'jsCall_appInnerLinkMethod'
static jsCall_receiveH5Data = 'jsCall_receiveH5Data'
static jsCall_getAppLoginAuthInfo = 'jsCall_getAppLoginAuthInfo'
// TODO 业务自行新增类型、自行在JsBridgeBiz#performJSCallNative里添加接收分支处理。
static {
...
...
@@ -19,6 +20,8 @@ export class H5CallNativeType {
H5CallNativeType.JsCallTypeList.push(H5CallNativeType.jsCall_callAppService)
H5CallNativeType.JsCallTypeList.push(H5CallNativeType.jsCall_appInnerLinkMethod)
H5CallNativeType.JsCallTypeList.push(H5CallNativeType.jsCall_receiveH5Data)
H5CallNativeType.JsCallTypeList.push(H5CallNativeType.jsCall_getAppLoginAuthInfo)
}
}
...
...
sight_harmony/commons/wdWebComponent/src/main/ets/pages/JsBridgeBiz.ets
View file @
12cb576
import HashMap from '@ohos.util.HashMap';
import { Callback } from 'wdJsBridge';
import { Message } from 'wdJsBridge/src/main/ets/bean/Message';
import { Logger } from 'wdKit';
...
...
@@ -8,6 +9,7 @@ import { ProcessUtils } from 'wdRouter';
import router from '@ohos.router';
import Url from '@ohos.url'
import { ContentDTO } from 'wdBean/Index';
import { ResponseDTO, WDHttp, HttpUrlUtils } from 'wdNetwork';
const TAG = 'JsBridgeBiz'
...
...
@@ -37,7 +39,9 @@ export function performJSCallNative(data: Message, call: Callback) {
case H5CallNativeType.jsCall_getArticleDetailBussinessData:
break;
case H5CallNativeType.jsCall_callAppService:
handleJsCallCallAppService(data)
handleJsCallCallAppService(data, (res: string) => {
call(res)
})
break;
case H5CallNativeType.jsCall_receiveH5Data:
handleJsCallReceiveH5Data(data)
...
...
@@ -60,6 +64,21 @@ function handleJsCallCurrentPageOperate(data: Message) {
}
}
function handleJsCallCallAppService(data: Message, callback: (res: string) => void) {
let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders();
let url: string = HttpUrlUtils.getHost() + data?.data?.url
if (data?.data?.method === 'get') {
WDHttp.get<ResponseDTO<string>>(url, headers).then((res: ResponseDTO<string>) => {
callback(JSON.stringify(res))
})
}
if (data?.data?.method === 'post') {
WDHttp.post<ResponseDTO<string>>(url, data?.data?.parameters, headers).then(res => {
callback(JSON.stringify(res))
})
}
}
/**
* 获取App公共信息
*/
...
...
@@ -87,19 +106,14 @@ function handleJsCallReceiveH5Data(data: Message) {
}
}
function handleJsCallCallAppService(data: Message) {
}
function handleJsCallAppInnerLinkMethod(data: Message) {
let urlObject = Url.URL.parseURL(data?.data?.appInnerLink);
let urlParams = new Url.URLParams(urlObject.search);
console.log('urlObject:', `${JSON.stringify(urlParams)}`)
let content: ContentDTO = {
objectId: urlParams.get('contentId') || '',
relId: urlParams.get('relId') || '',
relType: urlParams.get('relType') || '',
pageId:urlParams.get('pageId') || '',
pageId:
urlParams.get('pageId') || '',
objectType: ''
} as ContentDTO
if (urlParams.get('skipType') === '1') {
...
...
@@ -130,14 +144,14 @@ function handleJsCallAppInnerLinkMethod(data: Message) {
ProcessUtils.processPage(content)
break;
case 'topic':
if
(urlParams.get('subType') === 'h5')
{
if
(urlParams.get('subType') === 'h5')
{
content.objectType = ContentConstants.TYPE_SPECIAL_TOPIC
ProcessUtils.processPage(content)
}
if
(urlParams.get('subType') === 'moring_evening_news')
{
if
(urlParams.get('subType') === 'moring_evening_news')
{
ProcessUtils.gotoMorningEveningPaper()
}
if
(urlParams.get('subType') === 'electronic_newspapers')
{
if
(urlParams.get('subType') === 'electronic_newspapers')
{
ProcessUtils.gotoENewsPaper()
}
break;
...
...
@@ -148,7 +162,7 @@ function handleJsCallAppInnerLinkMethod(data: Message) {
case 'owner_page':
let creatorId = urlParams.get('creatorId') || ''
ProcessUtils.gotoPeopleShipHomePage(creatorId)
break;
break;
default:
break;
}
...
...
sight_harmony/features/wdComponent/src/main/ets/components/ImageAndTextWebComponent.ets
View file @
12cb576
...
...
@@ -6,7 +6,7 @@ import {
H5ReceiveDetailBean,
ResponseBean
} from 'wdBean';
import { Logger, SPHelper } from 'wdKit';
import { Logger, SPHelper
, NetworkUtil
} from 'wdKit';
import { SpConstants } from 'wdConstant';
import { WdWebLocalComponent } from 'wdWebComponent';
import { NativeCallH5Type } from 'wdWebComponent/src/main/ets/pages/NativeCallH5Type';
...
...
@@ -61,7 +61,7 @@ export struct ImageAndTextWebComponent {
let h5ReceiveDataExtraBean: H5ReceiveDataExtraBean = {
creatorId: creatorId,
isLogin: isLogin,
networkStatus:
1
,
networkStatus:
Number(NetworkUtil.isNetConnected())
,
loadImageOnlyWifiSwitch: '2',
} as H5ReceiveDataExtraBean
...
...
sight_harmony/products/phone/src/main/ets/pages/launchPage/LaunchInterestsHobbiesPage.ets
View file @
12cb576
...
...
@@ -118,6 +118,7 @@ struct LaunchInterestsHobbiesPage {
// .rowsTemplate('1fr 1fr 1fr 1fr')
.columnsGap('23lpx')
.rowsGap('23lpx')
.scrollBar(BarState.Off)
Stack({alignContent:Alignment.Center}){
Button(this.selectCount == 0?'选好了':'选好了(' + this.selectCount + ')')
...
...
Please
register
or
login
to post a comment