Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
C
clx-fluwx
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
openSourceLibrary
clx-fluwx
Commits
ffa730d5
提交
ffa730d5
authored
9月 29, 2018
作者:
JarvanMo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
response uses classes now;rm Fluwx.class
上级
d6b840e5
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
159 行增加
和
59 行删除
+159
-59
CHANGELOG.md
CHANGELOG.md
+2
-0
FluwxResponseHandler.kt
...n/kotlin/com/jarvan/fluwx/handler/FluwxResponseHandler.kt
+1
-0
FluwxResponseHandler.m
ios/Classes/wechat/FluwxResponseHandler.m
+2
-1
fluwx_class.dart
lib/src/fluwx_class.dart
+79
-58
wechat_response.dart
lib/src/models/wechat_response.dart
+75
-0
没有找到文件。
CHANGELOG.md
浏览文件 @
ffa730d5
## 0.2.2
## 0.2.2
*
回调方式发生变化,由Map变更为实体类。
*
iOS的SDK更换为'OpenWeChatSDK',并升级到了1.8.3。
*
iOS的SDK更换为'OpenWeChatSDK',并升级到了1.8.3。
*
修复iOS支付返回结果缺少
*returnKey*
的问题。
## 0.2.1
## 0.2.1
*
修复在Android处理网络图片后缀不对的问题。
*
修复在Android处理网络图片后缀不对的问题。
...
...
android/src/main/kotlin/com/jarvan/fluwx/handler/FluwxResponseHandler.kt
浏览文件 @
ffa730d5
...
@@ -49,6 +49,7 @@ object FluwxResponseHandler {
...
@@ -49,6 +49,7 @@ object FluwxResponseHandler {
}
}
private
fun
handlePayResp
(
response
:
PayResp
)
{
private
fun
handlePayResp
(
response
:
PayResp
)
{
val
result
=
mapOf
(
val
result
=
mapOf
(
"prepayId"
to
response
.
prepayId
,
"prepayId"
to
response
.
prepayId
,
"returnKey"
to
response
.
returnKey
,
"returnKey"
to
response
.
returnKey
,
...
...
ios/Classes/wechat/FluwxResponseHandler.m
浏览文件 @
ffa730d5
...
@@ -139,9 +139,10 @@ FlutterMethodChannel *methodChannel = nil;
...
@@ -139,9 +139,10 @@ FlutterMethodChannel *methodChannel = nil;
errStr:
[
StringUtil
nilToEmpty
:
resp
.
errStr
],
errStr:
[
StringUtil
nilToEmpty
:
resp
.
errStr
],
errCode:
@
(
payResp
.
errCode
),
errCode:
@
(
payResp
.
errCode
),
type:
payResp
.
type
==
nil
?
@5
:
@
(
payResp
.
type
),
type:
payResp
.
type
==
nil
?
@5
:
@
(
payResp
.
type
),
@"returnKey"
:
payResp
.
returnKey
==
nil
?
@""
:
payResp
.
returnKey
,
fluwxKeyPlatform:
fluwxKeyIOS
,
fluwxKeyPlatform:
fluwxKeyIOS
,
};
};
[
methodChannel
invokeMethod
:
@"on
Auth
Response"
arguments
:
result
];
[
methodChannel
invokeMethod
:
@"on
Pay
Response"
arguments
:
result
];
}
}
}
}
...
...
lib/src/fluwx_class.dart
浏览文件 @
ffa730d5
...
@@ -22,88 +22,109 @@ import 'models/wechat_response.dart';
...
@@ -22,88 +22,109 @@ import 'models/wechat_response.dart';
import
'models/wechat_send_auth_model.dart'
;
import
'models/wechat_send_auth_model.dart'
;
import
'models/wechat_share_models.dart'
;
import
'models/wechat_share_models.dart'
;
StreamController
<
WeChat
Response
>
_respons
eController
=
StreamController
<
WeChat
ShareResponse
>
_responseShar
eController
=
new
StreamController
.
broadcast
();
new
StreamController
.
broadcast
();
Stream
<
WeChatShareResponse
>
get
responseFromShare
=>
_responseShareController
.
stream
;
StreamController
<
WeChatAuthResponse
>
_responseAuthController
=
new
StreamController
.
broadcast
();
Stream
<
WeChatAuthResponse
>
get
responseFromAuth
=>
_responseAuthController
.
stream
;
StreamController
<
WeChatPaymentResponse
>
_responsePaymentController
=
new
StreamController
.
broadcast
();
Stream
<
WeChatPaymentResponse
>
get
responseFromPayment
=>
_responsePaymentController
.
stream
;
final
MethodChannel
_channel
=
const
MethodChannel
(
'com.jarvanmo/fluwx'
)
final
MethodChannel
_channel
=
const
MethodChannel
(
'com.jarvanmo/fluwx'
)
..
setMethodCallHandler
(
_handler
);
..
setMethodCallHandler
(
_handler
);
Future
<
dynamic
>
_handler
(
MethodCall
methodCall
)
{
Future
<
dynamic
>
_handler
(
MethodCall
methodCall
)
{
if
(
"onShareResponse"
==
methodCall
.
method
)
{
if
(
"onShareResponse"
==
methodCall
.
method
)
{
_responseController
_response
Share
Controller
.
add
(
WeChat
Response
(
methodCall
.
arguments
,
WeChatResponseType
.
SHARE
));
.
add
(
WeChat
ShareResponse
.
fromMap
(
methodCall
.
arguments
));
}
else
if
(
"onAuthResponse"
==
methodCall
.
method
)
{
}
else
if
(
"onAuthResponse"
==
methodCall
.
method
)
{
_responseController
_response
Auth
Controller
.
add
(
WeChat
Response
(
methodCall
.
arguments
,
WeChatResponseType
.
AUTH
));
.
add
(
WeChat
AuthResponse
.
fromMap
(
methodCall
.
arguments
));
}
else
if
(
"onPayResponse"
==
methodCall
.
method
)
{
}
else
if
(
"onPayResponse"
==
methodCall
.
method
)
{
_responseController
_response
Payment
Controller
.
add
(
WeChat
Response
(
methodCall
.
arguments
,
WeChatResponseType
.
PAYMENT
));
.
add
(
WeChat
PaymentResponse
.
fromMap
(
methodCall
.
arguments
));
}
}
return
Future
.
value
(
true
);
return
Future
.
value
(
true
);
}
}
class
Fluwx
{
const
Map
<
Type
,
String
>
_shareModelMethodMapper
=
{
static
const
Map
<
Type
,
String
>
_shareModelMethodMapper
=
{
WeChatShareTextModel:
"shareText"
,
WeChatShareTextModel:
"shareText"
,
WeChatShareImageModel:
"shareImage"
,
WeChatShareImageModel:
"shareImage"
,
WeChatShareMusicModel:
"shareMusic"
,
WeChatShareMusicModel:
"shareMusic"
,
WeChatShareVideoModel:
"shareVideo"
,
WeChatShareVideoModel:
"shareVideo"
,
WeChatShareWebPageModel:
"shareWebPage"
,
WeChatShareWebPageModel:
"shareWebPage"
,
WeChatShareMiniProgramModel:
"shareMiniProgram"
WeChatShareMiniProgramModel:
"shareMiniProgram"
};
};
///[appId] is not necessary.
Stream
<
WeChatResponse
>
get
response
=>
_responseController
.
stream
;
///if [doOnIOS] is true ,fluwx will register WXApi on iOS.
///if [doOnAndroid] is true, fluwx will register WXApi on Android.
///[appId] is not necessary.
Future
register
(
///if [doOnIOS] is true ,fluwx will register WXApi on iOS.
{
String
appId
,
///if [doOnAndroid] is true, fluwx will register WXApi on Android.
bool
doOnIOS:
true
,
static
Future
register
(
doOnAndroid:
true
,
{
String
appId
,
enableMTA:
false
})
async
{
bool
doOnIOS:
true
,
return
await
_channel
.
invokeMethod
(
"registerApp"
,
{
doOnAndroid:
true
,
"appId"
:
appId
,
enableMTA:
false
})
async
{
"iOS"
:
doOnIOS
,
return
await
_channel
.
invokeMethod
(
"registerApp"
,
{
"android"
:
doOnAndroid
,
"appId"
:
appId
,
"enableMTA"
:
enableMTA
"iOS"
:
doOnIOS
,
});
"android"
:
doOnAndroid
,
}
"enableMTA"
:
enableMTA
});
///we don't need the response any longer if params are true.
void
dispose
(
{
shareResponse:
true
,
authResponse:
true
,
paymentResponse:
true
})
{
if
(
shareResponse
)
{
_responseShareController
.
close
();
}
}
///we don't need the response any longer.
if
(
authResponse
)
{
static
void
dispose
()
{
_responseAuthController
.
close
();
_responseController
.
close
();
}
}
if
(
paymentResponse
)
{
_responseAuthController
.
close
();
}
}
// static Future unregisterApp(RegisterModel model) async {
// static Future unregisterApp(RegisterModel model) async {
// return await _channel.invokeMethod("unregisterApp", model.toMap());
// return await _channel.invokeMethod("unregisterApp", model.toMap());
// }
// }
///the [WeChatShareModel] can not be null
///the [WeChatShareModel] can not be null
///see [WeChatShareWebPageModel]
///see [WeChatShareWebPageModel]
/// [WeChatShareTextModel]
/// [WeChatShareTextModel]
///[WeChatShareVideoModel]
///[WeChatShareVideoModel]
///[WeChatShareMusicModel]
///[WeChatShareMusicModel]
///[WeChatShareImageModel]
///[WeChatShareImageModel]
Future
share
(
WeChatShareModel
model
)
async
{
Future
share
(
WeChatShareModel
model
)
async
{
if
(
_shareModelMethodMapper
.
containsKey
(
model
.
runtimeType
))
{
if
(
_shareModelMethodMapper
.
containsKey
(
model
.
runtimeType
))
{
return
await
_channel
.
invokeMethod
(
return
await
_channel
.
invokeMethod
(
_shareModelMethodMapper
[
model
.
runtimeType
],
model
.
toMap
());
_shareModelMethodMapper
[
model
.
runtimeType
],
model
.
toMap
());
}
else
{
}
else
{
return
Future
.
error
(
"no method mapper found[
${model.runtimeType}
]"
);
return
Future
.
error
(
"no method mapper found[
${model.runtimeType}
]"
);
}
}
}
}
Future
sendAuth
(
WeChatSendAuthModel
model
)
async
{
Future
sendAuth
(
WeChatSendAuthModel
model
)
async
{
return
await
_channel
.
invokeMethod
(
"sendAuth"
,
model
.
toMap
());
return
await
_channel
.
invokeMethod
(
"sendAuth"
,
model
.
toMap
());
}
}
Future
isWeChatInstalled
()
async
{
Future
isWeChatInstalled
(
)
async
{
return
await
_channel
.
invokeMethod
(
"isWeChatInstalled"
);
return
await
_channel
.
invokeMethod
(
"isWeChatInstalled"
);
}
}
Future
pay
(
WeChatPayModel
model
)
async
{
Future
pay
(
WeChatPayModel
model
)
async
{
return
await
_channel
.
invokeMethod
(
"pay"
,
model
.
toMap
());
return
await
_channel
.
invokeMethod
(
"pay"
,
model
.
toMap
());
}
}
}
lib/src/models/wechat_response.dart
浏览文件 @
ffa730d5
...
@@ -27,3 +27,78 @@ class WeChatResponse {
...
@@ -27,3 +27,78 @@ class WeChatResponse {
return
{
"type"
:
type
,
"result"
:
result
}.
toString
();
return
{
"type"
:
type
,
"result"
:
result
}.
toString
();
}
}
}
}
class
WeChatShareResponse
{
final
String
errStr
;
final
String
androidTransaction
;
final
int
type
;
final
int
errCode
;
final
String
androidOpenId
;
final
String
iOSDescription
;
final
String
iOSCountry
;
final
String
iOSLang
;
WeChatShareResponse
.
fromMap
(
Map
map
)
:
errStr
=
map
[
"errStr"
],
androidTransaction
=
map
[
"transaction"
],
type
=
map
[
"type"
],
errCode
=
map
[
"errCode"
],
androidOpenId
=
map
[
"openId"
],
iOSDescription
=
map
[
"description"
],
iOSCountry
=
map
[
"country"
],
iOSLang
=
map
[
"lang"
];
}
class
WeChatAuthResponse
{
final
String
errStr
;
final
int
type
;
final
int
errCode
;
final
String
androidOpenId
;
final
String
iOSDescription
;
final
String
country
;
final
String
lang
;
final
String
code
;
final
String
androidUrl
;
final
String
state
;
final
String
androidTransaction
;
WeChatAuthResponse
.
fromMap
(
Map
map
)
:
errStr
=
map
[
"errStr"
],
type
=
map
[
"type"
],
errCode
=
map
[
"errCode"
],
androidOpenId
=
map
[
"openId"
],
iOSDescription
=
map
[
"description"
],
country
=
map
[
"country"
],
lang
=
map
[
"lang"
],
code
=
map
[
"code"
],
androidUrl
=
map
[
"url"
],
state
=
map
[
"state"
],
androidTransaction
=
map
[
"transaction"
];
}
class
WeChatPaymentResponse
{
final
String
errStr
;
final
int
type
;
final
int
errCode
;
final
String
androidOpenId
;
final
String
iOSDescription
;
final
String
androidPrepayId
;
final
String
extData
;
final
String
androidTransaction
;
WeChatPaymentResponse
.
fromMap
(
Map
map
):
errStr
=
map
[
"errStr"
],
type
=
map
[
"type"
],
errCode
=
map
[
"errCode"
],
androidOpenId
=
map
[
"openId"
],
iOSDescription
=
map
[
"description"
],
androidPrepayId
=
map
[
"prepayId"
],
extData
=
map
[
"extData"
],
androidTransaction
=
map
[
"transaction"
]
;
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论