Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
C
clx-fluwx
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
openSourceLibrary
clx-fluwx
Commits
b1e3a51d
提交
b1e3a51d
authored
10月 26, 2018
作者:
JarvanMo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
format code
上级
a335eb8e
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
33 行增加
和
29 行删除
+33
-29
fluwx_iml.dart
lib/src/fluwx_iml.dart
+21
-12
wechat_response.dart
lib/src/models/wechat_response.dart
+0
-2
wechat_share_models.dart
lib/src/models/wechat_share_models.dart
+1
-2
utils.dart
lib/src/utils/utils.dart
+9
-11
wechat_type.dart
lib/src/wechat_type.dart
+2
-2
没有找到文件。
lib/src/fluwx_iml.dart
浏览文件 @
b1e3a51d
...
@@ -23,7 +23,6 @@ import 'wechat_type.dart';
...
@@ -23,7 +23,6 @@ import 'wechat_type.dart';
import
'package:flutter/foundation.dart'
;
import
'package:flutter/foundation.dart'
;
import
'utils/utils.dart'
;
import
'utils/utils.dart'
;
StreamController
<
WeChatShareResponse
>
_responseShareController
=
StreamController
<
WeChatShareResponse
>
_responseShareController
=
new
StreamController
.
broadcast
();
new
StreamController
.
broadcast
();
...
@@ -42,10 +41,11 @@ StreamController<WeChatPaymentResponse> _responsePaymentController =
...
@@ -42,10 +41,11 @@ StreamController<WeChatPaymentResponse> _responsePaymentController =
Stream
<
WeChatPaymentResponse
>
get
responseFromPayment
=>
Stream
<
WeChatPaymentResponse
>
get
responseFromPayment
=>
_responsePaymentController
.
stream
;
_responsePaymentController
.
stream
;
Stream
<
WeChatLaunchMiniProgramResponse
>
get
responseFromLaunchMiniProgram
=>
_responseLaunchMiniProgramController
.
stream
;
Stream
<
WeChatLaunchMiniProgramResponse
>
get
responseFromLaunchMiniProgram
=>
_responseLaunchMiniProgramController
.
stream
;
StreamController
<
WeChatLaunchMiniProgramResponse
>
_responseLaunchMiniProgramController
=
StreamController
<
WeChatLaunchMiniProgramResponse
>
new
StreamController
.
broadcast
();
_responseLaunchMiniProgramController
=
new
StreamController
.
broadcast
();
final
MethodChannel
_channel
=
const
MethodChannel
(
'com.jarvanmo/fluwx'
)
final
MethodChannel
_channel
=
const
MethodChannel
(
'com.jarvanmo/fluwx'
)
..
setMethodCallHandler
(
_handler
);
..
setMethodCallHandler
(
_handler
);
...
@@ -94,7 +94,11 @@ Future register(
...
@@ -94,7 +94,11 @@ Future register(
}
}
///we don't need the response any longer if params are true.
///we don't need the response any longer if params are true.
void
dispose
(
{
shareResponse:
true
,
authResponse:
true
,
paymentResponse:
true
,
launchMiniProgramResponse:
true
})
{
void
dispose
(
{
shareResponse:
true
,
authResponse:
true
,
paymentResponse:
true
,
launchMiniProgramResponse:
true
})
{
if
(
shareResponse
)
{
if
(
shareResponse
)
{
_responseShareController
.
close
();
_responseShareController
.
close
();
}
}
...
@@ -130,19 +134,26 @@ Future share(WeChatShareModel model) async {
...
@@ -130,19 +134,26 @@ Future share(WeChatShareModel model) async {
}
}
}
}
Future
sendAuth
(
{
String
openId
,
@required
String
scope
,
String
state
})
async
{
Future
sendAuth
(
{
String
openId
,
@required
String
scope
,
String
state
})
async
{
// "scope": scope, "state": state, "openId": openId
// "scope": scope, "state": state, "openId": openId
assert
(
scope
!=
null
&&
scope
.
trim
().
isNotEmpty
);
assert
(
scope
!=
null
&&
scope
.
trim
().
isNotEmpty
);
return
await
_channel
.
invokeMethod
(
"sendAuth"
,
{
"scope"
:
scope
,
"state"
:
state
,
"openId"
:
openId
});
return
await
_channel
.
invokeMethod
(
"sendAuth"
,
{
"scope"
:
scope
,
"state"
:
state
,
"openId"
:
openId
});
}
}
Future
launchMiniProgram
(
{
@required
String
username
,
String
path
,
WXMiniProgramType
miniProgramType
=
WXMiniProgramType
.
RELEASE
})
async
{
Future
launchMiniProgram
(
{
@required
String
username
,
String
path
,
WXMiniProgramType
miniProgramType
=
WXMiniProgramType
.
RELEASE
})
async
{
assert
(
username
!=
null
&&
username
.
trim
().
isNotEmpty
);
assert
(
username
!=
null
&&
username
.
trim
().
isNotEmpty
);
return
await
_channel
.
invokeMethod
(
"launchMiniProgram"
,
{
"userName"
:
username
,
"path"
:
path
,
"miniProgramType"
:
miniProgramTypeToInt
(
miniProgramType
)});
return
await
_channel
.
invokeMethod
(
"launchMiniProgram"
,
{
"userName"
:
username
,
"path"
:
path
,
"miniProgramType"
:
miniProgramTypeToInt
(
miniProgramType
)
});
}
}
Future
isWeChatInstalled
(
)
async
{
Future
isWeChatInstalled
(
)
async
{
return
await
_channel
.
invokeMethod
(
"isWeChatInstalled"
);
return
await
_channel
.
invokeMethod
(
"isWeChatInstalled"
);
}
}
...
@@ -169,5 +180,3 @@ Future pay(
...
@@ -169,5 +180,3 @@ Future pay(
"extData"
:
extData
,
"extData"
:
extData
,
});
});
}
}
lib/src/models/wechat_response.dart
浏览文件 @
b1e3a51d
...
@@ -76,7 +76,6 @@ class WeChatAuthResponse {
...
@@ -76,7 +76,6 @@ class WeChatAuthResponse {
androidTransaction
=
map
[
"transaction"
];
androidTransaction
=
map
[
"transaction"
];
}
}
class
WeChatLaunchMiniProgramResponse
{
class
WeChatLaunchMiniProgramResponse
{
final
String
errStr
;
final
String
errStr
;
final
int
type
;
final
int
type
;
...
@@ -96,7 +95,6 @@ class WeChatLaunchMiniProgramResponse {
...
@@ -96,7 +95,6 @@ class WeChatLaunchMiniProgramResponse {
extMsg
=
map
[
"extMsg"
];
extMsg
=
map
[
"extMsg"
];
}
}
class
WeChatPaymentResponse
{
class
WeChatPaymentResponse
{
final
String
errStr
;
final
String
errStr
;
final
int
type
;
final
int
type
;
...
...
lib/src/models/wechat_share_models.dart
浏览文件 @
b1e3a51d
...
@@ -17,6 +17,7 @@ import 'package:flutter/foundation.dart';
...
@@ -17,6 +17,7 @@ import 'package:flutter/foundation.dart';
import
'../wechat_type.dart'
;
import
'../wechat_type.dart'
;
import
'../utils/utils.dart'
;
import
'../utils/utils.dart'
;
const
String
_scene
=
"scene"
;
const
String
_scene
=
"scene"
;
const
String
_transaction
=
"transaction"
;
const
String
_transaction
=
"transaction"
;
const
String
_thumbnail
=
"thumbnail"
;
const
String
_thumbnail
=
"thumbnail"
;
...
@@ -80,8 +81,6 @@ class WeChatShareTextModel extends WeChatShareModel {
...
@@ -80,8 +81,6 @@ class WeChatShareTextModel extends WeChatShareModel {
/// [hdImagePath] only works with iOS
/// [hdImagePath] only works with iOS
///
///
class
WeChatShareMiniProgramModel
extends
WeChatShareModel
{
class
WeChatShareMiniProgramModel
extends
WeChatShareModel
{
final
String
webPageUrl
;
final
String
webPageUrl
;
final
WXMiniProgramType
miniProgramType
;
final
WXMiniProgramType
miniProgramType
;
final
String
userName
;
final
String
userName
;
...
...
lib/src/utils/utils.dart
浏览文件 @
b1e3a51d
import
'../wechat_type.dart'
;
import
'../wechat_type.dart'
;
int
miniProgramTypeToInt
(
WXMiniProgramType
type
){
int
miniProgramTypeToInt
(
WXMiniProgramType
type
)
{
switch
(
type
)
{
switch
(
type
)
{
case
WXMiniProgramType
.
PREVIEW
:
case
WXMiniProgramType
.
PREVIEW
:
return
2
;
return
2
;
case
WXMiniProgramType
.
TEST
:
case
WXMiniProgramType
.
TEST
:
return
1
;
return
1
;
case
WXMiniProgramType
.
RELEASE
:
case
WXMiniProgramType
.
RELEASE
:
return
0
;
return
0
;
}
}
return
0
;
return
0
;
}
}
\ No newline at end of file
lib/src/wechat_type.dart
浏览文件 @
b1e3a51d
...
@@ -13,6 +13,7 @@
...
@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* See the License for the specific language governing permissions and
* limitations under the License.
* limitations under the License.
*/
*/
///[WXMiniProgramType.RELEASE]正式版
///[WXMiniProgramType.RELEASE]正式版
///[WXMiniProgramType.TEST]测试版
///[WXMiniProgramType.TEST]测试版
///[WXMiniProgramType.PREVIEW]预览版
///[WXMiniProgramType.PREVIEW]预览版
...
@@ -21,4 +22,4 @@ enum WXMiniProgramType { RELEASE, TEST, PREVIEW }
...
@@ -21,4 +22,4 @@ enum WXMiniProgramType { RELEASE, TEST, PREVIEW }
///[WeChatScene.SESSION]会话
///[WeChatScene.SESSION]会话
///[WeChatScene.TIMELINE]朋友圈
///[WeChatScene.TIMELINE]朋友圈
///[WeChatScene.FAVORITE]收藏
///[WeChatScene.FAVORITE]收藏
enum
WeChatScene
{
SESSION
,
TIMELINE
,
FAVORITE
}
enum
WeChatScene
{
SESSION
,
TIMELINE
,
FAVORITE
}
\ No newline at end of file
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论