123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- const UIHelper = require("UIHelper");
- var WebViewNode = null;
- cc.Class({
- extends: cc.Component,
- properties: {
- },
- onLoad: function () {
- },
- update: function (dt) {
- },
- hide:function(){
- if(WebViewNode){
- WebViewNode.active = false;
- cc.vv.reflection.changeOrientation("Landscape");
- }
- },
- onWebviewEvent:function(Target,data){
- /*if(Target.url == ""){
- return;
- }
- if(WebViewNode){
- setTimeout(() => {
- WebViewNode.getChildByName("WaitNode").active = false;
- WebViewNode.getChildByName("WebView").opacity = 255;
- cc.vv.reflection.changeOrientation("Portrait");
- }, 2000);
- }*/
- },
- statics:{
- createWebViewNode:function() {
- WebViewNode = null;
- if(!WebViewNode) {
- cc.resources.load("GamePrefabs/Public/WebViewNode", cc.Prefab, function (err, prefab) {
- var runScene = cc.director.getScene();
- WebViewNode = cc.instantiate(prefab);
- WebViewNode.parent = runScene;
- WebViewNode.name ="WebViewNode";
- WebViewNode.setPosition(cc.winSize.width / 2, cc.winSize.height / 2);
- WebViewNode.active = false;
- });
- }
- },
- isActive(){
- if(WebViewNode){
- return WebViewNode.active;
- }
- return false;
- },
- openURL:function(url){
- UIHelper.showWaitNode();
- let startTime = Date.now();
- WebViewNode.getChildByName("WebView").getComponent(cc.WebView).loadURL(
- url,
- () => {
- UIHelper.hideWaitNode();
- WebViewNode.active = true;
- cc.vv.reflection.changeOrientation("Portrait");
-
- },
- null,
- () => {
- UIHelper.hideWaitNode();
- Global.print("WebView:: openURL: 载入URL发生问题(" + url + ")")
- });
- },
- close:function(){
- WebViewNode.active = false;
- cc.vv.reflection.changeOrientation("Landscape");
- },
- },
- });
|