Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
polysoft-nafmii
/
polysoft-android
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 14b7ae71
authored
Sep 16, 2021
by
amateur
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
1
1 parent
85bf6d84
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
150 additions
and
4 deletions
app/build.gradle
app/src/main/AndroidManifest.xml
app/src/main/assets/dist.zip
app/src/main/java/com/polysoft/nafmii/webview/NativeApi.java
app/src/main/java/com/polysoft/nafmii/wechat/WechatApi.java
app/src/main/java/com/whaty/nafmii/dev/wxapi/WXEntryActivity.java
app/src/main/java/com/whaty/nafmii/dev/wxapi/WXPayEntryActivity.java
app/build.gradle
View file @
14b7ae7
...
@@ -17,7 +17,7 @@ android {
...
@@ -17,7 +17,7 @@ android {
buildConfigField
"String"
,
"API_HOST"
,
"\"http://10.10.81.189/nafmii/app/\""
buildConfigField
"String"
,
"API_HOST"
,
"\"http://10.10.81.189/nafmii/app/\""
buildConfigField
"String"
,
"IMG_API"
,
"\"http://10.10.81.172/group1/\""
buildConfigField
"String"
,
"IMG_API"
,
"\"http://10.10.81.172/group1/\""
buildConfigField
"String"
,
"WX_APPID"
,
"\"
1234567890
\""
buildConfigField
"String"
,
"WX_APPID"
,
"\"
wx06a3b88ecb27f0d8
\""
buildConfigField
"String"
,
"ONLINE_URL"
,
"\"http://10.10.81.189/h5/\""
buildConfigField
"String"
,
"ONLINE_URL"
,
"\"http://10.10.81.189/h5/\""
buildConfigField
"boolean"
,
"SHOW_INPUT"
,
"true"
buildConfigField
"boolean"
,
"SHOW_INPUT"
,
"true"
ndk
{
ndk
{
...
@@ -83,13 +83,15 @@ android {
...
@@ -83,13 +83,15 @@ android {
}
}
uat
{
// 测试
uat
{
// 测试
debuggable
true
minifyEnabled
false
minifyEnabled
false
signingConfig
signingConfigs
.
debug
resValue
"string"
,
"app_name"
,
"Nafmii-uat"
resValue
"string"
,
"app_name"
,
"Nafmii-uat"
applicationIdSuffix
"uat"
applicationIdSuffix
"uat"
buildConfigField
"String"
,
"WX_APPID"
,
"\"wxb9dd952e6522ef31\""
buildConfigField
"String"
,
"API_HOST"
,
"\"http://10.10.34.155/nafmii/app/\""
buildConfigField
"String"
,
"API_HOST"
,
"\"http://10.10.34.155/nafmii/app/\""
buildConfigField
"String"
,
"IMG_API"
,
"\"http://10.10.34.155/file/\""
buildConfigField
"String"
,
"IMG_API"
,
"\"http://10.10.34.155/file/\""
buildConfigField
"String"
,
"ONLINE_URL"
,
"\"http://10.10.34.155/h5/\""
buildConfigField
"String"
,
"ONLINE_URL"
,
"\"http://10.10.34.155/h5/\""
signingConfig
signingConfigs
.
debug
manifestPlaceholders
=
[
manifestPlaceholders
=
[
JPUSH_PKGNAME:
"com.whaty.nafmii.uat"
,
JPUSH_PKGNAME:
"com.whaty.nafmii.uat"
,
JPUSH_APPKEY
:
"ef86f246857d981193987dee"
,
//值来自开发者平台取得的AppKey
JPUSH_APPKEY
:
"ef86f246857d981193987dee"
,
//值来自开发者平台取得的AppKey
...
@@ -97,9 +99,15 @@ android {
...
@@ -97,9 +99,15 @@ android {
]
]
}
}
dev
{
dev
{
debuggable
true
minifyEnabled
false
minifyEnabled
false
signingConfig
signingConfigs
.
debug
resValue
"string"
,
"app_name"
,
"Nafmii-dev"
resValue
"string"
,
"app_name"
,
"Nafmii-dev"
applicationIdSuffix
"dev"
applicationIdSuffix
"dev"
buildConfigField
"String"
,
"WX_APPID"
,
"\"wx06a3b88ecb27f0d8\""
buildConfigField
"String"
,
"API_HOST"
,
"\"http://10.10.81.189/nafmii/app/\""
buildConfigField
"String"
,
"IMG_API"
,
"\"http://10.10.81.172/group1/\""
buildConfigField
"String"
,
"ONLINE_URL"
,
"\"http://10.10.81.189/h5/\""
manifestPlaceholders
=
[
manifestPlaceholders
=
[
JPUSH_PKGNAME:
"com.whaty.nafmii.dev"
,
JPUSH_PKGNAME:
"com.whaty.nafmii.dev"
,
JPUSH_APPKEY
:
"ef86f246857d981193987dee"
,
//值来自开发者平台取得的AppKey
JPUSH_APPKEY
:
"ef86f246857d981193987dee"
,
//值来自开发者平台取得的AppKey
...
...
app/src/main/AndroidManifest.xml
View file @
14b7ae7
...
@@ -5,7 +5,7 @@
...
@@ -5,7 +5,7 @@
<permission
<permission
android:name=
"${applicationId}.permission.JPUSH_MESSAGE"
android:name=
"${applicationId}.permission.JPUSH_MESSAGE"
android:protectionLevel=
"signature"
/>
android:protectionLevel=
"signature"
/>
<uses-permission
android:name=
"${applicationId}.permission.JPUSH_MESSAGE"
/>
<uses-permission
android:name=
"${applicationId}.permission.JPUSH_MESSAGE"
/>
<uses-permission
android:name=
"android.permission.WAKE_LOCK"
/>
<uses-permission
android:name=
"android.permission.WAKE_LOCK"
/>
...
@@ -72,6 +72,18 @@
...
@@ -72,6 +72,18 @@
android:theme=
"@style/Nafmii.Fullscreen.NoTitleBar"
/>
android:theme=
"@style/Nafmii.Fullscreen.NoTitleBar"
/>
<activity
android:name=
"com.whaty.nafmii.activity.AdvertisementWebviewActvity"
/>
<activity
android:name=
"com.whaty.nafmii.activity.AdvertisementWebviewActvity"
/>
<!-- 微信开发环境-->
<activity
android:name=
"com.whaty.nafmii.dev.wxapi.WXEntryActivity"
android:exported=
"true"
android:launchMode=
"singleTask"
android:taskAffinity=
"${applicationId}"
/>
<activity
android:name=
"com.whaty.nafmii.dev.wxapi.WXPayEntryActivity"
android:exported=
"true"
android:launchMode=
"singleTask"
android:taskAffinity=
"${applicationId}"
/>
<service
<service
android:name=
"com.tencent.smtt.export.external.DexClassLoaderProviderService"
android:name=
"com.tencent.smtt.export.external.DexClassLoaderProviderService"
android:label=
"dexopt"
android:label=
"dexopt"
...
...
app/src/main/assets/dist.zip
View file @
14b7ae7
No preview for this file type
app/src/main/java/com/polysoft/nafmii/webview/NativeApi.java
View file @
14b7ae7
...
@@ -81,7 +81,10 @@ public class NativeApi {
...
@@ -81,7 +81,10 @@ public class NativeApi {
js
.
callJs
(
result
);
js
.
callJs
(
result
);
}));
}));
}
else
if
(
"2"
.
equals
(
type
))
{
// 微信
}
else
if
(
"2"
.
equals
(
type
))
{
// 微信
this
.
mActivity
.
runOnUiThread
(()
->
{
WechatApi
instance
=
WechatApi
.
getInstance
(
this
.
mActivity
);
instance
.
login
();
});
}
}
});
});
}
}
...
...
app/src/main/java/com/polysoft/nafmii/wechat/WechatApi.java
View file @
14b7ae7
...
@@ -13,6 +13,7 @@ import com.bumptech.glide.Glide;
...
@@ -13,6 +13,7 @@ import com.bumptech.glide.Glide;
import
com.bumptech.glide.request.target.SimpleTarget
;
import
com.bumptech.glide.request.target.SimpleTarget
;
import
com.bumptech.glide.request.transition.Transition
;
import
com.bumptech.glide.request.transition.Transition
;
import
com.tencent.mm.opensdk.modelbase.BaseReq
;
import
com.tencent.mm.opensdk.modelbase.BaseReq
;
import
com.tencent.mm.opensdk.modelmsg.SendAuth
;
import
com.tencent.mm.opensdk.modelmsg.SendMessageToWX
;
import
com.tencent.mm.opensdk.modelmsg.SendMessageToWX
;
import
com.tencent.mm.opensdk.modelmsg.WXMediaMessage
;
import
com.tencent.mm.opensdk.modelmsg.WXMediaMessage
;
import
com.tencent.mm.opensdk.modelmsg.WXWebpageObject
;
import
com.tencent.mm.opensdk.modelmsg.WXWebpageObject
;
...
@@ -63,6 +64,13 @@ public class WechatApi {
...
@@ -63,6 +64,13 @@ public class WechatApi {
this
.
sendRequest
(
JSON
.
parseObject
(
payInfo
,
PayReq
.
class
));
this
.
sendRequest
(
JSON
.
parseObject
(
payInfo
,
PayReq
.
class
));
}
}
public
void
login
()
{
final
SendAuth
.
Req
req
=
new
SendAuth
.
Req
();
req
.
scope
=
"snsapi_userinfo"
;
req
.
state
=
"wechat_sdk_demo_test"
;
this
.
sendRequest
(
req
);
}
public
void
share
(
Context
ctx
,
final
ShareBean
bean
)
{
public
void
share
(
Context
ctx
,
final
ShareBean
bean
)
{
String
webImg
=
bean
.
getWebImg
();
String
webImg
=
bean
.
getWebImg
();
String
shareType
=
bean
.
getShareType
();
String
shareType
=
bean
.
getShareType
();
...
...
app/src/main/java/com/whaty/nafmii/dev/wxapi/WXEntryActivity.java
0 → 100644
View file @
14b7ae7
package
com
.
whaty
.
nafmii
.
dev
.
wxapi
;
import
android.app.Activity
;
import
android.content.Intent
;
import
android.os.Bundle
;
import
com.polysoft.nafmii.broadcast.ShareReceiver
;
import
com.polysoft.nafmii.wechat.ShareResult
;
import
com.polysoft.nafmii.wechat.WechatApi
;
import
com.tencent.mm.opensdk.modelbase.BaseReq
;
import
com.tencent.mm.opensdk.modelbase.BaseResp
;
import
com.tencent.mm.opensdk.modelmsg.SendAuth
;
import
com.tencent.mm.opensdk.openapi.IWXAPIEventHandler
;
public
class
WXEntryActivity
extends
Activity
implements
IWXAPIEventHandler
{
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
WechatApi
.
getInstance
(
this
).
handleIntent
(
getIntent
(),
this
);
}
@Override
protected
void
onNewIntent
(
Intent
intent
)
{
super
.
onNewIntent
(
intent
);
setIntent
(
intent
);
WechatApi
.
getInstance
(
this
).
handleIntent
(
intent
,
this
);
}
@Override
public
void
onReq
(
BaseReq
baseReq
)
{
}
@Override
public
void
onResp
(
BaseResp
resp
)
{
if
(
resp
instanceof
SendAuth
.
Resp
)
{
}
int
code
=
resp
.
errCode
;
if
(
code
==
BaseResp
.
ErrCode
.
ERR_OK
)
{
// 分享成功
ShareReceiver
.
sendBroadcast
(
this
,
ShareResult
.
shareSuccess
());
}
else
if
(
code
==
BaseResp
.
ErrCode
.
ERR_USER_CANCEL
)
{
// 用户取消
ShareReceiver
.
sendBroadcast
(
this
,
ShareResult
.
shareCancel
());
}
else
{
// 分享失败
String
errStr
=
resp
.
errStr
;
ShareReceiver
.
sendBroadcast
(
this
,
ShareResult
.
shareFail
(
errStr
));
}
super
.
finish
();
}
@Override
protected
void
onDestroy
()
{
super
.
onDestroy
();
}
}
app/src/main/java/com/whaty/nafmii/dev/wxapi/WXPayEntryActivity.java
0 → 100644
View file @
14b7ae7
package
com
.
whaty
.
nafmii
.
dev
.
wxapi
;
import
android.app.Activity
;
import
android.content.Intent
;
import
android.os.Bundle
;
import
android.util.Log
;
import
com.polysoft.nafmii.wechat.WechatApi
;
import
com.tencent.mm.opensdk.constants.ConstantsAPI
;
import
com.tencent.mm.opensdk.modelbase.BaseReq
;
import
com.tencent.mm.opensdk.modelbase.BaseResp
;
import
com.tencent.mm.opensdk.openapi.IWXAPI
;
import
com.tencent.mm.opensdk.openapi.IWXAPIEventHandler
;
public
class
WXPayEntryActivity
extends
Activity
implements
IWXAPIEventHandler
{
private
static
final
String
TAG
=
WXPayEntryActivity
.
class
.
getName
();
private
IWXAPI
api
;
@Override
public
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
WechatApi
.
getInstance
(
this
).
handleIntent
(
getIntent
(),
this
);
}
@Override
protected
void
onNewIntent
(
Intent
intent
)
{
super
.
onNewIntent
(
intent
);
setIntent
(
intent
);
WechatApi
.
getInstance
(
this
).
handleIntent
(
intent
,
this
);
}
@Override
public
void
onReq
(
BaseReq
req
)
{
}
@Override
public
void
onResp
(
BaseResp
resp
)
{
Log
.
d
(
TAG
,
"onPayFinish, errCode = "
+
resp
.
errCode
);
if
(
resp
.
getType
()
!=
ConstantsAPI
.
COMMAND_PAY_BY_WX
)
{
return
;
}
int
code
=
resp
.
errCode
;
if
(
code
==
BaseResp
.
ErrCode
.
ERR_OK
)
{
// 支付成功
// PayReceiver.sendBroadcast(this, PayResult.success(PayMode.WECHATPAY, null));
}
else
if
(
code
==
BaseResp
.
ErrCode
.
ERR_USER_CANCEL
)
{
// 用户取消
// PayReceiver.sendBroadcast(this, PayResult.cancel(PayMode.WECHATPAY));
}
else
{
// 支付失败
String
errStr
=
resp
.
errStr
;
// PayReceiver.sendBroadcast(this, PayResult.fail(PayMode.WECHATPAY, errStr));
}
super
.
finish
();
}
}
\ No newline at end of file
\ No newline at end of file
Write
Preview
Markdown
is supported
Attach a file
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 post a comment