hanjing преди 6 години
родител
ревизия
11aa6e125d

+ 37 - 1
app/src/main/java/com/sheep/gamegroup/view/activity/ActModifyThird.java

@@ -1,6 +1,7 @@
 package com.sheep.gamegroup.view.activity;
 
 import android.content.Intent;
+import android.os.Bundle;
 import android.support.annotation.StringDef;
 import android.support.v7.widget.AppCompatEditText;
 import android.text.InputFilter;
@@ -11,6 +12,7 @@ import android.widget.TextView;
 
 import com.alibaba.fastjson.JSONObject;
 import com.sheep.gamegroup.absBase.BaseActivity;
+import com.sheep.gamegroup.event.WXLoginAuthEvent;
 import com.sheep.gamegroup.model.entity.BaseMessage;
 import com.sheep.gamegroup.model.util.SheepSubscriber;
 import com.sheep.gamegroup.util.CommonUtil;
@@ -18,16 +20,22 @@ import com.sheep.gamegroup.util.DataUtil;
 import com.sheep.gamegroup.util.SelfCountDownTimer;
 import com.sheep.gamegroup.util.StringUtils;
 import com.sheep.jiuyan.samllsheep.BuildConfig;
+import com.sheep.jiuyan.samllsheep.Config;
 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.sheep.jiuyan.samllsheep.wxutil.WXAPIUtil;
 import com.umeng.socialize.UMAuthListener;
 import com.umeng.socialize.UMShareAPI;
 import com.umeng.socialize.bean.SHARE_MEDIA;
 
+import org.greenrobot.eventbus.EventBus;
+import org.greenrobot.eventbus.Subscribe;
+
 import java.lang.annotation.Retention;
 import java.lang.annotation.RetentionPolicy;
+import java.util.HashMap;
 import java.util.Locale;
 import java.util.Map;
 
@@ -52,6 +60,12 @@ public class ActModifyThird extends BaseActivity {
     AppCompatEditText modifyThirdCodeEt;
 
     @Override
+    protected void onCreate(Bundle b){
+        super.onCreate(b);
+        EventBus.getDefault().register(this);
+    }
+
+    @Override
     protected int getLayoutId() {
         return R.layout.act_modify_third;
     }
@@ -272,6 +286,24 @@ public class ActModifyThird extends BaseActivity {
         });
     }
 
+    @Subscribe
+    public void whenWXAuth(WXLoginAuthEvent ev){
+        if (!TextUtils.isEmpty(ev.code)) {
+            WXAPIUtil.loadWXUserToken(ev.code, (ret, openid, accessToken, refreshToken) -> {
+                if (TextUtils.isEmpty(openid)) return;
+                Map<String, String> params = new HashMap<>();
+                params.put("access_token", accessToken);
+                params.put("refresh_token", refreshToken);
+                params.put("openid", openid);
+                params.put("account_type", "wx");
+                params.put("app_id", Config.WX_AUTH_APP_ID);
+                modifyThird("wechat", accessToken, openid);
+            });
+        } else {
+            G.shortToast("微信授权失败");
+        }
+    }
+
     /**
      * aaccess_token	string
      * authorization_code	string
@@ -282,7 +314,10 @@ public class ActModifyThird extends BaseActivity {
      * sheep, web_sheep
      */
     private void modifyThird(String platform, String access_token, String openid) {
-        if (TextUtils.isEmpty(openid)) return;
+        if (TextUtils.isEmpty(openid)) {
+            hideProgress();
+            return;
+        }
         JSONObject jsonObject = new JSONObject();
         jsonObject.put("access_token", access_token);
         jsonObject.put("authorization_code", authorization_code);
@@ -321,6 +356,7 @@ public class ActModifyThird extends BaseActivity {
 
     @Override
     protected void onDestroy() {
+        EventBus.getDefault().unregister(this);
         if (selfCountDownTimer != null)
             selfCountDownTimer.cancel();
         super.onDestroy();

+ 3 - 0
app/src/main/java/com/sheep/gamegroup/view/activity/PersonalInfoAct.java

@@ -325,6 +325,9 @@ public class PersonalInfoAct extends AbsChooseImageActivity {
 
     @Subscribe
     public void whenWXAuth(WXLoginAuthEvent ev) {
+        if (SheepApp.getInstance().getCurrentActivity() != null && !(SheepApp.getInstance().getCurrentActivity() instanceof PersonalInfoAct)) {
+            return;
+        }
         if (!TextUtils.isEmpty(ev.code)) {
             WXAPIUtil.loadWXUserToken(ev.code, (ret, openid, accessToken, refreshToken) -> {
                 if (TextUtils.isEmpty(openid)) return;

+ 4 - 0
app/src/main/res/drawable/rounder_e2f4fe_5.xml

@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+
+</selector>

+ 14 - 0
app/src/main/res/drawable/rounder_feeaed_10.xml

@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="utf-8"?>
+<shape xmlns:android="http://schemas.android.com/apk/res/android"
+    android:shape="rectangle">
+
+    <corners
+        android:topLeftRadius="5dp"
+        android:topRightRadius="5dp"
+        android:bottomLeftRadius="5dp"
+        android:bottomRightRadius="5dp"/>
+
+    <solid
+        android:color="@color/blue_E2F4FE"/>
+
+</shape>