Browse Source

添加小程序传参示例

yanglei 2 months ago
parent
commit
315647ce6f

+ 1 - 1
sqjw/src/main/java/com/xwkj/sqjw/app/utils/ShareInfo.java

@@ -155,7 +155,7 @@ public class ShareInfo {
     }
 
     //请求地址信息
-    public class Resource {
+    public static class Resource {
         private String resourceRegionalismCode;
         private String resourceAddress;
         private String resourceId;

+ 40 - 5
sqjw/src/main/java/com/xwkj/sqjw/mvp/ui/activity/MainActivity.java

@@ -15,17 +15,21 @@ import androidx.annotation.Nullable;
 import androidx.core.app.ActivityCompat;
 import androidx.core.content.ContextCompat;
 
+import com.google.gson.Gson;
 import com.jess.arms.base.BaseActivity;
 import com.jess.arms.di.component.AppComponent;
 import com.jess.arms.utils.ArmsUtils;
 import com.xwkj.sqjw.R;
 import com.xwkj.sqjw.app.utils.DownloadUtil;
+import com.xwkj.sqjw.app.utils.ShareInfo;
 import com.xwkj.sqjw.di.component.DaggerMainComponent;
 import com.xwkj.sqjw.mvp.contract.MainContract;
 import com.xwkj.sqjw.mvp.presenter.MainPresenter;
 
 import java.io.File;
+import java.util.ArrayList;
 import java.util.HashMap;
+import java.util.List;
 
 import butterknife.BindView;
 import butterknife.ButterKnife;
@@ -69,10 +73,40 @@ public class MainActivity extends BaseActivity<MainPresenter> implements MainCon
     public int initView(@Nullable Bundle savedInstanceState) {
         return R.layout.activity_main; //如果你不需要框架帮你设置 setContentView(id) 需要自行设置,请返回 0
     }
-    /** unimp小程序实例缓存**/
+
+    /**
+     * unimp小程序实例缓存
+     **/
     HashMap<String, IUniMP> mUniMPCaches = new HashMap<>();
+
     @Override
     public void initData(@Nullable Bundle savedInstanceState) {
+        Gson gson = new Gson();
+        ShareInfo shareInfo = new ShareInfo();
+        shareInfo.setAppCredential("应用凭证");
+        shareInfo.setDataObjId("资源id");
+        shareInfo.setDepCode("220000000000");
+        shareInfo.setDepName("吉林省公安厅");
+        shareInfo.setMobile("13122223331");
+        shareInfo.setPersonCode("106470");
+        shareInfo.setPersonId("410000000000");
+        shareInfo.setPersonIdentifier("12010119610707201X");
+        shareInfo.setPersonName("张胜男");
+        shareInfo.setPersonType("10");
+        shareInfo.setPolice("101470");
+        shareInfo.setSex("男");
+        shareInfo.setFields("data");
+        shareInfo.setNetworkCode("3");
+        List<ShareInfo.Resource> resourceList = new ArrayList<>();
+        ShareInfo.Resource resource = new ShareInfo.Resource();
+        resource.setResourceAddress("http://20.3.1.162:9105/drs/ppc/v1/appQuery.do");
+        resource.setResourceRegionalismCode("220000000000");
+        resource.setResourceId(" 120000000000-3-0100-b0e037d83ecc4d43be788a5e9ddcbbe5");
+        resource.setResourceServiceType("10");
+        resourceList.add(resource);
+        shareInfo.setResourceList(resourceList);
+        shareInfo.setUserCredential("用户凭证");
+        System.out.println(gson.toJson(shareInfo));
         checkPermission();
         btOpen.setOnClickListener(view -> {
             /*try {
@@ -81,7 +115,7 @@ public class MainActivity extends BaseActivity<MainPresenter> implements MainCon
             } catch (Exception e) {
                 e.printStackTrace();
             }*/
-         updateWgt();
+            updateWgt();
         });
     }
 
@@ -90,7 +124,7 @@ public class MainActivity extends BaseActivity<MainPresenter> implements MainCon
      */
     private void updateWgt() {
         //
-       // final String wgtUrl = "https://native-res.dcloud.net.cn/unimp-sdk/__UNI__7AEA00D.wgt";
+        // final String wgtUrl = "https://native-res.dcloud.net.cn/unimp-sdk/__UNI__7AEA00D.wgt";
         final String wgtUrl = "http://111.26.204.4:9000/jdrh/upload/20241017/__UNI__0308C60.wgt";
         final String wgtName = "__UNI__0308C60.wgt";
 
@@ -157,12 +191,13 @@ public class MainActivity extends BaseActivity<MainPresenter> implements MainCon
     public void hideLoading() {
 
     }
+
     /**
      * 检查并申请权限
      */
     public void checkPermission() {
         int targetSdkVersion = 0;
-        String[] PermissionString={Manifest.permission.WRITE_EXTERNAL_STORAGE};
+        String[] PermissionString = {Manifest.permission.WRITE_EXTERNAL_STORAGE};
         try {
             final PackageInfo info = this.getPackageManager().getPackageInfo(this.getPackageName(), 0);
             targetSdkVersion = info.applicationInfo.targetSdkVersion;//获取应用的Target版本
@@ -177,7 +212,7 @@ public class MainActivity extends BaseActivity<MainPresenter> implements MainCon
                 //第 1 步: 检查是否有相应的权限
                 boolean isAllGranted = checkPermissionAllGranted(PermissionString);
                 if (isAllGranted) {
-                    Log.e("err","所有权限已经授权!");
+                    Log.e("err", "所有权限已经授权!");
                     return;
                 }
                 // 一次请求多个权限, 如果其他有权限是已经授予的将会自动忽略掉