瀏覽代碼

完成车主认证上传信息至后台

hy 4 年之前
父節點
當前提交
f42bc42a85

+ 83 - 25
app/src/main/java/com/electric/chargingpile/activity/CarModelActivity.java

25
import com.electric.chargingpile.event.CarSeriesEvent;
25
import com.electric.chargingpile.event.CarSeriesEvent;
26
import com.electric.chargingpile.manager.ProfileManager;
26
import com.electric.chargingpile.manager.ProfileManager;
27
import com.electric.chargingpile.util.BarColorUtil;
27
import com.electric.chargingpile.util.BarColorUtil;
28
import com.electric.chargingpile.util.DES3;
28
import com.electric.chargingpile.util.JsonUtils;
29
import com.electric.chargingpile.util.JsonUtils;
29
import com.electric.chargingpile.util.LoadingDialog;
30
import com.electric.chargingpile.util.LoadingDialog;
30
import com.electric.chargingpile.util.ToastUtil;
31
import com.electric.chargingpile.util.ToastUtil;
34
import com.zhy.http.okhttp.callback.StringCallback;
35
import com.zhy.http.okhttp.callback.StringCallback;
35
36
36
import org.greenrobot.eventbus.EventBus;
37
import org.greenrobot.eventbus.EventBus;
38
import org.jetbrains.annotations.NotNull;
37
39
38
import java.util.ArrayList;
40
import java.util.ArrayList;
41
import java.util.HashMap;
42
import java.util.Map;
39
43
40
import okhttp3.Call;
44
import okhttp3.Call;
45
46
import static com.electric.chargingpile.activity.CarBrandActivity.sourceType;
47
41
/**
48
/**
42
 * 车型选择
49
 * 车型选择
43
 * */
50
 * */
80
        adapter.setOnChildClickListener(new GroupedRecyclerViewAdapter.OnChildClickListener() {
87
        adapter.setOnChildClickListener(new GroupedRecyclerViewAdapter.OnChildClickListener() {
81
            @Override
88
            @Override
82
            public void onChildClick(GroupedRecyclerViewAdapter adapter, BaseViewHolder holder, int groupPosition, int childPosition) {
89
            public void onChildClick(GroupedRecyclerViewAdapter adapter, BaseViewHolder holder, int groupPosition, int childPosition) {
83
                String sourceType = CarBrandActivity.sourceType;
90
                CarModelEntity carModelEntity = getCarModelEntity(groupPosition, childPosition);
91
84
                if (!TextUtils.isEmpty(sourceType)){
92
                if (!TextUtils.isEmpty(sourceType)){
93
                    requestCarIntentModel(carModelEntity);
94
                }else{
95
                    EventBus.getDefault().post(new CarModelEvent(carModelEntity));
96
                    startActivity(new Intent(CarModelActivity.this, CarOwnerCertificateActivity.class));
97
                }
98
            }
99
        });
100
101
        recycler_view.setAdapter(adapter);
102
        // 设置是否吸顶。
103
        sticky_header_layout.setSticky(true);
104
    }
105
106
    @NotNull
107
    private CarModelEntity getCarModelEntity(int groupPosition, int childPosition) {
108
        CarModelChildEntity carModelChildEntity = groups.get(groupPosition).getList().get(childPosition);
109
        CarModelEntity carModelEntity = new CarModelEntity();
110
111
        carModelEntity.setBrandName(carSeriesEntity.getBrandName());
112
        carModelEntity.setCompanyId(carSeriesEntity.getCompanyId());
113
        carModelEntity.setCompanyName(carSeriesEntity.getCompanyName());
114
        carModelEntity.setSeriesId(carSeriesEntity.getSeriesId());
115
        carModelEntity.setSeriesName(carSeriesEntity.getSeriesName());
116
        carModelEntity.setSalePrice(carSeriesEntity.getSalePrice());
117
        carModelEntity.setIcon(carSeriesEntity.getIcon());
118
        carModelEntity.setMasterPic(carSeriesEntity.getMasterPic());
119
        carModelEntity.setMaxSalePrice(carSeriesEntity.getMaxSalePrice());
120
        carModelEntity.setMinSalePrice(carSeriesEntity.getMinSalePrice());
121
122
        carModelEntity.setModelId(carModelChildEntity.getModelId());
123
        carModelEntity.setModelName(carModelChildEntity.getModelName());
124
        return carModelEntity;
125
    }
126
127
    private void requestCarIntentModel( CarModelEntity carModelEntity) {
128
        loadDialog.show();
129
        String sourceType = CarBrandActivity.sourceType;
130
131
        String url = MainApplication.url + "/zhannew/basic/web/index.php/car/add";
132
133
        long tokenTime = System.currentTimeMillis() / 1000 - MainMapActivity.cha - 1;
134
        String token = null;
135
        try {
136
            token = DES3.encode(String.valueOf(tokenTime));
137
        } catch (Exception e) {
138
            e.printStackTrace();
139
        }
140
        Map<String, String> map = new HashMap<>();
141
        map.put("engine_number", "yixiang");
142
        map.put("plate_number", "yixiang");
143
        map.put("cartype", "自用");
144
        map.put("userid", MainApplication.userId);
145
        map.put("token", token);
146
147
        Gson gson = new Gson();
148
        String chexing = gson.toJson(carModelEntity);
149
        map.put("chexing", chexing);
150
151
        OkHttpUtils.post().params(map).url(url).build().execute(new StringCallback() {
152
153
            @Override
154
            public void onError(Call call, Exception e) {
155
                loadDialog.dismiss();
156
            }
157
158
            @Override
159
            public void onResponse(String response) {
160
                loadDialog.dismiss();
161
                String rtnCode = JsonUtils.getKeyResult(response, "rtnCode");
162
                if ("01".equals(rtnCode)) {
163
                    ToastUtil.showToast(getApplicationContext(), "意向车型提交成功", Toast.LENGTH_SHORT);
164
                    finish();
85
                    MainApplication.userCarIntentMode= carSeriesEntity.getSeriesName();
165
                    MainApplication.userCarIntentMode= carSeriesEntity.getSeriesName();
86
                    ProfileManager.getInstance().setCarIntentModel(CarModelActivity.this,carSeriesEntity.getSeriesName());
166
                    ProfileManager.getInstance().setCarIntentModel(CarModelActivity.this,carSeriesEntity.getSeriesName());
87
                    if (sourceType.equals("1")){
167
                    if (sourceType.equals("1")){
90
                        startActivity(new Intent(CarModelActivity.this, SkipUserInfoActivity.class));
170
                        startActivity(new Intent(CarModelActivity.this, SkipUserInfoActivity.class));
91
171
92
                    }
172
                    }
93
                }else{
94
                    CarModelChildEntity carModelChildEntity = groups.get(groupPosition).getList().get(childPosition);
95
                    CarModelEntity carModelEntity = new CarModelEntity();
96
97
                    carModelEntity.setBrandName(carSeriesEntity.getBrandName());
98
                    carModelEntity.setCompanyId(carSeriesEntity.getCompanyId());
99
                    carModelEntity.setCompanyName(carSeriesEntity.getCompanyName());
100
                    carModelEntity.setSeriesId(carSeriesEntity.getSeriesId());
101
                    carModelEntity.setSeriesName(carSeriesEntity.getSeriesName());
102
                    carModelEntity.setSalePrice(carSeriesEntity.getSalePrice());
103
                    carModelEntity.setIcon(carSeriesEntity.getIcon());
104
                    carModelEntity.setMasterPic(carSeriesEntity.getMasterPic());
105
                    carModelEntity.setMaxSalePrice(carSeriesEntity.getMaxSalePrice());
106
                    carModelEntity.setMinSalePrice(carSeriesEntity.getMinSalePrice());
107
108
                    carModelEntity.setModelId(carModelChildEntity.getModelId());
109
                    carModelEntity.setModelName(carModelChildEntity.getModelName());
110
111
                    EventBus.getDefault().post(new CarModelEvent(carModelEntity));
112
                    startActivity(new Intent(CarModelActivity.this, CarOwnerCertificateActivity.class));
173
                } else {
174
                    ToastUtil.showToast(getApplicationContext(), "意向车型提交失败,请重新提交", Toast.LENGTH_SHORT);
113
                }
175
                }
114
            }
176
            }
115
        });
177
        });
116
117
        recycler_view.setAdapter(adapter);
118
        // 设置是否吸顶。
119
        sticky_header_layout.setSticky(true);
120
    }
178
    }
121
179
122
    private void getModelList() {
180
    private void getModelList() {

+ 1 - 1
app/src/main/java/com/electric/chargingpile/activity/ChargingStatusActivity.java

713
    protected void onResume() {
713
    protected void onResume() {
714
        super.onResume();
714
        super.onResume();
715
        MobclickAgent.onResume(this);
715
        MobclickAgent.onResume(this);
716
        if (MainApplication.userCar.equals("")){
716
        if (MainApplication.userCertifiedModel.equals("")){
717
            layoutCarCertificate.setVisibility(View.VISIBLE);
717
            layoutCarCertificate.setVisibility(View.VISIBLE);
718
        }else{
718
        }else{
719
            layoutCarCertificate.setVisibility(View.GONE);
719
            layoutCarCertificate.setVisibility(View.GONE);

+ 6 - 1
app/src/main/java/com/electric/chargingpile/activity/UserCenterActivity.java

239
            int max = ProfileManager.getInstance().getUserCenterMaxCount(UserCenterActivity.this);
239
            int max = ProfileManager.getInstance().getUserCenterMaxCount(UserCenterActivity.this);
240
240
241
            if (MainApplication.isLogin()) {
241
            if (MainApplication.isLogin()) {
242
                if (MainApplication.userCar.equals("")){
242
                if (MainApplication.userCertifiedModel.equals("")){
243
                    count=ProfileManager.getInstance().getUserCenterCount(getApplicationContext()) + 1;
243
                    count=ProfileManager.getInstance().getUserCenterCount(getApplicationContext()) + 1;
244
                    int temp =count >= max  ? 0 :count;
244
                    int temp =count >= max  ? 0 :count;
245
                    ProfileManager.getInstance().setUserCenterCount(getApplicationContext(), temp);
245
                    ProfileManager.getInstance().setUserCenterCount(getApplicationContext(), temp);
1123
        }
1123
        }
1124
1124
1125
        String url = MainApplication.url + "/zhannew/basic/web/index.php/car/my?userid=" + MainApplication.userId + "&order=1" + "&token=" + token;
1125
        String url = MainApplication.url + "/zhannew/basic/web/index.php/car/my?userid=" + MainApplication.userId + "&order=1" + "&token=" + token;
1126
        Log.e(TAG, "getCarOwnerCertificateList: "+url);
1126
        OkHttpUtils.get().url(url).build().connTimeOut(6000).readTimeOut(6000).execute(new StringCallback() {
1127
        OkHttpUtils.get().url(url).build().connTimeOut(6000).readTimeOut(6000).execute(new StringCallback() {
1127
            @Override
1128
            @Override
1128
            public void onError(Call call, Exception e) {
1129
            public void onError(Call call, Exception e) {
1171
                    } else if ("init".equals(from)) {
1172
                    } else if ("init".equals(from)) {
1172
                        boolean certificated = false;
1173
                        boolean certificated = false;
1173
                        String chexing = "";
1174
                        String chexing = "";
1175
                        if (list.size()>0){
1176
                            MainApplication.userCertifiedModel="已认证";
1177
                        }
1174
                        for (CarOwnerCertificateBean bean : list) {
1178
                        for (CarOwnerCertificateBean bean : list) {
1175
                            if (bean.getStatus() == 1 && bean.getMain() == 1) {
1179
                            if (bean.getStatus() == 1 && bean.getMain() == 1) {
1176
                                certificated = true;
1180
                                certificated = true;
1182
                            Gson gson = new Gson();
1186
                            Gson gson = new Gson();
1183
                            CarSeriesEntity carSeriesEntity = gson.fromJson(chexing, CarSeriesEntity.class);
1187
                            CarSeriesEntity carSeriesEntity = gson.fromJson(chexing, CarSeriesEntity.class);
1184
                            car_owner_certificate_label.setText(carSeriesEntity.getSeriesName());
1188
                            car_owner_certificate_label.setText(carSeriesEntity.getSeriesName());
1189
                            MainApplication.userCertifiedModel=carSeriesEntity.getSeriesName();
1185
                        } else {
1190
                        } else {
1186
                            car_owner_certificate_label.setText("认证车主获取充电优惠");
1191
                            car_owner_certificate_label.setText("认证车主获取充电优惠");
1187
                        }
1192
                        }

+ 3 - 0
app/src/main/java/com/electric/chargingpile/activity/UserCenterMoreActivity.java

434
                ImageTools.deletePhotoAtPathAndName(MainApplication.storePath, "user_icon");
434
                ImageTools.deletePhotoAtPathAndName(MainApplication.storePath, "user_icon");
435
            }
435
            }
436
        }
436
        }
437
438
        MainApplication.userCertifiedModel="";
439
437
    }
440
    }
438
441
439
    private boolean isPermissionOK() {
442
    private boolean isPermissionOK() {

+ 4 - 1
app/src/main/java/com/electric/chargingpile/activity/UserInfoActivity.java

21
import android.os.Bundle;
21
import android.os.Bundle;
22
import android.os.Environment;
22
import android.os.Environment;
23
import android.os.Handler;
23
import android.os.Handler;
24
import android.os.Looper;
24
import android.os.Message;
25
import android.os.Message;
25
import android.provider.MediaStore;
26
import android.provider.MediaStore;
26
27
418
                break;
419
                break;
419
            case R.id.carIntentModel:
420
            case R.id.carIntentModel:
420
                CarBrandActivity.actionStart(this,"1");
421
                CarBrandActivity.actionStart(this,"1");
422
//                startActivityForResult(new Intent(UserInfoActivity.this, SelectCarActivity.class), 11);
423
421
                break;
424
                break;
422
        }
425
        }
423
    }
426
    }
881
    }
884
    }
882
885
883
886
884
    Handler handle = new Handler() {
887
    Handler handle = new Handler(Looper.getMainLooper()) {
885
        public void handleMessage(Message msg) {
888
        public void handleMessage(Message msg) {
886
            switch (msg.what) {
889
            switch (msg.what) {
887
                case StatusConstants.REQUEST_WHAT_SUCCESS:
890
                case StatusConstants.REQUEST_WHAT_SUCCESS:

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

16
import com.blankj.utilcode.util.LogUtils;
16
import com.blankj.utilcode.util.LogUtils;
17
import com.blankj.utilcode.util.Utils;
17
import com.blankj.utilcode.util.Utils;
18
import com.electric.chargingpile.BuildConfig;
18
import com.electric.chargingpile.BuildConfig;
19
import com.electric.chargingpile.activity.MainMapActivity;
19
import com.electric.chargingpile.data.AdDetail;
20
import com.electric.chargingpile.data.AdDetail;
21
import com.electric.chargingpile.data.CarOwnerCertificateBean;
20
import com.electric.chargingpile.data.Zhan;
22
import com.electric.chargingpile.data.Zhan;
23
import com.electric.chargingpile.entity.CarSeriesEntity;
21
import com.electric.chargingpile.gen.DaoMaster;
24
import com.electric.chargingpile.gen.DaoMaster;
22
import com.electric.chargingpile.gen.DaoSession;
25
import com.electric.chargingpile.gen.DaoSession;
23
import com.electric.chargingpile.manager.ProfileManager;
26
import com.electric.chargingpile.manager.ProfileManager;
27
import com.electric.chargingpile.util.DES3;
28
import com.electric.chargingpile.util.JsonUtils;
24
import com.electric.chargingpile.util.SharedPreferencesHelper;
29
import com.electric.chargingpile.util.SharedPreferencesHelper;
30
import com.google.gson.Gson;
25
import com.mob.MobSDK;
31
import com.mob.MobSDK;
26
import com.nostra13.universalimageloader.cache.disc.naming.Md5FileNameGenerator;
32
import com.nostra13.universalimageloader.cache.disc.naming.Md5FileNameGenerator;
27
import com.nostra13.universalimageloader.core.DisplayImageOptions;
33
import com.nostra13.universalimageloader.core.DisplayImageOptions;
30
import com.nostra13.universalimageloader.core.assist.ImageScaleType;
36
import com.nostra13.universalimageloader.core.assist.ImageScaleType;
31
import com.tencent.bugly.crashreport.CrashReport;
37
import com.tencent.bugly.crashreport.CrashReport;
32
import com.zhy.http.okhttp.OkHttpUtils;
38
import com.zhy.http.okhttp.OkHttpUtils;
39
import com.zhy.http.okhttp.callback.StringCallback;
33

40

41
import java.io.BufferedReader;
42
import java.io.BufferedWriter;
34
import java.io.File;
43
import java.io.File;
35
import java.io.IOException;
44
import java.io.IOException;
45
import java.io.InputStreamReader;
46
import java.io.OutputStreamWriter;
47
import java.io.PrintWriter;
48
import java.net.Socket;
49
import java.net.URLEncoder;
36
import java.util.ArrayList;
50
import java.util.ArrayList;
37
import java.util.HashMap;
51
import java.util.HashMap;
38
import java.util.List;
52
import java.util.List;
39
import java.util.Map;
53
import java.util.Map;
40

54

41
import cn.jpush.android.api.JPushInterface;
55
import cn.jpush.android.api.JPushInterface;
56
import okhttp3.Call;
42

57

43

58

44
public class MainApplication extends MultiDexApplication {
59
public class MainApplication extends MultiDexApplication {
56
    public static String userId = "";
71
    public static String userId = "";
57
    public static String userCar = "";
72
    public static String userCar = "";
58
    public static String userIcon = "";
73
    public static String userIcon = "";
59
    public static String userCarIntentMode="";
74
    public static String userCertifiedModel=""; //用户认证车型 此处仅为一个作为一个标识,如果有,则表示已认证过
75
    public static String userCarIntentMode="";  //用户意向车型
60
    public static LatLng center = null; // 用户位置
76
    public static LatLng center = null; // 用户位置
61
    public static String userNickname = "";
77
    public static String userNickname = "";
62
    public static String mapStatus = "";
78
    public static String mapStatus = "";
240
            ProfileManager.getInstance().setCount(getApplicationContext(), 0);
256
            ProfileManager.getInstance().setCount(getApplicationContext(), 0);
241
            ProfileManager.getInstance().setMaxCount(getApplicationContext(), 4);
257
            ProfileManager.getInstance().setMaxCount(getApplicationContext(), 4);
242

258

243
            if (userCar.equals("")){
244
                int max = ProfileManager.getInstance().getMaxCarModelCount(getApplicationContext());
245
                carCount=ProfileManager.getInstance().getCarModelCount(getApplicationContext()) + 1;
246
                Log.e("carCount ***-", carCount + "");
247
                int count =carCount >= max  ? 0 :carCount;
248
                ProfileManager.getInstance().setCarModelCount(getApplicationContext(), count);
249
            }else{
250
                ProfileManager.getInstance().setCarModelCount(getApplicationContext(), 0);
251
                ProfileManager.getInstance().setMaxCarModelCount(getApplicationContext(), 4);
252
            }
259
            new Thread(()->{
260
                try {
261
                    String host = "";
262
                    if (MainApplication.url.contains("cdz.evcharge.cc")) {
263
                        host = "cdz.evcharge.cc";
264
                    } else {
265
                        host = "59.110.68.162";
266
                    }
267
                    Socket socket = new Socket(host, 9503); // IP:10.14.114.127,端口54321
268
                    // 向服务器发送消息
269
                    PrintWriter out = new PrintWriter(new BufferedWriter(
270
                            new OutputStreamWriter(socket.getOutputStream())), true);
271
                    out.println("{\"fun\":\"timer\"}");
272
                    // out.println("{\"fun\":\"getcity\"}");
273
                    // 接收来自服务器的消息
274
                    BufferedReader br = new BufferedReader(new InputStreamReader(
275
                            socket.getInputStream()));
276
                    String msg = br.readLine();
277

278
                    int time = (int) (System.currentTimeMillis() / 1000);
279
                    MainMapActivity.cha = time - Integer.parseInt(msg);
280

281
                    long tokenTime = System.currentTimeMillis() / 1000 - MainMapActivity.cha - 1;
282
                    String token = null;
283
                    try {
284
                        token = DES3.encode(String.valueOf(tokenTime));
285
                        token = URLEncoder.encode(token, "UTF-8");
286
                    } catch (Exception e) {
287
                        e.printStackTrace();
288
                    }
289

290
                    String url = MainApplication.url + "/zhannew/basic/web/index.php/car/my?userid=" + MainApplication.userId + "&order=1" + "&token=" + token;
291
                    Log.e("TAG -- hyc", "getCarOwnerCertificateList: "+url);
292
                    OkHttpUtils.get().url(url).build().connTimeOut(6000).readTimeOut(6000).execute(new StringCallback() {
293

294
                        @Override
295
                        public void onError(Call call, Exception e) {
296

297
                        }
298

299
                        @Override
300
                        public void onResponse(String response) {
301
                            String rtnCode = JsonUtils.getKeyResult(response, "rtnCode");
302
                            if ("01".equals(rtnCode)) {
303
                                String chexing = "";
304
                                String data = JsonUtils.getKeyResult(response, "data");
305
                                List<CarOwnerCertificateBean> list = JsonUtils.parseToObjectList(data, CarOwnerCertificateBean.class);
306
                                boolean certificated = false;
307
                                for (CarOwnerCertificateBean bean : list) {
308
                                    chexing = bean.getChexing();
309
                                    certificated = true;
310
                                }
311
                                if (certificated) {
312
                                    Gson gson = new Gson();
313
                                    CarSeriesEntity carSeriesEntity = gson.fromJson(chexing, CarSeriesEntity.class);
314
                                    userCertifiedModel= carSeriesEntity.getSeriesName();
315
                                }
316

317
                                if (userCertifiedModel.equals("")){
318
                                    int max = ProfileManager.getInstance().getMaxCarModelCount(getApplicationContext());
319
                                    carCount=ProfileManager.getInstance().getCarModelCount(getApplicationContext()) + 1;
320
                                    int count =carCount >= max  ? 0 :carCount;
321
                                    ProfileManager.getInstance().setCarModelCount(getApplicationContext(), count);
322
                                }else{
323
                                    ProfileManager.getInstance().setCarModelCount(getApplicationContext(),0);
324
                                    ProfileManager.getInstance().setMaxCarModelCount(getApplicationContext(), 4);
325
                                }
326
                            }
327
                        }
328
                    });
329
                }catch (Exception e){
330

331
                }
332
            }).start();
253

333

254
        }
334
        }
255
    }
335
    }

+ 1 - 1
app/src/main/java/com/electric/chargingpile/data/CarOwnerCertificateBean.java

10
    private String chexing;
10
    private String chexing;
11
    private String regdate;
11
    private String regdate;
12
    private String cartype;
12
    private String cartype;
13
    private int status;
13
    private int status; //状态为1 表示通过审核,状态为2表示意向车型。
14
    private int main;
14
    private int main;
15
    private String addTime;
15
    private String addTime;
16
    private String errmsg;
16
    private String errmsg;