Commit cb277c4f by 严久程

h5重定向后路由加载失败的问题

parent 8b67ef7a
ext { ext {
kotlin_version = "1.3.21" kotlin_version = "1.3.21"
dev_mode = false dev_mode = true
ydl_app = [ ydl_app = [
appName : "心理咨询壹点灵", appName : "心理咨询壹点灵",
...@@ -251,7 +251,7 @@ ext { ...@@ -251,7 +251,7 @@ ext {
"ydl-pushagent" : "com.ydl:ydl-pushagent:0.1.9", "ydl-pushagent" : "com.ydl:ydl-pushagent:0.1.9",
"ydl-notracepoint" : "com.ydl:notracepoint-lib:0.1.8@aar", "ydl-notracepoint" : "com.ydl:notracepoint-lib:0.1.8@aar",
"ydl-js" : "com.ydl:ydl-js:1.0.7-SNAPSHOT@aar", "ydl-js" : "com.ydl:ydl-js:1.0.7-SNAPSHOT@aar",
"ydl-router" : "com.ydl:ydl-router:1.3.2-SNAPSHOT@aar", "ydl-router" : "com.ydl:ydl-router:1.3.7-SNAPSHOT@aar",
"xrecyclerview" : "com.ydl:xrecyclerview:1.0.0-SNAPSHOT@aar", "xrecyclerview" : "com.ydl:xrecyclerview:1.0.0-SNAPSHOT@aar",
"arouter-api" : "com.alibaba:arouter-api:1.4.1", "arouter-api" : "com.alibaba:arouter-api:1.4.1",
"arouter-compiler" : "com.alibaba:arouter-compiler:1.2.2", "arouter-compiler" : "com.alibaba:arouter-compiler:1.2.2",
......
...@@ -304,7 +304,7 @@ public class NewH5Activity extends BaseActivity implements PtrHandler { ...@@ -304,7 +304,7 @@ public class NewH5Activity extends BaseActivity implements PtrHandler {
@NotNull @NotNull
@Override @Override
public StatusBarOptions getStatusViewOptions() { public StatusBarOptions getStatusViewOptions() {
return new StatusBarOptions(true,true); return new StatusBarOptions(true, true);
} }
@Override @Override
...@@ -331,7 +331,7 @@ public class NewH5Activity extends BaseActivity implements PtrHandler { ...@@ -331,7 +331,7 @@ public class NewH5Activity extends BaseActivity implements PtrHandler {
} }
setUrlHeightParams(); setUrlHeightParams();
EventBus.getDefault().register(this); EventBus.getDefault().register(this);
jtoJHandle = WebModularServiceUtils.Companion.getWebService().getJavascripHandler(this,tellData = tellData); jtoJHandle = WebModularServiceUtils.Companion.getWebService().getJavascripHandler(this, tellData = tellData);
appFrom = BaseApp.instance.getGlobalConfig().getAppFrom(); appFrom = BaseApp.instance.getGlobalConfig().getAppFrom();
init(); init();
...@@ -396,11 +396,11 @@ public class NewH5Activity extends BaseActivity implements PtrHandler { ...@@ -396,11 +396,11 @@ public class NewH5Activity extends BaseActivity implements PtrHandler {
return pinjie(resultUrl); return pinjie(resultUrl);
} }
private String pinjie(String jumpUrl){ private String pinjie(String jumpUrl) {
if (jumpUrl.contains("hideNavBar=1")){ if (jumpUrl.contains("hideNavBar=1")) {
hideJavaTitleBar(); hideJavaTitleBar();
return jumpUrl; return jumpUrl;
}else if (jumpUrl.contains("hideNavBar=2")){ } else if (jumpUrl.contains("hideNavBar=2")) {
showTitleBar(); showTitleBar();
return jumpUrl; return jumpUrl;
} }
...@@ -500,7 +500,7 @@ public class NewH5Activity extends BaseActivity implements PtrHandler { ...@@ -500,7 +500,7 @@ public class NewH5Activity extends BaseActivity implements PtrHandler {
} }
} }
public void showTitleBar(){ public void showTitleBar() {
tb_title.setVisibility(VISIBLE); tb_title.setVisibility(VISIBLE);
if (null != getStatusView()) { if (null != getStatusView()) {
...@@ -634,16 +634,18 @@ public class NewH5Activity extends BaseActivity implements PtrHandler { ...@@ -634,16 +634,18 @@ public class NewH5Activity extends BaseActivity implements PtrHandler {
@Override @Override
public boolean shouldOverrideUrlLoading(WebView view, String url) { public boolean shouldOverrideUrlLoading(WebView view, String url) {
Boolean overridePayUrl = shouldOverridePayUrl(view, url); Boolean overridePayUrl = shouldOverridePayUrl(view, url);
if(overridePayUrl != null) { if (overridePayUrl != null) {
return overridePayUrl; return overridePayUrl;
} }
if (!TextUtils.isEmpty(url) && url.startsWith("http")) {
loadUrl(setUrlHeightParams(url));
} else {
if (YDLRouterManager.Companion.router(url)) { if (YDLRouterManager.Companion.router(url)) {
} else { } else {
loadUrl(setUrlHeightParams(url)); loadUrl(setUrlHeightParams(url));
} }
}
return true; return true;
} }
...@@ -710,16 +712,22 @@ public class NewH5Activity extends BaseActivity implements PtrHandler { ...@@ -710,16 +712,22 @@ public class NewH5Activity extends BaseActivity implements PtrHandler {
@Override @Override
public boolean shouldOverrideUrlLoading(WebView view, String url) { public boolean shouldOverrideUrlLoading(WebView view, String url) {
Boolean overridePayUrl = shouldOverridePayUrl(view, url); Boolean overridePayUrl = shouldOverridePayUrl(view, url);
if(overridePayUrl!=null) { if (overridePayUrl != null) {
return overridePayUrl; return overridePayUrl;
} }
if (!TextUtils.isEmpty(url) && url.startsWith("http")) {
loadUrl(setUrlHeightParams(url));
} else {
if (YDLRouterManager.Companion.router(url)) { if (YDLRouterManager.Companion.router(url)) {
} else { } else {
loadUrl(setUrlHeightParams(url)); loadUrl(setUrlHeightParams(url));
} }
}
return true; return true;
} }
...@@ -755,7 +763,7 @@ public class NewH5Activity extends BaseActivity implements PtrHandler { ...@@ -755,7 +763,7 @@ public class NewH5Activity extends BaseActivity implements PtrHandler {
tb_title.setImageVis(1); tb_title.setImageVis(1);
} }
} else { } else {
tb_title.setImage(getResources().getDrawable(YDLConstants.FROM_YDL.equals(appFrom)?R.drawable.platform_toolbar_back :R.drawable.platform_toolbar_back_yellow)); tb_title.setImage(getResources().getDrawable(YDLConstants.FROM_YDL.equals(appFrom) ? R.drawable.platform_toolbar_back : R.drawable.platform_toolbar_back_yellow));
tb_title.setmLeftText(""); tb_title.setmLeftText("");
tb_title.setImageListener(v -> { tb_title.setImageListener(v -> {
if (h5Params.getShowUrlTitle()) { if (h5Params.getShowUrlTitle()) {
...@@ -831,7 +839,7 @@ public class NewH5Activity extends BaseActivity implements PtrHandler { ...@@ -831,7 +839,7 @@ public class NewH5Activity extends BaseActivity implements PtrHandler {
return true; return true;
} }
} else if (url.startsWith("alipays://") || url.startsWith("alipay")) { } else if (url.startsWith("alipays://") || url.startsWith("alipay")) {
try{ try {
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url))); startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
return true; return true;
} catch (Exception e) { } catch (Exception e) {
...@@ -848,7 +856,7 @@ public class NewH5Activity extends BaseActivity implements PtrHandler { ...@@ -848,7 +856,7 @@ public class NewH5Activity extends BaseActivity implements PtrHandler {
// 处理微信 H5 支付跳转时验证请求头 referer 失效 // 处理微信 H5 支付跳转时验证请求头 referer 失效
// 验证不通过会出现“商家参数格式有误,请联系商家解决” // 验证不通过会出现“商家参数格式有误,请联系商家解决”
if (url.contains("wx.tenpay.com")){ if (url.contains("wx.tenpay.com")) {
// 申请微信 H5 支付时填写的域名 // 申请微信 H5 支付时填写的域名
// 比如经常用来测试网络连通性的 http://www.baidu.com // 比如经常用来测试网络连通性的 http://www.baidu.com
...@@ -857,12 +865,12 @@ public class NewH5Activity extends BaseActivity implements PtrHandler { ...@@ -857,12 +865,12 @@ public class NewH5Activity extends BaseActivity implements PtrHandler {
String redirectUrlStr = parse.getQueryParameter("redirect_url"); String redirectUrlStr = parse.getQueryParameter("redirect_url");
Uri redirectUrl = Uri.parse(redirectUrlStr); Uri redirectUrl = Uri.parse(redirectUrlStr);
// 申请微信 H5 支付时填写的域名 // 申请微信 H5 支付时填写的域名
String referer = redirectUrl.getScheme()+"://"+redirectUrl.getHost(); String referer = redirectUrl.getScheme() + "://" + redirectUrl.getHost();
// 兼容 Android 4.4.3 和 4.4.4 两个系统版本设置 referer 无效的问题 // 兼容 Android 4.4.3 和 4.4.4 两个系统版本设置 referer 无效的问题
if (("4.4.3".equals(Build.VERSION.RELEASE)) if (("4.4.3".equals(Build.VERSION.RELEASE))
|| ("4.4.4".equals(Build.VERSION.RELEASE))) { || ("4.4.4".equals(Build.VERSION.RELEASE))) {
if (firstVisitWXH5PayUrl){ if (firstVisitWXH5PayUrl) {
view.loadDataWithBaseURL(referer, "<script>window.location.href=\"" + url + "\";</script>", view.loadDataWithBaseURL(referer, "<script>window.location.href=\"" + url + "\";</script>",
"text/html", "utf-8", null); "text/html", "utf-8", null);
// 修改标记位状态,避免循环调用 // 修改标记位状态,避免循环调用
...@@ -878,7 +886,7 @@ public class NewH5Activity extends BaseActivity implements PtrHandler { ...@@ -878,7 +886,7 @@ public class NewH5Activity extends BaseActivity implements PtrHandler {
view.loadUrl(url, map); view.loadUrl(url, map);
return true; return true;
} }
}else if(url.contains("alipay")) { } else if (url.contains("alipay")) {
return false; return false;
} }
...@@ -907,11 +915,11 @@ public class NewH5Activity extends BaseActivity implements PtrHandler { ...@@ -907,11 +915,11 @@ public class NewH5Activity extends BaseActivity implements PtrHandler {
} }
public void onEvent(RefreshWebEvent event) { public void onEvent(RefreshWebEvent event) {
if(event.isClearHistory) { if (event.isClearHistory) {
wv_content.clearCache(true); wv_content.clearCache(true);
wv_content.clearHistory(); wv_content.clearHistory();
loadUrl(h5Params.getUrl()); loadUrl(h5Params.getUrl());
}else{ } else {
//刷新页面 //刷新页面
loadUrl(h5Params.getUrl()); loadUrl(h5Params.getUrl());
shouldClearHistory = true; shouldClearHistory = true;
...@@ -977,7 +985,7 @@ public class NewH5Activity extends BaseActivity implements PtrHandler { ...@@ -977,7 +985,7 @@ public class NewH5Activity extends BaseActivity implements PtrHandler {
} }
String resultUrl = h5Params.getSuffix() ? TemporaryUtils.getSuffix(url) : url; String resultUrl = h5Params.getSuffix() ? TemporaryUtils.getSuffix(url) : url;
Log.e("AAAA",resultUrl); Log.e("AAAA", resultUrl);
wv_content.loadUrl(resultUrl); wv_content.loadUrl(resultUrl);
pointBI(resultUrl); pointBI(resultUrl);
} }
...@@ -994,7 +1002,7 @@ public class NewH5Activity extends BaseActivity implements PtrHandler { ...@@ -994,7 +1002,7 @@ public class NewH5Activity extends BaseActivity implements PtrHandler {
private void initHead() { private void initHead() {
// header // header
final MaterialHeader header = new MaterialHeader(this); final MaterialHeader header = new MaterialHeader(this);
int[] colors = new int[]{getResources().getColor(YDLConstants.FROM_YDL.equals(appFrom)?R.color.platform_google_green :R.color.platform_google_yellow)}; int[] colors = new int[]{getResources().getColor(YDLConstants.FROM_YDL.equals(appFrom) ? R.color.platform_google_green : R.color.platform_google_yellow)};
header.setColorSchemeColors(colors); header.setColorSchemeColors(colors);
header.setLayoutParams(new PtrFrameLayout.LayoutParams(-1, -2)); header.setLayoutParams(new PtrFrameLayout.LayoutParams(-1, -2));
int padding = (int) getResources().getDimension(R.dimen.platform_default_dis_size); int padding = (int) getResources().getDimension(R.dimen.platform_default_dis_size);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment