From 34f0d1927d662956202620b8036384a026ceca29 Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期一, 18 四月 2022 10:17:48 +0800
Subject: [PATCH] 风行网页播放

---
 BuWanVideo/src/com/weikou/beibeivideo/ui/login/PhoneLoginActivity.java |   99 ++++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 92 insertions(+), 7 deletions(-)

diff --git a/BuWanVideo/src/com/weikou/beibeivideo/ui/login/PhoneLoginActivity.java b/BuWanVideo/src/com/weikou/beibeivideo/ui/login/PhoneLoginActivity.java
index b7810e9..9fc7bae 100644
--- a/BuWanVideo/src/com/weikou/beibeivideo/ui/login/PhoneLoginActivity.java
+++ b/BuWanVideo/src/com/weikou/beibeivideo/ui/login/PhoneLoginActivity.java
@@ -1,6 +1,8 @@
 package com.weikou.beibeivideo.ui.login;
 
+import android.content.Context;
 import android.content.Intent;
+import android.content.SharedPreferences;
 import android.graphics.Color;
 import android.graphics.Paint;
 import android.os.Bundle;
@@ -45,7 +47,7 @@
 
     private PhoneNumberAuthHelper mPhoneNumberAuthHelper;
 
-    private TextView tv_login_onekey, tv_obtain_verfication_code, tv_title;
+    private TextView tv_login_onekey, tv_obtain_verfication_code, tv_title, tv_confirm;
 
     private EditText et_phone, et_verfication_code;
 
@@ -65,13 +67,15 @@
         cb_user_agreement = findViewById(R.id.cb_user_agreement);
         et_verfication_code = findViewById(R.id.et_verfication_code);
         tv_title = findViewById(R.id.tv_title);
+        tv_confirm = findViewById(R.id.tv_confirm);
+
         tv_login_onekey.getPaint().setFlags(Paint.UNDERLINE_TEXT_FLAG); //涓嬪垝绾�
         tv_login_onekey.getPaint().setAntiAlias(true);//鎶楅敮榻�
 
 
         tv_obtain_verfication_code.setOnClickListener(this);
         tv_login_onekey.setOnClickListener(this);
-        findViewById(R.id.tv_confirm).setOnClickListener(this);
+        tv_confirm.setOnClickListener(this);
         findViewById(R.id.tv_back).setOnClickListener(this);
         findViewById(R.id.tv_user_agreement).setOnClickListener(this);
         findViewById(R.id.tv_privacy_policy).setOnClickListener(this);
@@ -92,10 +96,15 @@
         initView();
         login = getIntent().getBooleanExtra("login", false);
         tv_title.setText(login ? "鐧诲綍" : "缁戝畾鎵嬫満鍙�");
+        tv_confirm.setText(login ? "鐧诲綍" : "缁戝畾");
 
+        if (login) {
+            tv_login_onekey.setVisibility(View.GONE);
+        }
 
-        openOneKeyLogin(false);
-
+        if (!login) {
+            openOneKeyLogin(false);
+        }
     }
 
 
@@ -223,7 +232,11 @@
                     break;
                 }
                 tv_obtain_verfication_code.setEnabled(false);
-                sendBindVerifyCode(phone);
+                if (login) {
+                    sendLoginVerifyCode(phone);
+                } else {
+                    sendBindVerifyCode(phone);
+                }
                 break;
 
 
@@ -243,7 +256,11 @@
                     SingleToast.showToast(this, "楠岃瘉鐮佷笉鑳戒负绌�");
                     return;
                 }
-                bindPhone(null);
+                if (login) {
+                    phoneLogin();
+                } else {
+                    bindPhone(null);
+                }
                 break;
 
             case R.id.tv_login_onekey:
@@ -366,6 +383,29 @@
         });
     }
 
+    private void sendLoginVerifyCode(String phone) {
+        timer = new Timer();
+        timer.schedule(new PhoneLoginActivity.MyTask(), 1000, 1000);
+        String loginUid = UserUtil.getLoginUid(this);
+        BeibeiVideoAPI.sendLoginVerifyCode(PhoneLoginActivity.this, phone, new BasicTextHttpResponseHandler() {
+            @Override
+            public void onSuccessPerfect(int statusCode, Header[] headers, JSONObject jsonObject) throws Exception {
+                if (jsonObject.optBoolean("IsPost")) {
+                    SingleToast.showToast(PhoneLoginActivity.this, "楠岃瘉鐮佸彂閫佹垚鍔燂紝璇锋敞鎰忔煡鏀�");
+                } else {
+                    SingleToast.showToast(PhoneLoginActivity.this, "鑾峰彇楠岃瘉鐮佸け璐�,璇烽噸鏂拌幏鍙栵紒");
+                    handler.sendEmptyMessage(1);
+                }
+            }
+
+            @Override
+            public void onFinish() {
+                super.onFinish();
+                tv_obtain_verfication_code.setEnabled(true);
+            }
+        });
+    }
+
 
     private void bindPhone(String accessToken) {
         String loginUid = UserUtil.getLoginUid(this);
@@ -394,7 +434,52 @@
             public void onFinish() {
                 super.onFinish();
                 DialogUtil.dismiss(loadingDialog);
-                mPhoneNumberAuthHelper.quitLoginPage();
+                if (mPhoneNumberAuthHelper != null) {
+                    mPhoneNumberAuthHelper.quitLoginPage();
+                }
+            }
+        });
+
+
+    }
+
+
+    private void phoneLogin() {
+        String phone = (et_phone.getText() + "").trim();
+        String code = (et_verfication_code.getText() + "").trim();
+        BeibeiVideoAPI.phoneLogin(this, phone, code, new BasicTextHttpResponseHandler() {
+
+            @Override
+            public void onStart() {
+                super.onStart();
+                DialogUtil.show(loadingDialog);
+            }
+
+            @Override
+            public void onSuccessPerfect(int statusCode, Header[] headers, JSONObject jsonObject) throws Exception {
+                if (jsonObject.optBoolean("IsPost")) {
+                    JSONObject user = jsonObject.optJSONObject("Data");
+
+                    SharedPreferences.Editor edit = getSharedPreferences("user",
+                            Context.MODE_PRIVATE).edit();
+                    edit.putString("portrait", user.optString("Portrait"));
+                    edit.putString("LoginUid",
+                            user.optString("Id"));
+                    edit.putString("name",
+                            user.optString("Nickname"));
+                    edit.commit();
+                    //缁戝畾鎴愬姛
+                    Toast.makeText(PhoneLoginActivity.this, "鐧诲綍鎴愬姛", Toast.LENGTH_SHORT).show();
+                    PhoneLoginActivity.this.finish();
+                } else {
+                    Toast.makeText(PhoneLoginActivity.this, jsonObject.optString("Error"), Toast.LENGTH_SHORT).show();
+                }
+            }
+
+            @Override
+            public void onFinish() {
+                super.onFinish();
+                DialogUtil.dismiss(loadingDialog);
             }
         });
 

--
Gitblit v1.8.0