liujian1_wd

图文详情页面

@@ -7,7 +7,7 @@ import { @@ -7,7 +7,7 @@ import {
7 ResponseBean 7 ResponseBean
8 } from 'wdBean'; 8 } from 'wdBean';
9 import { Logger } from 'wdKit'; 9 import { Logger } from 'wdKit';
10 -import { WdWebComponent } from 'wdWebComponent'; 10 +import { WdWebComponent, WdWebLocalComponent } from 'wdWebComponent';
11 import { BridgeWebViewControl } from '../../../../../wdWebComponent/oh_modules/wdJsBridge/Index'; 11 import { BridgeWebViewControl } from '../../../../../wdWebComponent/oh_modules/wdJsBridge/Index';
12 12
13 @Component 13 @Component
@@ -74,12 +74,10 @@ export struct ImageAndTextWebComponent { @@ -74,12 +74,10 @@ export struct ImageAndTextWebComponent {
74 74
75 build() { 75 build() {
76 Column() { 76 Column() {
77 - WdWebComponent({  
78 - type: 0, 77 + WdWebLocalComponent({
79 webviewControl: this.webviewControl, 78 webviewControl: this.webviewControl,
80 webResource: $rawfile('apph5/index.html'), 79 webResource: $rawfile('apph5/index.html'),
81 backVisibility: false, 80 backVisibility: false,
82 - reload: this.reload  
83 }) 81 })
84 } 82 }
85 } 83 }
1 -export { WdWebComponent } from './src/main/ets/pages/WdWebComponent'  
  1 +export { WdWebComponent } from './src/main/ets/pages/WdWebComponent'
  2 +
  3 +export { WdWebLocalComponent } from './src/main/ets/pages/WdWebLocalComponent'
@@ -13,11 +13,6 @@ export struct WdWebComponent { @@ -13,11 +13,6 @@ export struct WdWebComponent {
13 private webviewControl: BridgeWebViewControl = new BridgeWebViewControl() 13 private webviewControl: BridgeWebViewControl = new BridgeWebViewControl()
14 //TODO 默认网页 14 //TODO 默认网页
15 webUrl: string = ConfigConstants.DETAIL_URL 15 webUrl: string = ConfigConstants.DETAIL_URL
16 -  
17 - // 0网页, 1本地html  
18 - type: number = 0  
19 -  
20 - webResource: Resource = {} as Resource  
21 /** 16 /**
22 * 对外暴露webview的回调,能力 17 * 对外暴露webview的回调,能力
23 */ 18 */
@@ -68,7 +63,7 @@ export struct WdWebComponent { @@ -68,7 +63,7 @@ export struct WdWebComponent {
68 .height(44) 63 .height(44)
69 .visibility(this.backVisibility ? Visibility.Visible : Visibility.None) 64 .visibility(this.backVisibility ? Visibility.Visible : Visibility.None)
70 65
71 - Web({ src: this.type == 0 ? this.webUrl : this.webResource, controller: this.webviewControl }) 66 + Web({ src: this.webUrl, controller: this.webviewControl })
72 .domStorageAccess(true) 67 .domStorageAccess(true)
73 .databaseAccess(true) 68 .databaseAccess(true)
74 .javaScriptAccess(true) 69 .javaScriptAccess(true)
  1 +import router from '@ohos.router';
  2 +import { BridgeWebViewControl } from 'wdJsBridge';
  3 +
  4 +const TAG = 'WdWebLocalComponent';
  5 +
  6 +@Component
  7 +export struct WdWebLocalComponent {
  8 + private webviewControl: BridgeWebViewControl = new BridgeWebViewControl()
  9 + backVisibility: boolean = false
  10 + webResource: Resource = {} as Resource
  11 +
  12 + build() {
  13 + Column() {
  14 + Row() {
  15 + Image($r("app.media.ic_back"))
  16 + .width(44)
  17 + .padding(13)
  18 + .aspectRatio(1)
  19 + .onClick(() => {
  20 + router.back();
  21 + })
  22 + }.backgroundColor(Color.Black)
  23 + .width('100%')
  24 + .height(44)
  25 + .visibility(this.backVisibility ? Visibility.Visible : Visibility.None)
  26 +
  27 + Web({ src: this.webResource, controller: this.webviewControl })
  28 + .domStorageAccess(true)
  29 + .databaseAccess(true)
  30 + .javaScriptAccess(true)
  31 + .backgroundColor(Color.Yellow)
  32 + }
  33 + }
  34 +}
  35 +