/** 获取验证码 */ private void getVerifyCode(String phone) { // String phone = AppContext.mUserInfo.phone; if (TextUtils.isEmpty(phone)) { UIHelper.showToast(R.string.phone_is_null); return; } else if (!StringUtils.isPhoneNumber(phone)) { UIHelper.showToast(R.string.phone_disenable); return; } RequstClient.getRegeditCode( phone, "0", new CustomResponseHandler(FragmentModifyPhone.this.getActivity()) { @Override public void onFailure(Throwable error, String content) { super.onFailure(error, content); } @Override public void onSuccess(int statusCode, Header[] headers, String content) { super.onSuccess(statusCode, headers, content); Log.d("phone", "checkIdentity msg:" + content); int type = JSONParseUtils.getInt(content, "type"); String msg = JSONParseUtils.getString(content, "msg"); if (1 == type) { showResendTip(); UIHelper.showToast(msg); } else { UIHelper.showToast(msg); } } }); }
/** * 修改手机号码 */ private void amendPhone(final String phone, String messageVerifyCode) { // 判断手机 if (TextUtils.isEmpty(phone)) { UIHelper.showToast(R.string.phone_is_null); return; } else if (!StringUtils.isPhoneNumber(phone)) { UIHelper.showToast(R.string.phone_disenable); return; } // 验证码 if (TextUtils.isEmpty(messageVerifyCode)) { UIHelper.showToast(R.string.ver_code_is_null); return; } String userId = AppContext.mUserInfo.userId; RequstClient.amendPhone( userId, phone, messageVerifyCode, new CustomResponseHandler(FragmentModifyPhone.this.getActivity()) { @Override public void onFailure(Throwable error, String content) { super.onFailure(error, content); } @Override public void onSuccess(int statusCode, Header[] headers, String content) { super.onSuccess(statusCode, headers, content); try { LogUtil.i("phone", "postValidateCode:" + content); JSONObject result = new JSONObject(content); if (!result.getString("type").equals("1")) { String errorMsg = result.getString("msg"); Toast.makeText(mContext, errorMsg, Toast.LENGTH_SHORT).show(); return; } // 手机号码修改成功 AppContext.mUserInfo.phone = phone; UIHelper.showToast("手机修改成功"); // 杀掉timer线程 if (mListener != null) { mTimer.cancel(); mListener.stepToModifyFinish(); } } catch (JSONException e) { e.printStackTrace(); } } }); }