|
|
@@ -1,4 +1,5 @@
|
|
|
import 'dart:async';
|
|
|
+import 'dart:io';
|
|
|
|
|
|
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
|
|
import 'package:injectable/injectable.dart';
|
|
|
@@ -11,6 +12,7 @@ import '../../../data/repository/store_repository.dart';
|
|
|
import '../../../utils/async_util.dart';
|
|
|
import '../../../utils/error_handler.dart';
|
|
|
import 'package:keyboard/utils/atmob_log.dart';
|
|
|
+
|
|
|
// 这里控制两个弹窗的数据
|
|
|
@injectable
|
|
|
class GoodsSurpriseController extends BaseController {
|
|
|
@@ -19,6 +21,7 @@ class GoodsSurpriseController extends BaseController {
|
|
|
final RxInt timeLeft = countdownTime.obs; // 剩余时间(10ms 为单位)
|
|
|
Timer? _timer;
|
|
|
final StoreRepository storeRepository;
|
|
|
+
|
|
|
// 华为不展示
|
|
|
|
|
|
CancelableFuture? _storeDataFuture;
|
|
|
@@ -46,17 +49,24 @@ class GoodsSurpriseController extends BaseController {
|
|
|
return;
|
|
|
}
|
|
|
if (goodsInfoList.length < 2) {
|
|
|
-
|
|
|
- AtmobLog.e(tag,"商品列表少于2个,无法处理");
|
|
|
+ AtmobLog.e(tag, "商品列表少于2个,无法处理");
|
|
|
return;
|
|
|
}
|
|
|
- // 第一个直接拿第一个
|
|
|
- _firstAmount.value = goodsInfoList.first;
|
|
|
- // 第二个找一个 code 不一样的
|
|
|
- _secondAmount.value = goodsInfoList.firstWhereOrNull(
|
|
|
- (item) => item.code != _firstAmount.value?.code,
|
|
|
- );
|
|
|
-
|
|
|
+ if (Platform.isAndroid) {
|
|
|
+ // 第一个直接拿第一个
|
|
|
+ _firstAmount.value = goodsInfoList.first;
|
|
|
+ // 第二个找一个 code 不一样的
|
|
|
+ _secondAmount.value = goodsInfoList.firstWhereOrNull(
|
|
|
+ (item) => item.code != _firstAmount.value?.code,
|
|
|
+ );
|
|
|
+ } else if (Platform.isIOS) {
|
|
|
+ // iOS 直接拿第二个
|
|
|
+ _secondAmount.value = goodsInfoList.first;
|
|
|
+ // 第二个找一个 code 不一样的
|
|
|
+ _firstAmount.value = goodsInfoList.firstWhereOrNull(
|
|
|
+ (item) => item.code != _secondAmount.value?.code,
|
|
|
+ );
|
|
|
+ }
|
|
|
// 打印
|
|
|
print('qqq firstAmount: ${_firstAmount.value?.toJson()}');
|
|
|
print('qqq secondAmount: ${_secondAmount.value?.toJson()}');
|
|
|
@@ -65,7 +75,6 @@ class GoodsSurpriseController extends BaseController {
|
|
|
_secondAmount.value = goodsInfoList[1];
|
|
|
}
|
|
|
|
|
|
-
|
|
|
super.onInit();
|
|
|
}
|
|
|
|