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

response from auto deduct & change auto-deduct behavoir

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