3
This commit is contained in:
@@ -67,6 +67,28 @@ import io.dcloud.feature.unimp.config.UniMPReleaseConfiguration;
|
||||
|
||||
public class UniappUtil {
|
||||
|
||||
private static String lastUniMPToken = "";
|
||||
|
||||
/**
|
||||
* 判断目标路径是否允许游客模式(未登录)访问
|
||||
* 覆盖:肝胆视频、肝胆新闻(肝胆时讯)、肝胆课件及其详情页
|
||||
*/
|
||||
public static boolean isGuestAllowedPath(String targetPath) {
|
||||
if (StringUtil.isEmpty(targetPath)) {
|
||||
return false;
|
||||
}
|
||||
return targetPath.startsWith("/pages_app/video/video")
|
||||
|| targetPath.startsWith("/pages_app/videoDetail/videoDetail")
|
||||
|| targetPath.startsWith("/pages_app/liveReplay/liveReplay")
|
||||
|| targetPath.startsWith("/pages_app/replayList/replayList")
|
||||
|| targetPath.startsWith("/pages_app/newsList/newsList")
|
||||
|| targetPath.startsWith("/pages_app/news/news")
|
||||
|| targetPath.startsWith("/pages_app/webview/webviewClass")
|
||||
|| targetPath.startsWith("/pages_app/webview/webview")
|
||||
|| targetPath.startsWith("/pages_app/ppt/ppt")
|
||||
|| targetPath.startsWith("/pages_app/pptDetail/pptDetail");
|
||||
}
|
||||
|
||||
/**
|
||||
* 展示uniapp mp - 公共方法
|
||||
* @param context 上下文
|
||||
@@ -75,7 +97,7 @@ public class UniappUtil {
|
||||
public static void showUniMp(Context context, String targetPath, com.alibaba.fastjson.JSONObject pageParams) {
|
||||
try {
|
||||
|
||||
if (!UIUtils.checkLoginAndJump(context)) {
|
||||
if (!isGuestAllowedPath(targetPath) && !UIUtils.checkLoginAndJump(context)) {
|
||||
return;
|
||||
}
|
||||
checkWgt(context, targetPath, pageParams);
|
||||
@@ -109,14 +131,14 @@ public class UniappUtil {
|
||||
|
||||
private static void showInternal(Context context, String targetPath, com.alibaba.fastjson.JSONObject pageParams) {
|
||||
try {
|
||||
if (!UIUtils.checkLoginAndJump(context)) {
|
||||
if (!isGuestAllowedPath(targetPath) && !UIUtils.checkLoginAndJump(context)) {
|
||||
return;
|
||||
}
|
||||
String uuid = SharePrefUtil.getString(context, Constant.uuid, "");
|
||||
if(StringUtil.isEmpty(uuid)){
|
||||
if(!isGuestAllowedPath(targetPath) && StringUtil.isEmpty(uuid)){
|
||||
return;
|
||||
}
|
||||
String access_token = SharePrefUtil.getString(context, "access_token", "");
|
||||
String access_token = UIUtils.isLogined() ? SharePrefUtil.getString(context, "access_token", "") : "";
|
||||
String QueryString = StringUtil.toQueryString(pageParams);
|
||||
JSONObject userInfo = new JSONObject();
|
||||
userInfo.put("uuid", SharePrefUtil.getString(context, Constant.uuid, ""));
|
||||
@@ -154,7 +176,12 @@ public class UniappUtil {
|
||||
Log.d("UniappUtil","uniapp_MP_cash.isRunning()="+uniapp_MP_cash.isRunning());
|
||||
}
|
||||
//存在但是不在运行
|
||||
if(uniapp_MP_cash != null && !uniapp_MP_cash.isRunning()){
|
||||
if(uniapp_MP_cash != null && (!uniapp_MP_cash.isRunning() || !StringUtil.equals(lastUniMPToken, access_token))){
|
||||
BaseApplication.getUniMPCaches().remove(uniapp_mp_appid);
|
||||
uniapp_MP_cash.closeUniMP();
|
||||
uniapp_MP_cash = null;
|
||||
}
|
||||
if(false && uniapp_MP_cash != null && !uniapp_MP_cash.isRunning()){
|
||||
BaseApplication.getUniMPCaches().remove(uniapp_mp_appid);
|
||||
uniapp_MP_cash.closeUniMP();
|
||||
}
|
||||
@@ -179,6 +206,7 @@ public class UniappUtil {
|
||||
}
|
||||
}
|
||||
IUniMP uniapp_MP = DCUniMPSDK.getInstance().openUniMP(openContext, uniapp_mp_appid, uniMPOpenConfiguration);
|
||||
lastUniMPToken = access_token != null ? access_token : "";
|
||||
BaseApplication.getUniMPCaches().put(uniapp_MP.getAppid(), uniapp_MP);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
||||
Reference in New Issue
Block a user