Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
C
clx-fluwx
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
openSourceLibrary
clx-fluwx
Commits
75552677
提交
75552677
authored
8月 21, 2018
作者:
JarvanMo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
send auth on android
上级
451f258e
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
113 行增加
和
1 行删除
+113
-1
FluwxPlugin.kt
android/src/main/kotlin/com/jarvan/fluwx/FluwxPlugin.kt
+5
-0
FluwxLoginHandler.kt
...main/kotlin/com/jarvan/fluwx/handler/FluwxLoginHandler.kt
+33
-0
WXAPiHandler.kt
.../src/main/kotlin/com/jarvan/fluwx/handler/WXAPiHandler.kt
+51
-0
fluwx_class.dart
lib/src/fluwx_class.dart
+5
-1
wechat_send_auth_model.dart
lib/src/models/wechat_send_auth_model.dart
+19
-0
没有找到文件。
android/src/main/kotlin/com/jarvan/fluwx/FluwxPlugin.kt
浏览文件 @
75552677
package
com.jarvan.fluwx
package
com.jarvan.fluwx
import
com.jarvan.fluwx.constant.WeChatPluginMethods
import
com.jarvan.fluwx.constant.WeChatPluginMethods
import
com.jarvan.fluwx.handler.FluwxLoginHandler
import
com.jarvan.fluwx.handler.FluwxShareHandler
import
com.jarvan.fluwx.handler.FluwxShareHandler
import
io.flutter.plugin.common.MethodCall
import
io.flutter.plugin.common.MethodCall
import
io.flutter.plugin.common.MethodChannel
import
io.flutter.plugin.common.MethodChannel
...
@@ -32,6 +33,10 @@ class FluwxPlugin(private var registrar: Registrar) : MethodCallHandler {
...
@@ -32,6 +33,10 @@ class FluwxPlugin(private var registrar: Registrar) : MethodCallHandler {
return
return
}
}
if
(
"sendAuth"
==
call
.
method
){
FluwxLoginHandler
.
sendAuth
(
call
,
result
)
return
}
if
(
call
.
method
.
startsWith
(
"share"
)){
if
(
call
.
method
.
startsWith
(
"share"
)){
FluwxShareHandler
.
handle
(
call
,
result
)
FluwxShareHandler
.
handle
(
call
,
result
)
...
...
android/src/main/kotlin/com/jarvan/fluwx/handler/FluwxLoginHandler.kt
0 → 100644
浏览文件 @
75552677
package
com.jarvan.fluwx.handler
import
com.tencent.mm.opensdk.modelbase.BaseResp
import
com.tencent.mm.opensdk.modelmsg.SendAuth
import
io.flutter.plugin.common.MethodCall
import
io.flutter.plugin.common.MethodChannel
object
FluwxLoginHandler
{
private
var
channel
:
MethodChannel
?
=
null
fun
setMethodChannel
(
channel
:
MethodChannel
)
{
FluwxLoginHandler
.
channel
=
channel
}
fun
sendAuth
(
call
:
MethodCall
,
result
:
MethodChannel
.
Result
)
{
val
req
=
SendAuth
.
Req
()
req
.
scope
=
call
.
argument
(
"scope"
)
req
.
state
=
call
.
argument
(
"state"
)
result
.
success
(
WXAPiHandler
.
wxApi
!!
.
sendReq
(
req
))
}
fun
handleResponse
(
response
:
BaseResp
){
}
}
\ No newline at end of file
android/src/main/kotlin/com/jarvan/fluwx/handler/WXAPiHandler.kt
0 → 100644
浏览文件 @
75552677
package
com.jarvan.fluwx.handler
import
com.jarvan.fluwx.constant.WechatPluginKeys
import
com.tencent.mm.opensdk.openapi.IWXAPI
import
com.tencent.mm.opensdk.openapi.WXAPIFactory
import
io.flutter.plugin.common.MethodCall
import
io.flutter.plugin.common.MethodChannel
import
io.flutter.plugin.common.PluginRegistry
object
WXAPiHandler
{
private
var
registrar
:
PluginRegistry
.
Registrar
?
=
null
var
wxApi
:
IWXAPI
?
=
null
fun
setRegistrar
(
registrar
:
PluginRegistry
.
Registrar
)
{
WXAPiHandler
.
registrar
=
registrar
}
fun
registerApp
(
call
:
MethodCall
,
result
:
MethodChannel
.
Result
)
{
if
(!
call
.
argument
<
Boolean
>(
WechatPluginKeys
.
ANDROID
)){
return
}
if
(
wxApi
!=
null
)
{
result
.
success
(
mapOf
(
WechatPluginKeys
.
PLATFORM
to
WechatPluginKeys
.
ANDROID
,
WechatPluginKeys
.
RESULT
to
true
))
return
}
val
appId
:
String
?
=
call
.
argument
(
WechatPluginKeys
.
APP_ID
)
if
(
appId
.
isNullOrBlank
())
{
result
.
error
(
"invalid app id"
,
"are you sure your app id is correct ?"
,
appId
)
return
}
val
api
=
WXAPIFactory
.
createWXAPI
(
registrar
!!
.
context
().
applicationContext
,
appId
)
val
registered
=
api
.
registerApp
(
appId
)
wxApi
=
api
result
.
success
(
mapOf
(
WechatPluginKeys
.
PLATFORM
to
WechatPluginKeys
.
ANDROID
,
WechatPluginKeys
.
RESULT
to
registered
))
}
}
\ No newline at end of file
lib/src/fluwx_class.dart
浏览文件 @
75552677
...
@@ -4,7 +4,7 @@ import 'package:flutter/services.dart';
...
@@ -4,7 +4,7 @@ import 'package:flutter/services.dart';
import
'models/flutter_register_model.dart'
;
import
'models/flutter_register_model.dart'
;
import
'models/wechat_share_models.dart'
;
import
'models/wechat_share_models.dart'
;
import
'models/wechat_send_auth_model.dart'
;
class
Fluwx
{
class
Fluwx
{
static
const
Map
<
Type
,
String
>
_shareModelMethodMapper
=
{
static
const
Map
<
Type
,
String
>
_shareModelMethodMapper
=
{
WeChatShareTextModel:
"shareText"
,
WeChatShareTextModel:
"shareText"
,
...
@@ -58,6 +58,10 @@ class Fluwx {
...
@@ -58,6 +58,10 @@ class Fluwx {
}
}
}
}
Future
sendAuth
(
WeChatSendAuthModel
model
)
async
{
return
await
_channel
.
invokeMethod
(
"sendAuth"
,
model
.
toMap
());
}
Future
<
dynamic
>
_handler
(
MethodCall
methodCall
)
{
Future
<
dynamic
>
_handler
(
MethodCall
methodCall
)
{
if
(
"onShareResponse"
==
methodCall
.
method
)
{
if
(
"onShareResponse"
==
methodCall
.
method
)
{
_responseFromShareController
.
add
(
methodCall
.
arguments
);
_responseFromShareController
.
add
(
methodCall
.
arguments
);
...
...
lib/src/models/wechat_send_auth_model.dart
0 → 100644
浏览文件 @
75552677
class
WeChatSendAuthModel
{
final
String
scope
;
final
String
state
;
WeChatSendAuthModel
(
this
.
scope
,
this
.
state
)
:
assert
(
scope
!=
null
&&
scope
.
trim
()
.
isNotEmpty
);
Map
toMap
()
{
return
{
"scope"
:
scope
,
"state"
:
state
};
}
}
\ No newline at end of file
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论