|
@@ -7,24 +7,19 @@ import android.content.pm.ActivityInfo;
|
|
|
import android.content.pm.PackageManager;
|
|
|
import android.graphics.Color;
|
|
|
import android.media.MediaPlayer;
|
|
|
-import android.util.Base64;
|
|
|
import android.view.KeyEvent;
|
|
|
import android.webkit.JavascriptInterface;
|
|
|
|
|
|
-import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.ailabs.genie.assistant.sdk.asr.TBUserData;
|
|
|
+import com.alibaba.ailabs.genie.assistant.sdk.asr.UserDataProvider;
|
|
|
import com.edufound.android.xyyf.R;
|
|
|
-import com.edufound.android.xyyf.activity.PhoneNumLoginActivity;
|
|
|
import com.edufound.android.xyyf.application.EApplication;
|
|
|
import com.edufound.android.xyyf.bean.MessageDialogBean;
|
|
|
import com.edufound.android.xyyf.bean.UpgradeBean;
|
|
|
-import com.edufound.android.xyyf.config.AppUtils;
|
|
|
-import com.edufound.android.xyyf.config.AuthPageConfig;
|
|
|
-import com.edufound.android.xyyf.config.BaseUIConfig;
|
|
|
import com.edufound.android.xyyf.main.MainView;
|
|
|
import com.edufound.android.xyyf.pay.PayInit;
|
|
|
import com.edufound.android.xyyf.util.ContextUtil;
|
|
|
import com.edufound.android.xyyf.util.Logger;
|
|
|
-import com.edufound.android.xyyf.util.OKHttpUtil;
|
|
|
import com.edufound.android.xyyf.util.SPutil;
|
|
|
import com.edufound.android.xyyf.util.ShowDebugUrl;
|
|
|
import com.edufound.android.xyyf.util.ShowDevice;
|
|
@@ -32,10 +27,6 @@ import com.edufound.android.xyyf.util.ShowSetting;
|
|
|
import com.edufound.android.xyyf.util.ToastUtil;
|
|
|
import com.edufound.android.xyyf.util.UpdateUtil;
|
|
|
import com.google.gson.Gson;
|
|
|
-import com.mobile.auth.gatewayauth.PhoneNumberAuthHelper;
|
|
|
-import com.mobile.auth.gatewayauth.ResultCode;
|
|
|
-import com.mobile.auth.gatewayauth.TokenResultListener;
|
|
|
-import com.mobile.auth.gatewayauth.model.TokenRet;
|
|
|
import com.tencent.mm.opensdk.modelbiz.WXLaunchMiniProgram;
|
|
|
import com.tencent.mm.opensdk.modelmsg.SendAuth;
|
|
|
|
|
@@ -44,8 +35,6 @@ import java.lang.reflect.Method;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.Map;
|
|
|
|
|
|
-import okhttp3.Request;
|
|
|
-
|
|
|
public class JsInterfaces {
|
|
|
|
|
|
Gson mGson;
|
|
@@ -53,9 +42,6 @@ public class JsInterfaces {
|
|
|
MediaPlayer mediaPlayer;
|
|
|
AlertDialog.Builder mMessageDialogBuilder;
|
|
|
MessageDialogBean mMessageBean;
|
|
|
- PhoneNumberAuthHelper mPhoneNumberAuthHelperl;
|
|
|
- String mSecret = "UgC3rEZPVMBKi8WqdoubeWMSJNSeeA6i0dLu3Z1GZKfIgXFhF8RmMLdsmDSgmwWjg2TUOhkvbuHZH6pt4RUxiQSpVyu9P1Q7h9Th05DhNVqxuOU2GRLLs0C43B59eS6nXrUEy7PZzn3wPTXEpelTmH5rMl+VZ7UKa3tC35qkB073Dfikr6ITRfCF31mTPjOGQRo9RKrtbeIhj4jIqx7M9PJSp9+W8huzLCUEOVquVNKDtpCBUq2Znu+PgISvLg3JouLtVv9ldoftxKci+VfHaO3izxkHOi+3jauqBTigrfA7D4I4va/7PlgCNoXJogcy";
|
|
|
- public final String GET_USER_PHONENUMBER_URL = "http://m-xyyf-api.ai160.com/member/getMobile";
|
|
|
|
|
|
public JsInterfaces(MainView view) {
|
|
|
mGson = new Gson();
|
|
@@ -65,8 +51,6 @@ public class JsInterfaces {
|
|
|
mediaPlayer.reset();
|
|
|
mediaPlayer = MediaPlayer.create(mView.getActivity(), R.raw.click_music);
|
|
|
}
|
|
|
- mPhoneNumberAuthHelperl = PhoneNumberAuthHelper.getInstance(mView.getActivity(), tokenResultListener);
|
|
|
- mPhoneNumberAuthHelperl.setAuthSDKInfo(mSecret);
|
|
|
}
|
|
|
|
|
|
Map<String, String> jsMap = new HashMap<>();
|
|
@@ -382,97 +366,6 @@ public class JsInterfaces {
|
|
|
}
|
|
|
|
|
|
|
|
|
- public int getdp(int num) {
|
|
|
- return AppUtils.dp2px(mView.getActivity(), num);
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- @JavascriptInterface
|
|
|
- public void showPhoneNumberLogin(int type) {
|
|
|
- //0是横屏。2是竖屏
|
|
|
- AuthPageConfig mUIConfig = BaseUIConfig.init(type, mView.getActivity(), mPhoneNumberAuthHelperl, mView);
|
|
|
- mUIConfig.configAuthPage();
|
|
|
- mPhoneNumberAuthHelperl.getLoginToken(mView.getActivity(), 3000);
|
|
|
- }
|
|
|
-
|
|
|
- @JavascriptInterface
|
|
|
- public void showPhoneNumberLogin() {
|
|
|
- AuthPageConfig mUIConfig = BaseUIConfig.init(2, mView.getActivity(), mPhoneNumberAuthHelperl, mView);
|
|
|
- mUIConfig.configAuthPage();
|
|
|
- mPhoneNumberAuthHelperl.getLoginToken(mView.getActivity(), 3000);
|
|
|
- }
|
|
|
-
|
|
|
- public void quitLoginPage() {
|
|
|
- mPhoneNumberAuthHelperl.quitLoginPage();
|
|
|
- }
|
|
|
-
|
|
|
- public void NOUILOGIN() {
|
|
|
-// AuthPageConfig mUIConfig = BaseUIConfig.init(1, mView.getActivity(), mPhoneNumberAuthHelperl,mView);
|
|
|
-// mUIConfig.configAuthPage();
|
|
|
-// mPhoneNumberAuthHelperl.getLoginToken(mView.getActivity(), 5000);
|
|
|
- }
|
|
|
-
|
|
|
- TokenResultListener tokenResultListener = new TokenResultListener() {
|
|
|
- @Override
|
|
|
- public void onTokenSuccess(String s) {
|
|
|
- Logger.e("sssss:" + s);
|
|
|
- TokenRet tokenRet = null;
|
|
|
- try {
|
|
|
- tokenRet = JSON.parseObject(s, TokenRet.class);
|
|
|
- if (ResultCode.CODE_START_AUTHPAGE_SUCCESS.equals(tokenRet.getCode())) {
|
|
|
-// Logger.e("唤起授权页成功:" + s);
|
|
|
- mPhoneNumberAuthHelperl.hideLoginLoading();
|
|
|
-// ToastUtil.showToast(s);
|
|
|
- }
|
|
|
- if (ResultCode.CODE_GET_TOKEN_SUCCESS.equals(tokenRet.getCode())) {
|
|
|
-// Logger.e("获取token成功:" + s);
|
|
|
-// ToastUtil.showToast(s);
|
|
|
- mPhoneNumberAuthHelperl.hideLoginLoading();
|
|
|
- mPhoneNumberAuthHelperl.quitLoginPage();
|
|
|
- String token = JSON.parseObject(s).get("token").toString();
|
|
|
- OKHttpUtil.postDataAsync(GET_USER_PHONENUMBER_URL, new OKHttpUtil.ResultCallback() {
|
|
|
- @Override
|
|
|
- public void onError(Request request, Exception e) {
|
|
|
- Logger.e("error-------------");
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void onResponse(Object response) {
|
|
|
- String a = JSON.parseObject(response.toString()).getString("data").toString();
|
|
|
- SPutil.setPrefString(mView.getActivity(), "user_phone", Base64.encodeToString(a.getBytes(), Base64.DEFAULT));
|
|
|
- mView.loadJsMehtod("phoneLogin('" + a + "')");
|
|
|
- }
|
|
|
- }, new OKHttpUtil.Param("accessToken", token));
|
|
|
-//
|
|
|
- }
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void onTokenFailed(String s) {
|
|
|
-// ToastUtil.showToast("失败了:" + s);
|
|
|
- String code = JSON.parseObject(s).get("code").toString();
|
|
|
- Logger.e("code:" + code);
|
|
|
- Intent intent = new Intent(mView.getActivity(), PhoneNumLoginActivity.class);
|
|
|
- if (code.equals("700000")) {
|
|
|
- mView.loadJsMehtod("closeLogin(" + code + ")");
|
|
|
- } else {
|
|
|
- intent.putExtra("code", code);
|
|
|
- mView.getActivity().startActivity(intent);
|
|
|
- ToastUtil.showToast(JSON.parseObject(s).get("msg").toString());
|
|
|
- mView.getActivity().startActivity(intent);
|
|
|
- mPhoneNumberAuthHelperl.quitLoginPage();
|
|
|
- }
|
|
|
- return;
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- };
|
|
|
-
|
|
|
-
|
|
|
@JavascriptInterface
|
|
|
public void setScreenOriention(int oriention) {
|
|
|
switch (oriention) {
|
|
@@ -501,4 +394,25 @@ public class JsInterfaces {
|
|
|
public void removeSPUserPhone() {
|
|
|
delPreData("user_phone");
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ @JavascriptInterface
|
|
|
+ public String getUserID() {
|
|
|
+ return UserDataProvider.getUserID(mView.getActivity());
|
|
|
+ //1101585593650761728
|
|
|
+ }
|
|
|
+
|
|
|
+ @JavascriptInterface
|
|
|
+ public String getUUID() {
|
|
|
+ return UserDataProvider.getUUID(mView.getActivity());
|
|
|
+ //32EBE680BE5914F6240E4CD941CA77B0
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @JavascriptInterface
|
|
|
+ public String getTBUserData() {
|
|
|
+ return mView.getGson().toJson(UserDataProvider.getTBUserData(mView.getActivity()));
|
|
|
+ //{"avatar":"https://wwc.alicdn.com/avatar/getAvatar.do?userNick\u003d%E7%BC%98%E6%9D%A5%E6%98%AF%E4%BD%A0%E5%93%9F666\u0026_input_charset\u003dUTF-8\u0026width\u003d160\u0026height\u003d160\u0026type\u003dsns","location":"","loginTime":"2021-05-20 15:16:46.074","mobile":"15832226563","tbNickName":"缘来是你哟666","tbUserId":"2845700557"}
|
|
|
+ }
|
|
|
+
|
|
|
}
|