Skip to content

Commit

Permalink
fix 二维码打开小程序的qrcode参数错误问题
Browse files Browse the repository at this point in the history
  • Loading branch information
wanghualei committed Jun 19, 2024
1 parent 2c79693 commit 3761753
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,17 @@ private void qrcodeOpenApplet(Map param, ICallback callback) {
} else {
taskMode = IFinAppletRequest.TaskMode.MULTI;
}
Integer reLaunchMode = (Integer) param.get("reLaunchMode");
IFinAppletRequest.ReLaunchMode mode = IFinAppletRequest.ReLaunchMode.PARAMS_EXIST;
if (reLaunchMode == 1) {
mode = IFinAppletRequest.ReLaunchMode.ONLY_PARAMS_DIFF;
} else if (reLaunchMode == 2) {
mode = IFinAppletRequest.ReLaunchMode.ALWAYS;
} else if (reLaunchMode == 3) {
mode = IFinAppletRequest.ReLaunchMode.NEVER;
}
FinAppClient.INSTANCE.getAppletApiManager().startApplet(mContext, IFinAppletRequest.Companion.fromQrCode(qrcode)
.setProcessMode(processMode).setTaskMode(taskMode), new FinCallback<String>() {
.setProcessMode(processMode).setTaskMode(taskMode).setReLaunchMode(mode), new FinCallback<String>() {
@Override
public void onSuccess(String s) {
callback.onSuccess(new HashMap());
Expand Down
17 changes: 16 additions & 1 deletion example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ class _MyAppState extends State<MyApp> {
height: 10,
),
Container(
height: 60,
height: 100,
child: GridView.count(
crossAxisCount: 4,
childAspectRatio: 2,
Expand Down Expand Up @@ -196,6 +196,21 @@ class _MyAppState extends State<MyApp> {
_buildAppletItem(appletId, "finishAll", () {
Mop.instance.clearApplets();
}),
_buildAppletItem(appletId, "qrcodeOpen", () {
FCReLaunchMode mode = FCReLaunchMode.PARAMS_EXIST;
if (index == 1) {
mode = FCReLaunchMode.ONLY_PARAMS_DIFF;
} else if (index == 2) {
mode = FCReLaunchMode.ALWAYS;
} else if (index == 3) {
mode = FCReLaunchMode.NEVER;
}
String qrCode = 'https://api.finclip.com/api/v1/mop/runtime/applet/-f-78d53c04618315e7--';
QRCodeAppletRequest qrcodeRequest = QRCodeAppletRequest(qrCode, reLaunchMode: mode);
Mop.instance.qrcodeStartApplet(qrcodeRequest);

// Mop.instance.qrcodeOpenApplet('https://api.finclip.com/api/v1/mop/runtime/applet/-f-78d53c04618315e7--');
}),
],
),
)
Expand Down
1 change: 1 addition & 0 deletions ios/Classes/Api/MOP_qrcodeOpenApplet.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ NS_ASSUME_NONNULL_BEGIN
@interface MOP_qrcodeOpenApplet : MOPBaseApi

@property (nonatomic,copy) NSString *qrcode;
@property (nonatomic,copy) NSString *reLaunchMode;

@end

Expand Down
1 change: 1 addition & 0 deletions ios/Classes/Api/MOP_qrcodeOpenApplet.m
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ - (void)setupApiWithSuccess:(void (^)(NSDictionary<NSString *,id> * _Nonnull))su
NSLog(@"MOP_qrcodeOpenApplet:%@", self.qrcode);
FATAppletQrCodeRequest *qrcodeRequest = [[FATAppletQrCodeRequest alloc] init];
qrcodeRequest.qrCode = self.qrcode;
qrcodeRequest.reLaunchMode = [self.reLaunchMode intValue];

dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
UIViewController *currentVC = [MOPTools topViewController];
Expand Down
8 changes: 7 additions & 1 deletion lib/mop.dart
Original file line number Diff line number Diff line change
Expand Up @@ -902,7 +902,7 @@ class QRCodeAppletRequest {

Map<String, dynamic> toMap() {
return {
"apiServer": qrCode,
"qrcode": qrCode,
"animated": animated,
"isSingleProcess": isSingleProcess,
"isSingTask": isSingTask,
Expand Down Expand Up @@ -1142,6 +1142,12 @@ class Mop {
return await _channel.invokeMapMethod("qrcodeOpenApplet", params);
}

Future<Map> qrcodeStartApplet(QRCodeAppletRequest qrcodeRequest) async {
Map<String, dynamic> params = qrcodeRequest.toMap();
final Map ret = await _channel.invokeMethod("qrcodeOpenApplet", params);
return ret;
}

/// (扫码后)解密-鉴权-打开小程序
Future scanOpenApplet(String info,
{bool isSingleProcess = false, bool isSingTask = false}) async {
Expand Down

0 comments on commit 3761753

Please sign in to comment.