跳微信二维码关注公众号
This commit is contained in:
parent
d75925aebf
commit
43e0531396
3
.idea/misc.xml
Executable file → Normal file
3
.idea/misc.xml
Executable file → Normal file
@ -1,4 +1,3 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="CMakeSettings">
|
<component name="CMakeSettings">
|
||||||
<configurations>
|
<configurations>
|
||||||
@ -34,7 +33,7 @@
|
|||||||
<option name="OPTION_DOCUMENT_TAG_AUTHOR" value="true" />
|
<option name="OPTION_DOCUMENT_TAG_AUTHOR" value="true" />
|
||||||
<option name="OPTION_DOCUMENT_TAG_VERSION" value="true" />
|
<option name="OPTION_DOCUMENT_TAG_VERSION" value="true" />
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_13" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_13" default="true" project-jdk-name="13" project-jdk-type="JavaSDK">
|
||||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectType">
|
<component name="ProjectType">
|
||||||
|
@ -6,6 +6,9 @@ buildscript {
|
|||||||
google()
|
google()
|
||||||
jcenter()
|
jcenter()
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
|
maven {
|
||||||
|
url "https://jitpack.io"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'com.android.tools.build:gradle:7.0.2'
|
classpath 'com.android.tools.build:gradle:7.0.2'
|
||||||
|
@ -10,14 +10,19 @@
|
|||||||
<application
|
<application
|
||||||
android:maxAspectRatio="2.4"
|
android:maxAspectRatio="2.4"
|
||||||
android:resizeableActivity="true">
|
android:resizeableActivity="true">
|
||||||
|
<activity
|
||||||
|
android:name=".core.widget.base.CommonWebActivity"
|
||||||
|
android:configChanges="keyboardHidden|orientation|screenSize|screenLayout"
|
||||||
|
android:launchMode="singleTop"
|
||||||
|
android:screenOrientation="portrait"
|
||||||
|
android:exported="false" />
|
||||||
|
|
||||||
<meta-data
|
<meta-data
|
||||||
android:name="android.max_aspect"
|
android:name="android.max_aspect"
|
||||||
android:value="2.4" />
|
android:value="2.4" /> <!-- 适配华为(huawei)刘海屏 -->
|
||||||
<!--适配华为(huawei)刘海屏-->
|
|
||||||
<meta-data
|
<meta-data
|
||||||
android:name="android.notch_support"
|
android:name="android.notch_support"
|
||||||
android:value="true" />
|
android:value="true" /> <!-- 适配小米(xiaomi)刘海屏 -->
|
||||||
<!--适配小米(xiaomi)刘海屏-->
|
|
||||||
<meta-data
|
<meta-data
|
||||||
android:name="notch.config"
|
android:name="notch.config"
|
||||||
android:value="portrait|landscape" />
|
android:value="portrait|landscape" />
|
||||||
@ -38,6 +43,7 @@
|
|||||||
android:name="android.support.FILE_PROVIDER_PATHS"
|
android:name="android.support.FILE_PROVIDER_PATHS"
|
||||||
android:resource="@xml/provider_paths" />
|
android:resource="@xml/provider_paths" />
|
||||||
</provider>
|
</provider>
|
||||||
|
|
||||||
<service android:name=".core.network.update.service.DownloadService" />
|
<service android:name=".core.network.update.service.DownloadService" />
|
||||||
</application>
|
</application>
|
||||||
|
|
||||||
|
38
cm_utils/src/main/assets/html/qrcode.html
Normal file
38
cm_utils/src/main/assets/html/qrcode.html
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<title>公众号</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div>
|
||||||
|
<input id="content" value="测试" style="width:200px;height:80px;font-size:60px;" />
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
<script type="text/javascript">
|
||||||
|
window.onload = openWeChat
|
||||||
|
|
||||||
|
function openWeChat() {
|
||||||
|
var url = window.location.href;
|
||||||
|
let params = url.split('?')[1];
|
||||||
|
let paramsObj = {};
|
||||||
|
if (typeof(params) == 'undefined' || params == null) {
|
||||||
|
return paramsObj;
|
||||||
|
}
|
||||||
|
let paramsKVs = params.split('&');
|
||||||
|
for (let i = 0; i < paramsKVs.length; i++) {
|
||||||
|
let item = paramsKVs[i];
|
||||||
|
let kvs = item.split('=');
|
||||||
|
if (kvs.length === 1) {
|
||||||
|
paramsObj[kvs[0]] = null;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
paramsObj[kvs[0]] = decodeURI(item.replace(kvs[0] + '=', ''));
|
||||||
|
}
|
||||||
|
// location.href="weixin://dl/business/?t=zfwpEa9dHOv"
|
||||||
|
location.href = "weixin://dl/business/?t=" + paramsObj.t;
|
||||||
|
console.log(paramsObj)
|
||||||
|
document.getElementById("content").setAttribute("value", paramsObj.t)
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
</html>
|
@ -30,6 +30,9 @@ public class PathConfig {
|
|||||||
public static final String MODULE_VISITOR = "visitor";
|
public static final String MODULE_VISITOR = "visitor";
|
||||||
public static final String MODULE_PATROL = "patrol";
|
public static final String MODULE_PATROL = "patrol";
|
||||||
public static final String SECRET = "CMXX_TOKEN_INFOS";//秘钥
|
public static final String SECRET = "CMXX_TOKEN_INFOS";//秘钥
|
||||||
|
public static final String WECHAT_LINK = "weixin://dl/business/?t=";
|
||||||
|
public static final String WECHAT_APPID="wx3267db0076f8b522";
|
||||||
|
public static final String WECHAT_SECERT="3d4dcd2a2c2d131f42ed986fa2d5a903";
|
||||||
public static final String PROJECT_NAME = "locationReal";//TODO ===项目名称==
|
public static final String PROJECT_NAME = "locationReal";//TODO ===项目名称==
|
||||||
public static final String ACTION_SYSTEM_MESSAGE = "com.sucstepsoft.hs.message";
|
public static final String ACTION_SYSTEM_MESSAGE = "com.sucstepsoft.hs.message";
|
||||||
public static final String ACTION_LOCATION_MESSAGE = "com.sucstepsoft.realtimelocation.MESSAGE_RECEIVED_ACTION";
|
public static final String ACTION_LOCATION_MESSAGE = "com.sucstepsoft.realtimelocation.MESSAGE_RECEIVED_ACTION";
|
||||||
|
@ -0,0 +1,23 @@
|
|||||||
|
package com.sucstepsoft.cm_utils.core.beans;
|
||||||
|
|
||||||
|
public class AccessToken {
|
||||||
|
|
||||||
|
private String access_token;
|
||||||
|
private int expires_in;
|
||||||
|
|
||||||
|
public String getAccess_token() {
|
||||||
|
return access_token;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAccess_token(String access_token) {
|
||||||
|
this.access_token = access_token;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getExpires_in() {
|
||||||
|
return expires_in;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setExpires_in(int expires_in) {
|
||||||
|
this.expires_in = expires_in;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,71 @@
|
|||||||
|
package com.sucstepsoft.cm_utils.core.beans;
|
||||||
|
|
||||||
|
public class PostWeChatTicketBean {
|
||||||
|
|
||||||
|
private JumpWxaBean jump_wxa;
|
||||||
|
private boolean is_expire;
|
||||||
|
private int expire_type;
|
||||||
|
private int expire_interval;
|
||||||
|
|
||||||
|
public JumpWxaBean getJump_wxa() {
|
||||||
|
return jump_wxa;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setJump_wxa(JumpWxaBean jump_wxa) {
|
||||||
|
this.jump_wxa = jump_wxa;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isIs_expire() {
|
||||||
|
return is_expire;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIs_expire(boolean is_expire) {
|
||||||
|
this.is_expire = is_expire;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getExpire_type() {
|
||||||
|
return expire_type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setExpire_type(int expire_type) {
|
||||||
|
this.expire_type = expire_type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getExpire_interval() {
|
||||||
|
return expire_interval;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setExpire_interval(int expire_interval) {
|
||||||
|
this.expire_interval = expire_interval;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class JumpWxaBean {
|
||||||
|
private String path;
|
||||||
|
private String query;
|
||||||
|
private String env_version;
|
||||||
|
|
||||||
|
public String getPath() {
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPath(String path) {
|
||||||
|
this.path = path;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getQuery() {
|
||||||
|
return query;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setQuery(String query) {
|
||||||
|
this.query = query;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getEnv_version() {
|
||||||
|
return env_version;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEnv_version(String env_version) {
|
||||||
|
this.env_version = env_version;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,32 @@
|
|||||||
|
package com.sucstepsoft.cm_utils.core.beans;
|
||||||
|
|
||||||
|
public class TicketBean {
|
||||||
|
|
||||||
|
private int errcode;
|
||||||
|
private String errmsg;
|
||||||
|
private String openlink;
|
||||||
|
|
||||||
|
public int getErrcode() {
|
||||||
|
return errcode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setErrcode(int errcode) {
|
||||||
|
this.errcode = errcode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getErrmsg() {
|
||||||
|
return errmsg;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setErrmsg(String errmsg) {
|
||||||
|
this.errmsg = errmsg;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getOpenlink() {
|
||||||
|
return openlink;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOpenlink(String openlink) {
|
||||||
|
this.openlink = openlink;
|
||||||
|
}
|
||||||
|
}
|
@ -1,7 +1,5 @@
|
|||||||
package com.sucstepsoft.cm_utils.core.retrofit_net;
|
package com.sucstepsoft.cm_utils.core.retrofit_net;
|
||||||
|
|
||||||
import com.sucstepsoft.cm_utils.constant.PathConfig;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 作者 : Adam on 2018/12/5.
|
* 作者 : Adam on 2018/12/5.
|
||||||
* 邮箱 : itgaojian@163.com
|
* 邮箱 : itgaojian@163.com
|
||||||
@ -9,13 +7,13 @@ import com.sucstepsoft.cm_utils.constant.PathConfig;
|
|||||||
*/
|
*/
|
||||||
public class BaseUrlApi {
|
public class BaseUrlApi {
|
||||||
|
|
||||||
// public static final String IP_URL = "http://v3.xzszwhy.cn/";/* 测试IP */
|
// public static final String IP_URL = "http://v3.xzszwhy.cn/";/* 测试IP */
|
||||||
public static final String IP_URL = "https://www.xzszwhy.cn/";/* 测试IP */
|
public static final String IP_URL = "https://www.xzszwhy.cn/";/* 测试IP */
|
||||||
// public static final String IP_URL = "http://192.168.0.120:8081/";/* 测试IP */
|
// public static final String IP_URL = "http://192.168.0.120:8081/";/* 测试IP */
|
||||||
|
|
||||||
// public static final String BASE_SYSTEM_IP = "http://192.168.0.120:8081/xzszwhy/";/*测试IP*/
|
public static final String BASE_SYSTEM_IP = "http://192.168.0.120:8081/xzszwhy/";/*测试IP*/
|
||||||
// public static final String BASE_SYSTEM_IP = "http://v3.xzszwhy.cn/xzszwhy/";/*正式IP*/
|
// public static final String BASE_SYSTEM_IP = "http://v3.xzszwhy.cn/xzszwhy/";/*正式IP*/
|
||||||
public static final String BASE_SYSTEM_IP = "https://www.xzszwhy.cn/xzszwhy/";/*正式IP*/
|
// public static final String BASE_SYSTEM_IP = "https://www.xzszwhy.cn/xzszwhy/";/*正式IP*/
|
||||||
|
|
||||||
public static final String PROJECT_NAME = "app/";
|
public static final String PROJECT_NAME = "app/";
|
||||||
public static final String BASE_URL = BASE_SYSTEM_IP;
|
public static final String BASE_URL = BASE_SYSTEM_IP;
|
||||||
@ -88,5 +86,6 @@ public class BaseUrlApi {
|
|||||||
public static final String BASE_SOCIAL_IMG_URL = BASE_CULTURAL_SHARE + "route/file/download/true/";
|
public static final String BASE_SOCIAL_IMG_URL = BASE_CULTURAL_SHARE + "route/file/download/true/";
|
||||||
public static final String APK_DOWNLOAD_URL = "downloadUrl";
|
public static final String APK_DOWNLOAD_URL = "downloadUrl";
|
||||||
public static final String UPDATE_URL = "version.json";
|
public static final String UPDATE_URL = "version.json";
|
||||||
|
public static final String WECHAT_OPENLINK = "https://api.weixin.qq.com/wxa/generatescheme?access_token=";
|
||||||
|
public static final String WECHAT_ACCESSTOKEN = "https://api.weixin.qq.com/cgi-bin/token";
|
||||||
}
|
}
|
||||||
|
@ -2,10 +2,12 @@ package com.sucstepsoft.cm_utils.core.retrofit_net.api;
|
|||||||
|
|
||||||
|
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
|
import com.sucstepsoft.cm_utils.core.beans.AccessToken;
|
||||||
import com.sucstepsoft.cm_utils.core.beans.AreaBean;
|
import com.sucstepsoft.cm_utils.core.beans.AreaBean;
|
||||||
import com.sucstepsoft.cm_utils.core.beans.BaseDictionaryBean;
|
import com.sucstepsoft.cm_utils.core.beans.BaseDictionaryBean;
|
||||||
import com.sucstepsoft.cm_utils.core.beans.BaseSuccessBean;
|
import com.sucstepsoft.cm_utils.core.beans.BaseSuccessBean;
|
||||||
import com.sucstepsoft.cm_utils.core.beans.DictionaryBean;
|
import com.sucstepsoft.cm_utils.core.beans.DictionaryBean;
|
||||||
|
import com.sucstepsoft.cm_utils.core.beans.TicketBean;
|
||||||
import com.sucstepsoft.cm_utils.core.beans.UploadBean;
|
import com.sucstepsoft.cm_utils.core.beans.UploadBean;
|
||||||
import com.sucstepsoft.cm_utils.core.beans.UserInfoFieldBean;
|
import com.sucstepsoft.cm_utils.core.beans.UserInfoFieldBean;
|
||||||
import com.sucstepsoft.cm_utils.core.beans.UserLoginBean;
|
import com.sucstepsoft.cm_utils.core.beans.UserLoginBean;
|
||||||
@ -324,4 +326,27 @@ public interface BaseApiService {
|
|||||||
@Headers({"base_url_name:bigdata", "Content-Type:application/json", "Accept:application/json"})
|
@Headers({"base_url_name:bigdata", "Content-Type:application/json", "Accept:application/json"})
|
||||||
@GET("app/contentcensusrelease/log")
|
@GET("app/contentcensusrelease/log")
|
||||||
Observable<BaseSuccessBean> bigDataRead(@Query("requestUrl") String id);
|
Observable<BaseSuccessBean> bigDataRead(@Query("requestUrl") String id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取accesstoken
|
||||||
|
*
|
||||||
|
* @param url
|
||||||
|
* @param type
|
||||||
|
* @param appid
|
||||||
|
* @param secret
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Headers({"Content-Type:application/json", "Accept:application/json"})
|
||||||
|
@GET
|
||||||
|
Observable<AccessToken> getWechatAccessToken(@Url String url, @Query("grant_type") String type, @Query("appid") String appid, @Query("secret") String secret);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取ticket
|
||||||
|
*
|
||||||
|
* @param url
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Headers({"Content-Type:application/json", "Accept:application/json"})
|
||||||
|
@POST
|
||||||
|
Observable<TicketBean> getWechatOpenLink(@Url String url, @Body RequestBody body);
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ package com.sucstepsoft.cm_utils.core.retrofit_net.conver;
|
|||||||
|
|
||||||
|
|
||||||
import com.sucstepsoft.cm_utils.core.retrofit_net.BaseUrlApi;
|
import com.sucstepsoft.cm_utils.core.retrofit_net.BaseUrlApi;
|
||||||
|
import com.sucstepsoft.cm_utils.utils.LogUtils;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -60,6 +61,7 @@ public class BaseUrlInterceptor implements Interceptor {
|
|||||||
.build();
|
.build();
|
||||||
return chain.proceed(builder.url(newFullUrl).build());
|
return chain.proceed(builder.url(newFullUrl).build());
|
||||||
} else {
|
} else {
|
||||||
|
LogUtils.e(request.url().toString());
|
||||||
return chain.proceed(request);
|
return chain.proceed(request);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,217 @@
|
|||||||
|
package com.sucstepsoft.cm_utils.core.widget.base;
|
||||||
|
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.net.Uri;
|
||||||
|
import android.net.http.SslError;
|
||||||
|
import android.os.Build;
|
||||||
|
import android.text.TextUtils;
|
||||||
|
import android.webkit.SslErrorHandler;
|
||||||
|
import android.webkit.WebResourceError;
|
||||||
|
import android.webkit.WebResourceRequest;
|
||||||
|
import android.webkit.WebSettings;
|
||||||
|
import android.webkit.WebView;
|
||||||
|
import android.webkit.WebViewClient;
|
||||||
|
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
import com.sucstepsoft.cm_utils.R;
|
||||||
|
import com.sucstepsoft.cm_utils.constant.PathConfig;
|
||||||
|
import com.sucstepsoft.cm_utils.core.beans.AccessToken;
|
||||||
|
import com.sucstepsoft.cm_utils.core.beans.PostWeChatTicketBean;
|
||||||
|
import com.sucstepsoft.cm_utils.core.beans.TicketBean;
|
||||||
|
import com.sucstepsoft.cm_utils.core.retrofit_net.BaseUrlApi;
|
||||||
|
import com.sucstepsoft.cm_utils.core.retrofit_net.RetrofitManager;
|
||||||
|
import com.sucstepsoft.cm_utils.core.retrofit_net.api.BaseApiService;
|
||||||
|
import com.sucstepsoft.cm_utils.utils.ExceptionHandler;
|
||||||
|
import com.sucstepsoft.cm_utils.utils.LogUtils;
|
||||||
|
|
||||||
|
import io.reactivex.Observer;
|
||||||
|
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||||
|
import io.reactivex.disposables.Disposable;
|
||||||
|
import io.reactivex.schedulers.Schedulers;
|
||||||
|
import okhttp3.MediaType;
|
||||||
|
import okhttp3.RequestBody;
|
||||||
|
|
||||||
|
public class CommonWebActivity extends BaseActivity {
|
||||||
|
|
||||||
|
private WebView mWvWeb;
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected int setLayoutId() {
|
||||||
|
return R.layout.activity_common_web;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void initData() {
|
||||||
|
mTvBaseTitle.setText("公众号");
|
||||||
|
this.mWvWeb = findViewById(R.id.wv_web);
|
||||||
|
WebSettings settings = this.mWvWeb.getSettings();
|
||||||
|
settings.setJavaScriptEnabled(true);
|
||||||
|
settings.setDomStorageEnabled(true);
|
||||||
|
settings.setJavaScriptCanOpenWindowsAutomatically(true);
|
||||||
|
settings.setAllowFileAccess(true);
|
||||||
|
settings.setSupportMultipleWindows(true);
|
||||||
|
settings.setUseWideViewPort(true);
|
||||||
|
settings.setLoadWithOverviewMode(true);
|
||||||
|
settings.setSupportZoom(false);
|
||||||
|
settings.setBuiltInZoomControls(true);
|
||||||
|
settings.setDisplayZoomControls(false);
|
||||||
|
settings.setCacheMode(WebSettings.LOAD_NO_CACHE);
|
||||||
|
if (Build.VERSION.SDK_INT >= 21) {
|
||||||
|
settings.setMixedContentMode(0);
|
||||||
|
}
|
||||||
|
if (Build.VERSION.SDK_INT >= 17) {
|
||||||
|
settings.setMediaPlaybackRequiresUserGesture(false);
|
||||||
|
}
|
||||||
|
this.mWvWeb.setWebViewClient(new WebViewClient() {
|
||||||
|
public void onReceivedSslError(WebView webView, SslErrorHandler sslErrorHandler, SslError sslError) {
|
||||||
|
sslErrorHandler.proceed();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onPageFinished(WebView webView, String str) {
|
||||||
|
super.onPageFinished(webView, str);
|
||||||
|
LogUtils.e(webView.getUrl() + "===" + str);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean shouldOverrideUrlLoading(WebView webView, String str) {
|
||||||
|
webView.loadUrl(str);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onReceivedError(WebView webView, WebResourceRequest webResourceRequest,
|
||||||
|
WebResourceError webResourceError) {
|
||||||
|
super.onReceivedError(webView, webResourceRequest, webResourceError);
|
||||||
|
if (Build.VERSION.SDK_INT >= 23) {
|
||||||
|
LogUtils.e(webResourceError.getErrorCode() + webResourceError.getDescription().toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onReceivedError(WebView webView, int i, String str, String str2) {
|
||||||
|
super.onReceivedError(webView, i, str, str2);
|
||||||
|
LogUtils.e(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean shouldOverrideUrlLoading(WebView webView, WebResourceRequest webResourceRequest) {
|
||||||
|
if (Build.VERSION.SDK_INT < 21) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
webView.loadUrl(webResourceRequest.getUrl().toString());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
getAccessToken();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取微信小程序accessToken
|
||||||
|
*/
|
||||||
|
private void getAccessToken() {
|
||||||
|
RetrofitManager.getInstance()
|
||||||
|
.create(BaseApiService.class)
|
||||||
|
.getWechatAccessToken(BaseUrlApi.WECHAT_ACCESSTOKEN,
|
||||||
|
"client_credential",
|
||||||
|
PathConfig.WECHAT_APPID,
|
||||||
|
PathConfig.WECHAT_SECERT)
|
||||||
|
.subscribeOn(Schedulers.io())
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.subscribe(new Observer<AccessToken>() {
|
||||||
|
@Override
|
||||||
|
public void onSubscribe(Disposable d) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onNext(AccessToken areaBean) {
|
||||||
|
if (!TextUtils.isEmpty(areaBean.getAccess_token())) {
|
||||||
|
getOpenLink(areaBean.getAccess_token());
|
||||||
|
} else {
|
||||||
|
refreshView(STATE_LOAD_ERROR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onError(Throwable e) {
|
||||||
|
refreshView(STATE_LOAD_ERROR);
|
||||||
|
ExceptionHandler.handleException(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onComplete() {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取微信小程序ticket
|
||||||
|
*
|
||||||
|
* @param token
|
||||||
|
*/
|
||||||
|
private void getOpenLink(String token) {
|
||||||
|
LogUtils.e(token);
|
||||||
|
RequestBody body = buildRequestBody();
|
||||||
|
RetrofitManager.getInstance()
|
||||||
|
.create(BaseApiService.class)
|
||||||
|
.getWechatOpenLink(BaseUrlApi.WECHAT_OPENLINK + token,
|
||||||
|
body)
|
||||||
|
.subscribeOn(Schedulers.io())
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.subscribe(new Observer<TicketBean>() {
|
||||||
|
@Override
|
||||||
|
public void onSubscribe(Disposable d) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onNext(TicketBean b) {
|
||||||
|
LogUtils.e(b.getErrcode());
|
||||||
|
if (b.getErrcode() == 0) {
|
||||||
|
refreshView(STATE_LOAD_SUCCESS);
|
||||||
|
startWeChat(b.getOpenlink());
|
||||||
|
} else {
|
||||||
|
refreshView(STATE_LOAD_ERROR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onError(Throwable e) {
|
||||||
|
ExceptionHandler.handleException(e);
|
||||||
|
refreshView(STATE_LOAD_ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onComplete() {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void startWeChat(String openlink) {
|
||||||
|
LogUtils.e(openlink);
|
||||||
|
try {
|
||||||
|
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(openlink));
|
||||||
|
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
|
startActivity(intent);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private RequestBody buildRequestBody() {
|
||||||
|
PostWeChatTicketBean bean = new PostWeChatTicketBean();
|
||||||
|
PostWeChatTicketBean.JumpWxaBean subBean = new PostWeChatTicketBean.JumpWxaBean();
|
||||||
|
subBean.setEnv_version("release");//默认 release 正式版 trial 体验版 develop 开发版
|
||||||
|
// subBean.setPath("/pages/commonQrCode/commonQrCode");
|
||||||
|
subBean.setPath("/pages/heritage/heritage");
|
||||||
|
subBean.setQuery("");
|
||||||
|
bean.setJump_wxa(subBean);
|
||||||
|
bean.setIs_expire(true);
|
||||||
|
bean.setExpire_type(1);
|
||||||
|
bean.setExpire_interval(1);
|
||||||
|
Gson gson = new Gson();
|
||||||
|
String obj = gson.toJson(bean);
|
||||||
|
RequestBody body = RequestBody.create(MediaType.parse("application/json; charset=utf-8"), obj);
|
||||||
|
return body;
|
||||||
|
}
|
||||||
|
}
|
13
cm_utils/src/main/res/layout/activity_common_web.xml
Normal file
13
cm_utils/src/main/res/layout/activity_common_web.xml
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
tools:context=".core.widget.base.CommonWebActivity">
|
||||||
|
<WebView
|
||||||
|
android:id="@+id/wv_web"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"/>
|
||||||
|
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
@ -1,7 +1,9 @@
|
|||||||
package com.tengshisoft.mudulemain.cultural.fragment;
|
package com.tengshisoft.mudulemain.cultural.fragment;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
|
import android.net.Uri;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.view.Gravity;
|
import android.view.Gravity;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@ -27,6 +29,7 @@ import com.sucstepsoft.cm_utils.core.retrofit_net.RetrofitManager;
|
|||||||
import com.sucstepsoft.cm_utils.core.widget.base.BannerImageTextAdapter;
|
import com.sucstepsoft.cm_utils.core.widget.base.BannerImageTextAdapter;
|
||||||
import com.sucstepsoft.cm_utils.core.widget.base.BaseFragment;
|
import com.sucstepsoft.cm_utils.core.widget.base.BaseFragment;
|
||||||
import com.sucstepsoft.cm_utils.core.widget.base.BaseRecyclerAdapter;
|
import com.sucstepsoft.cm_utils.core.widget.base.BaseRecyclerAdapter;
|
||||||
|
import com.sucstepsoft.cm_utils.core.widget.base.CommonWebActivity;
|
||||||
import com.sucstepsoft.cm_utils.core.widget.views.CustomStateView;
|
import com.sucstepsoft.cm_utils.core.widget.views.CustomStateView;
|
||||||
import com.sucstepsoft.cm_utils.core.widget.views.ItemSplitDivider;
|
import com.sucstepsoft.cm_utils.core.widget.views.ItemSplitDivider;
|
||||||
import com.sucstepsoft.cm_utils.core.widget.views.TypeFaceTextView;
|
import com.sucstepsoft.cm_utils.core.widget.views.TypeFaceTextView;
|
||||||
@ -778,9 +781,16 @@ public class HomeFragment extends BaseFragment {
|
|||||||
*/
|
*/
|
||||||
private void chooseFuncPage(NewsTabBean mainFuncBean) {
|
private void chooseFuncPage(NewsTabBean mainFuncBean) {
|
||||||
if ("精彩活动".equals(mainFuncBean.getDirectoriesName())) {
|
if ("精彩活动".equals(mainFuncBean.getDirectoriesName())) {
|
||||||
ARouter.getInstance()
|
Intent intent= new Intent(mActivity,CommonWebActivity.class);
|
||||||
.build(PathConfig.PATH_MODULEACTIVITY_ACTIVITY_MAIN)
|
// intent.setData(Uri.parse("http://weixin.qq.com/r/tR28uI-EHEdgKcvbb0gx"));
|
||||||
.navigation();
|
// intent.setPackage(getContext().getPackageName());
|
||||||
|
// intent.putExtra(Intent.EXTRA_SUBJECT,"Share");
|
||||||
|
// intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
|
startActivity(intent);
|
||||||
|
|
||||||
|
// ARouter.getInstance()
|
||||||
|
// .build(PathConfig.PATH_MODULEACTIVITY_ACTIVITY_MAIN)
|
||||||
|
// .navigation();
|
||||||
} else if ("场馆导航".equals(mainFuncBean.getDirectoriesName())) {
|
} else if ("场馆导航".equals(mainFuncBean.getDirectoriesName())) {
|
||||||
mMainActivity.setCurrentPage(2, "场馆");
|
mMainActivity.setCurrentPage(2, "场馆");
|
||||||
} else if ("非遗文化".equals(mainFuncBean.getDirectoriesName())) {
|
} else if ("非遗文化".equals(mainFuncBean.getDirectoriesName())) {
|
||||||
|
Loading…
Reference in New Issue
Block a user