Commit 14b7ae71 by amateur

1

1 parent 85bf6d84
......@@ -17,7 +17,7 @@ android {
buildConfigField "String", "API_HOST", "\"http://10.10.81.189/nafmii/app/\""
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 "boolean", "SHOW_INPUT", "true"
ndk {
......@@ -83,13 +83,15 @@ android {
}
uat { // 测试
debuggable true
minifyEnabled false
signingConfig signingConfigs.debug
resValue "string", "app_name", "Nafmii-uat"
applicationIdSuffix "uat"
buildConfigField "String", "WX_APPID", "\"wxb9dd952e6522ef31\""
buildConfigField "String", "API_HOST", "\"http://10.10.34.155/nafmii/app/\""
buildConfigField "String", "IMG_API", "\"http://10.10.34.155/file/\""
buildConfigField "String", "ONLINE_URL", "\"http://10.10.34.155/h5/\""
signingConfig signingConfigs.debug
manifestPlaceholders = [
JPUSH_PKGNAME: "com.whaty.nafmii.uat",
JPUSH_APPKEY : "ef86f246857d981193987dee",//值来自开发者平台取得的AppKey
......@@ -97,9 +99,15 @@ android {
]
}
dev {
debuggable true
minifyEnabled false
signingConfig signingConfigs.debug
resValue "string", "app_name", "Nafmii-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 = [
JPUSH_PKGNAME: "com.whaty.nafmii.dev",
JPUSH_APPKEY : "ef86f246857d981193987dee",//值来自开发者平台取得的AppKey
......
......@@ -5,7 +5,7 @@
<permission
android:name="${applicationId}.permission.JPUSH_MESSAGE"
android:protectionLevel="signature"/>
android:protectionLevel="signature" />
<uses-permission android:name="${applicationId}.permission.JPUSH_MESSAGE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
......@@ -72,6 +72,18 @@
android:theme="@style/Nafmii.Fullscreen.NoTitleBar" />
<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
android:name="com.tencent.smtt.export.external.DexClassLoaderProviderService"
android:label="dexopt"
......
......@@ -81,7 +81,10 @@ public class NativeApi {
js.callJs(result);
}));
} else if ("2".equals(type)) { // 微信
this.mActivity.runOnUiThread(() -> {
WechatApi instance = WechatApi.getInstance(this.mActivity);
instance.login();
});
}
});
}
......
......@@ -13,6 +13,7 @@ import com.bumptech.glide.Glide;
import com.bumptech.glide.request.target.SimpleTarget;
import com.bumptech.glide.request.transition.Transition;
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.WXMediaMessage;
import com.tencent.mm.opensdk.modelmsg.WXWebpageObject;
......@@ -63,6 +64,13 @@ public class WechatApi {
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) {
String webImg = bean.getWebImg();
String shareType = bean.getShareType();
......
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();
}
}
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
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!