This commit is contained in:
2025-12-15 14:10:54 +08:00
parent 434f134f53
commit 2491213ca6
361 changed files with 7533 additions and 5354 deletions
@@ -47,6 +47,8 @@ import com.umeng.commonsdk.UMConfigure;
import com.umeng.socialize.PlatformConfig;
import com.zhy.http.okhttp.OkHttpUtils;
import org.json.JSONObject;
import java.io.File;
import java.io.InvalidClassException;
import java.lang.reflect.Constructor;
@@ -59,8 +61,17 @@ import java.util.Map;
import java.util.concurrent.TimeUnit;
import io.dcloud.feature.sdk.Interface.IUniMP;
import io.dcloud.feature.sdk.DCSDKInitConfig;
import io.dcloud.feature.sdk.DCUniMPSDK;
import io.dcloud.feature.sdk.Interface.IOnUniMPEventCallBack;
import io.dcloud.feature.sdk.Interface.IUniMPOnCloseCallBack;
import io.dcloud.feature.unimp.DCUniMPJSCallback;
import cn.shangyu.gdxzExpert.activity.LoginNewActivity;
import cn.shangyu.gdxzExpert.activity.PublicSearchActivity;
import cn.shangyu.gdxzExpert.base.AppManager;
import cn.shangyu.gdxzExpert.base.BaseActivity;
import cn.shangyu.gdxzExpert.pointsmall.BuyIntegerActivty;
import cn.shangyu.gdxzExpert.cast.PolyvScreencastManager;
import cn.shangyu.gdxzExpert.ecdemo.common.CCPAppManager;
import cn.shangyu.gdxzExpert.ecdemo.common.ECPreferenceSettings;
@@ -280,6 +291,106 @@ public class BaseApplication extends Application {
{
initYinsi();
}
//uniapp
DCSDKInitConfig config = new DCSDKInitConfig.Builder()
.setCapsule(false)
.setMenuDefFontSize("16px")
.setMenuDefFontColor("#ff00ff")
.setMenuDefFontWeight("normal")
.setEnableBackground(true)
.build();
DCUniMPSDK.getInstance().initialize(this, config);
DCUniMPSDK.getInstance().setUniMPOnCloseCallBack(new IUniMPOnCloseCallBack() {
@Override
public void onClose(String appid) {
LogUtil.i("unimp", appid+" 被关闭了");
getUniMPCaches().clear();
}
});
// 设置 UniMP 事件回调
DCUniMPSDK.getInstance().setOnUniMPEventCallBack(new IOnUniMPEventCallBack() {
@Override
public void onUniMPEventReceive(String appid, String event, Object data, DCUniMPJSCallback callback) {
LogUtil.i("onUniMPEventReceive appid="+appid);
LogUtil.i("onUniMPEventReceive event="+event);
LogUtil.i("onUniMPEventReceive data="+data);
try {
// 解析 data
String msgValue = null;
if (data instanceof com.alibaba.fastjson.JSONObject) {
com.alibaba.fastjson.JSONObject fastJsonObj = (com.alibaba.fastjson.JSONObject) data;
msgValue = fastJsonObj.getString("msg");
} else if (data instanceof String) {
JSONObject jsonObject = new JSONObject((String) data);
msgValue = jsonObject.getString("msg");
} else {
JSONObject jsonObject = new JSONObject(data.toString());
msgValue = jsonObject.getString("msg");
}
Activity currentActivity = null;
try {
AppManager appManager = AppManager.getAppManager();
if (appManager != null) {
currentActivity = appManager.currentActivity();
}
} catch (Exception e) {
LogUtil.e("获取当前Activity失败: " + e.getMessage());
}
if (currentActivity == null) {
LogUtil.e("当前Activity为空,无法处理uniapp事件");
return;
}
if(event.equals("goTabbarPage")){
// MainActivity 特有的逻辑,需要检查当前 Activity 是否是 MainActivity
if (currentActivity instanceof cn.shangyu.gdxzExpert.activity.MainActivity) {
cn.shangyu.gdxzExpert.activity.MainActivity mainActivity = (cn.shangyu.gdxzExpert.activity.MainActivity) currentActivity;
if (currentActivity instanceof BaseActivity) {
((BaseActivity) currentActivity).handleMainActivityEvent(mainActivity, event, msgValue);
}
}
} else if (event.equals("getScanCodeAuth")){
if (currentActivity instanceof BaseActivity) {
((BaseActivity) currentActivity).handleScanCodeAuth(callback);
}
} else if(event.equals("checkToken")){
if (currentActivity instanceof BaseActivity) {
((BaseActivity) currentActivity).handleCheckToken(callback);
}
} else if(event.equals("goHomeSearch")){
if (currentActivity != null) {
Intent intentv = new Intent(currentActivity, cn.shangyu.gdxzExpert.activity.PublicSearchActivity.class);
if (msgValue.equals("patientVideo")) {
intentv.setType("patientVideo");
}else if (msgValue.equals("meetVideo")) {
intentv.setType("video");
}else if (msgValue.equals("zhinan")) {
intentv.setType("drug");
}
currentActivity.startActivity(intentv);
}
} else if(event.equals("buyPointPage")) {
if (currentActivity != null) {
Intent intentv = new Intent(currentActivity, cn.shangyu.gdxzExpert.pointsmall.BuyIntegerActivty.class);
currentActivity.startActivity(intentv);
}
}
}catch (Exception e){
LogUtil.e("处理uniapp事件时出错: " + e.getMessage());
e.printStackTrace();
}
}
});
}
public void initYinsi()
{