Commit d9f4ba632f498a49bc6985d54b382a3c3f06c1a1

Authored by xiongwei
1 parent a41324295d
Exists in master

电子保卡接口的调试

PersonalCenter/app/src/main/java/com/hjx/personalcenter/activity/ChoiseTextBookActivity.java
1 1 package com.hjx.personalcenter.activity;
2 2  
  3 +import android.content.Intent;
3 4 import android.os.Bundle;
  5 +import android.os.Handler;
  6 +import android.os.Message;
4 7 import android.support.v7.app.AppCompatActivity;
5 8 import android.view.View;
6 9 import android.widget.Button;
... ... @@ -9,6 +12,11 @@ import android.widget.SimpleAdapter;
9 12  
10 13 import com.hjx.personalcenter.R;
11 14 import com.hjx.personalcenter.customdialog.ElectronicCardDialog;
  15 +import com.hjx.personalcenter.http.HttpCode;
  16 +import com.hjx.personalcenter.http.HttpManager;
  17 +
  18 +import org.json.JSONException;
  19 +import org.json.JSONObject;
12 20  
13 21 import java.util.ArrayList;
14 22 import java.util.HashMap;
... ... @@ -34,6 +42,40 @@ public class ChoiseTextBookActivity extends AppCompatActivity implements View.On
34 42 private String[] publish = { "人民教育出版社", "人民教育出版社", "人民教育出版社",
35 43 "人民教育出版社", "人民教育出版社", "人民教育出版社", "人民教育出版社",
36 44 "人民教育出版社", "人民教育出版社" };
  45 +
  46 +
  47 + Handler handler = new Handler(){
  48 + @Override
  49 + public void handleMessage(Message msg) {
  50 + super.handleMessage(msg);
  51 + JSONObject jsonObject;
  52 + String status;
  53 + switch (msg.what){
  54 + case HttpCode.CHECKCARD:
  55 + try {
  56 + jsonObject = new JSONObject( (String) msg.obj);
  57 + status = jsonObject.optString("status");
  58 + if (status.equals("1")){
  59 + Intent intent = new Intent();
  60 + intent.setClass(ChoiseTextBookActivity.this, TheStartPageActivity.class);
  61 + ChoiseTextBookActivity.this.startActivity(intent);
  62 + overridePendingTransition(R.anim.rightin, R.anim.rightout);
  63 + finish();
  64 + }else if(status.equals("0")){
  65 + ElectronicCardDialog.getInstance().show(getSupportFragmentManager(), "ElectronicCardDialog");
  66 + }
  67 +
  68 + } catch (JSONException e) {
  69 + e.printStackTrace();
  70 + }
  71 +
  72 + break;
  73 +
  74 + }
  75 +
  76 + }
  77 + };
  78 +
37 79 @Override
38 80 protected void onCreate(Bundle savedInstanceState) {
39 81 super.onCreate(savedInstanceState);
... ... @@ -80,7 +122,7 @@ public class ChoiseTextBookActivity extends AppCompatActivity implements View.On
80 122 public void onClick(View v) {
81 123 switch (v.getId()){
82 124 case R.id.btn_ok:
83   - ElectronicCardDialog.getInstance().show(getSupportFragmentManager(), "ElectronicCardDialog");
  125 + HttpManager.getInstance().cardinfocheck(this,836,handler);
84 126 break;
85 127 }
86 128  
... ...
PersonalCenter/app/src/main/java/com/hjx/personalcenter/activity/ElectronicCardInfoOKActivity.java
... ... @@ -67,7 +67,7 @@ public class ElectronicCardInfoOKActivity extends Activity implements View.OnCli
67 67 public void onClick(View v) {
68 68 switch (v.getId()){
69 69 case R.id.btn_finish:
70   - HttpManager.getInstance().subcardinfo(this,636,usename.getText().toString().trim(),
  70 + HttpManager.getInstance().subcardinfo(this,736,usename.getText().toString().trim(),
71 71 customer_address.getText().toString().trim(),shopadress.getText().toString().trim(),
72 72 shoptime.getText().toString().trim(),tlePhone.getText().toString().trim(),
73 73 deviceModel.getText().toString().trim(),deviceNumber.getText().toString().trim(),
... ...
PersonalCenter/app/src/main/java/com/hjx/personalcenter/activity/ElectronicCardLookInfoActivity.java
... ... @@ -2,6 +2,8 @@ package com.hjx.personalcenter.activity;
2 2  
3 3 import android.content.Intent;
4 4 import android.os.Bundle;
  5 +import android.os.Handler;
  6 +import android.os.Message;
5 7 import android.support.v7.app.AppCompatActivity;
6 8 import android.view.View;
7 9 import android.widget.ImageView;
... ... @@ -10,8 +12,14 @@ import android.widget.TextView;
10 12 import com.hjx.personalcenter.R;
11 13 import com.hjx.personalcenter.db.Content;
12 14 import com.hjx.personalcenter.db.SaveParam;
  15 +import com.hjx.personalcenter.http.HttpCode;
  16 +import com.hjx.personalcenter.http.HttpManager;
  17 +import com.hjx.personalcenter.util.AlertUtils;
13 18 import com.hjx.personalcenter.util.GetDevicesUtil;
14 19  
  20 +import org.json.JSONException;
  21 +import org.json.JSONObject;
  22 +
15 23 /**
16 24 * Created by h on 2017/8/11.
17 25 */
... ... @@ -21,6 +29,34 @@ public class ElectronicCardLookInfoActivity extends AppCompatActivity implements
21 29 private TextView usename,deviceModel,customer_address,mac_adress,shoptime,deviceNumber,
22 30 shopadress,phone,tlePhone,tv_card_adress_change,tv_card_phone_change;
23 31  
  32 + Handler handler = new Handler(){
  33 + @Override
  34 + public void handleMessage(Message msg) {
  35 + super.handleMessage(msg);
  36 + JSONObject jsonObject;
  37 + String status;
  38 + switch (msg.what){
  39 + case HttpCode.SUCHCARDINFO:
  40 + try {
  41 + jsonObject = new JSONObject( (String) msg.obj);
  42 + status = jsonObject.optString("status");
  43 + if (status.equals("1")){
  44 + AlertUtils.showToast(ElectronicCardLookInfoActivity.this,"显示电子保卡信息");
  45 + }else {
  46 + AlertUtils.showToast(ElectronicCardLookInfoActivity.this,"保卡信息查询失败");
  47 + }
  48 +
  49 + } catch (JSONException e) {
  50 + e.printStackTrace();
  51 + }
  52 +
  53 + break;
  54 +
  55 + }
  56 +
  57 + }
  58 + };
  59 +
24 60 @Override
25 61 protected void onCreate(Bundle savedInstanceState) {
26 62 super.onCreate(savedInstanceState);
... ... @@ -44,6 +80,7 @@ public class ElectronicCardLookInfoActivity extends AppCompatActivity implements
44 80 tv_card_phone_change = (TextView) findViewById(R.id.tv_card_phone_change);
45 81 }
46 82 private void initData() {
  83 + HttpManager.getInstance().getcardinfo(this,736,handler);
47 84 //获取设备信息
48 85 deviceModel.setText(GetDevicesUtil.getDevicesInfo(this).getDeviceModel());
49 86 deviceNumber.setText(GetDevicesUtil.getDevicesInfo(this).getDeviceNumber());
... ...
PersonalCenter/app/src/main/java/com/hjx/personalcenter/activity/ElectronicCardValidationActivity.java
... ... @@ -86,11 +86,15 @@ public class ElectronicCardValidationActivity extends Activity implements View.O
86 86 private void initData() {
87 87 if (Content.authcodeflag==1){
88 88 menu_title.setText("填写保卡信息");
  89 + btn_card_valiyanzhen.setText("下一步");
89 90  
90 91 }else if (Content.authcodeflag==2){
91 92 menu_title.setText("修改保卡信息");
  93 + btn_card_valiyanzhen.setText("确定");
  94 +
92 95 }else {
93 96 menu_title.setText("更换绑定");
  97 + btn_card_valiyanzhen.setText("确定");
94 98 }
95 99  
96 100  
... ... @@ -107,11 +111,6 @@ public class ElectronicCardValidationActivity extends Activity implements View.O
107 111 public void onClick(View v) {
108 112 switch (v.getId()){
109 113 case R.id.btn_card_valiyanzhen:
110   - SaveParam.getInstance().saveCustomizeParam(this,SaveParam.CARDPHONE, phonenumber.getText().toString().trim());
111   - Intent intent = new Intent();
112   - intent.setClass(ElectronicCardValidationActivity.this, ElectronicCardEditInfoActivity.class);
113   - startActivity(intent);
114   - overridePendingTransition(R.anim.rightin, R.anim.rightout);
115 114  
116 115 String usernameStr = phonenumber.getText().toString().trim();
117 116 String authcodeStr = anth_6num.getText().toString().trim();
... ... @@ -125,11 +124,16 @@ public class ElectronicCardValidationActivity extends Activity implements View.O
125 124 AlertUtils.showToast(ElectronicCardValidationActivity.this, "您输入的验证码不正确");
126 125 }else {
127 126 if (Content.authcodeflag==1){
128   - menu_title.setText("填写保卡信息");
  127 + SaveParam.getInstance().saveCustomizeParam(this,SaveParam.CARDPHONE, phonenumber.getText().toString().trim());
  128 + Intent intent = new Intent();
  129 + intent.setClass(ElectronicCardValidationActivity.this, ElectronicCardEditInfoActivity.class);
  130 + startActivity(intent);
  131 + overridePendingTransition(R.anim.rightin, R.anim.rightout);
129 132  
130 133 }else if (Content.authcodeflag==2){
131   - //调用接口
132   - menu_title.setText("修改保卡信息");
  134 + //修改保卡手机号
  135 + HttpManager.getInstance().changecardinfophone(this,
  136 + 736,usernameStr,authcodeStr);
133 137 }else {
134 138 //修改手机号
135 139 menu_title.setText("更换绑定");
... ...
PersonalCenter/app/src/main/java/com/hjx/personalcenter/activity/MainActivity.java
... ... @@ -8,10 +8,14 @@ import android.widget.ImageView;
8 8 import android.widget.TextView;
9 9  
10 10 import com.hjx.personalcenter.R;
  11 +import com.mylhyl.circledialog.CircleDialog;
  12 +import com.mylhyl.circledialog.callback.ConfigInput;
  13 +import com.mylhyl.circledialog.params.InputParams;
  14 +import com.mylhyl.circledialog.view.listener.OnInputClickListener;
11 15  
12 16 public class MainActivity extends AppCompatActivity implements View.OnClickListener {
13   - private ImageView iv_imformatioan,iv_look_card,iv_setting;
14   - private TextView tv_edit_presoninfo;
  17 + private ImageView iv_imformatioan,iv_look_card,iv_setting,iv_sign;
  18 + private TextView tv_edit_presoninfo,tv_sign;
15 19 @Override
16 20 protected void onCreate(Bundle savedInstanceState) {
17 21 super.onCreate(savedInstanceState);
... ... @@ -26,6 +30,8 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
26 30 iv_look_card = (ImageView) findViewById(R.id.iv_look_card);
27 31 tv_edit_presoninfo = (TextView) findViewById(R.id.tv_edit_presoninfo);
28 32 iv_setting = (ImageView) findViewById(R.id.iv_setting);
  33 + iv_sign = (ImageView) findViewById(R.id.iv_sign);
  34 + tv_sign = (TextView) findViewById(R.id.tv_sign);
29 35 }
30 36  
31 37 private void initData() {
... ... @@ -37,6 +43,7 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
37 43 iv_look_card.setOnClickListener(this);
38 44 tv_edit_presoninfo.setOnClickListener(this);
39 45 iv_setting.setOnClickListener(this);
  46 + iv_sign.setOnClickListener(this);
40 47  
41 48 }
42 49  
... ... @@ -67,6 +74,29 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
67 74 startActivity(settingintent);
68 75 overridePendingTransition(R.anim.rightin, R.anim.rightout);
69 76 break;
  77 + case R.id.iv_sign:
  78 + new CircleDialog.Builder(this)
  79 + .setCanceledOnTouchOutside(false)
  80 + .setCancelable(true)
  81 + .setTitle("个性签名")
  82 + .setInputHint("请输入个性签名")
  83 + .setWidth(0.5f)
  84 + .configInput(new ConfigInput() {
  85 + @Override
  86 + public void onConfig(InputParams params) {
  87 +// params.inputBackgroundResourceId = R.drawable.bg_input;
  88 + }
  89 + })
  90 + .setNegative("取消", null)
  91 + .setPositiveInput("确定", new OnInputClickListener() {
  92 + @Override
  93 + public void onClick(String text, View v) {
  94 + tv_sign.setText(text);
  95 + }
  96 + })
  97 + .show();
  98 + break;
  99 +
70 100 }
71 101  
72 102 }
... ...
PersonalCenter/app/src/main/java/com/hjx/personalcenter/adapter/CitysAdapter.java
... ... @@ -0,0 +1,65 @@
  1 +package com.hjx.personalcenter.adapter;
  2 +
  3 +import android.content.Context;
  4 +import android.view.View;
  5 +import android.view.ViewGroup;
  6 +import android.widget.BaseAdapter;
  7 +import android.widget.TextView;
  8 +
  9 +import com.hjx.personalcenter.R;
  10 +import com.hjx.personalcenter.model.CityInfo;
  11 +
  12 +import java.util.ArrayList;
  13 +
  14 +/**
  15 + * Created by h on 2017/8/18.
  16 + */
  17 +
  18 +public class CitysAdapter extends BaseAdapter {
  19 + ArrayList<CityInfo.CitiesBean> objects;
  20 + private Context context;
  21 +
  22 + public CitysAdapter(ArrayList<CityInfo.CitiesBean> objects, Context context) {
  23 + this.objects = objects;
  24 + this.context = context;
  25 + }
  26 +
  27 + @Override
  28 + public int getCount() {
  29 + return objects.size();
  30 + }
  31 +
  32 + @Override
  33 + public Object getItem(int position) {
  34 + return position;
  35 + }
  36 +
  37 + @Override
  38 + public long getItemId(int position) {
  39 + return position;
  40 + }
  41 +
  42 + @Override
  43 + public View getView(final int position, View convertView, ViewGroup parent) {
  44 +
  45 + ProvincesAdapter.ViewHolder holder = null;
  46 +
  47 + if (convertView == null) {
  48 + convertView = View.inflate(context, R.layout.custom_adilog_list_item, null);
  49 + holder = new ProvincesAdapter.ViewHolder();
  50 + holder.nameText = (TextView) convertView.findViewById(R.id.list_items);
  51 + convertView.setTag(holder);
  52 + } else {
  53 + holder = (ProvincesAdapter.ViewHolder) convertView.getTag();
  54 + }
  55 +
  56 + holder.nameText.setText(objects.get(position).getRegionName());
  57 +
  58 + return convertView;
  59 + }
  60 +
  61 +
  62 + static class ViewHolder {
  63 + TextView nameText;
  64 + }
  65 +}
... ...
PersonalCenter/app/src/main/java/com/hjx/personalcenter/customdialog/CitysListDialog.java
... ... @@ -8,27 +8,28 @@ import android.view.LayoutInflater;
8 8 import android.view.View;
9 9 import android.view.ViewGroup;
10 10 import android.widget.AdapterView;
11   -import android.widget.ArrayAdapter;
12 11 import android.widget.ListView;
13 12  
14 13 import com.hjx.personalcenter.R;
  14 +import com.hjx.personalcenter.adapter.CitysAdapter;
15 15 import com.hjx.personalcenter.db.SaveParam;
16   -import com.hjx.personalcenter.http.HttpManager;
  16 +import com.hjx.personalcenter.interfaces.DialogCallBack;
  17 +import com.hjx.personalcenter.model.CityInfo;
17 18 import com.mylhyl.circledialog.BaseCircleDialog;
18 19 import com.mylhyl.circledialog.res.values.CircleDimen;
19 20  
20 21 import java.util.ArrayList;
21 22  
22 23 /**
23   - * 自定义级列表对话框
  24 + * 自定义级列表对话框
24 25 * Created by h on 2017/8/10.
25 26 */
26 27  
27 28 public class CitysListDialog extends BaseCircleDialog implements AdapterView.OnItemClickListener {
28   - ArrayAdapter listadapter;
29   - ListView listView;
30   - ArrayList<String> data = new ArrayList<>();
31   -
  29 + private CitysAdapter listadapter;
  30 + private ListView listView;
  31 + private DialogCallBack.CallBack mCallBack;
  32 + private ArrayList<CityInfo.CitiesBean> data = new ArrayList<>();
32 33 public static CitysListDialog getInstance() {
33 34 CitysListDialog dialogFragment = new CitysListDialog();
34 35 dialogFragment.setCanceledBack(true);
... ... @@ -50,19 +51,19 @@ public class CitysListDialog extends BaseCircleDialog implements AdapterView.OnI
50 51 super.onActivityCreated(savedInstanceState);
51 52 listView = (ListView) getView().findViewById(R.id.listadapter);
52 53 String provinces = SaveParam.getInstance().getLoginParam(getActivity(), SaveParam.CITYS);
53   - if (provinces != null) {
54   -
55   - for (int i = 0; i < provinces.split(",").length; i++) {
56   - String[] itmt = provinces.split(",");
57   - data.add(itmt[i] + "区");
58   - //data.add(i,provinces.replaceAll(",","省"));
59   -
60   - }
61   - } else {
62   - HttpManager.getInstance().provices(getActivity());
63   - }
64   -
65   - listadapter = new ArrayAdapter(getActivity(), R.layout.custom_adilog_list_item, R.id.list_items, data);
  54 +// if (provinces != null) {
  55 +//
  56 +// for (int i = 0; i < provinces.split(",").length; i++) {
  57 +// String[] itmt = provinces.split(",");
  58 +// data.add(itmt[i] + "区");
  59 +// //data.add(i,provinces.replaceAll(",","省"));
  60 +//
  61 +// }
  62 +// } else {
  63 +// HttpManager.getInstance().provices(getActivity());
  64 +// }
  65 +
  66 + listadapter = new CitysAdapter(data,getActivity());
66 67 listView.setAdapter(listadapter);
67 68 listView.setOnItemClickListener(this);
68 69  
... ...
PersonalCenter/app/src/main/java/com/hjx/personalcenter/db/SaveParam.java
... ... @@ -34,6 +34,7 @@ public class SaveParam {
34 34 sp.edit().putString(spname, spstr).commit();
35 35 }
36 36  
  37 +
37 38 public String getLoginParam(Context context,String spname) {
38 39 SharedPreferences sp = context.getSharedPreferences("loginparam",
39 40 Activity.MODE_PRIVATE);
... ...
PersonalCenter/app/src/main/java/com/hjx/personalcenter/http/HttpCode.java
... ... @@ -5,9 +5,10 @@ package com.hjx.personalcenter.http;
5 5 */
6 6  
7 7 public class HttpCode {
8   - //登录
9   - public static final int LONGIN_SUCESS = 1;
10   - public static final int LONGIN_FAIL = 0;
  8 + //查询保卡信息
  9 + public static final int SUCHCARDINFO = 1;
  10 + //是否填写保卡信息
  11 + public static final int CHECKCARD = 1;
11 12 //注册
12 13 public static final int REGISTERED_SUCESS = 2;
13 14 public static final int REGISTERED_FAIL = 3;
... ...
PersonalCenter/app/src/main/java/com/hjx/personalcenter/http/HttpManager.java
... ... @@ -35,6 +35,7 @@ import java.io.UnsupportedEncodingException;
35 35 public class HttpManager {
36 36 private static HttpManager instance;
37 37 private ProgressDialog mProgress = null;
  38 +
38 39 public static HttpManager getInstance() {
39 40 if (instance == null) {
40 41 instance = new HttpManager();
... ... @@ -62,22 +63,21 @@ public class HttpManager {
62 63 String access_token = jsonObject.getString("access_token");
63 64 String userId = jsonObject.getString("userId");
64 65 // //登录成功,保存登录数据并且获取个人信息
65   - saveLoginInfo(mContext,username, password, access_token, "true", userId);
  66 + saveLoginInfo(mContext, username, password, access_token, "true", userId);
66 67 //HttpManager.getInstance().getuserinfo(username,mContext);
67 68  
68   - }else if (status.equals("200")) {
  69 + } else if (status.equals("200")) {
69 70 closeProgress();
70 71 Toast.makeText(mContext, "用户名不存在!", Toast.LENGTH_LONG).show();
71 72 return;
72   - } else if(status.equals("204")){
  73 + } else if (status.equals("204")) {
73 74 closeProgress();
74 75 Toast.makeText(mContext, "密码错误!", Toast.LENGTH_LONG).show();
75   - }else{
  76 + } else {
76 77 closeProgress();
77 78 Toast.makeText(mContext, "登录失败!请检查网络", Toast.LENGTH_LONG).show();
78 79  
79 80  
80   -
81 81 }
82 82 } catch (JSONException e) {
83 83 e.printStackTrace();
... ... @@ -89,7 +89,7 @@ public class HttpManager {
89 89 @Override
90 90 public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) {
91 91 closeProgress();
92   - Toast.makeText(mContext, "请检查网络。。"+arg3 , Toast.LENGTH_LONG).show();
  92 + Toast.makeText(mContext, "请检查网络。。" + arg3, Toast.LENGTH_LONG).show();
93 93 }
94 94 });
95 95 }
... ... @@ -257,78 +257,186 @@ public class HttpManager {
257 257 }
258 258  
259 259 //保存用户登录信息
260   - public void saveLoginInfo(Context context,String username, String password, String access_token, String loginStatus, String userId) {
261   - SaveParam.getInstance().saveLoginParam(context,"username", username);
262   - SaveParam.getInstance().saveLoginParam(context,"password", password);
263   - SaveParam.getInstance().saveLoginParam(context,"access_token", access_token);
264   - SaveParam.getInstance().saveLoginParam(context,"login", loginStatus);
265   - SaveParam.getInstance().saveLoginParam(context,"userId", userId);
  260 + public void saveLoginInfo(Context context, String username, String password, String access_token, String loginStatus, String userId) {
  261 + SaveParam.getInstance().saveLoginParam(context, "username", username);
  262 + SaveParam.getInstance().saveLoginParam(context, "password", password);
  263 + SaveParam.getInstance().saveLoginParam(context, "access_token", access_token);
  264 + SaveParam.getInstance().saveLoginParam(context, "login", loginStatus);
  265 + SaveParam.getInstance().saveLoginParam(context, "userId", userId);
266 266  
267 267  
268 268 }
269 269  
270 270 //保存用户个人信息
271   - public void savePresonInfo(Context context,String lastname, String gender, String mobilePortrait) {
272   - SaveParam.getInstance().saveLoginParam(context,"lastname", lastname);
273   - SaveParam.getInstance().saveLoginParam(context,"gender", gender);
274   - SaveParam.getInstance().saveLoginParam(context,"mobilePortrait", mobilePortrait);
  271 + public void savePresonInfo(Context context, String lastname, String gender, String mobilePortrait) {
  272 + SaveParam.getInstance().saveLoginParam(context, "lastname", lastname);
  273 + SaveParam.getInstance().saveLoginParam(context, "gender", gender);
  274 + SaveParam.getInstance().saveLoginParam(context, "mobilePortrait", mobilePortrait);
275 275 }
  276 +
276 277 //提交保卡信息
277 278 public void subcardinfo(final Context context, int userId, String customerName, String customerAddress,
278   - String buyAddress,String buyTime,String alterSaleCall,
279   - String productModel,String deviceNumber,String macAddress,
  279 + String buyAddress, String buyTime, String alterSaleCall,
  280 + String productModel, String deviceNumber, String macAddress,
280 281 String mobilePhone) {
281   - JSONObject params = new JSONObject();
282   - ByteArrayEntity entity = null;
283   - try {
284   - params.put(HttpKey.USEID, userId);
285   - params.put(HttpKey.CUSTOMENAME, customerName);
286   - params.put(HttpKey.CUSTOMADRESS, customerAddress);
287   - params.put(HttpKey.BUYADREES, buyAddress);
288   - params.put(HttpKey.BUYTIME, buyTime);
289   - params.put(HttpKey.ALTERSALECALL, alterSaleCall);
290   - params.put(HttpKey.PRODUCTMODEL, productModel);
291   - params.put(HttpKey.DEVICENUMBER, deviceNumber);
292   - params.put(HttpKey.MACADRESS, macAddress);
293   - params.put(HttpKey.MOBILPHONE, mobilePhone);
294   - entity = new ByteArrayEntity(params.toString().getBytes("UTF-8"));
295   - entity.setContentType(new BasicHeader(HTTP.CONTENT_TYPE, "application/json"));
296   - } catch (Exception e) {
297   - e.printStackTrace();
298   - }
  282 + mProgress = DialogPermission.showProgress(context, null, "正在绑定保卡...",
  283 + false, true, null);
  284 + RequestParams params = new RequestParams();
  285 +
  286 + params.put(HttpKey.USEID, userId);
  287 + params.put(HttpKey.CUSTOMENAME, customerName);
  288 + params.put(HttpKey.CUSTOMADRESS, customerAddress);
  289 + params.put(HttpKey.BUYADREES, buyAddress);
  290 + params.put(HttpKey.BUYTIME, buyTime);
  291 + params.put(HttpKey.ALTERSALECALL, alterSaleCall);
  292 + params.put(HttpKey.PRODUCTMODEL, productModel);
  293 + params.put(HttpKey.DEVICENUMBER, deviceNumber);
  294 + params.put(HttpKey.MACADRESS, macAddress);
  295 + params.put(HttpKey.MOBILPHONE, mobilePhone);
299 296  
300 297 HttpClient.getInstance().addHeader("Accept", "*/*");
301 298  
302 299 Log.e("test", "params" + params);
303   - HttpClient.getInstance().post(context,HttpUrl.subcardinfo, entity, "application/json", new JsonHttpResponseHandler() {
  300 + HttpClient.getInstance().setTimeout(5 * 1000);
  301 + HttpClient.getInstance().post(context, HttpUrl.subcardinfo, params, new AsyncHttpResponseHandler() {
304 302 @Override
305   - public void onSuccess(int statusCode, Header[] headers, JSONObject response) {
306   - super.onSuccess(statusCode, headers, response);
307   - String status = response.optString("status");
  303 + public void onSuccess(int i, Header[] headers, byte[] bytes) {
  304 + JSONObject jsonObject = null;
  305 + closeProgress();
  306 + try {
  307 + jsonObject = new JSONObject(new String(bytes));
  308 + String status = jsonObject.optString("status");
308 309 if (status.equals("1")) {
309   - Log.e("test", "onSuccess" +response);
  310 + Log.e("test", "onSuccess" + jsonObject);
310 311 Toast.makeText(context, "保卡绑定成功!", Toast.LENGTH_LONG).show();
311 312 Intent intent = new Intent();
312   - intent.setClass((Activity) context,TheStartPageActivity.class);
  313 + intent.setClass((Activity) context, TheStartPageActivity.class);
313 314 ((Activity) context).startActivity(intent);
314 315 ((Activity) context).overridePendingTransition(R.anim.rightin, R.anim.rightout);
315 316 ((Activity) context).finish();
316 317 }
  318 + } catch (JSONException e) {
  319 + e.printStackTrace();
  320 + }
  321 +
317 322  
318 323 }
319 324  
320 325 @Override
321   - public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONObject errorResponse) {
322   - super.onFailure(statusCode, headers, throwable, errorResponse);
323   - Log.e("test", "onFailure" + (errorResponse));
324   - Toast.makeText(context, "保卡绑定失败!", Toast.LENGTH_LONG).show();
  326 + public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) {
  327 + Log.e("test", "onFailure" + (throwable));
  328 + closeProgress();
  329 + Toast.makeText(context, "保卡绑定失败!,请检查网络", Toast.LENGTH_LONG).show();
  330 +
325 331 }
326 332 });
327 333  
328 334 }
  335 + //获取保卡信息
  336 + public void getcardinfo(final Context mContext, int userId , final Handler handler) {
  337 + mProgress = DialogPermission.showProgress(mContext, null, "正在获取保卡信息...",
  338 + false, true, null);
  339 + HttpClient.getInstance().setTimeout(5 * 1000);
  340 + HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");
  341 + HttpClient.getInstance().get(HttpUrl.getcardinfo+ "?userId=" + userId , new AsyncHttpResponseHandler() {
  342 + @Override
  343 + public void onSuccess(int arg0, Header[] arg1, byte[] arg2) {
  344 + closeProgress();
  345 + Log.e("test", "省" + new String(arg2));
  346 + Message msg = Message.obtain();
  347 + msg.what = HttpCode.SUCHCARDINFO;
  348 + msg.obj = new String(arg2);
  349 + handler.sendMessage(msg);
  350 + }
  351 +
  352 + @Override
  353 + public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) {
  354 + closeProgress();
  355 + Toast.makeText(mContext, "请检查网络。。" , Toast.LENGTH_LONG).show();
  356 + }
  357 + });
  358 + }
  359 + //修改保卡信息电话
  360 + public void changecardinfophone(final Context mContext, int userId, final String customerPhone, String authCode) {
  361 + RequestParams params = new RequestParams();
  362 + params.put("userId", userId);
  363 + params.put("customerPhone", customerPhone);
  364 + params.put("authCode", authCode);
  365 + HttpClient.getInstance().addHeader("Accept", "*/*");
  366 + HttpClient.getInstance().post(HttpUrl.changecardinfo, params, new AsyncHttpResponseHandler() {
  367 + @Override
  368 + public void onSuccess(int i, Header[] headers, byte[] bytes) {
  369 + try {
  370 + JSONObject jsonObject = new JSONObject(new String(bytes));
  371 + String status = jsonObject.optString("status");
  372 + if (status.equals("1")) {
  373 + Toast.makeText(mContext, "手机号修改成功", Toast.LENGTH_LONG).show();
  374 + SaveParam.getInstance().saveCustomizeParam(mContext,SaveParam.CARDPHONE, customerPhone);
  375 + ((Activity) mContext).finish();
  376 + }else if (status.equals("1001")){
  377 + Toast.makeText(mContext, "验证码输入错误", Toast.LENGTH_LONG).show();
  378 + }
  379 + } catch (JSONException e) {
  380 + e.printStackTrace();
  381 + }
  382 + }
329 383  
  384 + @Override
  385 + public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) {
  386 + Log.e("test", "onFailure" + new String(bytes));
  387 + Toast.makeText(mContext, "请检查网络。。" + new String(bytes), Toast.LENGTH_LONG).show();
  388 + }
  389 + });
  390 + }
  391 + //修改保卡信息地址
  392 + public void changecardinfo(final Context mContext,int userId,String customerPhone,String authCode,String customerAddress) {
  393 + RequestParams params = new RequestParams();
  394 + params.put("userId", userId);
  395 + params.put("customerPhone", customerPhone);
  396 + params.put("authCode", authCode);
  397 + params.put("customerAddress", customerAddress);
  398 + HttpClient.getInstance().addHeader("Accept", "*/*");
  399 + HttpClient.getInstance().post(HttpUrl.changecardinfo, params, new AsyncHttpResponseHandler() {
  400 + @Override
  401 + public void onSuccess(int i, Header[] headers, byte[] bytes) {
  402 + try {
  403 + JSONObject jsonObject = new JSONObject(new String(bytes));
  404 + String status = jsonObject.optString("status");
  405 + if (status.equals("1")) {
  406 + Log.e("test", "省" + jsonObject);
  407 + Toast.makeText(mContext, "成功。。" + jsonObject, Toast.LENGTH_LONG).show();
  408 + }
  409 + } catch (JSONException e) {
  410 + e.printStackTrace();
  411 + }
  412 + }
330 413  
  414 + @Override
  415 + public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) {
  416 + Log.e("test", "onFailure" + new String(bytes));
  417 + Toast.makeText(mContext, "请检查网络。。" + new String(bytes), Toast.LENGTH_LONG).show();
  418 + }
  419 + });
  420 + }
  421 + //验证是否保卡信息
  422 + public void cardinfocheck(final Context mContext, int userId, final Handler handler) {
  423 + HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");
  424 + HttpClient.getInstance().get(HttpUrl.cardcheck+ "?userId=" + userId, new AsyncHttpResponseHandler() {
  425 + @Override
  426 + public void onSuccess(int arg0, Header[] arg1, byte[] arg2) {
  427 + Log.e("test", "省" + new String(arg2));
  428 + Message msg = Message.obtain();
  429 + msg.what = HttpCode.CHECKCARD;
  430 + msg.obj = new String(arg2);
  431 + handler.sendMessage(msg);
  432 + }
331 433  
  434 + @Override
  435 + public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) {
  436 + Toast.makeText(mContext, "请检查网络。。" + arg3, Toast.LENGTH_LONG).show();
  437 + }
  438 + });
  439 + }
332 440  
333 441  
334 442  
... ... @@ -341,42 +449,40 @@ public class HttpManager {
341 449 public void onSuccess(int arg0, Header[] arg1, byte[] arg2) {
342 450 Log.e("test", "省" + new String(arg2));
343 451 ProvinceInfo provinceInfo = GsonTool.getPerson(new String(arg2), ProvinceInfo.class);//解析json数据
344   - Log.e("test", "状态码" +provinceInfo.getStatus());
  452 + Log.e("test", "状态码" + provinceInfo.getStatus());
345 453 StringBuffer sb = new StringBuffer();
346   - StringBuffer sb1 = new StringBuffer();
347   - for (int i =0 ; i<provinceInfo.getProvinces().size();i++){
348   - sb.append(provinceInfo.getProvinces().get(i).getRegionName()+",");
349   - sb1.append(provinceInfo.getProvinces().get(i).getRegionId()+",");
  454 + for (int i = 0; i < provinceInfo.getProvinces().size(); i++) {
  455 + sb.append(provinceInfo.getProvinces().get(i).getRegionName() + ",");
350 456  
351 457 }
352   - Log.e("test", "省" +sb.toString());
353   - SaveParam.getInstance().saveLoginParam(mContext,SaveParam.PROVINCES, "" + sb.toString());
354   - SaveParam.getInstance().saveLoginParam(mContext,SaveParam.CITYS, sb1.toString());
  458 + Log.e("test", "省" + sb.toString());
  459 + SaveParam.getInstance().saveLoginParam(mContext, SaveParam.PROVINCES, "" + sb.toString());
355 460  
356 461  
357 462 }
358 463  
359 464 @Override
360 465 public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) {
361   - Toast.makeText(mContext, "请检查网络。。"+arg3 , Toast.LENGTH_LONG).show();
  466 + Toast.makeText(mContext, "请检查网络。。" + arg3, Toast.LENGTH_LONG).show();
362 467 }
363 468 });
364 469 }
  470 +
365 471 //市级接口
366   - public void cityinfo(final Context mContext,int regionId) {
  472 + public void cityinfo(final Context mContext, int regionId) {
367 473 HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");
368 474 HttpClient.getInstance().get(HttpUrl.cityUrl + "?regionId=" + regionId, new AsyncHttpResponseHandler() {
369 475 @Override
370 476 public void onSuccess(int arg0, Header[] arg1, byte[] arg2) {
371 477 Log.e("test", "市" + new String(arg2));
372 478 Gson gson = new Gson();
373   - CityInfo cityInfo = gson.fromJson(new String(arg2),CityInfo.class);
374   - for (int i =0 ; i<cityInfo.getCities().size();i++){
375   - Log.e("test", "市" +cityInfo.getCities().get(i)
  479 + CityInfo cityInfo = gson.fromJson(new String(arg2), CityInfo.class);
  480 + for (int i = 0; i < cityInfo.getCities().size(); i++) {
  481 + Log.e("test", "市" + cityInfo.getCities().get(i)
376 482 .getParentId());
377   - Log.e("test", "市" +cityInfo.getCities().get(i)
  483 + Log.e("test", "市" + cityInfo.getCities().get(i)
378 484 .getRegionId());
379   - Log.e("test", "市" +cityInfo.getCities().get(i).getRegionName()+"");
  485 + Log.e("test", "市" + cityInfo.getCities().get(i).getRegionName() + "");
380 486  
381 487 }
382 488  
... ... @@ -385,25 +491,26 @@ public class HttpManager {
385 491  
386 492 @Override
387 493 public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) {
388   - Toast.makeText(mContext, "请检查网络。。"+arg3 , Toast.LENGTH_LONG).show();
  494 + Toast.makeText(mContext, "请检查网络。。" + arg3, Toast.LENGTH_LONG).show();
389 495 }
390 496 });
391 497 }
  498 +
392 499 //区县级接口
393   - public void countyinfo(final Context mContext,int parentId) {
  500 + public void countyinfo(final Context mContext, int parentId) {
394 501 HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");
395 502 HttpClient.getInstance().get(HttpUrl.countyUrl + "?regionId=" + parentId, new AsyncHttpResponseHandler() {
396 503 @Override
397 504 public void onSuccess(int arg0, Header[] arg1, byte[] arg2) {
398 505 Log.e("test", "区" + new String(arg2));
399 506 Gson gson = new Gson();
400   - CountyInfo countyInfo = gson.fromJson(new String(arg2),CountyInfo.class);
401   - for (int i =0 ; i<countyInfo.getCounties().size();i++){
402   - Log.e("test", "区" +countyInfo.getCounties().get(i)
  507 + CountyInfo countyInfo = gson.fromJson(new String(arg2), CountyInfo.class);
  508 + for (int i = 0; i < countyInfo.getCounties().size(); i++) {
  509 + Log.e("test", "区" + countyInfo.getCounties().get(i)
403 510 .getParentId());
404   - Log.e("test", "区" +countyInfo.getCounties().get(i)
  511 + Log.e("test", "区" + countyInfo.getCounties().get(i)
405 512 .getRegionId());
406   - Log.e("test", "区" +countyInfo.getCounties().get(i).getRegionName()+"");
  513 + Log.e("test", "区" + countyInfo.getCounties().get(i).getRegionName() + "");
407 514  
408 515 }
409 516  
... ... @@ -412,7 +519,7 @@ public class HttpManager {
412 519  
413 520 @Override
414 521 public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) {
415   - Toast.makeText(mContext, "请检查网络。。"+arg3 , Toast.LENGTH_LONG).show();
  522 + Toast.makeText(mContext, "请检查网络。。" + arg3, Toast.LENGTH_LONG).show();
416 523 }
417 524 });
418 525 }
... ...
PersonalCenter/app/src/main/java/com/hjx/personalcenter/http/HttpUrl.java
... ... @@ -21,5 +21,8 @@ public class HttpUrl {
21 21 public static String isRegiterUrl=GetDomain()+"/ozing/timer/user/registered";//手机号是否注册
22 22 public static String changepassword=GetDomain()+"/ozing/timer/user/changepassword";//修改密码
23 23 public static String subcardinfo=GetDomain()+"/electronicCard/addCustomer";//提交保卡信息
  24 + public static String getcardinfo=GetDomain()+"/electronicCard/info";//得到保卡信息
  25 + public static String changecardinfo=GetDomain()+"/electronicCard/updateByUserId";//修改保卡信息
  26 + public static String cardcheck=GetDomain()+"/electronicCard/check";//检查保卡是否填写
24 27  
25 28 }
... ...
PersonalCenter/app/src/main/java/com/hjx/personalcenter/model/CardInfo.java
... ... @@ -0,0 +1,113 @@
  1 +package com.hjx.personalcenter.model;
  2 +
  3 +/**
  4 + * Created by h on 2017/8/18.
  5 + */
  6 +
  7 +public class CardInfo {
  8 +
  9 + /**
  10 + * customerName : FuQiang
  11 + * createTime : 2017-08-01 13:21:00
  12 + * mobilePhone : 13162530008
  13 + * buyTime : 2017-08-01 12:23:50
  14 + * productModel : GT-N7100
  15 + * buyAddress : HaojixingZhengZhou
  16 + * customerAddress : HeNamZhengSheng
  17 + * alterSaleCall : 4022210201
  18 + * macAddress : 00:22:F4:93:7A:B
  19 +
  20 + * deviceNumber : A909A90997011012
  21 + */
  22 +
  23 + private String customerName;
  24 + private String createTime;
  25 + private String mobilePhone;
  26 + private String buyTime;
  27 + private String productModel;
  28 + private String buyAddress;
  29 + private String customerAddress;
  30 + private String alterSaleCall;
  31 + private String macAddress;
  32 + private String deviceNumber;
  33 +
  34 + public String getCustomerName() {
  35 + return customerName;
  36 + }
  37 +
  38 + public void setCustomerName(String customerName) {
  39 + this.customerName = customerName;
  40 + }
  41 +
  42 + public String getCreateTime() {
  43 + return createTime;
  44 + }
  45 +
  46 + public void setCreateTime(String createTime) {
  47 + this.createTime = createTime;
  48 + }
  49 +
  50 + public String getMobilePhone() {
  51 + return mobilePhone;
  52 + }
  53 +
  54 + public void setMobilePhone(String mobilePhone) {
  55 + this.mobilePhone = mobilePhone;
  56 + }
  57 +
  58 + public String getBuyTime() {
  59 + return buyTime;
  60 + }
  61 +
  62 + public void setBuyTime(String buyTime) {
  63 + this.buyTime = buyTime;
  64 + }
  65 +
  66 + public String getProductModel() {
  67 + return productModel;
  68 + }
  69 +
  70 + public void setProductModel(String productModel) {
  71 + this.productModel = productModel;
  72 + }
  73 +
  74 + public String getBuyAddress() {
  75 + return buyAddress;
  76 + }
  77 +
  78 + public void setBuyAddress(String buyAddress) {
  79 + this.buyAddress = buyAddress;
  80 + }
  81 +
  82 + public String getCustomerAddress() {
  83 + return customerAddress;
  84 + }
  85 +
  86 + public void setCustomerAddress(String customerAddress) {
  87 + this.customerAddress = customerAddress;
  88 + }
  89 +
  90 + public String getAlterSaleCall() {
  91 + return alterSaleCall;
  92 + }
  93 +
  94 + public void setAlterSaleCall(String alterSaleCall) {
  95 + this.alterSaleCall = alterSaleCall;
  96 + }
  97 +
  98 + public String getMacAddress() {
  99 + return macAddress;
  100 + }
  101 +
  102 + public void setMacAddress(String macAddress) {
  103 + this.macAddress = macAddress;
  104 + }
  105 +
  106 + public String getDeviceNumber() {
  107 + return deviceNumber;
  108 + }
  109 +
  110 + public void setDeviceNumber(String deviceNumber) {
  111 + this.deviceNumber = deviceNumber;
  112 + }
  113 +}
... ...
PersonalCenter/app/src/main/res/layout/activity_main.xml
... ... @@ -141,6 +141,7 @@
141 141 android:orientation="horizontal">
142 142  
143 143 <TextView
  144 + android:id="@+id/tv_sign"
144 145 android:layout_width="0dp"
145 146 android:layout_height="wrap_content"
146 147 android:layout_weight="5"
... ... @@ -148,6 +149,7 @@
148 149 android:textSize="18sp" />
149 150  
150 151 <ImageView
  152 + android:id="@+id/iv_sign"
151 153 android:layout_width="0dp"
152 154 android:layout_height="wrap_content"
153 155 android:layout_weight="1"
... ...