admin
2022-08-09 399ac289f80b7a40aa4210341db6b447cacdcf14
app/src/main/java/com/tejia/lijin/app/ui/mine/MyInfoActivity.java
@@ -5,8 +5,10 @@
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import androidx.databinding.BindingAdapter;
import androidx.databinding.DataBindingUtil;
import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable;
import android.net.Uri;
@@ -14,7 +16,9 @@
import android.os.Bundle;
import android.os.Environment;
import android.provider.MediaStore;
import androidx.annotation.NonNull;
import android.util.Log;
import android.view.Gravity;
import android.view.View;
@@ -31,7 +35,17 @@
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.reflect.TypeToken;
import com.tejia.lijin.app.entity.common.GoodsConvertLinkJumpLink;
import com.tejia.lijin.app.entity.user.UserLijinLevelInfoVO;
import com.tejia.lijin.app.ui.dialog.ShapeLoadingDialog;
import com.tejia.lijin.app.util.GoodsBuyJumpUtil;
import com.tejia.lijin.app.util.ui.dialog.DialogUtil;
import com.tejia.lijin.app.util.user.AccountBindManager;
import com.tejia.lijin.app.util.user.LoginManager;
import com.tejia.lijin.app.util.user.QQLoginManager;
import com.tejia.lijin.app.util.user.UserUtil;
import com.tencent.mm.opensdk.modelmsg.SendAuth;
import com.wpc.library.util.SingleToast;
import com.wpc.library.util.common.DimenUtils;
import com.wpc.library.util.common.StringUtils;
import com.tejia.lijin.app.BasicTextHttpResponseHandler;
@@ -78,6 +92,12 @@
    private String fansCountLink;
    //拼多多是否备案
    private Boolean pddBuyBind;
    private Boolean pddShareBind;
    protected ShapeLoadingDialog loading = null;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
@@ -89,7 +109,6 @@
//        tv_middle.setText("我的信息");
        binding.includeTopBar.tvTopBarLeft.setOnClickListener(this);
        binding.llInfoSex.setOnClickListener(this);
        binding.llInfoWchatNum.setOnClickListener(this);
        binding.llInfoPortrait.setOnClickListener(this);
        binding.llInfoNickname.setOnClickListener(this);
        binding.llInfoRelativeQq.setOnClickListener(this);
@@ -97,8 +116,11 @@
        binding.llInfoRelativeWechat.setOnClickListener(this);
        binding.llInfoRelativeMobile.setOnClickListener(this);
        binding.llInfoInviteCode.setOnClickListener(this);
        binding.llInfoVip.setOnClickListener(this);
        binding.llInfoFans.setOnClickListener(this);
        binding.llInfoPddBuy.setOnClickListener(this);
        binding.llInfoPddShare.setOnClickListener(this);
        binding.tvInfoUid.setOnLongClickListener(new View.OnLongClickListener() {
            @Override
            public boolean onLongClick(View v) {
@@ -110,9 +132,9 @@
                return false;
            }
        });
        binding.llVipAction.setOnClickListener(this);
        mPermissionsChecker = new PermissionHelper(this, this);//权限
        loading = new ShapeLoadingDialog.Builder(this).build();
    }
    @Override
@@ -127,12 +149,13 @@
    @Override
    public void onClick(View view) {
        Boolean buy = null;
        switch (view.getId()) {
            case R.id.tv_top_bar_left:
                finish();
                break;
            case R.id.ll_info_relative_wechat:
                if(info==null)
            case R.id.ll_info_relative_wechat: {
                if (info == null)
                    return;
                String title = "更换微信帐号";
                String message = "确定更换微信账号";
@@ -167,6 +190,46 @@
                    }
                }).create().show();
                break;
            }
            case R.id.ll_info_relative_qq: {
                if (info == null)
                    return;
                String title = "更换QQ帐号";
                String message = "确定更换QQ帐号";
                String positive = "更换";
                if (StringUtils.isEmpty(info.getQqOpenId())) {//QQ
                    title = "绑定QQ帐号";
                    message = "确定绑定QQ账号";
                    positive = "绑定";
                }
                if (StringUtils.isEmpty(phoneNum)) {
                    title = "更换提醒";
                    message = "该帐号没有绑定手机号,需绑定手机号才能完成QQ更换。";
                    positive = "绑定手机号";
                }
                AddZFBInfoDialog2.Builder builder1 = new AddZFBInfoDialog2.Builder(MyInfoActivity.this);
                builder1.setTitle(title).setMessage(message)
                        .setPositiveButton(positive, new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                                dialog.dismiss();
                                if (StringUtils.isEmpty(phoneNum)) {
                                    bindMobile();
                                } else {
                                    bindQQ();
                                }
                            }
                        }).setNegativeButton("不了", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        dialog.dismiss();
                    }
                }).create().show();
                break;
            }
            case R.id.ll_info_tbaccount:
                String title1 = "更换淘宝账号";
                String message1 = "确定更换淘宝账号";
@@ -176,13 +239,23 @@
                    message1 = "确定绑定淘宝账号";
                    positive1 = "绑定";
                }
                if (info != null && StringUtils.isEmpty(phoneNum)) {
                    title1 = "更换提醒";
                    positive1 = "绑定手机号";
                    message1 = "该帐号没有绑定手机号,需绑定手机号才能完成淘宝更换。";
                }
                AddZFBInfoDialog2.Builder builder2 = new AddZFBInfoDialog2.Builder(MyInfoActivity.this);
                builder2.setTitle(title1).setMessage(message1)
                        .setPositiveButton(positive1, new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                                dialog.dismiss();
                                if (StringUtils.isEmpty(phoneNum)) {
                                    bindMobile();
                                } else {
                                    bindTB();
                                }
                            }
                        }).setNegativeButton("不了", new DialogInterface.OnClickListener() {
                    @Override
@@ -207,17 +280,9 @@
            case R.id.ll_info_sex://设置性别
                popwindow_sex();//选择相册
                break;
            case R.id.ll_info_wchat_num://设置微信号
                startActivity(new Intent(this, MyWXNumActivity.class)
                        .putExtra("weixin", StringUtils.isEmpty(weixin) ? "" : weixin)
                        .putExtra("weixintip", weixintip).putExtra("erCode", info.getErCode()));
                break;
            case R.id.ll_info_vip://超级会员信息
                Intent intent = new Intent(this, ShareBrowserActivity.class);
                intent.putExtra("url", vipLink);
                startActivity(intent);
                break;
            case R.id.ll_info_invite_code://邀请码
                if (info == null)
                    return;
                if (invitCodeUpdated || StringUtils.isEmpty(inviteCode) || !info.isVip())
                    return;
                Intent intent2 = new Intent(this, MyInviteCodeActivity.class);
@@ -227,9 +292,49 @@
            case R.id.ll_info_fans:
                startActivity(new Intent(this, ShareBrowserActivity.class).putExtra("url", fansCountLink));
                break;
            case R.id.ll_vip_action:
                if (vipAction != null)
                    JumpActivityUtil.jumpPage(this, vipAction.getJumpDetail(), vipAction.getParams());
            case R.id.ll_info_pdd_buy:
                buy = true;
            case R.id.ll_info_pdd_share:
                if (buy == null)
                    buy = false;
                ShoppingApi.getPDDAuthInfo(getApplicationContext(), UserUtil.getUid(getApplicationContext()), buy, new BasicTextHttpResponseHandler() {
                    @Override
                    public void onStart() {
                        super.onStart();
                        if (loading != null && !loading.isShowing())
                            loading.show();
                    }
                    @Override
                    public void onSuccessPerfect(int statusCode, Header[] headers, JSONObject jsonObject) throws Exception {
                        super.onSuccessPerfect(statusCode, headers, jsonObject);
                        if (jsonObject.optInt("code") == 0) {
                            JSONObject data = jsonObject.optJSONObject("data");
                            GoodsConvertLinkJumpLink pddJumpLink = new Gson().fromJson(data.toString(), GoodsConvertLinkJumpLink.class);
                            UserLijinLevelInfoVO userLevel = null;
                            if (data.optJSONObject("userLevel") != null) {
                                userLevel = new Gson().fromJson(data.optJSONObject("userLevel").toString(), UserLijinLevelInfoVO.class);
                            }
                            GoodsBuyJumpUtil.jumpPDD(MyInfoActivity.this, pddJumpLink, userLevel);
                        } else {
                            Toast.makeText(MyInfoActivity.this, jsonObject.optString("msg"), Toast.LENGTH_SHORT).show();
                        }
                    }
                    @Override
                    public void onFailure(int statusCode, Header[] headers, String jsonObject, Throwable e) {
                        super.onFailure(statusCode, headers, jsonObject, e);
                    }
                    @Override
                    public void onFinish() {
                        super.onFinish();
                        if (loading != null && loading.isShowing())
                            loading.dismiss();
                    }
                });
                break;
        }
    }
@@ -401,8 +506,7 @@
     * 保存用户信息
     */
    private void saveInfo(String nickName, String weixin, final Integer sex) {
        String uid = getSharedPreferences("user", MODE_PRIVATE).getString("uid", "");
        ShoppingApi.saveInfo(this, uid, nickName, weixin, sex, null, null, new BasicTextHttpResponseHandler() {
        ShoppingApi.saveInfo(this, UserUtil.getUid(ShoppingApplication.application), nickName, weixin, sex, null, null, new BasicTextHttpResponseHandler() {
            @Override
            public void onSuccessPerfect(int statusCode, Header[] headers, JSONObject jsonObject) throws Exception {
                if (jsonObject.optInt("code") == 0) {
@@ -452,12 +556,81 @@
        }
    }
    private void bindQQ() {
        DialogUtil.show(loadingDialog);
        QQLoginManager.getInstance(getApplicationContext()).startLogin(this, new QQLoginManager.QQLoginListener() {
            @Override
            public void onAuthCancel() {
                DialogUtil.dismiss(loadingDialog);
            }
            @Override
            public void onAuthSuccess(String openId) {
            }
            @Override
            public void onAuthFail(int code, String msg) {
                DialogUtil.dismiss(loadingDialog);
                SingleToast.showToast(getApplicationContext(), "QQ授权失败,请稍后再试");
            }
            @Override
            public void onGetUserInfoSuccess(final QQLoginManager.QQUserInfo user) {
                runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        DialogUtil.dismiss(loadingDialog);
                        AccountBindManager.bindQQ(getApplicationContext(), UserUtil.getUid(getApplicationContext()), user, new LoginManager.LoginAndBindListener() {
                            @Override
                            public void onBindStart() {
                                super.onBindStart();
                            }
                            @Override
                            public void onBindFinish() {
                                super.onBindFinish();
                            }
                            @Override
                            public void onBindSuccess(UserInfo user) {
                                super.onBindSuccess(user);
                                UserUtil.loginSuccess(getApplicationContext(), user);
                                Toast.makeText(getApplicationContext(), "绑定成功", Toast.LENGTH_SHORT).show();
                                getUserInfo(user.getId());
                            }
                            @Override
                            public void onBindFail(int code, String msg) {
                                super.onBindFail(code, msg);
                                Toast.makeText(getApplicationContext(), msg, Toast.LENGTH_SHORT).show();
                            }
                        });
                    }
                });
            }
            @Override
            public void onGetUserInfoFail(int code, String msg) {
                runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        SingleToast.showToast(getApplicationContext(), "用户信息获取失败,请稍后再试");
                        DialogUtil.dismiss(loadingDialog);
                    }
                });
            }
        });
    }
    /*
    绑定淘宝授权
     */
    private void getTaoBaoH5AuthInfo() {
        String uid = getSharedPreferences("user", MODE_PRIVATE).getString("uid", null);
        ShoppingApi.getTaoBaoAuthInfo(MyInfoActivity.this, uid, "", "bind", true, new BasicTextHttpResponseHandler() {
        ShoppingApi.getTaoBaoAuthInfo(MyInfoActivity.this, UserUtil.getUid(ShoppingApplication.application), "", "bind", true, new BasicTextHttpResponseHandler() {
            @Override
            public void onSuccessPerfect(int statusCode, Header[] headers, JSONObject jsonObject) throws Exception {
                if (jsonObject.optInt("code") == 0) {
@@ -527,7 +700,7 @@
    VIPActionInfo vipAction = null;
    private void getUserInfo(String uid) {
        ShoppingApi.getUserInfo2(this, uid, new BasicTextHttpResponseHandler() {
        ShoppingApi.getUserInfo2(this, UserUtil.getUid(ShoppingApplication.application), new BasicTextHttpResponseHandler() {
            @Override
            public void onSuccessPerfect(int statusCode, Header[] headers, JSONObject jsonObject) throws Exception {
                if (jsonObject.optString("code").equalsIgnoreCase("0")) {
@@ -539,6 +712,8 @@
                    if (data.optJSONObject("vipAction") != null) {
                        vipAction = new Gson().fromJson(data.optJSONObject("vipAction").toString(), VIPActionInfo.class);
                    }
                    pddBuyBind = data.optBoolean("pddBuyBind");
                    pddShareBind = data.optBoolean("pddShareBind");
                    String json = data.optJSONObject("user").toString();
@@ -572,6 +747,13 @@
        } else {
            binding.tvInfoRelativeWechat.setText(info.getWxName());
        }
        if (StringUtils.isEmpty(info.getQqOpenId())) {//QQ
            binding.tvInfoRelativeQq.setText("去绑定");
        } else {
            binding.tvInfoRelativeQq.setText(info.getQqNickName());
        }
        if (StringUtils.isEmpty(info.getOpenid())) {//淘宝
            binding.tvInfoTbaccount.setText("去绑定");
        } else {
@@ -583,33 +765,45 @@
            binding.tvInfoRelativeMobile.setText(info.getPhone());
        }
        //信息设置
//        if (info.isVip()) {
            binding.tvInfoVip.setVisibility(View.GONE);
//        } else {
//            binding.tvInfoVip.setVisibility(View.VISIBLE);
//        }
        //邀请码设置
        if (StringUtils.isEmpty(inviteCode) || !info.isVip())
            binding.llInfoInviteCode.setVisibility(View.GONE);
        else {
            binding.llInfoInviteCode.setVisibility(View.VISIBLE);
            binding.tvInfoInviteCode.setText(inviteCode);
            if (invitCodeUpdated || !info.isVip()) {
                binding.ivInfoInviteCodeEdit.setVisibility(View.GONE);
                ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams) binding.tvInfoInviteCode.getLayoutParams();
                params.setMargins(0, 0, DimenUtils.dip2px(this, 20), 0);
                binding.tvInfoInviteCode.requestLayout();
        if (pddBuyBind != null) {
            if (pddBuyBind) {
                binding.tvInfoPddBuy.setText("去更改");
            } else {
                binding.ivInfoInviteCodeEdit.setVisibility(View.VISIBLE);
                ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams) binding.tvInfoInviteCode.getLayoutParams();
                params.setMargins(0, 0, DimenUtils.dip2px(this, 10), 0);
                binding.tvInfoInviteCode.requestLayout();
                binding.tvInfoPddBuy.setText("去备案");
            }
        } else {
            binding.tvInfoPddBuy.setText("");
        }
        binding.llInfoInviteCode.setVisibility(View.GONE);
        if (pddShareBind != null) {
            if (pddShareBind) {
                binding.tvInfoPddShare.setText("去更改");
            } else {
                binding.tvInfoPddShare.setText("去备案");
            }
        } else {
            binding.tvInfoPddShare.setText("");
        }
        //邀请码设置
//        if (StringUtils.isEmpty(inviteCode) || !info.isVip())
//            binding.llInfoInviteCode.setVisibility(View.GONE);
//        else {
//            binding.llInfoInviteCode.setVisibility(View.VISIBLE);
//            binding.tvInfoInviteCode.setText(inviteCode);
//            if (invitCodeUpdated || !info.isVip()) {
//                binding.ivInfoInviteCodeEdit.setVisibility(View.GONE);
//                ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams) binding.tvInfoInviteCode.getLayoutParams();
//                params.setMargins(0, 0, DimenUtils.dip2px(this, 20), 0);
//                binding.tvInfoInviteCode.requestLayout();
//            } else {
//                binding.ivInfoInviteCodeEdit.setVisibility(View.VISIBLE);
//                ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams) binding.tvInfoInviteCode.getLayoutParams();
//                params.setMargins(0, 0, DimenUtils.dip2px(this, 10), 0);
//                binding.tvInfoInviteCode.requestLayout();
//            }
//        }
        //是否显示邀请人
//        if (StringUtils.isEmpty(fansCountLink)) {
@@ -619,15 +813,6 @@
//            binding.ivInfoFansEdit.setVisibility(View.VISIBLE);
//        }
        //设置会员动作
        if (vipAction != null) {
            binding.llVipAction.setVisibility(View.VISIBLE);
            binding.tvVipActionName.setText(vipAction.getName());
            if (vipAction.getContent() != null)
                binding.tvVipActionContent.setText(vipAction.getContent());
        } else {
            binding.llVipAction.setVisibility(View.GONE);
        }
    }
@@ -661,6 +846,7 @@
                }
            }
        }
        QQLoginManager.getInstance(getApplicationContext()).onActivityResult(requestCode,resultCode,data);
    }
    /**
@@ -674,7 +860,7 @@
        final SharedPreferences sp = getSharedPreferences("user", MODE_PRIVATE);
        if (sp.getBoolean("isLogin", false)) {
            mUid = sp.getString("uid", "0");
            ShoppingApi.uploadPortrait(this, mUid, photo, new BasicTextHttpResponseHandler() {
            ShoppingApi.uploadPortrait(this, UserUtil.getUid(ShoppingApplication.application), photo, new BasicTextHttpResponseHandler() {
                @Override
                public void onSuccessPerfect(int statusCode, Header[] headers, JSONObject jsonObject) throws Exception {
                    if (jsonObject.optInt("code") == 0) {