提交 770c57c8 authored 作者: JarvanMo's avatar JarvanMo

WeChatShareMiniProgramModel now uses WXMiniProgramType

上级 47c82af2
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
......@@ -21,6 +21,7 @@ import 'models/wechat_response.dart';
import 'models/wechat_share_models.dart';
import 'wechat_type.dart';
import 'package:flutter/foundation.dart';
import 'utils/utils.dart';
StreamController<WeChatShareResponse> _responseShareController =
new StreamController.broadcast();
......@@ -133,9 +134,9 @@ Future sendAuth({ String openId,@required String scope,String state}) async {
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);
return await _channel.invokeMethod("launchMiniProgram", {"userName": username, "path": path, "miniProgramType": miniprogramtype});
return await _channel.invokeMethod("launchMiniProgram", {"userName": username, "path": path, "miniProgramType": miniProgramType});
}
......@@ -167,15 +168,3 @@ Future pay(
}
int _miniProgramTypeToInt(WXMiniProgramType type){
switch(type){
case WXMiniProgramType.PREVIEW:
return 0;
case WXMiniProgramType.TEST:
return 1;
case WXMiniProgramType.RELEASE:
return 2;
}
}
\ No newline at end of file
......@@ -16,7 +16,7 @@
import 'package:flutter/foundation.dart';
import '../wechat_type.dart';
import '../utils/utils.dart';
const String _scene = "scene";
const String _transaction = "transaction";
const String _thumbnail = "thumbnail";
......@@ -75,21 +75,15 @@ class WeChatShareTextModel extends WeChatShareModel {
///
/// [WeChatScene] is not supported here due to WeChat's limits.
/// [miniProgramTyp] only supports the following number:
/// [MINI_PROGRAM_TYPE_RELEASE]
/// [MINI_PROGRAM_TYPE_TEST]
/// [MINI_PROGRAM_TYPE_PREVIEW]
/// the default value is [MINI_PROGRAM_TYPE_RELEASE]
///
/// [hdImagePath] only works with iOS
///
class WeChatShareMiniProgramModel extends WeChatShareModel {
static const int MINI_PROGRAM_TYPE_RELEASE = 0;
static const int MINI_PROGRAM_TYPE_TEST = 1;
static const int MINI_PROGRAM_TYPE_PREVIEW = 2;
final String webPageUrl;
final int miniProgramType;
final WXMiniProgramType miniProgramType;
final String userName;
final String path;
......@@ -108,7 +102,7 @@ class WeChatShareMiniProgramModel extends WeChatShareModel {
///[hdImagePath] only works on iOS.
WeChatShareMiniProgramModel(
{@required this.webPageUrl,
int miniProgramType,
WXMiniProgramType miniProgramType,
this.userName,
this.path: "/",
this.title,
......@@ -122,11 +116,10 @@ class WeChatShareMiniProgramModel extends WeChatShareModel {
String messageAction,
String mediaTagName})
: this.transaction = transaction ?? "miniProgram",
this.miniProgramType = miniProgramType ?? MINI_PROGRAM_TYPE_RELEASE,
this.miniProgramType = miniProgramType ?? WXMiniProgramType.RELEASE,
assert(webPageUrl != null && webPageUrl.isNotEmpty),
assert(userName != null && userName.isNotEmpty),
assert(path != null && path.isNotEmpty),
assert(miniProgramType < 3 && miniProgramType > -1),
super(
mediaTagName: mediaTagName,
messageAction: messageAction,
......@@ -137,7 +130,7 @@ class WeChatShareMiniProgramModel extends WeChatShareModel {
Map toMap() {
return {
'webPageUrl': webPageUrl,
"miniProgramType": miniProgramType,
"miniProgramType": miniProgramTypeToInt(miniProgramType),
"userName": userName,
"path": path,
"title": title,
......
import '../wechat_type.dart';
int miniProgramTypeToInt(WXMiniProgramType type){
switch(type){
case WXMiniProgramType.PREVIEW:
return 2;
case WXMiniProgramType.TEST:
return 1;
case WXMiniProgramType.RELEASE:
return 0;
}
return 0;
}
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论