1,新增实名认证弹出框及购买
2,新增购买增值服务相关网页回退机制
This commit is contained in:
parent
983dce53f6
commit
fb403df092
@ -792,5 +792,7 @@
|
||||
"开通高级功能后才可以对锁进行管理":"You can manage locks only after the advanced function is enabled",
|
||||
"去开通":"Go and Activate",
|
||||
"实名认证":"Real-name authentication",
|
||||
"当前剩余数量":"Current surplus quantity"
|
||||
"当前剩余数量":"Current surplus quantity",
|
||||
"购买":"Buy",
|
||||
"实名认证为付费功能,请购买后再使用":"Real-name authentication is a paid function, please use it after purchase"
|
||||
}
|
||||
|
||||
@ -819,5 +819,7 @@
|
||||
"开通高级功能后才可以对锁进行管理":"开通高级功能后才可以对锁进行管理",
|
||||
"去开通":"去开通",
|
||||
"实名认证":"实名认证",
|
||||
"当前剩余数量":"当前剩余数量"
|
||||
"当前剩余数量":"当前剩余数量",
|
||||
"购买":"购买",
|
||||
"实名认证为付费功能,请购买后再使用":"实名认证为付费功能,请购买后再使用"
|
||||
}
|
||||
|
||||
@ -822,5 +822,7 @@
|
||||
"开通高级功能后才可以对锁进行管理":"开通高级功能后才可以对锁进行管理",
|
||||
"去开通":"去开通",
|
||||
"实名认证":"实名认证",
|
||||
"当前剩余数量":"当前剩余数量"
|
||||
"当前剩余数量":"当前剩余数量",
|
||||
"购买":"购买",
|
||||
"实名认证为付费功能,请购买后再使用":"实名认证为付费功能,请购买后再使用"
|
||||
}
|
||||
|
||||
@ -1071,7 +1071,7 @@ abstract class AppRouters {
|
||||
GetPage(name: Routers.addPalmPage, page: (() => const AddPalmPage())),
|
||||
GetPage(
|
||||
name: Routers.advancedFeaturesWebPage,
|
||||
page: (() => AdvancedFeaturesWebPage())),
|
||||
page: (() => const AdvancedFeaturesWebPage())),
|
||||
GetPage(
|
||||
name: Routers.advancedFunctionRecordPage,
|
||||
page: (() => const AdvancedFunctionRecordPage())),
|
||||
|
||||
@ -215,8 +215,8 @@ class _SendElectronicKeyPageState extends State<SendElectronicKeyPage>
|
||||
rightTitle: state.timeLimitEndTime.value,
|
||||
isHaveDirection: true,
|
||||
action: () {
|
||||
PDuration selectDate =
|
||||
PDuration.parse(DateTime.tryParse(state.timeLimitEndTime.value));
|
||||
PDuration selectDate = PDuration.parse(
|
||||
DateTime.tryParse(state.timeLimitEndTime.value));
|
||||
Pickers.showDatePicker(context,
|
||||
selectDate: selectDate, mode: DateMode.YMDHM, onConfirm: (p) {
|
||||
state.timeLimitEndTime.value =
|
||||
@ -233,19 +233,17 @@ class _SendElectronicKeyPageState extends State<SendElectronicKeyPage>
|
||||
return Column(
|
||||
children: [
|
||||
CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.realNameAuthentication!.tr,
|
||||
rightTitle: "",
|
||||
isTipsImg: true,
|
||||
tipsImgAction: () {
|
||||
ShowTipView().showSureAlertDialog(
|
||||
"人脸实名认证指的是用户在使用手机APP开锁时,需要先进行本人人脸验证,验证通过才能开锁。".tr);
|
||||
},
|
||||
isHaveRightWidget: true,
|
||||
rightWidget: SizedBox(
|
||||
width: 60.w, height: 50.h, child: _remoteSwitch(false)),
|
||||
action: () {
|
||||
// Toast.show(msg: '此功能暂未开放');
|
||||
}),
|
||||
leftTitel: TranslationLoader.lanKeys!.realNameAuthentication!.tr,
|
||||
rightTitle: "",
|
||||
isTipsImg: true,
|
||||
tipsImgAction: () {
|
||||
ShowTipView().showSureAlertDialog(
|
||||
"人脸实名认证指的是用户在使用手机APP开锁时,需要先进行本人人脸验证,验证通过才能开锁。".tr);
|
||||
},
|
||||
isHaveRightWidget: true,
|
||||
rightWidget:
|
||||
SizedBox(width: 60.w, height: 50.h, child: _remoteSwitch(false)),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
@ -609,6 +607,14 @@ class _SendElectronicKeyPageState extends State<SendElectronicKeyPage>
|
||||
state.isRemoteUnlock.value = !state.isRemoteUnlock.value;
|
||||
} else {
|
||||
state.isAuthentication.value = !state.isAuthentication.value;
|
||||
if (state.isAuthentication.value) {
|
||||
ShowTipView().showBuyTipWithContentAlert(
|
||||
titleStr: '实名认证为付费功能,请购买后再使用'.tr,
|
||||
sureClick: () {
|
||||
Get.toNamed(Routers.advancedFeaturesWebPage,
|
||||
arguments: {'isShop': false});
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
@ -1,8 +1,10 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:fluwx/fluwx.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/app_settings/app_settings.dart';
|
||||
import 'package:star_lock/flavors.dart';
|
||||
import 'package:star_lock/mine/valueAddedServices/advancedFeaturesWeb/advancedFeaturesWeb_entity.dart';
|
||||
import 'package:star_lock/mine/valueAddedServices/advancedFeaturesWeb/advancedFeaturesWeb_state.dart';
|
||||
import 'package:star_lock/network/api_repository.dart';
|
||||
@ -14,11 +16,9 @@ import 'package:webview_flutter/webview_flutter.dart';
|
||||
class AdvancedFeaturesWebLogic extends BaseGetXController {
|
||||
late AdvancedFeaturesWebState state = AdvancedFeaturesWebState();
|
||||
|
||||
// AdvancedFeaturesWebLogic({required bool allowReturn, required bool isShop})
|
||||
// : state =
|
||||
// AdvancedFeaturesWebState(allowReturn: allowReturn, isShop: isShop);
|
||||
DateTime? _lastPressedAt; // 记录上一次按下返回键的时间
|
||||
|
||||
//获取商城跳转地址
|
||||
//获取购买跳转地址
|
||||
Future<void> getVipBuyURLRequest() async {
|
||||
AdvancedFeaturesWebEntity entity =
|
||||
await ApiRepository.to.getServicePackageBuyUrl();
|
||||
@ -26,7 +26,7 @@ class AdvancedFeaturesWebLogic extends BaseGetXController {
|
||||
state.vipBuyUrl.value = state.isShop.value == true
|
||||
? entity.data!.shopList!
|
||||
: entity.data!.cloudauthBuyUrl!;
|
||||
state.mallWebView.setNavigationDelegate(
|
||||
state.vipBuyWebView.setNavigationDelegate(
|
||||
NavigationDelegate(
|
||||
onProgress: (int progress) {
|
||||
// Update loading bar.
|
||||
@ -49,15 +49,13 @@ class AdvancedFeaturesWebLogic extends BaseGetXController {
|
||||
},
|
||||
),
|
||||
);
|
||||
state.mallWebView.loadRequest(Uri.parse(state.vipBuyUrl.value));
|
||||
// FlutterBridge.postMessage({action:'',data:'{}',callFun:'回调给js的方法'})
|
||||
state.mallWebView.addJavaScriptChannel(
|
||||
state.vipBuyWebView.loadRequest(Uri.parse(state.vipBuyUrl.value));
|
||||
state.vipBuyWebView.addJavaScriptChannel(
|
||||
"FlutterBridge",
|
||||
onMessageReceived: (JavaScriptMessage message) async {
|
||||
flutterBridge(message);
|
||||
},
|
||||
);
|
||||
// onMessageReceived
|
||||
}
|
||||
}
|
||||
|
||||
@ -89,7 +87,7 @@ class AdvancedFeaturesWebLogic extends BaseGetXController {
|
||||
'errCode': response.errCode,
|
||||
'errStr': response.errStr,
|
||||
};
|
||||
state.mallWebView.runJavaScript(
|
||||
state.vipBuyWebView.runJavaScript(
|
||||
'window.$callFun(`${json.encode(data)}`)',
|
||||
);
|
||||
}
|
||||
@ -98,15 +96,39 @@ class AdvancedFeaturesWebLogic extends BaseGetXController {
|
||||
|
||||
//判断webview 是否可以有路由可以回退,无则退出当前页面
|
||||
Future<bool> canGoBack(bool didPop) async {
|
||||
bool canGoBack = await state.mallWebView.canGoBack();
|
||||
bool canGoBack = await state.vipBuyWebView.canGoBack();
|
||||
if (canGoBack) {
|
||||
await state.mallWebView.goBack();
|
||||
await state.vipBuyWebView.goBack();
|
||||
} else if (state.allowReturn) {
|
||||
Get.back();
|
||||
} else {
|
||||
if (state.allowReturn) Get.back();
|
||||
if (_lastPressedAt == null ||
|
||||
DateTime.now().difference(_lastPressedAt!) >
|
||||
const Duration(seconds: 2)) {
|
||||
// 如果两次返回键时间间隔大于 2 秒,则提示再次按下返回键退出
|
||||
_lastPressedAt = DateTime.now();
|
||||
showToast('再返回一次退出${F.title}');
|
||||
return false;
|
||||
}
|
||||
SystemNavigator.pop();
|
||||
return true;
|
||||
}
|
||||
refreshGoBack();
|
||||
return false;
|
||||
}
|
||||
|
||||
//刷新当前路由状态
|
||||
void refreshGoBack() {
|
||||
//如果属于一直返回按钮,则根据是否有路由可以回退刷新
|
||||
if (state.allowReturn) {
|
||||
return;
|
||||
}
|
||||
state.vipBuyWebView.canGoBack().then((value) {
|
||||
state.canGoBack = value;
|
||||
update();
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> onReady() async {
|
||||
super.onReady();
|
||||
@ -117,9 +139,4 @@ class AdvancedFeaturesWebLogic extends BaseGetXController {
|
||||
super.onInit();
|
||||
getVipBuyURLRequest();
|
||||
}
|
||||
|
||||
@override
|
||||
void onClose() {
|
||||
super.onClose();
|
||||
}
|
||||
}
|
||||
|
||||
@ -7,15 +7,7 @@ import 'package:star_lock/tools/titleAppBar.dart';
|
||||
import 'package:webview_flutter/webview_flutter.dart';
|
||||
|
||||
class AdvancedFeaturesWebPage extends StatefulWidget {
|
||||
AdvancedFeaturesWebPage(
|
||||
{Key? key,
|
||||
this.showAppBar = true,
|
||||
this.allowReturn = true,
|
||||
this.isShop = true})
|
||||
: super(key: key);
|
||||
bool showAppBar;
|
||||
bool allowReturn;
|
||||
bool isShop;
|
||||
const AdvancedFeaturesWebPage({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<AdvancedFeaturesWebPage> createState() =>
|
||||
@ -39,17 +31,20 @@ class _AdvancedFeaturesWebPageState extends State<AdvancedFeaturesWebPage> {
|
||||
child: Scaffold(
|
||||
resizeToAvoidBottomInset: false,
|
||||
backgroundColor: const Color(0xFFFFFFFF),
|
||||
appBar: widget.showAppBar
|
||||
? TitleAppBar(
|
||||
barTitle: logic.state.isShop.value == true
|
||||
? '高级功能'.tr
|
||||
: '实名认证'.tr,
|
||||
haveBack: true,
|
||||
backgroundColor: AppColors.mainColor,
|
||||
)
|
||||
: null,
|
||||
appBar: TitleAppBar(
|
||||
barTitle:
|
||||
logic.state.isShop.value == true ? '高级功能'.tr : '实名认证'.tr,
|
||||
haveBack: true,
|
||||
backgroundColor: AppColors.mainColor,
|
||||
backAction: () => logic.canGoBack(false),
|
||||
),
|
||||
body: Obx(() => Column(
|
||||
children: <Widget>[
|
||||
PopScope(
|
||||
onPopInvoked: logic.canGoBack,
|
||||
canPop: false,
|
||||
child: const SizedBox(),
|
||||
),
|
||||
Container(
|
||||
padding: EdgeInsets.only(bottom: 10.w),
|
||||
child: LinearProgressIndicator(
|
||||
@ -61,7 +56,7 @@ class _AdvancedFeaturesWebPageState extends State<AdvancedFeaturesWebPage> {
|
||||
),
|
||||
Expanded(
|
||||
child: WebViewWidget(
|
||||
controller: logic.state.mallWebView),
|
||||
controller: logic.state.vipBuyWebView),
|
||||
),
|
||||
],
|
||||
))),
|
||||
|
||||
@ -4,13 +4,12 @@ import 'package:star_lock/webview/webview_logic.dart';
|
||||
import 'package:webview_flutter/webview_flutter.dart';
|
||||
|
||||
class AdvancedFeaturesWebState {
|
||||
// AdvancedFeaturesWebState({required this.allowReturn, required this.isShop});
|
||||
|
||||
var vipBuyUrl = "".obs;
|
||||
var vipBuyUrl = "".obs; //购买跳转地址
|
||||
var webProgress = 0.0.obs;
|
||||
bool allowReturn = true;
|
||||
late WebViewController mallWebView = initWebViewController();
|
||||
late WebViewController vipBuyWebView = initWebViewController();
|
||||
var isShop = true.obs; //是否为高级功能购买页面
|
||||
bool canGoBack = false;
|
||||
|
||||
//初始化webView控制器
|
||||
WebViewController initWebViewController() {
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
||||
@ -11,7 +10,6 @@ import 'showDeleteAdministratorIsHaveAllDataWidget.dart';
|
||||
typedef BlockIsHaveAllDataCallback = void Function(bool isAllData);
|
||||
|
||||
class ShowTipView {
|
||||
|
||||
// 只有一个确定按钮
|
||||
void showSureAlertDialog(String contentStr) {
|
||||
showCupertinoDialog(
|
||||
@ -33,7 +31,8 @@ class ShowTipView {
|
||||
}
|
||||
|
||||
// 授权管理员调用是否删除数据
|
||||
void showDeleteAdministratorIsHaveAllDataDialog(String contentStr, BlockIsHaveAllDataCallback blockIsHaveAllDataCallback) {
|
||||
void showDeleteAdministratorIsHaveAllDataDialog(String contentStr,
|
||||
BlockIsHaveAllDataCallback blockIsHaveAllDataCallback) {
|
||||
bool selet = false;
|
||||
showDialog(
|
||||
context: Get.context!,
|
||||
@ -44,7 +43,7 @@ class ShowTipView {
|
||||
// height: 100.h,
|
||||
child: ShowDeleteAdministratorIsHaveAllDataWidget(
|
||||
contentStr: contentStr,
|
||||
blockIsHaveAllDataCallback: (a){
|
||||
blockIsHaveAllDataCallback: (a) {
|
||||
selet = a;
|
||||
},
|
||||
),
|
||||
@ -96,14 +95,15 @@ class ShowTipView {
|
||||
);
|
||||
}
|
||||
|
||||
void showTFViewAlertDialog(TextEditingController controller, String title, String tipTitle, Function sureClick) {
|
||||
void showTFViewAlertDialog(TextEditingController controller, String title,
|
||||
String tipTitle, Function sureClick) {
|
||||
// 点击删除 开始扫描
|
||||
showDialog(
|
||||
context: Get.context!,
|
||||
builder: (BuildContext context) {
|
||||
return ShowTFView(
|
||||
title: title,
|
||||
tipTitle: tipTitle??"",
|
||||
tipTitle: tipTitle ?? "",
|
||||
controller: controller,
|
||||
sureClick: () {
|
||||
//发送删除锁请求
|
||||
@ -122,4 +122,31 @@ class ShowTipView {
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
// 购买按钮
|
||||
void showBuyTipWithContentAlert(
|
||||
{required String titleStr, required Function sureClick}) {
|
||||
showCupertinoDialog(
|
||||
context: Get.context!,
|
||||
builder: (context) {
|
||||
return CupertinoAlertDialog(
|
||||
title: Text(titleStr),
|
||||
actions: [
|
||||
CupertinoDialogAction(
|
||||
child: Text(TranslationLoader.lanKeys!.cancel!.tr),
|
||||
onPressed: () {
|
||||
Get.back();
|
||||
},
|
||||
),
|
||||
CupertinoDialogAction(
|
||||
child: Text('购买'.tr),
|
||||
onPressed: () {
|
||||
Get.back();
|
||||
sureClick();
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user