|
@@ -60,89 +60,87 @@ public class TMailSDKUtil {
|
|
|
Logger.e("requestPermissions==null???---" + (requestPermissions == null));
|
|
|
if (requestPermissions == null) {
|
|
|
Logger.e("没有授权服务模块,请升级系统版本");
|
|
|
+ Intent tologin = new Intent(context, LoginAlertActivity.class);
|
|
|
+ context.startActivity(tologin);
|
|
|
return;
|
|
|
}
|
|
|
//Step2 调用查询授权接口
|
|
|
AuthProtocolParameters authProtocolParameters = new AuthProtocolParameters(genieAppType, genieAppIdentifier, permissions);
|
|
|
- if (requestPermissions != null) {
|
|
|
- Logger.e("不是空的,调用了");
|
|
|
- try {
|
|
|
- requestPermissions.requestPermissions(authProtocolParameters, new IRequestPermissionListener() {
|
|
|
- @Override
|
|
|
- public void authServiceResponse(AuthResponse authResponse) {
|
|
|
- Logger.e(" authResponse = " + authResponse);
|
|
|
- if (authResponse.isSuccess()) {
|
|
|
- //这里返回的token就是API访问令牌
|
|
|
- String token = authResponse.getData().getApiAccessToken();
|
|
|
- Logger.e("token:" + token);
|
|
|
- Gson gson = new Gson();
|
|
|
- Map<String, String> map = new HashMap<>();
|
|
|
- map.put("accessToken", token);
|
|
|
- map.put("deviceOpenId", Consts.getTmailDeviceId());
|
|
|
- map.put("userOpenId", Consts.getTmailUserId());
|
|
|
- map.put("packageName", Consts.getmApplicAtion().getPackageName());
|
|
|
- map.put("deviceCode", DeviceUuidFactory.getUuid());
|
|
|
- if (MMKVUtil.getInstance().decodeString(MMKVEncodeKey.USER_GRADE).equals("") || MMKVUtil.getInstance().decodeString(MMKVEncodeKey.USER_GRADE) == null) {
|
|
|
- //如果没有,默认给一年级
|
|
|
- map.put("grade", "PRIMARY_FIRST_GRADE");
|
|
|
- } else {
|
|
|
- map.put("grade", MMKVUtil.getInstance().decodeString(MMKVEncodeKey.USER_GRADE));
|
|
|
- }
|
|
|
- mUserApi.getTMailPhone(gson.toJson(map), new Callback() {
|
|
|
- @Override
|
|
|
- public void onSuccess(HttpInfo info) throws IOException {
|
|
|
- Logger.e("获取天猫手机号成功哦--info:" + info.getRetDetail());
|
|
|
- HttpResultBean<UserBean> bean = info.getRetDetail(new TypeToken<HttpResultBean<UserBean>>() {
|
|
|
- }.getType());
|
|
|
- Consts.setmConstsUserBean(bean.getData());
|
|
|
- Consts.setUID(bean.getData().getUid());
|
|
|
- Toast.makeText(context, "登录成功", Toast.LENGTH_SHORT).show();
|
|
|
- OrderApiServerImpl orderApiServer = new OrderApiServerImpl();
|
|
|
- orderApiServer.getAuth(new Callback() {
|
|
|
- @Override
|
|
|
- public void onSuccess(HttpInfo info) throws IOException {
|
|
|
- HttpResultBean<String> bean = info.getRetDetail(new TypeToken<HttpResultBean<String>>() {
|
|
|
- }.getType());
|
|
|
- Logger.e("获取是否有权限info.getRetDetail():" + info.getRetDetail());
|
|
|
- Logger.e("bean.getData():" + bean.getData());
|
|
|
- if (!TextUtils.isEmpty(bean.getData())) {
|
|
|
- Consts.setIsYFVip(true);
|
|
|
- }
|
|
|
+ try {
|
|
|
+ requestPermissions.requestPermissions(authProtocolParameters, new IRequestPermissionListener() {
|
|
|
+ @Override
|
|
|
+ public void authServiceResponse(AuthResponse authResponse) {
|
|
|
+ Logger.e(" authResponse = " + authResponse);
|
|
|
+ if (authResponse.isSuccess()) {
|
|
|
+ //这里返回的token就是API访问令牌
|
|
|
+ String token = authResponse.getData().getApiAccessToken();
|
|
|
+ Logger.e("token:" + token);
|
|
|
+ Gson gson = new Gson();
|
|
|
+ Map<String, String> map = new HashMap<>();
|
|
|
+ map.put("accessToken", token);
|
|
|
+ map.put("deviceOpenId", Consts.getTmailDeviceId());
|
|
|
+ map.put("userOpenId", Consts.getTmailUserId());
|
|
|
+ map.put("packageName", Consts.getmApplicAtion().getPackageName());
|
|
|
+ map.put("deviceCode", DeviceUuidFactory.getUuid());
|
|
|
+ if (MMKVUtil.getInstance().decodeString(MMKVEncodeKey.USER_GRADE).equals("") || MMKVUtil.getInstance().decodeString(MMKVEncodeKey.USER_GRADE) == null) {
|
|
|
+ //如果没有,默认给一年级
|
|
|
+ map.put("grade", "PRIMARY_FIRST_GRADE");
|
|
|
+ } else {
|
|
|
+ map.put("grade", MMKVUtil.getInstance().decodeString(MMKVEncodeKey.USER_GRADE));
|
|
|
+ }
|
|
|
+ mUserApi.getTMailPhone(gson.toJson(map), new Callback() {
|
|
|
+ @Override
|
|
|
+ public void onSuccess(HttpInfo info) throws IOException {
|
|
|
+ Logger.e("获取天猫手机号成功哦--info:" + info.getRetDetail());
|
|
|
+ HttpResultBean<UserBean> bean = info.getRetDetail(new TypeToken<HttpResultBean<UserBean>>() {
|
|
|
+ }.getType());
|
|
|
+ Consts.setmConstsUserBean(bean.getData());
|
|
|
+ Consts.setUID(bean.getData().getUid());
|
|
|
+ Toast.makeText(context, "登录成功", Toast.LENGTH_SHORT).show();
|
|
|
+ OrderApiServerImpl orderApiServer = new OrderApiServerImpl();
|
|
|
+ orderApiServer.getAuth(new Callback() {
|
|
|
+ @Override
|
|
|
+ public void onSuccess(HttpInfo info) throws IOException {
|
|
|
+ HttpResultBean<String> bean = info.getRetDetail(new TypeToken<HttpResultBean<String>>() {
|
|
|
+ }.getType());
|
|
|
+ Logger.e("获取是否有权限info.getRetDetail():" + info.getRetDetail());
|
|
|
+ Logger.e("bean.getData():" + bean.getData());
|
|
|
+ if (!TextUtils.isEmpty(bean.getData())) {
|
|
|
+ Consts.setIsYFVip(true);
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
- @Override
|
|
|
- public void onFailure(HttpInfo info) throws IOException {
|
|
|
+ @Override
|
|
|
+ public void onFailure(HttpInfo info) throws IOException {
|
|
|
|
|
|
- }
|
|
|
- });
|
|
|
- //检查活动
|
|
|
- EfunboxUtil.checkEvents(context, ((BaseActivity) context).getRootView(), true);
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void onFailure(HttpInfo info) throws IOException {
|
|
|
- Logger.e("info.params:" + info.getParamJson());
|
|
|
- Logger.e("获取天猫手机号失败--info:" + info.getRetDetail());
|
|
|
- }
|
|
|
- });
|
|
|
- } else {
|
|
|
- Logger.e("用户拒绝天猫精灵授权,调用自己的手机号登录");
|
|
|
- Intent tologin = new Intent(context, LoginAlertActivity.class);
|
|
|
- context.startActivity(tologin);
|
|
|
- }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ //检查活动
|
|
|
+ EfunboxUtil.checkEvents(context, ((BaseActivity) context).getRootView(), true);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onFailure(HttpInfo info) throws IOException {
|
|
|
+ Logger.e("info.params:" + info.getParamJson());
|
|
|
+ Logger.e("获取天猫手机号失败--info:" + info.getRetDetail());
|
|
|
+ }
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ Logger.e("用户拒绝天猫精灵授权,调用自己的手机号登录");
|
|
|
+ Intent tologin = new Intent(context, LoginAlertActivity.class);
|
|
|
+ context.startActivity(tologin);
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
|
|
|
- });
|
|
|
+ });
|
|
|
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
- Logger.e("不是空的,但是异常了=" + e.getMessage());
|
|
|
- }
|
|
|
- } else {
|
|
|
- Logger.e("空的,别调用了");
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ Logger.e("不是空的,但是异常了=" + e.getMessage());
|
|
|
}
|
|
|
|
|
|
+
|
|
|
Intent intent = new Intent();
|
|
|
intent.setPackage("com.alibaba.ailabs.genie.smartapp");
|
|
|
intent.setAction("com.alibaba.ailabs.genie.authservice.intent.action.AuthPermissionService");
|