Selaa lähdekoodia

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

hy 3 vuotta sitten
vanhempi
commit
f42bc42a85

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

@ -25,6 +25,7 @@ import com.electric.chargingpile.event.CarModelEvent;
25 25
import com.electric.chargingpile.event.CarSeriesEvent;
26 26
import com.electric.chargingpile.manager.ProfileManager;
27 27
import com.electric.chargingpile.util.BarColorUtil;
28
import com.electric.chargingpile.util.DES3;
28 29
import com.electric.chargingpile.util.JsonUtils;
29 30
import com.electric.chargingpile.util.LoadingDialog;
30 31
import com.electric.chargingpile.util.ToastUtil;
@ -34,10 +35,16 @@ import com.zhy.http.okhttp.OkHttpUtils;
34 35
import com.zhy.http.okhttp.callback.StringCallback;
35 36
36 37
import org.greenrobot.eventbus.EventBus;
38
import org.jetbrains.annotations.NotNull;
37 39
38 40
import java.util.ArrayList;
41
import java.util.HashMap;
42
import java.util.Map;
39 43
40 44
import okhttp3.Call;
45
46
import static com.electric.chargingpile.activity.CarBrandActivity.sourceType;
47
41 48
/**
42 49
 * 车型选择
43 50
 * */
@ -80,8 +87,81 @@ public class CarModelActivity extends AppCompatActivity implements View.OnClickL
80 87
        adapter.setOnChildClickListener(new GroupedRecyclerViewAdapter.OnChildClickListener() {
81 88
            @Override
82 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 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 165
                    MainApplication.userCarIntentMode= carSeriesEntity.getSeriesName();
86 166
                    ProfileManager.getInstance().setCarIntentModel(CarModelActivity.this,carSeriesEntity.getSeriesName());
87 167
                    if (sourceType.equals("1")){
@ -90,33 +170,11 @@ public class CarModelActivity extends AppCompatActivity implements View.OnClickL
90 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 180
    private void getModelList() {

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

@ -713,7 +713,7 @@ public class ChargingStatusActivity extends Activity implements View.OnClickList
713 713
    protected void onResume() {
714 714
        super.onResume();
715 715
        MobclickAgent.onResume(this);
716
        if (MainApplication.userCar.equals("")){
716
        if (MainApplication.userCertifiedModel.equals("")){
717 717
            layoutCarCertificate.setVisibility(View.VISIBLE);
718 718
        }else{
719 719
            layoutCarCertificate.setVisibility(View.GONE);

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

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

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

@ -434,6 +434,9 @@ public class UserCenterMoreActivity extends Activity implements View.OnClickList
434 434
                ImageTools.deletePhotoAtPathAndName(MainApplication.storePath, "user_icon");
435 435
            }
436 436
        }
437
438
        MainApplication.userCertifiedModel="";
439
437 440
    }
438 441
439 442
    private boolean isPermissionOK() {

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

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

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

@ -16,12 +16,18 @@ import com.amap.api.maps.model.LatLng;
16 16
import com.blankj.utilcode.util.LogUtils;
17 17
import com.blankj.utilcode.util.Utils;
18 18
import com.electric.chargingpile.BuildConfig;
19
import com.electric.chargingpile.activity.MainMapActivity;
19 20
import com.electric.chargingpile.data.AdDetail;
21
import com.electric.chargingpile.data.CarOwnerCertificateBean;
20 22
import com.electric.chargingpile.data.Zhan;
23
import com.electric.chargingpile.entity.CarSeriesEntity;
21 24
import com.electric.chargingpile.gen.DaoMaster;
22 25
import com.electric.chargingpile.gen.DaoSession;
23 26
import com.electric.chargingpile.manager.ProfileManager;
27
import com.electric.chargingpile.util.DES3;
28
import com.electric.chargingpile.util.JsonUtils;
24 29
import com.electric.chargingpile.util.SharedPreferencesHelper;
30
import com.google.gson.Gson;
25 31
import com.mob.MobSDK;
26 32
import com.nostra13.universalimageloader.cache.disc.naming.Md5FileNameGenerator;
27 33
import com.nostra13.universalimageloader.core.DisplayImageOptions;
@ -30,15 +36,24 @@ import com.nostra13.universalimageloader.core.ImageLoaderConfiguration;
30 36
import com.nostra13.universalimageloader.core.assist.ImageScaleType;
31 37
import com.tencent.bugly.crashreport.CrashReport;
32 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 43
import java.io.File;
35 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 50
import java.util.ArrayList;
37 51
import java.util.HashMap;
38 52
import java.util.List;
39 53
import java.util.Map;
40 54

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

43 58

44 59
public class MainApplication extends MultiDexApplication {
@ -56,7 +71,8 @@ public class MainApplication extends MultiDexApplication {
56 71
    public static String userId = "";
57 72
    public static String userCar = "";
58 73
    public static String userIcon = "";
59
    public static String userCarIntentMode="";
74
    public static String userCertifiedModel=""; //用户认证车型 此处仅为一个作为一个标识,如果有,则表示已认证过
75
    public static String userCarIntentMode="";  //用户意向车型
60 76
    public static LatLng center = null; // 用户位置
61 77
    public static String userNickname = "";
62 78
    public static String mapStatus = "";
@ -240,16 +256,80 @@ public class MainApplication extends MultiDexApplication {
240 256
            ProfileManager.getInstance().setCount(getApplicationContext(), 0);
241 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,7 +10,7 @@ public class CarOwnerCertificateBean implements Serializable {
10 10
    private String chexing;
11 11
    private String regdate;
12 12
    private String cartype;
13
    private int status;
13
    private int status; //状态为1 表示通过审核,状态为2表示意向车型。
14 14
    private int main;
15 15
    private String addTime;
16 16
    private String errmsg;