admin
2021-07-06 abce02c7a61820f5d580f87364d542e817be429c
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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
package com.tejia.lijin.app.ui.mine;
 
import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
 
import com.google.gson.Gson;
import com.tejia.lijin.app.BasicTextHttpResponseHandler;
import com.tejia.lijin.app.R;
import com.tejia.lijin.app.ShoppingApi;
import com.tejia.lijin.app.ShoppingApplication;
import com.tejia.lijin.app.entity.user.money.statistic.MoneyStatisticVO;
import com.tejia.lijin.app.ui.BaseActivity;
import com.tejia.lijin.app.ui.invite.ShareBrowserActivity;
import com.tejia.lijin.app.ui.main.MainActivity;
import com.tejia.lijin.app.util.ToolUtil;
import com.tejia.lijin.app.util.TopStatusSettings;
import com.tejia.lijin.app.util.umengCustomEvent.UserCustomEvent;
import com.tejia.lijin.app.util.user.UserUtil;
import com.wpc.library.util.common.StringUtils;
 
import org.apache.http.Header;
import org.json.JSONException;
import org.json.JSONObject;
 
import java.math.BigDecimal;
 
/**
 * Created by weikou2015 on 2018/1/18.
 * 资金
 */
 
public class LijinCapitalActivity extends BaseActivity implements View.OnClickListener {
    TextView tv_left, tv_middle, tv_available_rebate,
            tv_mine_drawcash;
    private String TYPE = "lijinMoney";
    private TextView tv_notice_content;
    private LinearLayout ll_notice;
    private ImageView iv_close;
    private TextView tv_available_withdrawal;//提款中 显示余额
 
 
    //账户明细,提现记录
    private FrameLayout fl_account_detail, fl_withdraw_history;
 
 
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_lijin_capital);
        TopStatusSettings.setStatusViewAndDeepColor(this);
        tv_left = findViewById(R.id.tv_top_bar_left);
        tv_middle = findViewById(R.id.tv_top_bar_middle);
        tv_available_rebate = findViewById(R.id.tv_available_rebate);
        tv_mine_drawcash = findViewById(R.id.tv_mine_drawcash);
        tv_available_withdrawal = findViewById(R.id.tv_available_withdrawal);
 
 
        fl_account_detail = findViewById(R.id.fl_account_detail);
        fl_withdraw_history = findViewById(R.id.fl_withdraw_history);
 
        fl_account_detail.setOnClickListener(this);
        fl_withdraw_history.setOnClickListener(this);
        findViewById(R.id.tv_course).setOnClickListener(this);
        findViewById(R.id.tv_rule).setOnClickListener(this);
 
 
        tv_middle.setText("礼金红包");
 
 
        tv_notice_content = findViewById(R.id.tv_notice_content);
        ll_notice = findViewById(R.id.ll_notice);
        iv_close = findViewById(R.id.iv_close);
        getAppPageNotification();
 
        tv_left.setOnClickListener(this);
        tv_mine_drawcash.setOnClickListener(this);
    }
 
 
    @Override
    protected void onResume() {
        super.onResume();
        getUserMoney();
    }
 
    private void getAppPageNotification() {
        ShoppingApi.getAppPageNotification(this, TYPE, new BasicTextHttpResponseHandler() {
            @Override
            public void onSuccessPerfect(int statusCode, Header[] headers, JSONObject jsonObject) throws Exception {
                if (jsonObject.optInt("code") == 0) {
                    boolean isClose = jsonObject.optJSONObject("data").optBoolean("canClose");
                    String content = jsonObject.optJSONObject("data").optString("content");
                    final String contentUrl = jsonObject.optJSONObject("data").optString("contentUrl");
                    final String md5 = jsonObject.optJSONObject("data").optString("md5");
 
                    tv_notice_content.setText(content);
                    final SharedPreferences sp = getSharedPreferences("notice", Context.MODE_PRIVATE);
                    if (!sp.getBoolean(md5, false)) {//false 展示,true不展示
                        ll_notice.setVisibility(View.VISIBLE);
                    } else {
                        ll_notice.setVisibility(View.GONE);
                    }
 
                    if (isClose) {
                        iv_close.setImageDrawable(getResources().getDrawable(R.drawable.ic_notice_close));
                        iv_close.setOnClickListener(new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {
                                ll_notice.setVisibility(View.GONE);
                                SharedPreferences.Editor editor = sp.edit();
                                editor.putBoolean(md5, true);
                                editor.commit();
                            }
                        });
                    } else {
                        iv_close.setImageDrawable(getResources().getDrawable(R.drawable.ic_notice_input));
                    }
                    ll_notice.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View v) {
                            if (StringUtils.isEmpty(contentUrl))
                                return;
                            Intent intent = new Intent(LijinCapitalActivity.this, ShareBrowserActivity.class);
                            intent.putExtra("url", contentUrl);
                            startActivity(intent);
                        }
                    });
                }
            }
        });
    }
 
    private void getUserMoney() {
        ShoppingApi.getHongBaoBalance(this, new BasicTextHttpResponseHandler() {
            @Override
            public void onSuccessPerfect(int statusCode, Header[] headers, JSONObject jsonObject) throws Exception {
                super.onSuccessPerfect(statusCode, headers, jsonObject);
                if (jsonObject.optInt("code") == 0) {
                    setUserMoneyInfo(jsonObject.optJSONObject("data"));
                }
 
            }
 
            @Override
            public void onFailure(int statusCode, Header[] headers, String responseString, Throwable throwable) {
                super.onFailure(statusCode, headers, responseString, throwable);
                ToolUtil.showToast(tv_available_rebate.getContext(), "网络连接异常,请检测网络设置");
            }
        });
    }
 
    String ruleLink = null;
    String courseLink = null;
    String recordLink = null;
 
 
    private void setUserMoneyInfo(JSONObject data) {
        ruleLink = data.optString("ruleLink");
        courseLink = data.optString("courseLink");
        recordLink = data.optString("recordLink");
        String balance = data.optString("balance");
        tv_available_rebate.setText(balance);
        String using = data.optString("using");
 
        if (!StringUtils.isNullOrEmpty(using) && new BigDecimal(using).compareTo(new BigDecimal(0)) > 0) {
            tv_available_withdrawal.setText("使用中:¥ " + data.optString("using"));//使用中
        } else {
            tv_available_withdrawal.setText("");
        }
    }
 
 
    @Override
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.tv_top_bar_left:
                finish();
                break;
            case R.id.tv_top_bar_right://账目明细
 
                break;
            case R.id.tv_mine_drawcash://提现
                Intent intent = new Intent(LijinCapitalActivity.this, MainActivity.class);
                startActivity(intent);
                break;
            case R.id.fl_account_detail://账户明细
                if (!StringUtils.isNullOrEmpty(recordLink)) {
                    startActivity(new Intent(LijinCapitalActivity.this, ShareBrowserActivity.class).putExtra("url", recordLink));
                }
                break;
            case R.id.tv_course://教程
                if (!StringUtils.isNullOrEmpty(courseLink)) {
                    startActivity(new Intent(LijinCapitalActivity.this, ShareBrowserActivity.class).putExtra("url", courseLink));
                }
                break;
            case R.id.tv_rule://规则
                if (!StringUtils.isNullOrEmpty(ruleLink)) {
                    startActivity(new Intent(LijinCapitalActivity.this, ShareBrowserActivity.class).putExtra("url", ruleLink));
                }
                break;
        }
    }
 
 
    @Override
    protected void onPause() {
        super.onPause();
    }
 
    @Override
    protected void onDestroy() {
        super.onDestroy();
 
    }
}