| | |
| | | package com.tejia.lijin.app.ui.mine; |
| | | |
| | | import android.app.Activity; |
| | | import android.content.DialogInterface; |
| | | import android.content.Intent; |
| | | import android.content.SharedPreferences; |
| | |
| | | import android.text.TextWatcher; |
| | | import android.util.Log; |
| | | import android.view.View; |
| | | import android.widget.FrameLayout; |
| | | import android.view.animation.AnimationUtils; |
| | | import android.widget.ImageView; |
| | | import android.widget.LinearLayout; |
| | | import android.widget.TextView; |
| | | import android.widget.Toast; |
| | | |
| | | import com.tencent.mm.opensdk.modelmsg.SendAuth; |
| | | import com.umeng.analytics.MobclickAgent; |
| | | import com.wpc.library.util.common.StringUtils; |
| | | import com.wpc.library.widget.PhoneNumberClearEditText; |
| | | import com.androidquery.AQuery; |
| | | 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.UserInfo; |
| | | import com.tejia.lijin.app.entity.eventbus.WXLoginEvent; |
| | | import com.tejia.lijin.app.ui.BaseActivity; |
| | | import com.tejia.lijin.app.ui.dialog.AddZFBInfoDialog; |
| | | import com.tejia.lijin.app.ui.dialog.ShapeLoadingDialog; |
| | | import com.tejia.lijin.app.ui.dialog.VerifyMobileDialog; |
| | | import com.tejia.lijin.app.ui.invite.ShareBrowserActivity; |
| | | import com.tejia.lijin.app.util.Constant; |
| | | import com.tejia.lijin.app.util.KeFuUtil; |
| | | import com.tejia.lijin.app.util.SystemParamsUtil; |
| | | import com.tejia.lijin.app.util.TopStatusSettings; |
| | | import com.tejia.lijin.app.util.ui.dialog.DialogUtil; |
| | | import com.tejia.lijin.app.util.umengCustomEvent.UserCustomEvent; |
| | | import com.tejia.lijin.app.util.user.AccountBindManager; |
| | | import com.tejia.lijin.app.util.user.AliyunSmsOneKeyLoginManager; |
| | | 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.tejia.lijin.wxapi.WXEntryActivity; |
| | | import com.tencent.connect.auth.QQToken; |
| | | import com.tencent.mm.opensdk.modelmsg.SendAuth; |
| | | import com.tencent.tauth.DefaultUiListener; |
| | | import com.tencent.tauth.IUiListener; |
| | | import com.tencent.tauth.Tencent; |
| | | import com.tencent.tauth.UiError; |
| | | import com.umeng.analytics.MobclickAgent; |
| | | import com.wpc.library.util.SingleToast; |
| | | import com.wpc.library.util.common.StringUtils; |
| | | import com.wpc.library.widget.PhoneNumberClearEditText; |
| | | |
| | | import org.apache.http.Header; |
| | | import org.json.JSONException; |
| | | import org.json.JSONObject; |
| | | |
| | | import de.greenrobot.event.EventBus; |
| | |
| | | * Created by weikou2015 on 2017/12/15. |
| | | */ |
| | | |
| | | public class LoginSelectActivity extends Activity implements View.OnClickListener { |
| | | public class LoginSelectActivity extends BaseActivity implements View.OnClickListener { |
| | | |
| | | public final static int TYPE_LOGIN = 1;//登录 |
| | | public final static int TYPE_BIND = 2;//绑定 |
| | | public final static int TYPE_BIND_WITHOUT_LOGINED = 3;//未登录绑定 |
| | | private ImageView iv_close, iv_contact_kefu, iv_login_wechat; |
| | | private TextView tv_user_agreement, tv_other_login, tv_mobile_hint, tv_privacy_policies, |
| | | tv_login_top_hint, tv_mobile_type; |
| | | FrameLayout fl_login_gain_sms; |
| | | private TextView tv_login_gain_sms, tv_user_agreement, tv_other_login, tv_privacy_policies, |
| | | tv_mobile_type; |
| | | private PhoneNumberClearEditText et_mobile_num; |
| | | LinearLayout ll_user_agreement; |
| | | private ImageView et_mobile_numimg; |
| | | private AQuery mAquery; |
| | | |
| | | String uid; |
| | | boolean isWXLogin = false; |
| | |
| | | int type; |
| | | String key;//微信登录尚未绑定手机时回传的标识 |
| | | |
| | | private static String TAG="LoginSelectActivity"; |
| | | private static String TAG = "LoginSelectActivity"; |
| | | |
| | | private AliyunSmsOneKeyLoginManager aliyunSmsOneKeyLoginManager; |
| | | |
| | | private boolean showOnkeyLoginToast = false; |
| | | |
| | | |
| | | @Override |
| | | protected void onCreate(Bundle savedInstanceState) { |
| | | super.onCreate(savedInstanceState); |
| | | setContentView(R.layout.activity_login_select); |
| | | setShowRecommend(false); |
| | | mAquery = new AQuery(this); |
| | | TopStatusSettings.setStatusViewAndDeepColorNoView(this); |
| | | // tv_user_agreement.getPaint().setFlags(Paint.UNDERLINE_TEXT_FLAG); |
| | | initData(getIntent()); |
| | | String from = getIntent().getStringExtra("from"); |
| | | UserCustomEvent.userLogin(this, StringUtils.isEmpty(from) ? "其它" : from); |
| | | EventBus.getDefault().register(this); |
| | | |
| | | String secretInfo = "rb6R3o8sx4BVXzip2GLC27gDVtY8EWD3BHYM8dAuvCE1e7Ux/6jHkaZjgOStr/EGvyH0Q2XHZnM6u0tp7mXY3wsHv6+bJaB6hsgzYEu1up3UgmIIrGwNOkDInWe5n6QOnNN+XSc4oF3Od1AJtAgd6oun7JkrbdJCqDN5qTPXF7rS44sYGlh7apz+fJAU9Nn1/Jzt5qdqEWsjmqu07Z3Gasrl+cEeBC9li2+5yqAnnXB+PflFHd/kdN9iCHRuY99qBVUizej95oL/jRMzw4SQKgWDW2PF9llOcSyYWivRGeFAaDISQSmc4g=="; |
| | | aliyunSmsOneKeyLoginManager = new AliyunSmsOneKeyLoginManager(this, secretInfo); |
| | | aliyunSmsOneKeyLoginManager.init(new AliyunSmsOneKeyLoginManager.IOneKeyLoginListener() { |
| | | |
| | | @Override |
| | | public void onFail(String st) { |
| | | if (showOnkeyLoginToast) { |
| | | showOnkeyLoginToast = false; |
| | | android.widget.Toast.makeText(LoginSelectActivity.this, st, Toast.LENGTH_SHORT).show(); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void onCancel() { |
| | | showOnkeyLoginToast = true; |
| | | } |
| | | |
| | | @Override |
| | | public void onEnvCheckSuccess() { |
| | | showOnkeyLoginToast = false; |
| | | //掉起授权框 |
| | | aliyunSmsOneKeyLoginManager.startGetLoginToken(); |
| | | } |
| | | |
| | | @Override |
| | | public void onStartAuthPageSuccess() { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onToken(String token) { |
| | | aliyunSmsOneKeyLoginManager.quitLoginPage(); |
| | | //登录 |
| | | if (type == TYPE_LOGIN) { |
| | | LoginManager.loginByPhone(null, null, token, new LoginManager.LoginAndBindListener() { |
| | | @Override |
| | | public void onLoginStart() { |
| | | DialogUtil.show(loadingDialog); |
| | | } |
| | | |
| | | @Override |
| | | public void onLoginFinish() { |
| | | DialogUtil.dismiss(loadingDialog); |
| | | } |
| | | |
| | | @Override |
| | | public void onLoginSuccess(UserInfo user) { |
| | | UserUtil.loginSuccess(getApplicationContext(), user); |
| | | Toast.makeText(getApplicationContext(), "恭喜你,登录成功", Toast.LENGTH_SHORT).show(); |
| | | finish(); |
| | | } |
| | | |
| | | @Override |
| | | public void onLoginFail(int code, String msg) { |
| | | Toast.makeText(LoginSelectActivity.this, msg, Toast.LENGTH_SHORT).show(); |
| | | } |
| | | }); |
| | | } else if (type == TYPE_BIND_WITHOUT_LOGINED) { |
| | | LoginManager.loginWithPhone(null, null, token, key, new LoginManager.LoginAndBindListener() { |
| | | @Override |
| | | public void onBindStart() { |
| | | DialogUtil.show(loadingDialog); |
| | | } |
| | | |
| | | @Override |
| | | public void onBindFinish() { |
| | | DialogUtil.dismiss(loadingDialog); |
| | | } |
| | | |
| | | @Override |
| | | public void onBindSuccess(UserInfo user) { |
| | | UserUtil.loginSuccess(getApplicationContext(), user); |
| | | Toast.makeText(getApplicationContext(), "恭喜你,登录成功", Toast.LENGTH_SHORT).show(); |
| | | finish(); |
| | | } |
| | | |
| | | @Override |
| | | public void onBindFail(int code, String msg) { |
| | | Toast.makeText(LoginSelectActivity.this, msg, Toast.LENGTH_SHORT).show(); |
| | | } |
| | | }); |
| | | } else { |
| | | //电话号码绑定 |
| | | AccountBindManager.bindPhone(getApplicationContext(), null, null, token, new LoginManager.LoginAndBindListener() { |
| | | |
| | | @Override |
| | | public void onBindFail(int code, String msg) { |
| | | super.onBindFail(code, msg); |
| | | if (code == 2) { |
| | | AddZFBInfoDialog.Builder builder = new AddZFBInfoDialog.Builder(LoginSelectActivity.this); |
| | | builder.setTitle("号码已占用提示").setMessage("很抱歉,该手机号已被其他帐号占用," + |
| | | "若要继续完成本帐号手机号更换,请去取消占用或更换其他手机号,谢谢。\n") |
| | | .setPositiveButton("知道了", new DialogInterface.OnClickListener() { |
| | | @Override |
| | | public void onClick(DialogInterface dialog, int which) { |
| | | dialog.dismiss(); |
| | | } |
| | | }).create().show(); |
| | | setResult(100); |
| | | } else { |
| | | Toast.makeText(getApplicationContext(), msg, Toast.LENGTH_SHORT).show(); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void onBindFinish() { |
| | | super.onBindFinish(); |
| | | } |
| | | |
| | | @Override |
| | | public void onBindStart() { |
| | | super.onBindStart(); |
| | | } |
| | | |
| | | @Override |
| | | public void onBindSuccess(UserInfo user) { |
| | | super.onBindSuccess(user); |
| | | UserUtil.loginSuccess(getApplicationContext(), user); |
| | | Toast.makeText(getApplicationContext(), "绑定成功", Toast.LENGTH_SHORT).show(); |
| | | finish(); |
| | | } |
| | | }); |
| | | } |
| | | } |
| | | |
| | | }); |
| | | |
| | | // openOneKeyLogin(showOnkeyLoginToast); |
| | | |
| | | } |
| | | |
| | | private synchronized void openOneKeyLogin(final boolean notify) { |
| | | ShoppingApi.allowOneKeyLogin(this, new BasicTextHttpResponseHandler() { |
| | | |
| | | @Override |
| | | public void onStart() { |
| | | DialogUtil.show(loadingDialog); |
| | | } |
| | | |
| | | @Override |
| | | public void onSuccessPerfect(int statusCode, Header[] headers, JSONObject jsonObject) throws Exception { |
| | | if (jsonObject.optInt("code") == 0) { |
| | | aliyunSmsOneKeyLoginManager.checkEnv(); |
| | | } else { |
| | | if (notify) { |
| | | Toast.makeText(LoginSelectActivity.this, jsonObject.optString("msg"), Toast.LENGTH_SHORT).show(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void onFinish() { |
| | | DialogUtil.dismiss(loadingDialog); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | private void initData(Intent intent) { |
| | | type =intent.getIntExtra("type", TYPE_LOGIN); |
| | | type = intent.getIntExtra("type", TYPE_LOGIN); |
| | | init(intent); |
| | | addListener(); |
| | | } |
| | |
| | | @Override |
| | | protected void onNewIntent(Intent intent) { |
| | | super.onNewIntent(intent); |
| | | Log.i(TAG,"onNewIntent"); |
| | | Log.i(TAG, "onNewIntent"); |
| | | initData(intent); |
| | | } |
| | | |
| | |
| | | 初始化控件 |
| | | */ |
| | | private void init(Intent intent) { |
| | | iv_close = findViewById(R.id.iv_close); |
| | | iv_contact_kefu = findViewById(R.id.iv_contact_kefu); |
| | | tv_mobile_hint = findViewById(R.id.tv_mobile_hint); |
| | | tv_user_agreement = findViewById(R.id.tv_user_agreement); |
| | | iv_login_wechat = findViewById(R.id.iv_login_wechat); |
| | | fl_login_gain_sms = findViewById(R.id.fl_login_gain_sms); |
| | | tv_login_gain_sms = findViewById(R.id.tv_login_gain_sms); |
| | | et_mobile_num = findViewById(R.id.et_mobile_num); |
| | | tv_other_login = findViewById(R.id.tv_other_login); |
| | | tv_privacy_policies = findViewById(R.id.tv_privacy_policies); |
| | | tv_login_top_hint = findViewById(R.id.tv_login_top_hint); |
| | | tv_mobile_type = findViewById(R.id.tv_mobile_type); |
| | | ll_user_agreement = findViewById(R.id.ll_user_agreement); |
| | | et_mobile_numimg = findViewById(R.id.et_mobile_numimg); |
| | | et_mobile_numimg.setColorFilter(getResources().getColor(R.color.black)); |
| | | |
| | | tv_mobile_hint.setTextColor(getResources().getColor(R.color.gray)); |
| | | tv_mobile_hint.setText(String.format("新的手机号必须没有绑定过其他%s帐号",getResources().getString(R.string.app_name))); |
| | | |
| | | fl_login_gain_sms.setEnabled(false); |
| | | fl_login_gain_sms.setBackgroundResource(R.drawable.shape_login_gain_sms); |
| | | SharedPreferences sp = getSharedPreferences("user", MODE_PRIVATE); |
| | | sp.edit().putBoolean("first", true).commit(); |
| | | uid = intent.getStringExtra("uid"); |
| | | key =intent.getStringExtra("key"); |
| | | key = intent.getStringExtra("key"); |
| | | getUserConfig(); |
| | | } |
| | | |
| | |
| | | *添加监听 |
| | | */ |
| | | private void addListener() { |
| | | tv_login_gain_sms.setOnClickListener(this); |
| | | tv_user_agreement.setOnClickListener(this); |
| | | iv_close.setOnClickListener(this); |
| | | iv_contact_kefu.setOnClickListener(this); |
| | | fl_login_gain_sms.setOnClickListener(this); |
| | | iv_login_wechat.setOnClickListener(this); |
| | | tv_other_login.setOnClickListener(this); |
| | | tv_privacy_policies.setOnClickListener(this); |
| | | mAquery.id(R.id.tv_login_onekey).clicked(new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | openOneKeyLogin(true); |
| | | } |
| | | }); |
| | | mAquery.id(R.id.iv_close).clicked(this); |
| | | mAquery.id(R.id.tv_login_wx).clicked(this); |
| | | mAquery.id(R.id.tv_login_qq).clicked(this); |
| | | mAquery.id(R.id.tv_agree).clicked(this); |
| | | mAquery.id(R.id.tv_help).clicked(new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | startActivity(new Intent(getApplicationContext(), ShareBrowserActivity.class).putExtra("url", SystemParamsUtil.getHelpUrl(getApplicationContext()))); |
| | | } |
| | | }); |
| | | |
| | | |
| | | et_mobile_num.addTextChangedListener(new TextWatcher() { |
| | | @Override |
| | | public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) { |
| | |
| | | canSend = true; |
| | | } |
| | | } |
| | | |
| | | fl_login_gain_sms.setEnabled(canSend); |
| | | fl_login_gain_sms.setBackgroundResource(canSend ? |
| | | R.drawable.shape_mobile_login_light : R.drawable.shape_login_gain_sms); |
| | | if(canSend) { |
| | | tv_login_gain_sms.setEnabled(canSend); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void afterTextChanged(Editable editable) { |
| | | // fl_login_gain_sms.setEnabled(editable.length() == 13 ? true : false); |
| | | // fl_login_gain_sms.setBackgroundResource(editable.length() == 13 ? |
| | | String text=editable !=null?editable.toString():""; |
| | | if(text.replace(" ","").length()==11){ |
| | | tv_login_gain_sms.setEnabled(true); |
| | | }else{ |
| | | tv_login_gain_sms.setEnabled(false); |
| | | } |
| | | |
| | | // tv_login_gain_sms.setBackgroundResource(editable.length() == 13 ? |
| | | // R.drawable.shape_mobile_login_light : R.drawable.shape_login_gain_sms); |
| | | } |
| | | }); |
| | |
| | | @Override |
| | | protected void onResume() { |
| | | super.onResume(); |
| | | Log.i(TAG,"onResume"); |
| | | MobclickAgent.onResume(this); |
| | | SharedPreferences sp = getSharedPreferences("user", MODE_PRIVATE); |
| | | boolean isLogin = sp.getBoolean("isLogin", false); |
| | | Log.i(TAG, "onResume"); |
| | | boolean isLogin = UserUtil.isLogin(getApplicationContext()); |
| | | if (isLogin) {//用户已经登录 |
| | | if (isWXLogin) { |
| | | finish(); |
| | | return; |
| | | } |
| | | tv_login_top_hint.setText("请绑定你的常用手机号"); |
| | | // tv_login_top_hint.setVisibility(View.INVISIBLE); |
| | | ll_user_agreement.setVisibility(View.INVISIBLE); |
| | | tv_other_login.setVisibility(View.INVISIBLE); |
| | | iv_login_wechat.setVisibility(View.INVISIBLE); |
| | | tv_mobile_type.setText("绑定"+getResources().getString(R.string.app_name)); |
| | | tv_mobile_hint.setText(String.format("新的手机号必须没有绑定过其他%s帐号",getResources().getString(R.string.app_name))); |
| | | tv_mobile_hint.setVisibility(View.INVISIBLE); |
| | | } else { |
| | | if (type == TYPE_BIND_WITHOUT_LOGINED) {//用户尚未登录绑定电话号码 |
| | | tv_login_top_hint.setText("请绑定你的常用手机号"); |
| | | // tv_login_top_hint.setVisibility(View.INVISIBLE); |
| | | // ll_user_agreement.setVisibility(View.INVISIBLE); |
| | | tv_other_login.setVisibility(View.INVISIBLE); |
| | | iv_login_wechat.setVisibility(View.INVISIBLE); |
| | | ll_user_agreement.setVisibility(View.INVISIBLE); |
| | | tv_mobile_type.setText("绑定"+getResources().getString(R.string.app_name)); |
| | | tv_mobile_hint.setText(String.format("新的手机号必须没有绑定过其他%s帐号",getResources().getString(R.string.app_name))); |
| | | tv_mobile_hint.setVisibility(View.INVISIBLE); |
| | | } |
| | | } |
| | | initView(type); |
| | | } |
| | | |
| | | |
| | | private void initView(int type) { |
| | | switch (type) { |
| | | case TYPE_LOGIN: |
| | | mAquery.id(R.id.iv_login_mark).visibility(View.VISIBLE); |
| | | mAquery.id(R.id.tv_bind_mark).visibility(View.GONE); |
| | | mAquery.id(R.id.tv_other_login).visibility(View.VISIBLE); |
| | | mAquery.id(R.id.ll_other_login).visibility(View.VISIBLE); |
| | | mAquery.id(R.id.tv_login_onekey).text("本机号码一键登录"); |
| | | mAquery.id(R.id.tv_mobile_hint).text(String.format("新的手机号必须没有绑定过其他%s帐号", getResources().getString(R.string.app_name))); |
| | | break; |
| | | case TYPE_BIND: |
| | | case TYPE_BIND_WITHOUT_LOGINED: |
| | | mAquery.id(R.id.iv_login_mark).visibility(View.GONE); |
| | | mAquery.id(R.id.tv_bind_mark).visibility(View.VISIBLE); |
| | | mAquery.id(R.id.tv_other_login).visibility(View.GONE); |
| | | mAquery.id(R.id.ll_other_login).visibility(View.GONE); |
| | | mAquery.id(R.id.tv_login_onekey).text("本机号码一键绑定"); |
| | | mAquery.id(R.id.tv_mobile_hint).text(String.format("新的手机号必须没有绑定过其他%s帐号", getResources().getString(R.string.app_name))); |
| | | |
| | | mAquery.id(R.id.cb_agree).checked(false); |
| | | |
| | | break; |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public void onClick(View view) { |
| | |
| | | case R.id.iv_contact_kefu: |
| | | KeFuUtil.jumpKeFu(LoginSelectActivity.this, "登录"); |
| | | break; |
| | | case R.id.tv_other_login: |
| | | tv_other_login.setCompoundDrawablesWithIntrinsicBounds(0, 0, |
| | | iv_login_wechat.getVisibility() == View.VISIBLE ? |
| | | R.drawable.ic_other_login_close : |
| | | R.drawable.ic_other_login_open, 0); |
| | | iv_login_wechat.setVisibility(iv_login_wechat.getVisibility() == View.VISIBLE |
| | | ? View.INVISIBLE : View.VISIBLE); |
| | | break; |
| | | |
| | | case R.id.tv_user_agreement: |
| | | UserCustomEvent.userLoginProtocol(LoginSelectActivity.this); |
| | | if (StringUtils.isEmpty(serviceProtocolLink)) |
| | |
| | | intent.putExtra("url", serviceProtocolLink); |
| | | startActivity(intent); |
| | | break; |
| | | //隐私政策 |
| | | // serviceProtocolLink = jsonObject.optJSONObject("data").optString("serviceProtocolLink"); |
| | | // privacyProtocolLink = jsonObject.optJSONObject("data").optString("privacyProtocolLink"); |
| | | case R.id.tv_privacy_policies: |
| | | UserCustomEvent.userLoginProtocol(LoginSelectActivity.this); |
| | | if (StringUtils.isEmpty(privacyProtocolLink)) |
| | |
| | | intent1.putExtra("url", privacyProtocolLink); |
| | | startActivity(intent1); |
| | | break; |
| | | case R.id.iv_login_wechat: |
| | | case R.id.tv_login_wx: |
| | | if (!isAgreed()) { |
| | | return; |
| | | } |
| | | UserCustomEvent.userLoginWeixin(LoginSelectActivity.this); |
| | | if (ShoppingApplication.application.mWxApi.isWXAppInstalled()) { |
| | | isWXLogin = true; |
| | |
| | | Toast.makeText(LoginSelectActivity.this, "请先安装微信客户端", Toast.LENGTH_SHORT).show(); |
| | | } |
| | | break; |
| | | case R.id.fl_login_gain_sms: |
| | | fl_login_gain_sms.setEnabled(false); |
| | | case R.id.tv_login_qq: |
| | | if (!isAgreed()) { |
| | | return; |
| | | } |
| | | //QQ登录开始 |
| | | 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) { |
| | | Log.i(TAG, new Gson().toJson(user)); |
| | | runOnUiThread(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | DialogUtil.dismiss(loadingDialog); |
| | | //TODO 做QQ登录 |
| | | LoginManager.loginByQQ(user, new LoginManager.LoginAndBindListener() { |
| | | |
| | | @Override |
| | | public void onLoginStart() { |
| | | super.onLoginStart(); |
| | | DialogUtil.show(loadingDialog); |
| | | } |
| | | |
| | | @Override |
| | | public void onLoginFinish() { |
| | | super.onLoginFinish(); |
| | | DialogUtil.dismiss(loadingDialog); |
| | | } |
| | | |
| | | @Override |
| | | public void onLoginFail(int code, String msg) { |
| | | super.onLoginFail(code, msg); |
| | | Toast.makeText(getApplicationContext(), msg, Toast.LENGTH_SHORT).show(); |
| | | } |
| | | |
| | | @Override |
| | | public void onLoginSuccess(UserInfo user) { |
| | | super.onLoginSuccess(user); |
| | | UserUtil.loginSuccess(getApplicationContext(), user); |
| | | Toast.makeText(getApplicationContext(), "恭喜你,登录成功", Toast.LENGTH_SHORT).show(); |
| | | finish(); |
| | | } |
| | | |
| | | @Override |
| | | public void bindPhone(String key) { |
| | | super.bindPhone(key); |
| | | Intent intent = new Intent(getApplicationContext(), LoginSelectActivity.class); |
| | | intent.putExtra("type", LoginSelectActivity.TYPE_BIND_WITHOUT_LOGINED); |
| | | intent.putExtra("key", key); |
| | | startActivity(intent); |
| | | // finish(); |
| | | } |
| | | |
| | | |
| | | }); |
| | | |
| | | |
| | | } |
| | | }); |
| | | |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onGetUserInfoFail(int code, String msg) { |
| | | runOnUiThread(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | SingleToast.showToast(getApplicationContext(), "用户信息获取失败,请稍后再试"); |
| | | DialogUtil.dismiss(loadingDialog); |
| | | } |
| | | }); |
| | | |
| | | } |
| | | }); |
| | | |
| | | |
| | | break; |
| | | case R.id.tv_login_gain_sms: |
| | | if (!isAgreed() && (type == TYPE_LOGIN || type == TYPE_BIND_WITHOUT_LOGINED)) { |
| | | return; |
| | | } |
| | | tv_login_gain_sms.setEnabled(false); |
| | | UserCustomEvent.userLoginSms(LoginSelectActivity.this); |
| | | isWXLogin = false; |
| | | if (type == TYPE_BIND || type == TYPE_BIND_WITHOUT_LOGINED) { |
| | |
| | | getVerificationCode(); |
| | | } |
| | | break; |
| | | |
| | | case R.id.tv_agree: |
| | | mAquery.id(R.id.cb_agree).checked(!mAquery.id(R.id.cb_agree).isChecked()); |
| | | break; |
| | | } |
| | | } |
| | | |
| | | private boolean isAgreed() { |
| | | if (!mAquery.id(R.id.cb_agree).isChecked()) { |
| | | LinearLayout ll_user_agreement = (LinearLayout) mAquery.id(R.id.ll_user_agreement).getView(); |
| | | ll_user_agreement.startAnimation(AnimationUtils.loadAnimation(this, R.anim.user_agreement)); |
| | | SingleToast.showToast(getApplicationContext(), "请同意用户协议与隐私政策"); |
| | | return false; |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | private boolean isIntent = false; |
| | |
| | | @Override |
| | | protected void onPause() { |
| | | super.onPause(); |
| | | MobclickAgent.onPause(this); |
| | | if (isIntent) { |
| | | finish(); |
| | | } |
| | |
| | | @Override |
| | | public void onSuccessPerfect(int statusCode, Header[] headers, JSONObject jsonObject) throws Exception { |
| | | if (jsonObject.optString("code").equalsIgnoreCase("0")) { |
| | | tv_mobile_hint.setTextColor(getResources().getColor(R.color.gray)); |
| | | tv_mobile_hint.setText(String.format("新的手机号必须没有绑定过其他%s帐号",getResources().getString(R.string.app_name))); |
| | | mAquery.id(R.id.tv_mobile_hint).textColorId(R.color.gray); |
| | | mAquery.id(R.id.tv_mobile_hint).text(String.format("新的手机号必须没有绑定过其他%s帐号", getResources().getString(R.string.app_name))); |
| | | |
| | | Intent intent = new Intent(LoginSelectActivity.this, LoginVerifyCodeActivity.class); |
| | | intent.putExtra("title", "登录"); |
| | |
| | | } |
| | | }).create().show(); |
| | | } else { |
| | | tv_mobile_hint.setTextColor(getResources().getColor(R.color.detail_sharelist_reward_num)); |
| | | tv_mobile_hint.setText(jsonObject.optString("msg")); |
| | | mAquery.id(R.id.tv_mobile_hint).textColorId(R.color.detail_sharelist_reward_num); |
| | | mAquery.id(R.id.tv_mobile_hint).text(jsonObject.optString("msg")); |
| | | Toast.makeText(LoginSelectActivity.this, jsonObject.optString("msg"), Toast.LENGTH_SHORT).show(); |
| | | } |
| | | } |
| | |
| | | @Override |
| | | public void onFinish() { |
| | | super.onFinish(); |
| | | fl_login_gain_sms.setEnabled(true); |
| | | tv_login_gain_sms.setEnabled(true); |
| | | pd.dismiss(); |
| | | } |
| | | }); |
| | |
| | | } |
| | | pd.show(); |
| | | final String mobileNum = et_mobile_num.getText().toString().trim(); |
| | | ShoppingApi.sendMSMBind(LoginSelectActivity.this, slideVerify + "", mobileNum,UserUtil.getUid(getApplicationContext()), new BasicTextHttpResponseHandler() { |
| | | ShoppingApi.sendMSMBind(LoginSelectActivity.this, slideVerify + "", mobileNum, UserUtil.getUid(getApplicationContext()), new BasicTextHttpResponseHandler() { |
| | | @Override |
| | | public void onSuccessPerfect(int statusCode, Header[] headers, JSONObject jsonObject) throws Exception { |
| | | if (jsonObject.optString("code").equalsIgnoreCase("0")) { |
| | | tv_mobile_hint.setTextColor(getResources().getColor(R.color.gray)); |
| | | tv_mobile_hint.setText(String.format("新的手机号必须没有绑定过其他%s帐号",getResources().getString(R.string.app_name))); |
| | | mAquery.id(R.id.tv_mobile_hint).textColorId(R.color.gray); |
| | | mAquery.id(R.id.tv_mobile_hint).text(String.format("新的手机号必须没有绑定过其他%s帐号", getResources().getString(R.string.app_name))); |
| | | Intent intent = new Intent(LoginSelectActivity.this, LoginVerifyCodeActivity.class); |
| | | intent.putExtra("title", "绑定"); |
| | | intent.putExtra("uid", uid); |
| | |
| | | } |
| | | }).create().show(); |
| | | } else { |
| | | tv_mobile_hint.setTextColor(getResources().getColor(R.color.detail_sharelist_reward_num)); |
| | | tv_mobile_hint.setText(jsonObject.optString("msg")); |
| | | mAquery.id(R.id.tv_mobile_hint).textColorId(R.color.detail_sharelist_reward_num); |
| | | mAquery.id(R.id.tv_mobile_hint).text(jsonObject.optString("msg")); |
| | | Toast.makeText(LoginSelectActivity.this, jsonObject.optString("msg"), Toast.LENGTH_SHORT).show(); |
| | | } |
| | | } |
| | |
| | | @Override |
| | | public void onFinish() { |
| | | super.onFinish(); |
| | | fl_login_gain_sms.setEnabled(true); |
| | | tv_login_gain_sms.setEnabled(true); |
| | | if (pd.isShowing()) |
| | | pd.dismiss(); |
| | | } |
| | |
| | | |
| | | @Override |
| | | protected void onActivityResult(int requestCode, int resultCode, Intent data) { |
| | | super.onActivityResult(requestCode, resultCode, data); |
| | | if (requestCode == 99 && resultCode == 100) { |
| | | finish(); |
| | | } |
| | | QQLoginManager.getInstance(getApplicationContext()).onActivityResult(requestCode, resultCode, data); |
| | | super.onActivityResult(requestCode, resultCode, data); |
| | | } |
| | | |
| | | public void onEventMainThread(WXLoginEvent event) { |
| | |
| | | |
| | | @Override |
| | | protected void onDestroy() { |
| | | super.onDestroy(); |
| | | aliyunSmsOneKeyLoginManager.quitLoginPage(); |
| | | EventBus.getDefault().unregister(this); |
| | | super.onDestroy(); |
| | | } |
| | | } |