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 f70ac5ab
authored
Oct 18, 2021
by
amateur
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
1
1 parent
1decc8eb
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
186 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/utils/SpUtils.java
app/src/main/java/com/polysoft/nafmii/utils/WebVersionUtils.java
app/src/main/java/com/whaty/nafmii/qp/wxapi/WXEntryActivity.java
app/src/main/java/com/whaty/nafmii/qp/wxapi/WXPayEntryActivity.java
app/src/main/java/com/whaty/nafmii/wxapi/WXEntryActivity.java
app/build.gradle
View file @
f70ac5a
...
...
@@ -86,6 +86,7 @@ android {
signingConfig
signingConfigs
.
debug
resValue
"string"
,
"app_name"
,
"NAFMII之窗-qp"
applicationIdSuffix
"qp"
buildConfigField
"String"
,
"WEB_VERSION"
,
"\"0.0.1\""
buildConfigField
"String"
,
"WX_APPID"
,
"\"wx0c80bdc32795951b\""
buildConfigField
"String"
,
"QQ_APPID"
,
"\"101975384\""
buildConfigField
"String"
,
"API_HOST"
,
"\"http://172.20.101.132/nafmii/app/\""
...
...
app/src/main/AndroidManifest.xml
View file @
f70ac5a
...
...
@@ -95,6 +95,17 @@
android:configChanges=
"orientation|keyboardHidden"
android:screenOrientation=
"behind"
android:theme=
"@android:style/Theme.Translucent.NoTitleBar"
/>
<!-- 微信生产环境环境-->
<activity
android:name=
"com.whaty.nafmii.wxapi.WXEntryActivity"
android:exported=
"true"
android:launchMode=
"singleTask"
android:taskAffinity=
"${applicationId}"
/>
<activity
android:name=
"com.whaty.nafmii.wxapi.WXPayEntryActivity"
android:exported=
"true"
android:launchMode=
"singleTask"
android:taskAffinity=
"${applicationId}"
/>
<!-- 微信开发环境-->
<activity
android:name=
"com.whaty.nafmii.dev.wxapi.WXEntryActivity"
...
...
@@ -117,6 +128,17 @@
android:exported=
"true"
android:launchMode=
"singleTask"
android:taskAffinity=
"${applicationId}"
/>
<!-- 微信准生产环境-->
<activity
android:name=
"com.whaty.nafmii.qp.wxapi.WXEntryActivity"
android:exported=
"true"
android:launchMode=
"singleTask"
android:taskAffinity=
"${applicationId}"
/>
<activity
android:name=
"com.whaty.nafmii.qp.wxapi.WXPayEntryActivity"
android:exported=
"true"
android:launchMode=
"singleTask"
android:taskAffinity=
"${applicationId}"
/>
<service
android:name=
"com.tencent.smtt.export.external.DexClassLoaderProviderService"
...
...
app/src/main/assets/dist.zip
View file @
f70ac5a
No preview for this file type
app/src/main/java/com/polysoft/nafmii/utils/SpUtils.java
View file @
f70ac5a
...
...
@@ -7,6 +7,8 @@ public class SpUtils {
private
static
final
String
SP_NAME
=
"NAFMII"
;
public
static
final
String
WEB_VERSION_KEY
=
"WEB_VERSION"
;
public
static
void
putBoolean
(
String
key
,
boolean
val
)
{
SharedPreferences
.
Editor
edit
=
getSpMgr
().
edit
();
edit
.
putBoolean
(
key
,
val
).
commit
();
...
...
app/src/main/java/com/polysoft/nafmii/utils/WebVersionUtils.java
0 → 100644
View file @
f70ac5a
package
com
.
polysoft
.
nafmii
.
utils
;
import
com.whaty.nafmii.BuildConfig
;
import
java.io.File
;
public
class
WebVersionUtils
{
public
static
String
getVersion
()
{
return
SpUtils
.
getString
(
SpUtils
.
WEB_VERSION_KEY
,
BuildConfig
.
WEB_VERSION
);
}
public
static
void
setVersion
(
String
name
)
{
SpUtils
.
putString
(
SpUtils
.
WEB_VERSION_KEY
,
name
);
}
public
static
File
getIndex
()
{
return
new
File
(
getDistDir
(),
"index.html"
);
}
public
static
File
getDistDir
()
{
return
getDistDir
(
getVersion
());
}
public
static
File
getDistDir
(
String
version
)
{
File
verisonDir
=
new
File
(
FileUtils
.
getRootDir
(),
version
);
File
dist
=
new
File
(
verisonDir
,
"dist"
);
if
(!
dist
.
exists
())
{
dist
.
mkdirs
();
}
return
dist
;
}
}
app/src/main/java/com/whaty/nafmii/qp/wxapi/WXEntryActivity.java
0 → 100644
View file @
f70ac5a
package
com
.
whaty
.
nafmii
.
qp
.
wxapi
;
import
android.app.Activity
;
import
android.content.Intent
;
import
android.os.Bundle
;
import
com.polysoft.nafmii.broadcast.WechatReceiver
;
import
com.polysoft.nafmii.wechat.WechatApi
;
import
com.polysoft.nafmii.wechat.WechatResult
;
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
)
{
// 成功
if
(
resp
instanceof
SendAuth
.
Resp
)
{
WechatReceiver
.
sendBroadcast
(
this
,
WechatResult
.
loginSuccess
(
resp
));
}
else
{
WechatReceiver
.
sendBroadcast
(
this
,
WechatResult
.
shareSuccess
());
}
}
else
if
(
code
==
BaseResp
.
ErrCode
.
ERR_USER_CANCEL
)
{
// 用户取消
WechatReceiver
.
sendBroadcast
(
this
,
WechatResult
.
cancel
());
}
else
if
(
code
==
BaseResp
.
ErrCode
.
ERR_AUTH_DENIED
)
{
WechatReceiver
.
sendBroadcast
(
this
,
WechatResult
.
refuse
());
}
else
{
// 失败
String
errStr
=
resp
.
errStr
;
WechatReceiver
.
sendBroadcast
(
this
,
WechatResult
.
fail
(
errStr
));
}
super
.
finish
();
}
@Override
protected
void
onDestroy
()
{
super
.
onDestroy
();
}
}
app/src/main/java/com/whaty/nafmii/qp/wxapi/WXPayEntryActivity.java
0 → 100644
View file @
f70ac5a
package
com
.
whaty
.
nafmii
.
qp
.
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
app/src/main/java/com/whaty/nafmii/wxapi/WXEntryActivity.java
View file @
f70ac5a
...
...
@@ -5,8 +5,8 @@ import android.content.Intent;
import
android.os.Bundle
;
import
com.polysoft.nafmii.broadcast.WechatReceiver
;
import
com.polysoft.nafmii.wechat.WechatResult
;
import
com.polysoft.nafmii.wechat.WechatApi
;
import
com.polysoft.nafmii.wechat.WechatResult
;
import
com.tencent.mm.opensdk.modelbase.BaseReq
;
import
com.tencent.mm.opensdk.modelbase.BaseResp
;
import
com.tencent.mm.opensdk.modelmsg.SendAuth
;
...
...
@@ -32,6 +32,10 @@ public class WXEntryActivity extends Activity implements IWXAPIEventHandler {
@Override
public
void
onResp
(
BaseResp
resp
)
{
if
(
resp
instanceof
SendAuth
.
Resp
)
{
}
int
code
=
resp
.
errCode
;
if
(
code
==
BaseResp
.
ErrCode
.
ERR_OK
)
{
// 成功
if
(
resp
instanceof
SendAuth
.
Resp
)
{
...
...
@@ -41,11 +45,10 @@ public class WXEntryActivity extends Activity implements IWXAPIEventHandler {
}
}
else
if
(
code
==
BaseResp
.
ErrCode
.
ERR_USER_CANCEL
)
{
// 用户取消
WechatReceiver
.
sendBroadcast
(
this
,
WechatResult
.
cancel
());
}
else
if
(
code
==
BaseResp
.
ErrCode
.
ERR_AUTH_DENIED
)
{
WechatReceiver
.
sendBroadcast
(
this
,
WechatResult
.
refuse
());
}
else
{
// 失败
String
errStr
=
resp
.
errStr
;
// if (resp instanceof SendAuth.Resp) {
// WechatReceiver.sendBroadcast(this, WechatResult.fail(errStr));
// }
WechatReceiver
.
sendBroadcast
(
this
,
WechatResult
.
fail
(
errStr
));
}
super
.
finish
();
...
...
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