提交 bfac3c99 authored 作者: JarvanMo's avatar JarvanMo

response from auto deduct & change auto-deduct behavoir

上级 86f4940e
......@@ -20,6 +20,7 @@ class FluwxAutoDeductHandler {
val sign = call.argument<String>("sign") ?: ""
val timestamp = call.argument<String>("timestamp") ?: ""
val returnApp = call.argument<String>("return_app") ?: ""
val businessType = call.argument<Int>("businessType")?:12
val map = HashMap<String,String>()
map["appid"] = appId
......@@ -36,7 +37,7 @@ class FluwxAutoDeductHandler {
val req = WXOpenBusinessWebview.Req()
req.businessType = 12
req.businessType = businessType
req.queryInfo = map
val b = WXAPiHandler.wxApi?.sendReq(req)
result.success(b)
......
......@@ -20,6 +20,7 @@ import com.jarvan.fluwx.constant.WechatPluginKeys
import com.tencent.mm.opensdk.modelbase.BaseResp
import com.tencent.mm.opensdk.modelbiz.SubscribeMessage
import com.tencent.mm.opensdk.modelbiz.WXLaunchMiniProgram
import com.tencent.mm.opensdk.modelbiz.WXOpenBusinessWebview
import com.tencent.mm.opensdk.modelmsg.SendAuth
import com.tencent.mm.opensdk.modelmsg.SendMessageToWX
import com.tencent.mm.opensdk.modelpay.PayResp
......@@ -46,6 +47,7 @@ object FluwxResponseHandler {
is PayResp -> handlePayResp(response)
is WXLaunchMiniProgram.Resp -> handleLaunchMiniProgramResponse(response)
is SubscribeMessage.Resp -> handleSubscribeMessage(response)
is WXOpenBusinessWebview.Resp -> handlerWXOpenBusinessWebviewResponse(response)
}
}
......@@ -131,4 +133,20 @@ object FluwxResponseHandler {
}
private fun handlerWXOpenBusinessWebviewResponse(response:WXOpenBusinessWebview.Resp){
val result = mapOf(
WechatPluginKeys.PLATFORM to WechatPluginKeys.ANDROID,
errCode to response.errCode,
"businessType" to response.businessType,
"resultInfo" to response.resultInfo,
errStr to response.errStr,
openId to response.openId,
type to response.type,
WechatPluginKeys.TRANSACTION to response.transaction
)
channel?.invokeMethod("onAutoDeductResponse", result)
}
}
\ No newline at end of file
......@@ -183,6 +183,7 @@
TargetAttributes = {
97C146ED1CF9000F007C117D = {
CreatedOnToolsVersion = 7.3.1;
DevelopmentTeam = 8JJXUFV6F7;
SystemCapabilities = {
com.apple.BackgroundModes = {
enabled = 1;
......@@ -437,7 +438,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES = YES;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = "";
DEVELOPMENT_TEAM = 8JJXUFV6F7;
ENABLE_BITCODE = NO;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
......@@ -450,7 +451,7 @@
"$(inherited)",
"$(PROJECT_DIR)/Flutter",
);
PRODUCT_BUNDLE_IDENTIFIER = "com.jarvanmo.fluwx-example3";
PRODUCT_BUNDLE_IDENTIFIER = com.jarvanmo.fluwxexample;
PRODUCT_NAME = "$(TARGET_NAME)";
TARGETED_DEVICE_FAMILY = 1;
USER_HEADER_SEARCH_PATHS = "\"${PROJECT_DIR}/../..\"/** \"${PROJECT_DIR}/../..\"/**";
......@@ -465,7 +466,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES = YES;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = "";
DEVELOPMENT_TEAM = 8JJXUFV6F7;
ENABLE_BITCODE = NO;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
......@@ -478,7 +479,7 @@
"$(inherited)",
"$(PROJECT_DIR)/Flutter",
);
PRODUCT_BUNDLE_IDENTIFIER = "com.jarvanmo.fluwx-example3";
PRODUCT_BUNDLE_IDENTIFIER = com.jarvanmo.fluwxexample;
PRODUCT_NAME = "$(TARGET_NAME)";
TARGETED_DEVICE_FAMILY = 1;
USER_HEADER_SEARCH_PATHS = "\"${PROJECT_DIR}/../..\"/** \"${PROJECT_DIR}/../..\"/**";
......
......@@ -5,7 +5,7 @@
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleDisplayName</key>
<string>Fluwx</string>
<string>FluwxDemo</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
......
......@@ -21,9 +21,12 @@
-(void)handleAutoDeductWithCall:(FlutterMethodCall *)call result:(FlutterResult)result {
NSDictionary *params = call.arguments;
NSMutableDictionary *paramsFromDart = [NSMutableDictionary dictionaryWithDictionary:call.arguments];
[paramsFromDart removeObjectForKey:@"businessType"];
WXOpenBusinessWebViewReq *req = [[WXOpenBusinessWebViewReq alloc] init];
req.businessType = 12;
req.queryInfoDic = params;
NSNumber * businessType = call.arguments[@"businessType"];
req.businessType = [businessType unsignedIntValue];
req.queryInfoDic = paramsFromDart;
BOOL b = [WXApi sendReq:req];
result(@(b));
......
......@@ -179,6 +179,20 @@ FlutterMethodChannel *fluwxMethodChannel = nil;
fluwxKeyPlatform: fluwxKeyIOS,
};
[fluwxMethodChannel invokeMethod:@"onPayResponse" arguments:result];
} else if([resp isKindOfClass:[WXOpenBusinessWebViewResp class]]){
WXOpenBusinessWebViewResp *businessResp = (WXOpenBusinessWebViewResp *) resp;
NSDictionary *result = @{
description: [StringUtil nilToEmpty:businessResp.description],
errStr: [StringUtil nilToEmpty:resp.errStr],
errCode: @(businessResp.errCode),
type: businessResp.type == nil ? @5 : @(businessResp.type),
@"resultInfo": businessResp.result,
@"businessType":@(businessResp.businessType),
fluwxKeyPlatform: fluwxKeyIOS,
};
[fluwxMethodChannel invokeMethod:@"onAutoDeductResponse" arguments:result];
}
}
......
......@@ -78,6 +78,14 @@ StreamController _onQRCodeScannedController = new StreamController();
///after uer scanned the QRCode you just received
Stream get onQRCodeScanned => _onQRCodeScannedController.stream;
StreamController<WeChatAutoDeductResponse> _responseAutoDeductController =
new StreamController.broadcast();
/// Response from AutoDeduct
Stream<WeChatAutoDeductResponse> get responseFromAutoDeduct =>
_responseAutoDeductController.stream;
final MethodChannel _channel = const MethodChannel('com.jarvanmo/fluwx')
..setMethodCallHandler(_handler);
......@@ -103,6 +111,8 @@ Future<dynamic> _handler(MethodCall methodCall) {
_onAuthGotQRCodeController.add(methodCall.arguments);
} else if ("onQRCodeScanned" == methodCall.method) {
_onQRCodeScannedController.add(null);
} else if("onAutoDeductResponse" == methodCall.method){
_responseAutoDeductController.add(WeChatAutoDeductResponse.fromMap(methodCall.arguments));
}
return Future.value(true);
......@@ -313,6 +323,7 @@ Future autoDeDuct({
@required String sign,
@required String timestamp,
String returnApp = '3',
int businessType = 12
}) async {
return await _channel.invokeMethod("autoDeduct", {
'appid': appId,
......@@ -326,6 +337,7 @@ Future autoDeDuct({
'sign': sign,
'timestamp': timestamp,
'return_app': returnApp,
"businessType" : businessType
});
}
......
......@@ -130,3 +130,24 @@ class WeChatSubscribeMsgResp {
reserved = map["reserved"],
scene = map["scene"];
}
class WeChatAutoDeductResponse {
final String errStr;
final int type;
final String platform;
final int errCode;
final int businessType;
final String resultInfo;
final String androidTransaction;
final String androidOpenId;
WeChatAutoDeductResponse.fromMap(Map map)
: platform = map["platform"],
errStr = map["errStr"],
androidTransaction = map["transaction"],
type = map["type"],
errCode = map["errCode"],
androidOpenId = map["openId"],
businessType = map["businessType"],
resultInfo = map["resultInfo"];
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论