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