From 15a3fc02c120ff630a9721a2f48a82f76675213f Mon Sep 17 00:00:00 2001
From: zuojincheng <lf_zuo@163.com>
Date: 星期一, 07 四月 2025 09:04:20 +0800
Subject: [PATCH] feat(generallibrary): 添加新卡开卡界面并更新扫描图标

---
 qiheonlinelibrary/src/main/java/com/dayu/qiheonlinelibrary/QHOnLineApplication.java |   85 ++++++++++++++++++++++++++----------------
 1 files changed, 52 insertions(+), 33 deletions(-)

diff --git a/qiheonlinelibrary/src/main/java/com/dayu/qiheonlinelibrary/QHOnLineApplication.java b/qiheonlinelibrary/src/main/java/com/dayu/qiheonlinelibrary/QHOnLineApplication.java
index 201e430..3ad470d 100644
--- a/qiheonlinelibrary/src/main/java/com/dayu/qiheonlinelibrary/QHOnLineApplication.java
+++ b/qiheonlinelibrary/src/main/java/com/dayu/qiheonlinelibrary/QHOnLineApplication.java
@@ -5,15 +5,16 @@
 import android.content.Context;
 import android.content.Intent;
 
+import com.dayu.baselibrary.net.subscribers.SubscriberListener;
+import com.dayu.baselibrary.utils.TipUtil;
 import com.dayu.baselibrary.utils.ToastUtil;
+import com.dayu.qiheonlinelibrary.activity.HomeActivityQHOline;
 import com.dayu.qiheonlinelibrary.bean.LoginResult;
 import com.dayu.qiheonlinelibrary.bean.PricePlanResult;
 import com.dayu.qiheonlinelibrary.net.ApiManager;
 import com.dayu.qiheonlinelibrary.net.BaseResponse;
 import com.dayu.qiheonlinelibrary.net.RSAUtile;
-import com.dayu.qiheonlinelibrary.net.subscribers.SubscriberListener;
 
-import java.security.AllPermission;
 import java.text.SimpleDateFormat;
 import java.util.Date;
 import java.util.HashMap;
@@ -27,7 +28,7 @@
  * 澶囨敞锛�
  */
 public class QHOnLineApplication {
-    public static QHOnLineApplication qhAloneApplication;
+    public static QHOnLineApplication qhOnLineApplication;
     public Application application;
 
     public String tokenStr;
@@ -40,20 +41,22 @@
 
     public String electriclePriceStr;//鐢典环
 
+    public String adminId;//鐧诲綍鐨勮处鍙穒d
+
     public static QHOnLineApplication getInstance(Application context) {
-        if (qhAloneApplication == null) {
-            qhAloneApplication = new QHOnLineApplication();
+        if (qhOnLineApplication == null) {
+            qhOnLineApplication = new QHOnLineApplication();
         }
-        qhAloneApplication.application = context;
+        qhOnLineApplication.application = context;
         ApiManager.init();
-        return qhAloneApplication;
+        return qhOnLineApplication;
     }
 
     public static QHOnLineApplication getInstance() {
-        if (qhAloneApplication == null) {
-            qhAloneApplication = new QHOnLineApplication();
+        if (qhOnLineApplication == null) {
+            qhOnLineApplication = new QHOnLineApplication();
         }
-        return qhAloneApplication;
+        return qhOnLineApplication;
     }
 
 
@@ -61,11 +64,15 @@
         Map<String, Object> data = new HashMap<>();
         data.put("loginType", "account");
 
-        ApiManager.getInstance().requestPostLoading(context, "api/login/getPubKey", String.class, null, new SubscriberListener<BaseResponse<String>>() {
+        ApiManager.getInstance().requestPostLoading(context, "http://120.46.45.35:20081/api/login/getPubKey", String.class, null, new SubscriberListener<BaseResponse<String>>() {
             @Override
             public void onNext(BaseResponse<String> t) {
                 if (t.isSuccess()) {
-                    getToken(context, name, pw, t.getData());
+                    if (t.getData() != null) {
+                        getToken(context, name, pw, t.getData());
+                    }
+                } else {
+                    ToastUtil.show(t.getMsg());
                 }
             }
         });
@@ -79,12 +86,14 @@
         String dateString = sdf.format(new Date());
         data.put("password", RSAUtile.encryptByPublicKey(pw + "@TIME@" + dateString, pubKey));
         data.put("username", name);
-        ApiManager.getInstance().requestPostLoading(application, "api/login/login/getToken", String.class, data, new SubscriberListener<BaseResponse<String>>() {
+        ApiManager.getInstance().requestPostLoading(application, "http://120.46.45.35:20081/api/login/login/getToken", String.class, data, new SubscriberListener<BaseResponse<String>>() {
             @Override
             public void onNext(BaseResponse<String> t) {
                 if (t.isSuccess()) {
-                    tokenStr = t.getData();
-                    login(context, name, pw, pubKey);
+                    if (t.getData() != null) {
+                        tokenStr = t.getData();
+                        login(context, name, pw, pubKey);
+                    }
                 } else {
                     ToastUtil.show(t.getMsg());
                 }
@@ -100,25 +109,34 @@
         String dateString = sdf.format(new Date());
         data.put("password", RSAUtile.encryptByPublicKey(pw + "@TIME@" + dateString, pubKey));
         data.put("username", name);
-        ApiManager.getInstance().requestPostLoading(application, "api/login/login", LoginResult.class, data, new SubscriberListener<BaseResponse<LoginResult>>() {
+        ApiManager.getInstance().requestPostLoading(application, "http://120.46.45.35:20081/api/login/login", LoginResult.class, data, new SubscriberListener<BaseResponse<LoginResult>>() {
             @Override
             public void onNext(BaseResponse<LoginResult> t) {
                 if (t.isSuccess()) {
-                    if (t.getData() != null && t.getData().getOtherData() != null) {
-                        LoginResult.OtherData otherData = t.getData().getOtherData();
-                        String tenantAdnm = otherData.getTenantAdnm();
-                        List<String> adnmList = otherData.getAdnmList();
-                        if (tenantAdnm != null && adnmList != null && !adnmList.isEmpty()) {
-                            addressName = tenantAdnm + adnmList.get(0);
+                    try {
+                        if (t.getData() != null && t.getData().getOtherData() != null) {
+
+                            LoginResult.OtherData otherData = t.getData().getOtherData();
+                            String tenantAdnm = otherData.getTenantAdnm();
+                            List<String> adnmList = otherData.getAdnmList();
+                            if (tenantAdnm != null && adnmList != null && !adnmList.isEmpty()) {
+                                addressName = tenantAdnm + adnmList.get(0);
+                            }
+                            List<String> adcdList = otherData.getAdnmList();
+                            if (adcdList != null && !adcdList.isEmpty()) {
+                                adcd = t.getData().getOtherData().getAdcdList().get(0);
+                                arerNumber = t.getData().getOtherData().getAdcdList().get(0).substring(4);
+                            }
+                            adminId = t.getData().getUserId();
+                            context.startActivity(new Intent(context, HomeActivityQHOline.class));
+                            ((Activity) context).finish();
+                        } else {
+                            TipUtil.show((Activity) context, "鐧诲綍澶辫触锛岃閲嶈瘯");
                         }
-                        List<String> adcdList = otherData.getAdnmList();
-                        if (adcdList != null && !adcdList.isEmpty()) {
-                            adcd = t.getData().getOtherData().getAdcdList().get(0);
-                            arerNumber = t.getData().getOtherData().getAdcdList().get(0).substring(4);
-                        }
+                    } catch (Exception e) {
+                        e.printStackTrace();
                     }
-                    context.startActivity(new Intent(context, com.dayu.qiheonlinelibrary.activity.HomeActivity.class));
-                    ((Activity) context).finish();
+
                 } else {
                     ToastUtil.show(t.getMsg());
                 }
@@ -132,13 +150,14 @@
     public void getPricePlanVo(Context context) {
         Map<String, Object> data = new HashMap<>();
         data.put("priceMethod", 2);
-
-        ApiManager.getInstance().requestPost(context, "api/sjgg/water/waterPricePlan/pageWaterPricePlanVo", PricePlanResult.class, data, new SubscriberListener<BaseResponse<PricePlanResult>>() {
+        ApiManager.getInstance().requestPostHideLoading(context, "water/waterPricePlan/pageWaterPricePlanVo", PricePlanResult.class, data, new SubscriberListener<BaseResponse<PricePlanResult>>() {
             @Override
             public void onNext(BaseResponse<PricePlanResult> t) {
                 if (t.isSuccess()) {
-                    planId = t.getData().getRecords().get(0).getPlanId();
-                    electriclePriceStr = t.getData().getRecords().get(0).getElectricityPrice();
+                    if (t.getData() != null) {
+                        planId = t.getData().getRecords().get(0).getPlanId();
+                        electriclePriceStr = t.getData().getRecords().get(0).getElectricityPrice();
+                    }
                 }
             }
         });

--
Gitblit v1.8.0