wpc
2018-11-27 680fbc9e73da3e11988557cf88fd935efd3e0b1e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
package com.haicaojie.android.ui.mine;
 
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Build;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.LinearLayout;
import android.widget.TextView;
 
import com.haicaojie.android.BasicTextHttpResponseHandler;
import com.haicaojie.android.R;
import com.haicaojie.android.ShoppingApi;
import com.haicaojie.android.ui.BaseActivity;
import com.haicaojie.android.util.ProfitEstimateDialog;
import com.lcjian.library.util.SingleToast;
 
import org.apache.http.Header;
import org.json.JSONObject;
 
/**
 * Created by weikou2015 on 2018/1/18.
 * 资金
 */
 
public class CapitalActivity extends BaseActivity implements View.OnClickListener {
    TextView tv_left, tv_middle, tv_available_rebate, tv_rebate_total,
            tv_unavailable_rebate, tv_withdraw_cash, tv_withdraw_hint, tv_percentage_total, tv_unavailable_percentage;
    private TextView tv_estimate_today, tv_estimate_month, tv_last_month;
    private LinearLayout ll_account_details, ll_estimate_today, ll_estimate_month, ll_last_month;
 
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_rebate);
          /*
         * 计算状态栏高度并设置
         */
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            Window window = getWindow();
            window.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS,
                    WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
            int result = 0;
            int resourceId = getResources().getIdentifier("status_bar_height",
                    "dimen", "android");
            if (resourceId > 0) {
                result = getResources().getDimensionPixelSize(resourceId);
            }
            //设置状态栏文字颜色及图标为深色
            getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
            LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
                    result);
            findViewById(R.id.v_status_bar).setLayoutParams(params);
        } else {
            findViewById(R.id.v_status_bar).setVisibility(View.GONE);
        }
        tv_left = (TextView) findViewById(R.id.tv_top_bar_left);
        tv_middle = (TextView) findViewById(R.id.tv_top_bar_middle);
        ll_account_details = (LinearLayout) findViewById(R.id.ll_account_details);
        tv_available_rebate = (TextView) findViewById(R.id.tv_available_rebate);
        tv_rebate_total = (TextView) findViewById(R.id.tv_rebate_total);
        tv_unavailable_rebate = (TextView) findViewById(R.id.tv_unavailable_rebate);
        tv_withdraw_cash = (TextView) findViewById(R.id.tv_withdraw_cash);
        tv_withdraw_hint = (TextView) findViewById(R.id.tv_withdraw_hint);
        tv_estimate_today = (TextView) findViewById(R.id.tv_estimate_today);
        tv_estimate_month = (TextView) findViewById(R.id.tv_estimate_month);
        tv_last_month = (TextView) findViewById(R.id.tv_last_month);
        tv_percentage_total = (TextView) findViewById(R.id.tv_percentage_total);
        tv_unavailable_percentage = (TextView) findViewById(R.id.tv_unavailable_percentage);
        ll_estimate_today = (LinearLayout) findViewById(R.id.ll_estimate_today);
        ll_estimate_month = (LinearLayout) findViewById(R.id.ll_estimate_month);
        ll_last_month = (LinearLayout) findViewById(R.id.ll_last_month);
        tv_middle.setText("资金");
 
        SharedPreferences sp = getSharedPreferences("user", MODE_PRIVATE);
        String myHongBao = getIntent().getStringExtra("myHongBao");
        String totalHongBao = getIntent().getStringExtra("totalHongBao");
        String noOpenHongBao = getIntent().getStringExtra("noOpenHongBao");
        tv_rebate_total.setText(totalHongBao);
        tv_available_rebate.setText(myHongBao);
        tv_unavailable_rebate.setText(noOpenHongBao);
        tv_withdraw_hint.setText(sp.getString("Prompt", "") + "\n" + sp.getString("Prompt2", ""));
 
        tv_left.setOnClickListener(this);
        ll_account_details.setOnClickListener(this);
        tv_withdraw_cash.setOnClickListener(this);
        ll_estimate_today.setOnClickListener(this);
        ll_estimate_month.setOnClickListener(this);
        ll_last_month.setOnClickListener(this);
    }
 
    @Override
    protected void onResume() {
        super.onResume();
        getUserMoney();
    }
 
    private void getUserMoney() {
        String uid = getSharedPreferences("user", MODE_PRIVATE).getString("uid", "0");
        ShoppingApi.getUserMoney(this, uid, new BasicTextHttpResponseHandler() {
            @Override
            public void onSuccessPerfect(int statusCode, Header[] headers, JSONObject jsonObject) throws Exception {
                if (jsonObject.optString("code").equalsIgnoreCase("0")) {
                    tv_available_rebate.setText(jsonObject.optJSONObject("data").optString("money"));
                    tv_rebate_total.setText(jsonObject.optJSONObject("data").optString("totalFanLiMoney"));
                    tv_unavailable_rebate.setText(jsonObject.optJSONObject("data").optString("unGetMoney"));
                    tv_estimate_today.setText(jsonObject.optJSONObject("data").optString("moneyToday"));
                    tv_estimate_month.setText(jsonObject.optJSONObject("data").optString("moneyMonth"));
                    tv_last_month.setText(jsonObject.optJSONObject("data").optString("moneyLastMonth"));
                    tv_percentage_total.setText(jsonObject.optJSONObject("data").optString("totalTiChengMoney"));
                    tv_unavailable_percentage.setText(jsonObject.optJSONObject("data").optString("totalUnGetTiChengMoney"));
                }
            }
        });
    }
 
    @Override
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.tv_top_bar_left:
                finish();
                break;
            case R.id.ll_account_details:
                startActivity(new Intent(CapitalActivity.this, AccountDetailActivity.class));
                break;
            case R.id.tv_withdraw_cash:
                Intent intent = new Intent(CapitalActivity.this, WithdrawCashActivity.class);
                startActivity(intent);
                break;
            case R.id.ll_estimate_today:
                ProfitEstimateDialog.Builder builder = new ProfitEstimateDialog.Builder(CapitalActivity.this);
                builder.setTitle("今日预估分享奖金").setMessage("今日新增的分享订单预估奖金").setPositiveButton("知道啦", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialogInterface, int i) {
                        dialogInterface.dismiss();
                    }
                }).create().show();
 
                break;
            case R.id.ll_estimate_month:
                ProfitEstimateDialog.Builder builder1 = new ProfitEstimateDialog.Builder(CapitalActivity.this);
                builder1.setTitle("本月预估分享奖金").setMessage("本月内产生的所有的分享订单预估奖金,会在订单确认收货后的次月25日后转入您的余额,以实际转入余额为准").setPositiveButton("知道啦", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialogInterface, int i) {
                        dialogInterface.dismiss();
                    }
                }).create().show();
                break;
            case R.id.ll_last_month:
                ProfitEstimateDialog.Builder builder2 = new ProfitEstimateDialog.Builder(CapitalActivity.this);
                builder2.setTitle("上月分享奖金").setMessage("上个月内确认收货的分享订单奖金会在每月25日结算后,自动转入您的余额").setPositiveButton("知道啦", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialogInterface, int i) {
                        dialogInterface.dismiss();
                    }
                }).create().show();
                break;
        }
    }
}