|
@@ -32,6 +32,7 @@ import com.edufound.reader.annotation.BindView;
|
|
|
import com.edufound.reader.apiserver.UserApiServerImpl;
|
|
|
import com.edufound.reader.application.EApplication;
|
|
|
import com.edufound.reader.bean.BaiDuUserInfo;
|
|
|
+import com.edufound.reader.bean.ChannelCodeEnum;
|
|
|
import com.edufound.reader.bean.HttpResultBean;
|
|
|
import com.edufound.reader.bean.UserBean;
|
|
|
import com.edufound.reader.botsdk.BotRegisterListener;
|
|
@@ -77,9 +78,6 @@ public abstract class BaseActivity extends AppCompatActivity {
|
|
|
//Gson
|
|
|
Gson mGson;
|
|
|
|
|
|
- ShowFollowReceiver mFollowReceiver;
|
|
|
-
|
|
|
-
|
|
|
@Override
|
|
|
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
|
|
super.onCreate(savedInstanceState);
|
|
@@ -239,11 +237,6 @@ public abstract class BaseActivity extends AppCompatActivity {
|
|
|
}
|
|
|
};
|
|
|
|
|
|
- @Override
|
|
|
- protected void onResume() {
|
|
|
- super.onResume();
|
|
|
-
|
|
|
- }
|
|
|
|
|
|
protected void onLoginSuccess() {
|
|
|
}
|
|
@@ -363,20 +356,30 @@ public abstract class BaseActivity extends AppCompatActivity {
|
|
|
IBotIntentCallback mBotIntentCallBack = new IBotIntentCallback() {
|
|
|
@Override
|
|
|
public void handleIntent(BotIntent intent, String customData) {
|
|
|
+ Logger.e("fragment---intent.name:" + intent.name);
|
|
|
if (intent.name.equals("all_login")) {
|
|
|
//用户主动要求登录
|
|
|
+ Consts.setIsNeedLogin(true);
|
|
|
EfunboxUtil.userLogin(EApplication.mActivityList.get(EApplication.mActivityList.size() - 1));
|
|
|
return;
|
|
|
} else if (intent.name.equals("user_info")) {
|
|
|
//获取是不是百度VIP
|
|
|
Consts.setmConstsBaiDuUserBean(mGson.fromJson(customData, BaiDuUserInfo.class));
|
|
|
- BotRegisterListener.BaiDuLogin();
|
|
|
+ Logger.e("json----" + mGson.toJson(Consts.getmConstsBaiDuUserBean()));
|
|
|
+ if (Consts.getIsNeedLogin()) {
|
|
|
+ BotRegisterListener.BaiDuLogin();
|
|
|
+ } else {
|
|
|
+ Consts.setIsNeedLogin(true);
|
|
|
+ }
|
|
|
+ botHandleIntent(intent, customData);
|
|
|
return;
|
|
|
}
|
|
|
if (BotRegisterListener.isNoLoginIntent(intent)) {
|
|
|
//不是获取手机号
|
|
|
+ Logger.e("不是获取手机号--不是获取手机号:" + intent.name + "---" + intent.slots.toString());
|
|
|
botHandleIntent(intent, customData);
|
|
|
} else {
|
|
|
+ Logger.e("是获取手机号--是获取手机号");
|
|
|
//是获取手机号
|
|
|
if (intent.slots.get(0).value.equals("SUCCESS")) {
|
|
|
//获取手机号Token成功
|
|
@@ -388,12 +391,14 @@ public abstract class BaseActivity extends AppCompatActivity {
|
|
|
public void onSuccess(HttpInfo info) throws IOException {
|
|
|
JSONObject object = JSONObject.parseObject(info.getRetDetail().toString());
|
|
|
String phone = JSONObject.parseObject(object.getString("data")).getString("phone");
|
|
|
+ Logger.e("获取的手机号:" + phone);
|
|
|
if (EfunboxUtil.isMobileNO(phone)) {
|
|
|
Map<String, String> map = new HashMap<>();
|
|
|
map.put("deviceCode", DeviceUuidFactory.getUuid());
|
|
|
map.put("channel", Consts.getUmengChannel());
|
|
|
map.put("mobileNo", phone);
|
|
|
map.put("nickName", EfunboxUtil.setPhoneMiddle(phone));
|
|
|
+ Logger.e("Consts.getmConstsBaiDuUserBean().getUserInfo().getUserId():" + Consts.getmConstsBaiDuUserBean().getUserInfo().getUserId());
|
|
|
map.put("userId", Consts.getmConstsBaiDuUserBean().getUserInfo().getUserId());
|
|
|
if (MMKVUtil.getInstance().decodeString(MMKVEncodeKey.USER_GRADE).equals("") || MMKVUtil.getInstance().decodeString(MMKVEncodeKey.USER_GRADE) == null) {
|
|
|
//如果没有,默认给一年级
|
|
@@ -401,18 +406,23 @@ public abstract class BaseActivity extends AppCompatActivity {
|
|
|
} else {
|
|
|
map.put("grade", MMKVUtil.getInstance().decodeString(MMKVEncodeKey.USER_GRADE));
|
|
|
}
|
|
|
- String json = getGson().toJson(map);
|
|
|
+
|
|
|
+ String json = mGson.toJson(map);
|
|
|
+ Logger.e("json:" + json);
|
|
|
userApiServer.registerUserId(topActivity, json, new Callback() {
|
|
|
@Override
|
|
|
public void onSuccess(HttpInfo info) throws IOException {
|
|
|
+ Logger.e("手机号注册成功:" + info.getRetDetail());
|
|
|
+
|
|
|
HttpResultBean<UserBean> bean = info.getRetDetail(new TypeToken<HttpResultBean<UserBean>>() {
|
|
|
}.getType());
|
|
|
+
|
|
|
Consts.setUID(bean.getData().getUid());
|
|
|
//用户是否登录,登录了,创建Consts的userbean
|
|
|
-// String nickName = EfunboxUtil.setPhoneMiddle(bean.getData().getMobile());
|
|
|
-// bean.getData().setNickName(nickName);
|
|
|
+ String nickName = EfunboxUtil.setPhoneMiddle(bean.getData().getMobile());
|
|
|
+ bean.getData().setNickName(nickName);
|
|
|
Consts.setmConstsUserBean(bean.getData());
|
|
|
- Logger.e("看看到底对没有:" + getGson().toJson(Consts.getmConstsUserBean()));
|
|
|
+ Logger.e("看看到底对没有:" + mGson.toJson(Consts.getmConstsUserBean()));
|
|
|
refUserInfo(Consts.getmConstsUserBean());
|
|
|
}
|
|
|
|
|
@@ -434,7 +444,6 @@ public abstract class BaseActivity extends AppCompatActivity {
|
|
|
});
|
|
|
} else if (intent.slots.get(0).value.equals("FAIL")) {
|
|
|
//获取手机号Token失败
|
|
|
- Logger.e("获取手机号失败");
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -470,12 +479,34 @@ public abstract class BaseActivity extends AppCompatActivity {
|
|
|
@NonNull final String productId,
|
|
|
@NonNull final String baiduOrderId,
|
|
|
@NonNull final String sellerOrderId, @Nullable final String msg, String token) {
|
|
|
- Logger.e("baseActivity---onBuyStatusUpdated");
|
|
|
+
|
|
|
+ Consts.setIsNeedLogin(false);
|
|
|
+ //处理支付回调
|
|
|
+ Logger.e("purchaseResult:" + purchaseResult);
|
|
|
+ Logger.e("productId:" + productId);
|
|
|
+ Logger.e("baiduOrderId:" + baiduOrderId);
|
|
|
+ Logger.e("sellerOrderId:" + sellerOrderId);
|
|
|
+ Logger.e("msg:" + msg);
|
|
|
+ Logger.e("token:" + token);
|
|
|
+ if (purchaseResult.equals("SUCCESS")) {
|
|
|
+ //成功
|
|
|
+ } else if (purchaseResult.equals("ERROR")) {
|
|
|
+ //支付失败
|
|
|
+ }
|
|
|
botOnBuyStatusUpdated(purchaseResult, productId, baiduOrderId, sellerOrderId, msg, token);
|
|
|
|
|
|
}
|
|
|
};
|
|
|
|
|
|
+ @Override
|
|
|
+ protected void onResume() {
|
|
|
+ super.onResume();
|
|
|
+ if (Consts.getUmengChannel().equals(ChannelCodeEnum.BAIDU.getChannelCode())) {
|
|
|
+ if (!Consts.getIsNeedLogin()) {
|
|
|
+ BotRegisterListener.getBaiDuVipInfo();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
ShowFollowReceiver.ShowFollow showFollow = new ShowFollowReceiver.ShowFollow() {
|
|
|
@Override
|