Explorar el Código

web页面跳转原生功能添加

huyuguo %!s(int64=3) %!d(string=hace) años
padre
commit
f2a095d83e

+ 63 - 4
app/src/main/java/com/electric/chargingpile/activity/MyWebViewActivity.java

@ -19,10 +19,6 @@ import android.os.Bundle;
19 19
import android.os.Environment;
20 20
import android.os.Handler;
21 21
import android.provider.MediaStore;
22
23
import androidx.annotation.NonNull;
24
import androidx.core.content.FileProvider;
25
26 22
import android.text.TextUtils;
27 23
import android.util.Log;
28 24
import android.view.KeyEvent;
@ -43,19 +39,25 @@ import android.widget.RelativeLayout;
43 39
import android.widget.TextView;
44 40
import android.widget.Toast;
45 41
42
import androidx.annotation.NonNull;
43
import androidx.core.content.FileProvider;
44
46 45
import com.afollestad.materialdialogs.DialogAction;
47 46
import com.afollestad.materialdialogs.MaterialDialog;
48 47
import com.blankj.utilcode.util.LogUtils;
49 48
import com.electric.chargingpile.BuildConfig;
50 49
import com.electric.chargingpile.R;
51 50
import com.electric.chargingpile.application.MainApplication;
51
import com.electric.chargingpile.data.CarOwnerCertificateBean;
52 52
import com.electric.chargingpile.data.ChargingShareBean;
53 53
import com.electric.chargingpile.data.User;
54
import com.electric.chargingpile.entity.CarSeriesEntity;
54 55
import com.electric.chargingpile.manager.ProfileManager;
55 56
import com.electric.chargingpile.util.BarColorUtil;
56 57
import com.electric.chargingpile.util.DES3;
57 58
import com.electric.chargingpile.util.ImageUitl;
58 59
import com.electric.chargingpile.util.JsonUtils;
60
import com.electric.chargingpile.util.LoadingDialog;
59 61
import com.electric.chargingpile.util.ToastUtil;
60 62
import com.electric.chargingpile.util.Util;
61 63
import com.electric.chargingpile.view.AlertDialogTwo;
@ -93,6 +95,7 @@ public class MyWebViewActivity extends Activity implements PlatformActionListene
93 95
    private TextView tv_webTitle, tv_webShare;
94 96
    private ImageView iv_webClose, iv_webBack, iv_message;
95 97
    private ProgressBar pb_webBar;
98
    private LoadingDialog loadDialog;
96 99
    private WebView webView;
97 100
    private String canRefresh = "false";
98 101
    private String index = "0";
@ -135,6 +138,8 @@ public class MyWebViewActivity extends Activity implements PlatformActionListene
135 138
136 139
137 140
    private void initView() {
141
        loadDialog = new LoadingDialog(this);
142
        loadDialog.setCanceledOnTouchOutside(false);
138 143
        rl_point = (RelativeLayout) findViewById(R.id.rl_point);
139 144
        tv_point = (TextView) findViewById(R.id.tv_point);
140 145
        animation = AnimationUtils.loadAnimation(MyWebViewActivity.this, R.anim.nn);
@ -715,6 +720,16 @@ public class MyWebViewActivity extends Activity implements PlatformActionListene
715 720
            case "14":
716 721
                startActivity(new Intent(getApplication(), UnansweredActivity.class));
717 722
                break;
723
            case "15":
724
                if (MainApplication.isLogin()) {
725
                    loadDialog.show();
726
                    getCarOwnerCertificateList();
727
                } else {
728
                    startActivity(new Intent(getApplicationContext(), LoginActivity.class));
729
                    ToastUtil.showToast(getApplicationContext(), "请先登录", Toast.LENGTH_SHORT);
730
                    index = "15";
731
                }
732
                break;
718 733
        }
719 734
720 735
    }
@ -1560,4 +1575,48 @@ public class MyWebViewActivity extends Activity implements PlatformActionListene
1560 1575
        super.onDestroy();
1561 1576
        list.clear();
1562 1577
    }
1578
1579
    /**
1580
     * 获取车主认证信息
1581
     */
1582
    private void getCarOwnerCertificateList() {
1583
        long tokenTime = System.currentTimeMillis() / 1000 - MainMapActivity.cha - 1;
1584
        String token = null;
1585
        try {
1586
            token = DES3.encode(String.valueOf(tokenTime));
1587
            token = URLEncoder.encode(token, "UTF-8");
1588
        } catch (Exception e) {
1589
            e.printStackTrace();
1590
        }
1591
1592
        String url = MainApplication.url + "/zhannew/basic/web/index.php/car/my?userid=" + MainApplication.userId + "&order=1" + "&token=" + token;
1593
        OkHttpUtils.get().url(url).build().connTimeOut(6000).readTimeOut(6000).execute(new StringCallback() {
1594
            @Override
1595
            public void onError(Call call, Exception e) {
1596
                e.printStackTrace();
1597
                loadDialog.dismiss();
1598
                Toast.makeText(getApplicationContext(), e.getLocalizedMessage(), Toast.LENGTH_SHORT).show();
1599
            }
1600
1601
            @Override
1602
            public void onResponse(String response) {
1603
                loadDialog.dismiss();
1604
                String rtnCode = JsonUtils.getKeyResult(response, "rtnCode");
1605
                if ("01".equals(rtnCode)) {
1606
                    String data = JsonUtils.getKeyResult(response, "data");
1607
                    List<CarOwnerCertificateBean> list = JsonUtils.parseToObjectList(data, CarOwnerCertificateBean.class);
1608
                    if (list.size() == 0) {
1609
                        startActivity(new Intent(getApplication(), CarOwnerCertificateActivity.class));
1610
                    } else {
1611
                        Intent intent = new Intent(getApplication(), CarOwnerCertificateListActivity.class);
1612
                        intent.putExtra("data", data);
1613
                        startActivity(intent);
1614
                    }
1615
                } else {
1616
                    String rtnMsg = JsonUtils.getKeyResult(response, "rtnMsg");
1617
                    Toast.makeText(getApplicationContext(), rtnMsg, Toast.LENGTH_SHORT).show();
1618
                }
1619
            }
1620
        });
1621
    }
1563 1622
}

+ 2 - 2
app/src/main/java/com/electric/chargingpile/application/MainApplication.java

@ -77,9 +77,9 @@ public class MainApplication extends MultiDexApplication {
77 77
    public static String firstPoint = "";
78 78
    public static Boolean firstSsyd;
79 79
    public static String password = "";
80
//    public static String url = "http://59.110.68.162";// 充电桩测试环境
80
    public static String url = "http://59.110.68.162";// 充电桩测试环境
81 81
//    public static String pic_url = "http://59.110.68.162/zhannew/uploadfile/";
82
    public static String url = "http://cdz.evcharge.cc";// 充电桩正式环境
82
//    public static String url = "http://cdz.evcharge.cc";// 充电桩正式环境
83 83
    public static String pic_url = "http://cdz.evcharge.cc/zhannew/uploadfile/";
84 84

85 85
    //    public static String urlNew = "http://123.56.67.7:83/api/0300";// 一电测试环境

+ 1 - 1
app/src/main/res/layout/activity_unanswered.xml

@ -18,7 +18,7 @@
18 18
            android:layout_width="wrap_content"
19 19
            android:layout_height="wrap_content"
20 20
            android:layout_centerInParent="true"
21
            android:text="待答问题"
21
            android:text="待答问题"
22 22
            android:textColor="#222222"
23 23
            android:textSize="18sp"/>
24 24