Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
唐文
/
AiyoZhuaWaWa
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
67e7538f
authored
Nov 21, 2017
by
chengfengpiaopiao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
微信登录改用code,H5退出登录
parent
1cbfc587
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
79 additions
and
14 deletions
.idea/misc.xml
.idea/modules.xml
app/build.gradle
app/src/main/java/com/maile/jingcai/module/api/LoginApiService.java
app/src/main/java/com/maile/jingcai/view/fragment/SimpleCardFragment.java
app/src/main/java/com/maile/jingcai/wxapi/WXEntryActivity.java
.idea/misc.xml
View file @
67e7538f
...
@@ -55,7 +55,7 @@
...
@@ -55,7 +55,7 @@
</profile-state>
</profile-state>
</entry>
</entry>
</component>
</component>
<component
name=
"ProjectRootManager"
version=
"2"
languageLevel=
"JDK_1_8"
default=
"true"
project-jdk-name=
"1.8"
project-jdk-type=
"JavaSDK"
>
<component
name=
"ProjectRootManager"
version=
"2"
languageLevel=
"JDK_1_8"
default=
"true"
assert-keyword=
"true"
jdk-15=
"true"
project-jdk-name=
"1.8"
project-jdk-type=
"JavaSDK"
>
<output
url=
"file://$PROJECT_DIR$/build/classes"
/>
<output
url=
"file://$PROJECT_DIR$/build/classes"
/>
</component>
</component>
<component
name=
"ProjectType"
>
<component
name=
"ProjectType"
>
...
...
.idea/modules.xml
View file @
67e7538f
...
@@ -3,7 +3,8 @@
...
@@ -3,7 +3,8 @@
<component
name=
"ProjectModuleManager"
>
<component
name=
"ProjectModuleManager"
>
<modules>
<modules>
<module
fileurl=
"file://$PROJECT_DIR$/DuoBaoJingCai.iml"
filepath=
"$PROJECT_DIR$/DuoBaoJingCai.iml"
/>
<module
fileurl=
"file://$PROJECT_DIR$/DuoBaoJingCai.iml"
filepath=
"$PROJECT_DIR$/DuoBaoJingCai.iml"
/>
<module
fileurl=
"file://G:\Product\Android\DuoBaoJingCai\DuoBaoJingCai2.iml"
filepath=
"G:\Product\Android\DuoBaoJingCai\DuoBaoJingCai2.iml"
/>
<module
fileurl=
"file://$PROJECT_DIR$/DuoBaoJingCai2.iml"
filepath=
"$PROJECT_DIR$/DuoBaoJingCai2.iml"
/>
<module
fileurl=
"file://G:/Product/Android/DuoBaoJingCai/DuoBaoJingCai2.iml"
filepath=
"G:/Product/Android/DuoBaoJingCai/DuoBaoJingCai2.iml"
/>
<module
fileurl=
"file://$PROJECT_DIR$/app/app.iml"
filepath=
"$PROJECT_DIR$/app/app.iml"
/>
<module
fileurl=
"file://$PROJECT_DIR$/app/app.iml"
filepath=
"$PROJECT_DIR$/app/app.iml"
/>
</modules>
</modules>
</component>
</component>
...
...
app/build.gradle
View file @
67e7538f
...
@@ -13,12 +13,12 @@ if (customPropsFile.canRead()) {
...
@@ -13,12 +13,12 @@ if (customPropsFile.canRead()) {
println
(
"suffixName: "
+
suffixName
[
networkType
])
println
(
"suffixName: "
+
suffixName
[
networkType
])
android
{
android
{
compileSdkVersion
2
5
compileSdkVersion
2
3
buildToolsVersion
"2
5.0.0
"
buildToolsVersion
"2
3.0.3
"
defaultConfig
{
defaultConfig
{
applicationId
"com.maile.jingcai"
applicationId
"com.maile.jingcai"
minSdkVersion
16
minSdkVersion
16
targetSdkVersion
2
5
targetSdkVersion
2
3
versionCode
1
versionCode
1
versionName
"1.0"
versionName
"1.0"
manifestPlaceholders
=
[
UMENG_CHANNEL_VALUE:
"base"
]
//默认名称
manifestPlaceholders
=
[
UMENG_CHANNEL_VALUE:
"base"
]
//默认名称
...
...
app/src/main/java/com/maile/jingcai/module/api/LoginApiService.java
View file @
67e7538f
...
@@ -30,4 +30,7 @@ public interface LoginApiService {
...
@@ -30,4 +30,7 @@ public interface LoginApiService {
@GET
(
"h5AutoLogin"
)
@GET
(
"h5AutoLogin"
)
Observable
<
WrapperRspEntity
<
String
>>
h5AutoLogin
(
@Query
(
"token"
)
String
token
);
Observable
<
WrapperRspEntity
<
String
>>
h5AutoLogin
(
@Query
(
"token"
)
String
token
);
@GET
(
"wxLogin"
)
Observable
<
WrapperRspEntity
<
String
>>
uploadCode
(
@Query
(
"code"
)
String
code
);
}
}
app/src/main/java/com/maile/jingcai/view/fragment/SimpleCardFragment.java
View file @
67e7538f
package
com
.
maile
.
jingcai
.
view
.
fragment
;
package
com
.
maile
.
jingcai
.
view
.
fragment
;
import
android.annotation.SuppressLint
;
import
android.annotation.SuppressLint
;
import
android.app.Activity
;
import
android.content.Context
;
import
android.content.Context
;
import
android.content.Intent
;
import
android.os.Build
;
import
android.os.Build
;
import
android.os.Bundle
;
import
android.os.Bundle
;
import
android.os.Handler
;
import
android.os.Handler
;
...
@@ -13,6 +15,7 @@ import android.view.LayoutInflater;
...
@@ -13,6 +15,7 @@ import android.view.LayoutInflater;
import
android.view.View
;
import
android.view.View
;
import
android.view.ViewGroup
;
import
android.view.ViewGroup
;
import
android.webkit.CookieManager
;
import
android.webkit.CookieManager
;
import
android.webkit.JavascriptInterface
;
import
android.webkit.JsResult
;
import
android.webkit.JsResult
;
import
android.webkit.WebChromeClient
;
import
android.webkit.WebChromeClient
;
import
android.webkit.WebSettings
;
import
android.webkit.WebSettings
;
...
@@ -29,6 +32,8 @@ import com.maile.jingcai.module.net.RetrofitManager;
...
@@ -29,6 +32,8 @@ import com.maile.jingcai.module.net.RetrofitManager;
import
com.maile.jingcai.util.PublicUtils
;
import
com.maile.jingcai.util.PublicUtils
;
import
com.maile.jingcai.util.preferences.IPreferencesIds
;
import
com.maile.jingcai.util.preferences.IPreferencesIds
;
import
com.maile.jingcai.util.preferences.PreferencesManager
;
import
com.maile.jingcai.util.preferences.PreferencesManager
;
import
com.maile.jingcai.view.activity.LoginActivity
;
import
com.maile.jingcai.view.activity.MainActivity
;
import
com.umeng.analytics.MobclickAgent
;
import
com.umeng.analytics.MobclickAgent
;
import
java.lang.reflect.InvocationTargetException
;
import
java.lang.reflect.InvocationTargetException
;
...
@@ -170,7 +175,7 @@ public class SimpleCardFragment extends BaseFragment {
...
@@ -170,7 +175,7 @@ public class SimpleCardFragment extends BaseFragment {
Context
.
MODE_PRIVATE
);
Context
.
MODE_PRIVATE
);
final
String
token
=
preferencesManager
.
getString
(
IPreferencesIds
.
TOKEN
,
""
);
final
String
token
=
preferencesManager
.
getString
(
IPreferencesIds
.
TOKEN
,
""
);
mWebView
.
loadUrl
(
url
);
mWebView
.
loadUrl
(
url
);
mWebView
.
addJavascriptInterface
(
new
JavaScriptInterface
(
getActivity
()),
"android"
);
//覆盖WebView默认使用第三方或系统默认浏览器打开网页的行为,使网页用WebView打开
//覆盖WebView默认使用第三方或系统默认浏览器打开网页的行为,使网页用WebView打开
mWebView
.
setWebViewClient
(
new
WebViewClient
()
{
mWebView
.
setWebViewClient
(
new
WebViewClient
()
{
@Override
@Override
...
@@ -260,6 +265,22 @@ public class SimpleCardFragment extends BaseFragment {
...
@@ -260,6 +265,22 @@ public class SimpleCardFragment extends BaseFragment {
});
});
}
}
class
JavaScriptInterface
{
private
Context
mContext
;
public
JavaScriptInterface
(
Context
context
){
this
.
mContext
=
context
;
}
@JavascriptInterface
public
void
loginMain
(){
Intent
intent
=
new
Intent
(
mContext
,
LoginActivity
.
class
);
mContext
.
startActivity
(
intent
);
if
(
mContext
!=
null
)
{
((
Activity
)
mContext
).
finish
();
}
}
}
@Override
@Override
public
void
onDestroyView
()
{
public
void
onDestroyView
()
{
super
.
onDestroyView
();
super
.
onDestroyView
();
...
...
app/src/main/java/com/maile/jingcai/wxapi/WXEntryActivity.java
View file @
67e7538f
...
@@ -107,15 +107,16 @@ public class WXEntryActivity extends Activity implements IWXAPIEventHandler {
...
@@ -107,15 +107,16 @@ public class WXEntryActivity extends Activity implements IWXAPIEventHandler {
if
(
baseResp
.
getType
()
==
ConstantsAPI
.
COMMAND_SENDAUTH
)
{
//登录授权
if
(
baseResp
.
getType
()
==
ConstantsAPI
.
COMMAND_SENDAUTH
)
{
//登录授权
mCode
=
((
SendAuth
.
Resp
)
baseResp
).
code
;
mCode
=
((
SendAuth
.
Resp
)
baseResp
).
code
;
get_access_token
=
getCodeRequest
(((
SendAuth
.
Resp
)
baseResp
).
code
);
upLoadCode
(
mCode
);
// get_access_token = getCodeRequest(((SendAuth.Resp) baseResp).code);
// Log.i("zou", "WXEntryActivity mCode= " + mCode + " get_access_token= " + get_access_token);
// Log.i("zou", "WXEntryActivity mCode= " + mCode + " get_access_token= " + get_access_token);
Thread
thread
=
new
Thread
(
downloadRun
);
//
Thread thread = new Thread(downloadRun);
thread
.
start
();
//
thread.start();
try
{
//
try {
thread
.
join
();
//
thread.join();
}
catch
(
InterruptedException
e
)
{
//
} catch (InterruptedException e) {
e
.
printStackTrace
();
//
e.printStackTrace();
}
//
}
}
else
{
//TODO:分享成功
}
else
{
//TODO:分享成功
PublicUtils
.
showToast
(
"分享成功"
);
PublicUtils
.
showToast
(
"分享成功"
);
// this.finish();
// this.finish();
...
@@ -134,6 +135,45 @@ public class WXEntryActivity extends Activity implements IWXAPIEventHandler {
...
@@ -134,6 +135,45 @@ public class WXEntryActivity extends Activity implements IWXAPIEventHandler {
}
}
}
}
private
void
upLoadCode
(
String
mCode
){
RetrofitManager
.
getInstance
().
createReq
(
LoginApiService
.
class
).
uploadCode
(
mCode
).
subscribeOn
(
Schedulers
.
io
())
.
observeOn
(
AndroidSchedulers
.
mainThread
())
.
subscribe
(
new
Observer
<
WrapperRspEntity
<
String
>>()
{
@Override
public
void
onCompleted
()
{
}
@Override
public
void
onError
(
Throwable
errorException
)
{
mLoading
.
setVisibility
(
View
.
GONE
);
Log
.
d
(
"tangwen"
,
"onError: "
+
errorException
.
getMessage
());
if
(
errorException
==
null
)
{
PublicUtils
.
showToast
(
getString
(
R
.
string
.
error_server_not_ok
));
}
else
if
(
errorException
instanceof
java
.
net
.
ConnectException
)
{
PublicUtils
.
showToast
(
errorException
.
getMessage
());
}
else
if
(
errorException
.
equals
(
"com.android.volley.TimeoutError"
))
{
PublicUtils
.
showToast
(
getString
(
R
.
string
.
error_server_timeout_error
));
}
else
{
PublicUtils
.
showToast
(
getString
(
R
.
string
.
error_server_not_ok
));
}
finish
();
}
@Override
public
void
onNext
(
WrapperRspEntity
<
String
>
userWrapperRspEntity
)
{
PreferencesManager
preferencesManager
=
PreferencesManager
.
getSharedPreference
(
getApplication
(),
IPreferencesIds
.
DEFAULT_SHAREPREFERENCES_FILE
,
Context
.
MODE_PRIVATE
);
preferencesManager
.
putString
(
IPreferencesIds
.
TOKEN
,
userWrapperRspEntity
.
getData
());
LoginActivity
.
startEntranceActivity
(
mContext
);
mLoading
.
setVisibility
(
View
.
GONE
);
finish
();
}
});
}
/**
/**
* 获取access_token的URL(微信)
* 获取access_token的URL(微信)
*
*
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment