33
This commit is contained in:
@@ -0,0 +1,385 @@
|
||||
package cn.shangyu.gdxzExpert.activity;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.gyf.immersionbar.ImmersionBar;
|
||||
import com.nostra13.universalimageloader.core.ImageLoader;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import cn.shangyu.gdxzExpert.R;
|
||||
import cn.shangyu.gdxzExpert.base.BaseActivity;
|
||||
import cn.shangyu.gdxzExpert.bean.BankCardBean;
|
||||
import cn.shangyu.gdxzExpert.bean.OrderBean.OrderData;
|
||||
import cn.shangyu.gdxzExpert.http.OnCallBackFromNet;
|
||||
import cn.shangyu.gdxzExpert.utils.CommonUtil;
|
||||
import cn.shangyu.gdxzExpert.utils.Constant;
|
||||
import cn.shangyu.gdxzExpert.utils.GsonTools;
|
||||
import cn.shangyu.gdxzExpert.utils.ImageOptions;
|
||||
import cn.shangyu.gdxzExpert.utils.LogUtil;
|
||||
import cn.shangyu.gdxzExpert.utils.SharePrefUtil;
|
||||
import cn.shangyu.gdxzExpert.utils.StringUtil;
|
||||
import cn.shangyu.gdxzExpert.utils.ToastUtil;
|
||||
import cn.shangyu.gdxzExpert.utils.Url;
|
||||
import cn.shangyu.gdxzExpert.widget.ECAlertDialog;
|
||||
import cn.shangyu.gdxzExpert.widget.LoadingPage.ResultState;
|
||||
|
||||
/**
|
||||
* MyAccountActivity.java
|
||||
*
|
||||
* @author liufang
|
||||
* @date 2015-11-10 上午9:42:41
|
||||
*
|
||||
* Copyright (C) 2015 河南商宇科技有限公司
|
||||
*
|
||||
* 功能说明:我的-我的账户页面
|
||||
*/
|
||||
public class MyAccount2Activity extends BaseActivity implements
|
||||
OnCallBackFromNet {
|
||||
private TextView mTv_balance;
|
||||
private RelativeLayout mRl_withdrawals, mRl_bill;
|
||||
private MyAccount2Activity mActivity;
|
||||
private ImageView mIv_pic;
|
||||
private List<OrderData> datas = new ArrayList<>();
|
||||
private List<OrderData> details = new ArrayList<>();
|
||||
private double currentBalance;// 账户余额
|
||||
private double ableBlance;// 可提现金额
|
||||
private double minCash;// 最小提现额度
|
||||
private double mFwMoney;// 服务费用
|
||||
private double mOneDraw;// 单笔最高金额
|
||||
// 0 余额不足 ,1 余额足够, 2服务器异常
|
||||
private int MoneyEnpough = 0;
|
||||
// 0无银行卡 ,1 余额足够, 2服务器异常
|
||||
private int HaveBankCard = 0;
|
||||
private TextView mTv_least_monet;
|
||||
private boolean getmoney = false, getCar = false;
|
||||
|
||||
@Override
|
||||
public void setTitle() {
|
||||
top_title.setText(getString(R.string.my_account_text));
|
||||
if(CommonUtil.BigModule())
|
||||
{
|
||||
top_title.setTextSize(23);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateSuccessedView() {
|
||||
ImmersionBar.with(this).keyboardEnable(true).statusBarDarkFont(true).titleBar(mToolbar).init();
|
||||
View view;
|
||||
if(CommonUtil.BigModule())
|
||||
{
|
||||
view = View.inflate(ct, R.layout.activity_my_account2_big, null);
|
||||
}
|
||||
else
|
||||
{
|
||||
view = View.inflate(ct, R.layout.activity_my_account2, null);
|
||||
}
|
||||
mActivity = this;
|
||||
mIv_pic = (ImageView) view.findViewById(R.id.iv_pic);
|
||||
mTv_balance = (TextView) view.findViewById(R.id.iv_caccount_balance);
|
||||
mRl_withdrawals = (RelativeLayout) view
|
||||
.findViewById(R.id.rl_account_withdrawals);
|
||||
mRl_bill = (RelativeLayout) view.findViewById(R.id.rl_account_bill);
|
||||
mTv_least_monet = (TextView) view.findViewById(R.id.tv_least_money);
|
||||
mRl_withdrawals.setOnClickListener(this);
|
||||
mRl_bill.setOnClickListener(this);
|
||||
initData();
|
||||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
needreportPage("我的账户");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
// TODO Auto-generated method stub
|
||||
LogUtil.i("requestCode==" + requestCode + "resultCode==" + resultCode);
|
||||
if (Constant.DRAW_WITH_CODE == requestCode
|
||||
&& resultCode == Activity.RESULT_OK) {
|
||||
// showProgressDialog("加载中...");
|
||||
// showLoadingProgress();
|
||||
getMyAccount();
|
||||
}
|
||||
if (requestCode == 201) {
|
||||
getMyAccount();
|
||||
getCardList();
|
||||
}
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResultState onLoad() {
|
||||
return ResultState.STATE_SUCCESSED;
|
||||
}
|
||||
|
||||
/**
|
||||
* 数据加载完成时,取消加载动画
|
||||
*/
|
||||
private void onLoaded() {
|
||||
dismissLoadingProgress();
|
||||
closeProgressDialog();
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化数据
|
||||
*/
|
||||
private void initData() {
|
||||
String photo = SharePrefUtil.getString(mActivity, "photo", null);
|
||||
if (photo != null && !"null".equals(photo)) {
|
||||
ImageLoader.getInstance().displayImage(Url.urlHtml + photo,mIv_pic,ImageOptions
|
||||
.getImageOptions(R.drawable.icon_touxiang_persion_gray_big));
|
||||
}
|
||||
getMyAccount();
|
||||
getCardList();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取我的账户数据
|
||||
*/
|
||||
public void getMyAccount() {
|
||||
showProgressDialog("加载中");
|
||||
String uuid = SharePrefUtil.getString(ct, Constant.USERID, "");
|
||||
Map<String, String> param = new HashMap<String, String>();
|
||||
// param.put("user_uuid", uuid);
|
||||
sendJsonPostParamtoNetSignMD5(Url.getRetrieveUser, param, 101 ,this);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取我的银行卡列表
|
||||
*/
|
||||
public void getCardList() {
|
||||
showProgressDialog("加载中");
|
||||
String uuid = SharePrefUtil.getString(ct, Constant.USERID, "");
|
||||
Map<String, String> param = new HashMap<String, String>();
|
||||
param.put("expert_uuid", uuid);
|
||||
sendParamtoNet(Url.getBankCardList, param, 102, mActivity, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析并处理数据
|
||||
*
|
||||
*/
|
||||
private void processData(String result) {
|
||||
|
||||
// OrderBean bean = GsonTools.fromGsonToBean(result, OrderBean.class);
|
||||
// currentBalance = bean.totalIncome;// 账户余额
|
||||
// ableBlance = bean.totalPreCash;// 可提现金额
|
||||
// minCash = bean.minCash;// 最小提现额度
|
||||
// // 初始化列表的数据
|
||||
// datas.clear();
|
||||
// datas.addAll(bean.preCashOrderList);
|
||||
//
|
||||
// details.clear();
|
||||
// details.addAll(bean.totalIncomeList);
|
||||
getmoney = true;
|
||||
if (getCar) {
|
||||
closeProgressDialog();
|
||||
}
|
||||
|
||||
double availableCoupons = 0;// 优惠劵数量
|
||||
double availableBalance = 0;// 余额
|
||||
double withdrawableBalance = 0;// 可提款金额
|
||||
|
||||
JSONObject jsonObject = null;
|
||||
|
||||
if (result != null) {
|
||||
try {
|
||||
jsonObject = new JSONObject(result);
|
||||
availableCoupons = jsonObject.getDouble("data");
|
||||
availableBalance = jsonObject.getDouble("data");
|
||||
withdrawableBalance = jsonObject
|
||||
.getDouble("data");
|
||||
ableBlance = withdrawableBalance;
|
||||
if (withdrawableBalance != 0) {
|
||||
MoneyEnpough = 1;
|
||||
}
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
MoneyEnpough = 2;
|
||||
}
|
||||
}
|
||||
|
||||
// 回显数据
|
||||
// tvAbleBalance.setText("¥" + String.format("%.2f", ableBlance));
|
||||
// tvAbleBalance.setText("¥" + String.format("%.2f", 958.65));
|
||||
|
||||
mTv_balance.setText(String.format("%.2f", availableBalance / 100));
|
||||
// tvBalance.setText("¥" + String.format("%.2f", 958.64));
|
||||
// 数据请求成功呢后调用关闭加载框方法
|
||||
onLoaded();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void processClick(View v) {
|
||||
// AGP 8.0+ R.id 不再是 final 常量,不能用于 switch,改用 if-else
|
||||
int id = v.getId();
|
||||
if (id == R.id.rl_account_withdrawals) {
|
||||
if (ableBlance < minCash) {
|
||||
noMoney();
|
||||
return;
|
||||
}
|
||||
if (MoneyEnpough == 0) {
|
||||
noMoney();
|
||||
return;
|
||||
}
|
||||
if (HaveBankCard == 0) {
|
||||
noCard();
|
||||
return;
|
||||
}
|
||||
if (MoneyEnpough == 2 || HaveBankCard == 2) {
|
||||
ToastUtil.showMessage("服务器异常");
|
||||
return;
|
||||
}
|
||||
toDrawWith();
|
||||
} else if (id == R.id.rl_account_bill) {
|
||||
toDetail();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 账单明细
|
||||
*/
|
||||
public void toDetail() {
|
||||
Intent intent = new Intent(ct, BillDetailsActivity.class);
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
/**
|
||||
* 去提现
|
||||
*/
|
||||
public void toDrawWith() {
|
||||
|
||||
Intent intent = new Intent(ct, DrawWith2Atvitity.class);
|
||||
intent.putExtra("ableBlance", ableBlance);
|
||||
intent.putExtra("mFwMoney", mFwMoney);
|
||||
intent.putExtra("minCash", minCash);
|
||||
intent.putExtra("mOneDraw", mOneDraw);
|
||||
startActivityForResult(intent, Constant.DRAW_WITH_CODE);
|
||||
}
|
||||
|
||||
private ECAlertDialog buildAlert;
|
||||
|
||||
public void noMoney() {
|
||||
buildAlert = ECAlertDialog.buildAlert(mActivity, mActivity
|
||||
.getResources().getString(R.string.account_withdrawals_money),
|
||||
null, "确定", new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
// TODO Auto-generated method stub
|
||||
buildAlert.dismiss();
|
||||
}
|
||||
}, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
buildAlert.dismiss();
|
||||
|
||||
}
|
||||
});
|
||||
buildAlert.setTitle("提示");
|
||||
buildAlert.setTitleColor(mActivity.getResources().getColor(
|
||||
R.color.top_title));
|
||||
buildAlert.show();
|
||||
}
|
||||
|
||||
public void noCard() {
|
||||
buildAlert = ECAlertDialog.buildAlert(mActivity, mActivity
|
||||
.getResources().getString(R.string.account_withdrawals_card),
|
||||
"否", "是", new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
// TODO Auto-generated method stub
|
||||
buildAlert.dismiss();
|
||||
}
|
||||
}, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
Intent intent = new Intent(mActivity,
|
||||
AddBankCardFirstActivity.class);
|
||||
intent.putExtra("ableBlance", ableBlance);
|
||||
intent.putExtra("mFwMoney", mFwMoney);
|
||||
intent.putExtra("mOneDraw", mOneDraw);
|
||||
startActivityForResult(intent, 201);
|
||||
buildAlert.dismiss();
|
||||
|
||||
}
|
||||
});
|
||||
buildAlert.setTitle("提示");
|
||||
buildAlert.setTitleColor(mActivity.getResources().getColor(
|
||||
R.color.top_title));
|
||||
buildAlert.show();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCallbackFromThread(String resultJson) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCallBackFromThread(String resultJson, int resultCode) {
|
||||
Log.d("WXEntryActivity",resultCode+" "+resultJson);
|
||||
// TODO Auto-generated method stub
|
||||
switch (resultCode) {
|
||||
case 101:
|
||||
processData(resultJson);
|
||||
break;
|
||||
case 102:
|
||||
SharePrefUtil
|
||||
.saveString(mActivity, Url.getBankCardList, resultJson);
|
||||
processBanklist(resultJson);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析并处理数据
|
||||
*
|
||||
*/
|
||||
private void processBanklist(String result) {
|
||||
getCar = true;
|
||||
if (getmoney) {
|
||||
closeProgressDialog();
|
||||
}
|
||||
if (StringUtil.isEmpty(result)) {
|
||||
ToastUtil.showMessage("服务器异常");
|
||||
return;
|
||||
}
|
||||
BankCardBean bean = GsonTools
|
||||
.fromGsonToBean(result, BankCardBean.class);
|
||||
|
||||
minCash = bean.LessWithdrawalBalance;
|
||||
// 服务费用
|
||||
mFwMoney = bean.WithdrawalBalanceFee;
|
||||
mOneDraw = bean.WithdrawalBalanceMaxOnce;
|
||||
if (bean.code.equals("1")) {
|
||||
mTv_least_monet.setText(String.format("%.2f",
|
||||
bean.LessWithdrawalBalance / 100) + "元)");
|
||||
if (bean.bankList.size() > 0) {
|
||||
HaveBankCard = 1;
|
||||
}
|
||||
} else {
|
||||
HaveBankCard = 2;
|
||||
ToastUtil.showMessage(bean.message);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user