private void initData() { // TODO Auto-generated method stub try { RequestState = 4; // Is_Internet=appContext.getCartListByPage(ShoppingCartActivity.this, // appContext.getLoginUid(), networkHelper); if (appContext.isLogin()) { ApiClient.getCartListByPage(getActivity(), appContext.getLoginUid(), networkHelper); } // Toast.makeText(ShoppingCartActivity.this, "请检查网络是否连接",Toast.LENGTH_SHORT).show(); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } }
@Override public void onDataChanged(String data) { // TODO Auto-generated method stub JSONObject jsonObject = null; int code = -1; String content = null; try { jsonObject = new JSONObject(data); code = jsonObject.getInt("code"); content = jsonObject.getString("data"); } catch (JSONException e1) { e1.printStackTrace(); } if (code == 0) { if (requestCode.equals("CODE")) { // 获取的是验证码 Toast.makeText(this, content, Toast.LENGTH_SHORT).show(); System.out.println("获取验证码成功"); // }else if (requestCode.equals("CHECK")) { // requestCode="SUB"; // ApiClient.bindPhone(this, appContext.getLoginUid()+"", // etCheckCode.getText().toString(), // etNewNumber.getText().toString(), networkHelper); } else if (requestCode.equals("SUB")) { // 保存登陆绑定的手机号 Editor editor = sp.edit(); AppContext.setMoblie(etNewNumber.getText().toString()); editor.putString(Constant.MY_BANGDING, etNewNumber.getText().toString()); // editor.putString(Constant.MY_ACCOUNT, etNewNumber.getText().toString()); editor.commit(); // 修改显示绑定的手机号 Intent intent = getIntent(); intent.putExtra("newPhone", etNewNumber.getText().toString()); Log.v("新手机号", etNewNumber.getText().toString()); ActivityBind.this.setResult(1, intent); appContext.setLogin(true); Toast.makeText(this, "绑定手机成功,请登录", Toast.LENGTH_LONG).show(); finish(); } } else { System.out.println(content.toString() + "PPPPPPPPPPPPPPPPP"); Toast.makeText(this, content, Toast.LENGTH_SHORT).show(); } }
// @Override // public void onActivityResult(int requestCode, int resultCode, Intent data) { // // TODO Auto-generated method stub // super.onActivityResult(requestCode, resultCode, data); // if (requestCode==100) { // if (data!=null) { // initData(); // } // } // } @Override public void onResume() { // TODO Auto-generated method stub super.onResume(); if (appContext.isLogin()) { arrayList_cart.clear(); AllCount = 0; express = 0; weight = 0; cartCount = 0; tv_count.setText("(" + cartCount + ")" + ""); tv_express.setText("¥" + express); tv_weight.setText("总重量为" + weight + "kg"); tv_cart_Allprice.setText("合计:¥" + AllCount + ""); cb_cart_all.setChecked(false); initData(); } }
@Override public void onClick(View v) { String mobile = etNewNumber.getText().toString(); String checdcode = etCheckCode.getText().toString(); // TODO Auto-generated method stub switch (v.getId()) { case R.id.btn_getcheckcode: if (mobile.length() != 11) { Toast.makeText(ActivityBind.this, "请输入正确地新手机号", Toast.LENGTH_SHORT).show(); } else { requestCode = "CODE"; ApiClient.getCheckCode(ActivityBind.this, mobile, "3", networkHelper); } break; case R.id.btn_sub: if (mobile.length() != 11) { Toast.makeText(ActivityBind.this, "请输入正确地新手机号", Toast.LENGTH_SHORT).show(); } else if (checdcode.length() != 6) { Toast.makeText(ActivityBind.this, "请先获取验证码", Toast.LENGTH_SHORT).show(); } else { requestCode = "SUB"; ApiClient.bindPhone( this, appContext.getLoginUid() + "", etCheckCode.getText().toString(), etNewNumber.getText().toString(), networkHelper); // requestCode="CHECK"; // // ApiClient.judgeCheckCode(ActivityBind.this,AppContext.getUsername(),etCheckCode.getText().toString(), "4", appContext.getLoginUid()+"", networkHelper); } break; case R.id.iv_back: ActivityBind.this.finish(); overridePendingTransition(R.anim.push_right_in, R.anim.push_right_out); break; default: break; } }