From 5965c01b38a2e83cecd7616daa11185fc2499303 Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期五, 28 五月 2021 10:12:27 +0800 Subject: [PATCH] 特价完善 --- app/src/main/java/com/tejia/lijin/app/ui/main/MineFragment.java | 103 +++++++++++++++++++++++++++++---------------------- 1 files changed, 58 insertions(+), 45 deletions(-) diff --git a/app/src/main/java/com/tejia/lijin/app/ui/main/MineFragment.java b/app/src/main/java/com/tejia/lijin/app/ui/main/MineFragment.java index b560059..d3ac96d 100644 --- a/app/src/main/java/com/tejia/lijin/app/ui/main/MineFragment.java +++ b/app/src/main/java/com/tejia/lijin/app/ui/main/MineFragment.java @@ -127,7 +127,7 @@ public class MineFragment extends RetainViewFragment implements View.OnClickListener, PermissionInterface { private TextView tv_user_num; - private ImageView iv_portrait; + private ImageView iv_portrait, iv_rank; private TextView tv_nickName; //鐢ㄦ埛鏄电О涓庨個璇风爜 @@ -220,6 +220,7 @@ .displayer(new CircleBitmapDisplayer(300)) .build(); + iv_rank = contentView.findViewById(R.id.iv_rank); fl_msg = contentView.findViewById(R.id.fl_msg); tv_msg_count = contentView.findViewById(R.id.tv_msg_count); @@ -311,50 +312,32 @@ @Override public void onResume() { super.onResume(); + initUserView(); getUserConfig(); + getLijinUserLevel(); getUnReadMsgCount(UserUtil.getUid(getContext())); MobclickAgent.onPageStart("鎴戠殑"); - SharedPreferences sp = tv_nickName.getContext().getSharedPreferences("user", MODE_PRIVATE); - if (sp.getBoolean("isLogin", false)) { + vp_banner.postDelayed(mAutoScroller, 2000); + } + + private void initUserView() { + if (UserUtil.isLogin(getContext())) { tv_user_numlayout.setVisibility(View.VISIBLE); tv_user_num.setVisibility(View.VISIBLE); ll_nick_name_vip.setVisibility(View.VISIBLE); tv_nickName.setVisibility(View.VISIBLE); - Long uid = UserUtil.getUid(ShoppingApplication.application); - if (lastTime > 0 && (System.currentTimeMillis() - lastTime > 30 * 1000)) { - clickState = 0; - } - if (uid != null) { - String userInfo = sp.getString("userinfo", ""); - if (!StringUtils.isEmpty(userInfo)) { - try { - JSONObject jsonObject = new JSONObject(userInfo); - showInfo(jsonObject); - } catch (JSONException e) { - e.printStackTrace(); - } - } - String rewardInfo = sp.getString("estimatereward", ""); - - getUserInfo(uid); - } + UserInfo user = UserUtil.getUserInfo(getContext()); + showInfo(user); + getUserInfo(UserUtil.getUid(getContext())); } else { noLogin(); } - vp_banner.postDelayed(mAutoScroller, 2000); } /** * 灞曠ず鐢ㄦ埛淇℃伅 */ - private void showInfo(JSONObject jsonObject) { - if (jsonObject.optJSONObject("data") == null) { - return; - } - JSONObject data = jsonObject.optJSONObject("data"); - Gson gson = new GsonBuilder().serializeNulls().create(); - UserInfo info = gson.fromJson(jsonObject.optJSONObject("data").optJSONObject("user").toString(), new TypeToken<UserInfo>() { - }.getType()); + private void showInfo(UserInfo info) { if (info == null) { return; } @@ -651,23 +634,10 @@ if (inviteLevel != null) { userInviteLevel = gson.fromJson(inviteLevel.toString(), UserInviteLevel.class); } - showInfo(jsonObject);//灞曠ず鐢ㄦ埛涓汉淇℃伅 final UserInfo info = gson.fromJson(data.optJSONObject("user").toString(), new TypeToken<UserInfo>() { }.getType()); - SharedPreferences sp = tv_nickName.getContext().getSharedPreferences("user", MODE_PRIVATE); - SharedPreferences.Editor editor = sp.edit(); - editor.putBoolean("isLogin", true); - editor.putBoolean("isFirstInput", false); - editor.putString("uid", info.getId()); - editor.putString("openid", info.getOpenid()); - editor.putString("portrait", info.getPortrait()); - editor.putString("userinfo", jsonObject.toString()); - if (StringUtils.isEmpty(info.getWxOpenId())) { - editor.putBoolean("isWxBind", false); - } else { - editor.putBoolean("isWxBind", true); - } - editor.commit(); + showInfo(info);//灞曠ず鐢ㄦ埛涓汉淇℃伅 + UserUtil.loginSuccess(getContext(),info); /**bindPhone 缁戝畾鎵嬫満寮圭獥*/ if (jsonObject.optJSONObject("data").optBoolean("bindPhone", false)) { if (System.currentTimeMillis() - bindPhonetime < 1000) {//灏忎簬1绉掍笉杩涘叆 @@ -814,6 +784,49 @@ }); } + + private void getLijinUserLevel() { + if (!UserUtil.isLogin(getContext())) { + iv_rank.setVisibility(View.GONE); + return; + } + + ShoppingApi.getLijinUserLevel(getContext(), UserUtil.getUid(getContext()), new BasicTextHttpResponseHandler() { + @Override + public void onStart() { + super.onStart(); + } + + @Override + public void onSuccessPerfect(int statusCode, Header[] headers, JSONObject jsonObject) throws Exception { + if (jsonObject.optInt("code") == 0) { + JSONObject data = jsonObject.optJSONObject("data"); + String userLevel = data.optString("userLevel"); + final String vipLink = data.optString("lijinVipLink"); + try { + iv_rank.setImageResource(getResources().getIdentifier("icon_rank_" + userLevel, "drawable", getContext().getPackageName())); + } catch (Exception e) { + } + + iv_rank.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + startActivity(new Intent(getContext(), ShareBrowserActivity.class).putExtra("url", vipLink)); + } + }); + iv_rank.setVisibility(View.VISIBLE); + } + super.onSuccessPerfect(statusCode, headers, jsonObject); + } + + @Override + public void onFinish() { + super.onFinish(); + } + }); + + } + /** * 鎴戠殑淇℃伅-鎻愰啋璁板綍 * -- Gitblit v1.8.0