Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
C
clx-fluwx
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
openSourceLibrary
clx-fluwx
Commits
8921699b
提交
8921699b
authored
10月 19, 2018
作者:
JarvanMo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
lauch mini program on Android
上级
2b3b15d7
隐藏空白字符变更
内嵌
并排
正在显示
7 个修改的文件
包含
58 行增加
和
22 行删除
+58
-22
FluwxPlugin.kt
android/src/main/kotlin/com/jarvan/fluwx/FluwxPlugin.kt
+9
-3
WeChatPluginMethods.java
...kotlin/com/jarvan/fluwx/constant/WeChatPluginMethods.java
+2
-0
FluwxLaunchMiniProgramHandler.kt
...com/jarvan/fluwx/handler/FluwxLaunchMiniProgramHandler.kt
+24
-0
FluwxPayHandler.kt
...c/main/kotlin/com/jarvan/fluwx/handler/FluwxPayHandler.kt
+0
-1
FluwxResponseHandler.kt
...n/kotlin/com/jarvan/fluwx/handler/FluwxResponseHandler.kt
+20
-6
FluwxShareHandler.kt
...main/kotlin/com/jarvan/fluwx/handler/FluwxShareHandler.kt
+0
-1
wechat_response.dart
lib/src/models/wechat_response.dart
+3
-11
没有找到文件。
android/src/main/kotlin/com/jarvan/fluwx/FluwxPlugin.kt
浏览文件 @
8921699b
...
...
@@ -24,20 +24,21 @@ import io.flutter.plugin.common.MethodChannel.MethodCallHandler
import
io.flutter.plugin.common.MethodChannel.Result
import
io.flutter.plugin.common.PluginRegistry.Registrar
class
FluwxPlugin
(
private
val
registrar
:
Registrar
,
private
val
channel
:
MethodChannel
)
:
MethodCallHandler
{
class
FluwxPlugin
(
private
val
registrar
:
Registrar
,
private
val
channel
:
MethodChannel
)
:
MethodCallHandler
{
companion
object
{
@JvmStatic
fun
registerWith
(
registrar
:
Registrar
):
Unit
{
val
channel
=
MethodChannel
(
registrar
.
messenger
(),
"com.jarvanmo/fluwx"
)
WXAPiHandler
.
setRegistrar
(
registrar
)
FluwxResponseHandler
.
setMethodChannel
(
channel
)
channel
.
setMethodCallHandler
(
FluwxPlugin
(
registrar
,
channel
))
channel
.
setMethodCallHandler
(
FluwxPlugin
(
registrar
,
channel
))
}
}
private
val
fluwxShareHandler
=
FluwxShareHandler
()
private
val
fluwxAuthHandler
=
FluwxAuthHandler
()
private
val
fluwxPayHandler
=
FluwxPayHandler
()
private
val
fluwxPayHandler
=
FluwxPayHandler
()
private
val
fluwxLaunchMiniProgramHandler
=
FluwxLaunchMiniProgramHandler
()
init
{
fluwxShareHandler
.
setRegistrar
(
registrar
)
...
...
@@ -72,6 +73,11 @@ class FluwxPlugin(private val registrar: Registrar,private val channel: MethodCh
return
}
if
(
call
.
method
==
WeChatPluginMethods
.
LAUNCH_MINI_PROGRAM
){
fluwxLaunchMiniProgramHandler
.
launchMiniProgram
(
call
,
result
)
return
}
if
(
call
.
method
.
startsWith
(
"share"
))
{
fluwxShareHandler
.
handle
(
call
,
result
)
}
else
{
...
...
android/src/main/kotlin/com/jarvan/fluwx/constant/WeChatPluginMethods.java
浏览文件 @
8921699b
...
...
@@ -9,6 +9,7 @@ public class WeChatPluginMethods {
public
static
final
String
REGISTER_APP
=
"registerApp"
;
public
static
final
String
UNREGISTER_APP
=
"unregisterApp"
;
public
static
final
String
WE_CHAT_SHARE_RESPONSE
=
"onShareResponse"
;
public
static
final
String
WE_CHAT_LAUNCHMINIPROGRAM_RESPONSE
=
"onLaunchMiniProgramResponse"
;
public
static
final
String
IS_WE_CHAT_INSTALLED
=
"isWeChatInstalled"
;
...
...
@@ -19,6 +20,7 @@ public class WeChatPluginMethods {
public
static
final
String
SHARE_WEB_PAGE
=
"shareWebPage"
;
public
static
final
String
SHARE_MINI_PROGRAM
=
"shareMiniProgram"
;
public
static
final
String
LAUNCH_MINI_PROGRAM
=
"launchMiniProgram"
;
public
static
final
String
PAY
=
"payWithFluwx"
;
public
static
final
String
WE_CHAT_PAY_RESPONSE
=
"onPayResponse"
;
...
...
android/src/main/kotlin/com/jarvan/fluwx/handler/FluwxLaunchMiniProgramHandler.kt
0 → 100644
浏览文件 @
8921699b
package
com.jarvan.fluwx.handler
import
io.flutter.plugin.common.MethodCall
import
io.flutter.plugin.common.MethodChannel
import
com.tencent.mm.opensdk.modelbiz.WXLaunchMiniProgram
internal
class
FluwxLaunchMiniProgramHandler
{
fun
launchMiniProgram
(
call
:
MethodCall
,
result
:
MethodChannel
.
Result
){
val
req
=
WXLaunchMiniProgram
.
Req
()
req
.
userName
=
call
.
argument
<
String
?>(
"userName"
)
// 填小程序原始id
req
.
path
=
call
.
argument
<
String
?>(
"path"
)
//拉起小程序页面的可带参路径,不填默认拉起小程序首页
val
type
=
call
.
argument
(
"miniProgramType"
)
?:
0
req
.
miniprogramType
=
when
(
type
){
1
->
WXLaunchMiniProgram
.
Req
.
MINIPROGRAM_TYPE_TEST
2
->
WXLaunchMiniProgram
.
Req
.
MINIPROGRAM_TYPE_PREVIEW
else
->
WXLaunchMiniProgram
.
Req
.
MINIPTOGRAM_TYPE_RELEASE
}
// 可选打开 开发版,体验版和正式版
result
.
success
(
WXAPiHandler
.
wxApi
?.
sendReq
(
req
))
}
}
\ No newline at end of file
android/src/main/kotlin/com/jarvan/fluwx/handler/FluwxPayHandler.kt
浏览文件 @
8921699b
...
...
@@ -18,7 +18,6 @@ package com.jarvan.fluwx.handler
import
com.jarvan.fluwx.constant.CallResult
import
com.jarvan.fluwx.constant.WechatPluginKeys
import
com.tencent.mm.opensdk.modelpay.PayReq
import
com.tencent.mm.opensdk.openapi.WXAPIFactory
import
io.flutter.plugin.common.MethodCall
import
io.flutter.plugin.common.MethodChannel
...
...
android/src/main/kotlin/com/jarvan/fluwx/handler/FluwxResponseHandler.kt
浏览文件 @
8921699b
...
...
@@ -18,6 +18,7 @@ package com.jarvan.fluwx.handler
import
com.jarvan.fluwx.constant.WeChatPluginMethods
import
com.jarvan.fluwx.constant.WechatPluginKeys
import
com.tencent.mm.opensdk.modelbase.BaseResp
import
com.tencent.mm.opensdk.modelbiz.WXLaunchMiniProgram
import
com.tencent.mm.opensdk.modelmsg.SendAuth
import
com.tencent.mm.opensdk.modelmsg.SendMessageToWX
import
com.tencent.mm.opensdk.modelpay.PayResp
...
...
@@ -38,15 +39,28 @@ object FluwxResponseHandler {
fun
handleResponse
(
response
:
BaseResp
)
{
if
(
response
is
SendAuth
.
Resp
)
{
handleAuthResponse
(
response
)
}
else
if
(
response
is
SendMessageToWX
.
Resp
)
{
handleSendMessageResp
(
response
)
}
else
if
(
response
is
PayResp
)
{
handlePayResp
(
response
)
when
(
response
)
{
is
SendAuth
.
Resp
->
handleAuthResponse
(
response
)
is
SendMessageToWX
.
Resp
->
handleSendMessageResp
(
response
)
is
PayResp
->
handlePayResp
(
response
)
is
WXLaunchMiniProgram
.
Resp
->
handleLaunchMiniProgramResponse
(
response
)
}
}
private
fun
handleLaunchMiniProgramResponse
(
response
:
WXLaunchMiniProgram
.
Resp
)
{
val
result
=
mapOf
(
errStr
to
response
.
errStr
,
WechatPluginKeys
.
TRANSACTION
to
response
.
transaction
,
type
to
response
.
type
,
errCode
to
response
.
errCode
,
openId
to
response
.
openId
,
"extMsg"
to
response
.
extMsg
,
WechatPluginKeys
.
PLATFORM
to
WechatPluginKeys
.
ANDROID
)
channel
?.
invokeMethod
(
WeChatPluginMethods
.
WE_CHAT_LAUNCHMINIPROGRAM_RESPONSE
,
result
)
}
private
fun
handlePayResp
(
response
:
PayResp
)
{
val
result
=
mapOf
(
...
...
android/src/main/kotlin/com/jarvan/fluwx/handler/FluwxShareHandler.kt
浏览文件 @
8921699b
...
...
@@ -25,7 +25,6 @@ import io.flutter.plugin.common.MethodCall
import
io.flutter.plugin.common.MethodChannel
import
io.flutter.plugin.common.PluginRegistry
import
kotlinx.coroutines.experimental.*
import
kotlinx.coroutines.experimental.android.UI
/***
...
...
lib/src/models/wechat_response.dart
浏览文件 @
8921699b
...
...
@@ -83,12 +83,8 @@ class WeChatLaunchMiniProgramResponse {
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
;
final
String
extMsg
;
WeChatLaunchMiniProgramResponse
.
fromMap
(
Map
map
)
:
errStr
=
map
[
"errStr"
],
...
...
@@ -96,12 +92,8 @@ class WeChatLaunchMiniProgramResponse {
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"
];
androidTransaction
=
map
[
"transaction"
],
extMsg
=
map
[
"extMsg"
];
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论