admin
2021-07-06 abce02c7a61820f5d580f87364d542e817be429c
app/src/main/java/com/tejia/lijin/app/ui/main/MineFragment.java
@@ -53,6 +53,7 @@
import com.tejia.lijin.app.ShoppingApplication;
import com.tejia.lijin.app.ui.message.UserMessageActivity;
import com.tejia.lijin.app.ui.recommend.GoodsDetailActivity;
import com.tejia.lijin.app.ui.sellwellcommodity.SellWellGoods;
import com.tejia.lijin.app.util.ui.HomeUIUtil;
import com.umeng.analytics.MobclickAgent;
import com.viewpagerindicator.CirclePageIndicator;
@@ -127,7 +128,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;
    //用户昵称与邀请码
@@ -193,25 +194,14 @@
        listener(contentView);
        app = new UpdateApp(getActivity(), getResources().getString(R.string.update_key));
        mPermissionsChecker = new PermissionHelper(getActivity(), this);
//        startActivity(new Intent(getContext(),ShareBrowserActivity.class).putExtra("url","http://192.168.3.122:8848/flqFront/help/pdd.html?resourceType=39997"));
    }
    private void init(View contentView) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            Window window = getActivity().getWindow();
            window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
            window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                    | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
            window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
            window.setStatusBarColor(Color.TRANSPARENT);
            //设置状态栏文字颜色及图标为深色
//            getActivity().getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
        }
        //设置状态栏文字颜色及图标为深色
        getActivity().getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
        this.options = new DisplayImageOptions.Builder()
                .showImageForEmptyUri(R.drawable.ic_default_portrait)
                .showImageOnFail(R.drawable.ic_default_portrait)
                .showImageOnLoading(R.drawable.ic_default_portrait)
                .showImageForEmptyUri(R.drawable.ic_mine_default_portrait)
                .showImageOnFail(R.drawable.ic_mine_default_portrait)
                .showImageOnLoading(R.drawable.ic_mine_default_portrait)
                .resetViewBeforeLoading(true)
                .cacheInMemory(true)
                .cacheOnDisk(true)
@@ -220,6 +210,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);
@@ -235,8 +226,8 @@
        ll_top = contentView.findViewById(R.id.ll_top);
        view_mine_end_bg = contentView.findViewById(R.id.view_mine_end_bg);
        ll_top.setBackground(HomeUIUtil.getHomeTopBg("#FF227B", "#FF2A3E"));
        view_mine_end_bg.setBackground(HomeUIUtil.getHomeTopBg("#FF227B", "#FF2A3E"));
        ll_top.setBackground(HomeUIUtil.getHomeTopBg(getContext()));
        view_mine_end_bg.setBackground(HomeUIUtil.getHomeTopBg(getContext()));
        tv_user_numlayout = contentView.findViewById(R.id.tv_user_numlayout);
@@ -264,6 +255,7 @@
    private List<Functions> getFunctions() {
        List<Functions> list = new ArrayList<>();
        list.add(new Functions("礼金红包", R.drawable.icon_mine_hb, "jumpLijinHB"));
        list.add(new Functions("订单", R.drawable.icon_mine_order, "jumpOrder"));
        list.add(new Functions("找回订单", R.drawable.icon_mine_find_order, "jumpFindOrder"));
        list.add(new Functions("收藏", R.drawable.icon_mine_collect, "jumpCollect"));
@@ -311,53 +303,36 @@
    @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;
        }
        fl_msg.setVisibility(View.VISIBLE);
        ImageLoader.getInstance().displayImage(info.getPortrait(), iv_portrait, options);
        tv_nickName.setText(info.getNickName());
        String balance = info.getMyHongBao();
@@ -470,8 +445,7 @@
    @Override
    public void onClick(View v) {
        final SharedPreferences sp = getActivity().getSharedPreferences("user", Context.MODE_PRIVATE);
        boolean isLogin = sp.getBoolean("isLogin", false);
        boolean isLogin = UserUtil.isLogin(getContext());
        clickState = 0;
        switch (v.getId()) {
            case R.id.vp_close:
@@ -651,23 +625,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秒不进入
@@ -693,7 +654,7 @@
                    }
                } else if (jsonObject.optInt("code") == 80001) {
                    if (tv_nickName.getContext().getSharedPreferences("user", MODE_PRIVATE).getBoolean("isLogin", false)) {
                    if (UserUtil.isLogin(getContext())) {
                        loginOut();
                        UserUtil.logout(tv_nickName.getContext());
                        noLogin();
@@ -814,6 +775,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();
            }
        });
    }
    /**
     * 我的信息-提醒记录
     *