|
|
@@ -9,6 +9,7 @@ import android.widget.PopupWindow;
|
|
|
import android.widget.TextView;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.google.gson.JsonObject;
|
|
|
import com.sheep.gamegroup.absBase.AbsChooseImageActivity;
|
|
|
import com.sheep.gamegroup.model.entity.BaseMessage;
|
|
|
import com.sheep.gamegroup.model.entity.UserEntity;
|
|
|
@@ -23,6 +24,11 @@ import com.sheep.jiuyan.samllsheep.R;
|
|
|
import com.sheep.jiuyan.samllsheep.SheepApp;
|
|
|
import com.sheep.jiuyan.samllsheep.utils.G;
|
|
|
import com.sheep.jiuyan.samllsheep.utils.TitleBarUtils;
|
|
|
+import com.umeng.socialize.UMAuthListener;
|
|
|
+import com.umeng.socialize.UMShareAPI;
|
|
|
+import com.umeng.socialize.bean.SHARE_MEDIA;
|
|
|
+
|
|
|
+import java.util.Map;
|
|
|
|
|
|
import butterknife.BindView;
|
|
|
import butterknife.ButterKnife;
|
|
|
@@ -32,6 +38,8 @@ import rx.functions.Action1;
|
|
|
import rx.schedulers.Schedulers;
|
|
|
|
|
|
import static com.sheep.gamegroup.util.UMConfigUtils.Event.BIND_PHONE;
|
|
|
+import static com.sheep.gamegroup.util.UMConfigUtils.Event.BIND_QQ;
|
|
|
+import static com.sheep.gamegroup.util.UMConfigUtils.Event.BIND_TX_WX;
|
|
|
import static com.sheep.gamegroup.util.UMConfigUtils.Event.BIND_WX;
|
|
|
import static com.sheep.gamegroup.util.UMConfigUtils.Event.USER_INFO_AVATAR;
|
|
|
import static com.sheep.gamegroup.util.UMConfigUtils.Event.USER_INFO_NAME;
|
|
|
@@ -57,6 +65,16 @@ public class PersonalInfoAct extends AbsChooseImageActivity {
|
|
|
TextView tvSex;
|
|
|
@BindView(R.id.tv_birthday)
|
|
|
TextView tvBirthday;
|
|
|
+ @BindView(R.id.personal_info_phone)
|
|
|
+ TextView personal_info_phone;
|
|
|
+ @BindView(R.id.personal_info_bind_tx_wx)
|
|
|
+ TextView personal_info_bind_tx_wx;
|
|
|
+ @BindView(R.id.personal_info_bind_qq)
|
|
|
+ TextView personal_info_bind_qq;
|
|
|
+ @BindView(R.id.personal_info_bind_wx)
|
|
|
+ TextView personal_info_bind_wx;
|
|
|
+ @BindView(R.id.personal_info_authentication)
|
|
|
+ TextView personal_info_authentication;
|
|
|
|
|
|
|
|
|
@Override
|
|
|
@@ -82,12 +100,6 @@ public class PersonalInfoAct extends AbsChooseImageActivity {
|
|
|
|
|
|
}
|
|
|
|
|
|
- @BindView(R.id.personal_info_phone)
|
|
|
- TextView personal_info_phone;
|
|
|
- @BindView(R.id.personal_info_wx)
|
|
|
- TextView personal_info_wx;
|
|
|
- @BindView(R.id.personal_info_authentication)
|
|
|
- TextView personal_info_authentication;
|
|
|
|
|
|
@Override
|
|
|
public void initData() {
|
|
|
@@ -158,7 +170,9 @@ public class PersonalInfoAct extends AbsChooseImageActivity {
|
|
|
});
|
|
|
}
|
|
|
|
|
|
- @OnClick({R.id.personal_info_avatar_container, R.id.personal_info_name_container, R.id.personal_info_qr_container, R.id.personal_info_phone_container, R.id.personal_info_wx_container,
|
|
|
+ @OnClick({R.id.personal_info_avatar_container, R.id.personal_info_name_container, R.id.personal_info_qr_container,
|
|
|
+ R.id.personal_info_phone_container, R.id.personal_info_bind_tx_wx_container,
|
|
|
+ R.id.personal_info_bind_qq_container, R.id.personal_info_bind_wx_container,
|
|
|
R.id.personal_info_authentication_container, R.id.llayout_sex, R.id.llayout_birthday})
|
|
|
|
|
|
public void onClick(View view) {
|
|
|
@@ -196,14 +210,53 @@ public class PersonalInfoAct extends AbsChooseImageActivity {
|
|
|
Jump2View.getInstance().goBindPhone(activity, null);
|
|
|
BIND_PHONE.onEvent();
|
|
|
break;
|
|
|
- case R.id.personal_info_wx_container: ////跳转到微信
|
|
|
- if (userEntity == null) {
|
|
|
- G.showToast(R.string.loading_data);
|
|
|
- } else if (TextUtils.isEmpty(userEntity.getWx_openid())) {
|
|
|
- Jump2View.getInstance().goNoBindWx(activity, ChangeWxOrTelAct.TYPE_NORMAL);
|
|
|
- } else {
|
|
|
- G.showToast("您已经绑定微信");
|
|
|
- }
|
|
|
+ case R.id.personal_info_bind_tx_wx_container: //跳转到绑定提现微信号的界面
|
|
|
+ CommonUtil.getInstance().callActionWithUserInfo(new Action1<UserEntity>() {
|
|
|
+ @Override
|
|
|
+ public void call(UserEntity userEntity) {
|
|
|
+ if(userEntity == null){
|
|
|
+ G.showToast(R.string.error_data);
|
|
|
+ } else if (TextUtils.isEmpty(userEntity.getWx_openid())) {
|
|
|
+ Jump2View.getInstance().goNoBindWx(activity, ChangeWxOrTelAct.TYPE_NORMAL);
|
|
|
+ } else {
|
|
|
+ G.showToast("您已经绑定微信");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ BIND_TX_WX.onEvent();
|
|
|
+ break;
|
|
|
+ case R.id.personal_info_bind_qq_container: //跳转到验证手机号并绑定qq的界面
|
|
|
+ CommonUtil.getInstance().callActionWithUserInfo(new Action1<UserEntity>() {
|
|
|
+ @Override
|
|
|
+ public void call(UserEntity userEntity) {
|
|
|
+ if(userEntity == null){
|
|
|
+ G.showToast(R.string.error_data);
|
|
|
+ } else if(!userEntity.isBindMobile()){
|
|
|
+ G.showToast("请先绑定手机号");
|
|
|
+ } else if(!userEntity.isBindQQ()){
|
|
|
+ bindQQ();
|
|
|
+ } else {
|
|
|
+ Jump2View.getInstance().goBindThird(activity, ActModifyThird.THIRD_TYPE_QQ);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ BIND_QQ.onEvent();
|
|
|
+ break;
|
|
|
+ case R.id.personal_info_bind_wx_container: //跳转到验证手机号并绑定微信的界面
|
|
|
+ CommonUtil.getInstance().callActionWithUserInfo(new Action1<UserEntity>() {
|
|
|
+ @Override
|
|
|
+ public void call(UserEntity userEntity) {
|
|
|
+ if(userEntity == null){
|
|
|
+ G.showToast(R.string.error_data);
|
|
|
+ } else if(!userEntity.isBindMobile()){
|
|
|
+ G.showToast("请先绑定手机号");
|
|
|
+ } else if(!userEntity.isBindWx()){
|
|
|
+ bindWX();
|
|
|
+ } else {
|
|
|
+ Jump2View.getInstance().goBindThird(activity, ActModifyThird.THIRD_TYPE_WX);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
BIND_WX.onEvent();
|
|
|
break;
|
|
|
case R.id.personal_info_authentication_container: ////跳转授权
|
|
|
@@ -212,6 +265,99 @@ public class PersonalInfoAct extends AbsChooseImageActivity {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private void bindQQ() {
|
|
|
+ UMShareAPI.get(this).doOauthVerify(this, SHARE_MEDIA.QQ, new UMAuthListener() {
|
|
|
+ @Override
|
|
|
+ public void onStart(SHARE_MEDIA platform) {
|
|
|
+ showProgress();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onComplete(SHARE_MEDIA platform, int action, Map<String, String> data) {
|
|
|
+ bindThird("qzone", data.get("access_token"), data.get("openid"));
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onError(SHARE_MEDIA platform, int action, Throwable t) {
|
|
|
+ G.showToast("QQ授权失败 请检查网络是否正常");
|
|
|
+ hideProgress();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onCancel(SHARE_MEDIA platform, int action) {
|
|
|
+ G.showToast("您取消了QQ授权");
|
|
|
+ hideProgress();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ private void bindWX() {
|
|
|
+ UMShareAPI.get(this).doOauthVerify(this, SHARE_MEDIA.WEIXIN, new UMAuthListener() {
|
|
|
+ @Override
|
|
|
+ public void onStart(SHARE_MEDIA platform) {
|
|
|
+ showProgress();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onComplete(SHARE_MEDIA platform, int action, Map<String, String> data) {
|
|
|
+ bindThird("wechat", data.get("access_token"), data.get("openid"));
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onError(SHARE_MEDIA platform, int action, Throwable t) {
|
|
|
+ G.showToast("微信授权失败 请检查网络是否正常");
|
|
|
+ hideProgress();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onCancel(SHARE_MEDIA platform, int action) {
|
|
|
+ G.showToast("您取消了微信授权");
|
|
|
+ hideProgress();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * access_token string
|
|
|
+ open_id string
|
|
|
+ platform string
|
|
|
+ qzone, wechat
|
|
|
+ s_from string
|
|
|
+ sheep, web_sheep
|
|
|
+ * @param access_token
|
|
|
+ * @param openid
|
|
|
+ */
|
|
|
+ private void bindThird(String platform, String access_token, String openid) {
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
+ jsonObject.put("access_token", access_token);
|
|
|
+ jsonObject.put("open_id", openid);
|
|
|
+ jsonObject.put("platform", platform);
|
|
|
+ jsonObject.put("s_from", "sheep");
|
|
|
+ SheepApp.getInstance().getNetComponent().getApiService().bindThird(jsonObject)
|
|
|
+ .subscribeOn(Schedulers.io())
|
|
|
+ .observeOn(AndroidSchedulers.mainThread())
|
|
|
+ .subscribe(new SheepSubscriber<BaseMessage>(SheepApp.getInstance()) {
|
|
|
+ @Override
|
|
|
+ public void onNext(BaseMessage baseMessage) {
|
|
|
+ hideProgress();
|
|
|
+ CommonUtil.getInstance().updateUserInfo(new Action1<UserEntity>() {
|
|
|
+ @Override
|
|
|
+ public void call(UserEntity result) {
|
|
|
+ if(result != null){
|
|
|
+ userEntity = result;
|
|
|
+ loadUserInfo();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onError(BaseMessage baseMessage) {
|
|
|
+ hideProgress();
|
|
|
+ G.showToast(baseMessage);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
protected void onNotGetImage(String msg) {
|
|
|
G.showToast(msg);
|
|
|
@@ -290,13 +436,15 @@ public class PersonalInfoAct extends AbsChooseImageActivity {
|
|
|
|
|
|
if (TextUtils.isEmpty(userEntity.getWx_nickname())) {
|
|
|
if (TextUtils.isEmpty(userEntity.getWx_openid())) {
|
|
|
- personal_info_wx.setText("未绑定");
|
|
|
+ personal_info_bind_tx_wx.setText("未绑定");
|
|
|
} else {
|
|
|
- personal_info_wx.setText("");
|
|
|
+ personal_info_bind_tx_wx.setText("");
|
|
|
}
|
|
|
} else {
|
|
|
- personal_info_wx.setText(userEntity.getWx_nickname());
|
|
|
+ personal_info_bind_tx_wx.setText(userEntity.getWx_nickname());
|
|
|
}
|
|
|
+ personal_info_bind_qq.setText(userEntity.isBindQQ() ? "去修改" : "去绑定");
|
|
|
+ personal_info_bind_wx.setText(userEntity.isBindWx() ? "去修改" : "去绑定");
|
|
|
|
|
|
boolean isId_number = TextUtils.isEmpty(userEntity.getId_number());
|
|
|
boolean isRoalName = TextUtils.isEmpty(userEntity.getReal_name());
|
|
|
@@ -309,4 +457,13 @@ public class PersonalInfoAct extends AbsChooseImageActivity {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
|
|
+ super.onActivityResult(requestCode, resultCode, data);
|
|
|
+ try {
|
|
|
+ UMShareAPI.get(this).onActivityResult(requestCode, resultCode, data);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|