1,新增实名认证购买流程

2,新增实名认证获取用户余量接口对接
3,修改实名认证购买记录和使用记录逻辑及UI完善
This commit is contained in:
Daisy 2024-05-04 14:41:44 +08:00
parent 529ada69e4
commit 983dce53f6
17 changed files with 251 additions and 76 deletions

View File

@ -790,5 +790,7 @@
"固件升级完成": "Firmware upgrade completed",
"记录":"Record",
"开通高级功能后才可以对锁进行管理":"You can manage locks only after the advanced function is enabled",
"去开通":"Go and Activate"
"去开通":"Go and Activate",
"实名认证":"Real-name authentication",
"当前剩余数量":"Current surplus quantity"
}

View File

@ -817,5 +817,7 @@
"固件升级完成":"固件升级完成",
"记录":"记录",
"开通高级功能后才可以对锁进行管理":"开通高级功能后才可以对锁进行管理",
"去开通":"去开通"
"去开通":"去开通",
"实名认证":"实名认证",
"当前剩余数量":"当前剩余数量"
}

View File

@ -820,5 +820,7 @@
"文件校验失败 0x03":"文件校验失败 0x03",
"固件升级完成":"固件升级完成",
"开通高级功能后才可以对锁进行管理":"开通高级功能后才可以对锁进行管理",
"去开通":"去开通"
"去开通":"去开通",
"实名认证":"实名认证",
"当前剩余数量":"当前剩余数量"
}

View File

@ -65,7 +65,7 @@ class _WebviewShowPageState extends State<WebviewShowPage> {
onPressed: () {
Get.back();
},
icon: Icon(Icons.arrow_back_ios)),
icon: const Icon(Icons.arrow_back_ios)),
],
),
);

View File

@ -91,7 +91,8 @@ class StarLockMinePageState extends State<StarLockMinePage> with BaseWidget {
Obx(() => GestureDetector(
onTap: () {
if (state.isVip.value == null || !state.isVip.value) {
Get.toNamed(Routers.advancedFeaturesWebPage);
Get.toNamed(Routers.advancedFeaturesWebPage,
arguments: {'isShop': true});
} else {
Get.toNamed(
Routers.valueAddedServicesHighFunctionPage);

View File

@ -12,17 +12,20 @@ import 'package:star_lock/webview/webview_logic.dart';
import 'package:webview_flutter/webview_flutter.dart';
class AdvancedFeaturesWebLogic extends BaseGetXController {
late AdvancedFeaturesWebState state;
late AdvancedFeaturesWebState state = AdvancedFeaturesWebState();
AdvancedFeaturesWebLogic({required bool allowReturn})
: state = AdvancedFeaturesWebState(allowReturn: allowReturn);
// AdvancedFeaturesWebLogic({required bool allowReturn, required bool isShop})
// : state =
// AdvancedFeaturesWebState(allowReturn: allowReturn, isShop: isShop);
//
Future<void> getVipBuyURLRequest() async {
AdvancedFeaturesWebEntity entity =
await ApiRepository.to.getServicePackageBuyUrl();
if (entity.errorCode!.codeIsSuccessful) {
state.vipBuyUrl.value = entity.data!.shopList!;
state.vipBuyUrl.value = state.isShop.value == true
? entity.data!.shopList!
: entity.data!.cloudauthBuyUrl!;
state.mallWebView.setNavigationDelegate(
NavigationDelegate(
onProgress: (int progress) {

View File

@ -8,10 +8,14 @@ import 'package:webview_flutter/webview_flutter.dart';
class AdvancedFeaturesWebPage extends StatefulWidget {
AdvancedFeaturesWebPage(
{Key? key, this.showAppBar = true, this.allowReturn = true})
{Key? key,
this.showAppBar = true,
this.allowReturn = true,
this.isShop = true})
: super(key: key);
bool showAppBar;
bool allowReturn;
bool isShop;
@override
State<AdvancedFeaturesWebPage> createState() =>
@ -27,7 +31,7 @@ class _AdvancedFeaturesWebPageState extends State<AdvancedFeaturesWebPage> {
@override
Widget build(BuildContext context) {
return GetBuilder<AdvancedFeaturesWebLogic>(
init: AdvancedFeaturesWebLogic(allowReturn: widget.allowReturn),
init: AdvancedFeaturesWebLogic(),
builder: (AdvancedFeaturesWebLogic logic) {
return PopScope(
onPopInvoked: logic.canGoBack,
@ -37,7 +41,9 @@ class _AdvancedFeaturesWebPageState extends State<AdvancedFeaturesWebPage> {
backgroundColor: const Color(0xFFFFFFFF),
appBar: widget.showAppBar
? TitleAppBar(
barTitle: '高级功能',
barTitle: logic.state.isShop.value == true
? '高级功能'.tr
: '实名认证'.tr,
haveBack: true,
backgroundColor: AppColors.mainColor,
)

View File

@ -4,12 +4,13 @@ import 'package:star_lock/webview/webview_logic.dart';
import 'package:webview_flutter/webview_flutter.dart';
class AdvancedFeaturesWebState {
AdvancedFeaturesWebState({required this.allowReturn});
// AdvancedFeaturesWebState({required this.allowReturn, required this.isShop});
var vipBuyUrl = "".obs;
var webProgress = 0.0.obs;
bool allowReturn;
bool allowReturn = true;
late WebViewController mallWebView = initWebViewController();
var isShop = true.obs; //
//webView控制器
WebViewController initWebViewController() {
@ -19,4 +20,11 @@ class AdvancedFeaturesWebState {
allWebView.setUserAgent(WebViewLogic.userAgent);
return allWebView;
}
AdvancedFeaturesWebState() {
Map map = Get.arguments;
if (map['isShop'] != null) {
isShop.value = map['isShop'];
}
}
}

View File

@ -65,7 +65,8 @@ class _ValueAddedServicesPageListState
TranslationLoader.lanKeys!.advancedFunction!.tr, () async {
var isVip = await Storage.getBool(saveIsVip);
if (isVip == null || !isVip) {
Get.toNamed(Routers.advancedFeaturesWebPage);
Get.toNamed(Routers.advancedFeaturesWebPage,
arguments: {'isShop': true});
} else {
Get.toNamed(Routers.valueAddedServicesHighFunctionPage);
}

View File

@ -5,13 +5,12 @@ import 'package:star_lock/mine/valueAddedServices/valueAddedServicesRealName/fac
import 'package:star_lock/mine/valueAddedServices/valueAddedServicesRealName/value_added_services_real_name_state.dart';
import 'package:star_lock/tools/baseGetXController.dart';
import '../../../network/api_repository.dart';
import '../../../tools/eventBusEventManage.dart';
class ValueAddedServicesRealNameLogic extends BaseGetXController {
final ValueAddedServicesRealNameState state =
ValueAddedServicesRealNameState();
//
//
Future<bool> setFaceAuthentication(int faceAuthFrequence) async {
FaceAuthenticationEntity entity =
await ApiRepository.to.setFaceAuthentication(
@ -20,6 +19,24 @@ class ValueAddedServicesRealNameLogic extends BaseGetXController {
return entity.errorCode!.codeIsSuccessful;
}
//
Future<void> getServiceUserPackage() async {
var entity = await ApiRepository.to.getServiceUserPackage();
if (entity.errorCode!.codeIsSuccessful) {
state.realNameRemainCount.value = entity.data!.cloudauthCount!;
state.realNameRemainCount.refresh();
}
}
//
Future<void> getServicePackageBuyUrl() async {
var entity = await ApiRepository.to.getServicePackageBuyUrl();
if (entity.errorCode!.codeIsSuccessful) {
state.realNameBuyUrl.value = entity.data!.cloudauthBuyUrl!;
state.realNameBuyUrl.refresh();
}
}
Future<void> check(int index) async {
bool isSuccessful = await setFaceAuthentication(state.index + 1);
if (isSuccessful) {
@ -37,6 +54,8 @@ class ValueAddedServicesRealNameLogic extends BaseGetXController {
@override
void onInit() {
super.onInit();
getServiceUserPackage();
}
@override

View File

@ -19,6 +19,9 @@ class ValueAddedServicesRealNamePage extends StatefulWidget {
class _ValueAddedServicesRealNamePageState
extends State<ValueAddedServicesRealNamePage> {
final logic = Get.put(ValueAddedServicesRealNameLogic());
final state = Get.find<ValueAddedServicesRealNameLogic>().state;
@override
Widget build(BuildContext context) {
return GetBuilder<ValueAddedServicesRealNameLogic>(
@ -27,7 +30,7 @@ class _ValueAddedServicesRealNamePageState
return Scaffold(
backgroundColor: AppColors.mainBackgroundColor,
appBar: TitleAppBar(
barTitle: TranslationLoader.lanKeys!.realNameAuthentication!.tr,
barTitle: '实名认证'.tr,
haveBack: true,
backgroundColor: AppColors.mainColor),
body: Column(
@ -42,12 +45,6 @@ class _ValueAddedServicesRealNamePageState
style: TextStyle(
color: AppColors.darkGrayTextColor, fontSize: 20.sp),
)),
TextButton(
onPressed: () {
Get.toNamed(Routers.valueAddedServicesRecordPage,
arguments: UseRecordListArg.cloudauth);
},
child: Text('asdasd')),
middleWidget(),
bottomWidget()
],
@ -73,10 +70,10 @@ class _ValueAddedServicesRealNamePageState
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
"${TranslationLoader.lanKeys!.currentRemainingQuantity!.tr}:0",
style: TextStyle(fontSize: 24.sp),
)
Obx(() => Text(
"${'当前剩余数量'.tr}:${state.realNameRemainCount.value}",
style: TextStyle(fontSize: 24.sp),
))
],
),
),
@ -92,25 +89,24 @@ class _ValueAddedServicesRealNamePageState
},
child: Container(
width: 200.w,
color: Colors.transparent,
child: Center(
child: Text(TranslationLoader.lanKeys!.record!.tr,
child: Text('记录'.tr,
style: TextStyle(
color: Colors.black, fontSize: 24.sp)))),
),
GestureDetector(
onTap: () {
// Navigator.pushNamed(
// context, Routers.valueAddedServicesBuyPage,
// arguments: 3);
Get.toNamed(Routers.advancedFeaturesWebPage,
arguments: {'isShop': false});
},
child: Container(
width: 200.w,
color: Colors.transparent,
child: Center(
child: Text(TranslationLoader.lanKeys!.buy!.tr,
child: Text('购买'.tr,
style: TextStyle(
// color: AppColors.mainColor,
color: AppColors.blackColor,
color: AppColors.mainColor,
fontSize: 24.sp)))),
),
],

View File

@ -1,3 +1,7 @@
import 'package:get/get.dart';
class ValueAddedServicesRealNameState {
int index = 0;
var realNameRemainCount = 0.obs; //
var realNameBuyUrl = ''.obs; //
}

View File

@ -1,25 +1,130 @@
class BuyRecordListEntity {
BuyRecordListEntity({
this.description,
this.errorCode,
this.errorMsg,
});
BuyRecordListEntity.fromJson(dynamic json) {
description = json['description'];
errorCode = json['errorCode'];
errorMsg = json['errorMsg'];
}
String? description;
int? errorCode;
String? description;
String? errorMsg;
BuyRecordListData? data;
BuyRecordListEntity(
{this.errorCode, this.description, this.errorMsg, this.data});
BuyRecordListEntity.fromJson(Map<String, dynamic> json) {
errorCode = json['errorCode'];
description = json['description'];
errorMsg = json['errorMsg'];
data =
json['data'] != null ? BuyRecordListData.fromJson(json['data']) : null;
}
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['description'] = description;
map['errorCode'] = errorCode;
map['errorMsg'] = errorMsg;
return map;
final Map<String, dynamic> data = <String, dynamic>{};
data['errorCode'] = errorCode;
data['description'] = description;
data['errorMsg'] = errorMsg;
if (this.data != null) {
data['data'] = this.data!.toJson();
}
return data;
}
}
class BuyRecordListData {
int? pageNo;
int? pageSize;
int? total;
List<BuyRecordItem>? buyRecordlist;
BuyRecordListData(
{this.pageNo, this.pageSize, this.total, this.buyRecordlist});
BuyRecordListData.fromJson(Map<String, dynamic> json) {
pageNo = json['pageNo'];
pageSize = json['pageSize'];
total = json['total'];
if (json['list'] != null) {
buyRecordlist = <BuyRecordItem>[];
json['list'].forEach((v) {
buyRecordlist!.add(BuyRecordItem.fromJson(v));
});
}
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['pageNo'] = pageNo;
data['pageSize'] = pageSize;
data['total'] = total;
if (buyRecordlist != null) {
data['list'] = buyRecordlist!.map((v) => v.toJson()).toList();
}
return data;
}
}
class BuyRecordItem {
int? id;
int? userId;
String? orderNumber;
String? type;
int? recordType;
int? smsCount;
int? emailCount;
int? cloudauthCount;
int? vipLockCount;
int? vipYear;
int? isApply;
String? money;
String? createdAt;
String? updatedAt;
BuyRecordItem(
{this.id,
this.userId,
this.orderNumber,
this.type,
this.recordType,
this.smsCount,
this.emailCount,
this.cloudauthCount,
this.vipLockCount,
this.vipYear,
this.isApply,
this.money,
this.createdAt,
this.updatedAt});
BuyRecordItem.fromJson(Map<String, dynamic> json) {
id = json['id'];
userId = json['user_id'];
orderNumber = json['order_number'];
type = json['type'];
recordType = json['record_type'];
smsCount = json['sms_count'];
emailCount = json['email_count'];
cloudauthCount = json['cloudauth_count'];
vipLockCount = json['vip_lock_count'];
vipYear = json['vip_year'];
isApply = json['is_apply'];
money = json['money'];
createdAt = json['created_at'];
updatedAt = json['updated_at'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['id'] = id;
data['user_id'] = userId;
data['order_number'] = orderNumber;
data['type'] = type;
data['record_type'] = recordType;
data['sms_count'] = smsCount;
data['email_count'] = emailCount;
data['cloudauth_count'] = cloudauthCount;
data['vip_lock_count'] = vipLockCount;
data['vip_year'] = vipYear;
data['is_apply'] = isApply;
data['money'] = money;
data['created_at'] = createdAt;
data['updated_at'] = updatedAt;
return data;
}
}

View File

@ -1,13 +1,10 @@
import 'dart:async';
import 'package:get/get.dart';
import 'package:get/utils.dart';
import 'package:star_lock/mine/valueAddedServices/valueAddedServicesRealName/face_authentication_entity.dart';
import 'package:star_lock/mine/valueAddedServices/valueAddedServicesRecord/buy_record_list_entity.dart';
import 'package:star_lock/mine/valueAddedServices/valueAddedServicesRecord/value_added_services_record_state.dart';
import 'package:star_lock/tools/baseGetXController.dart';
import '../../../network/api_repository.dart';
import '../../../tools/eventBusEventManage.dart';
class ValueAddedServicesRecordLogic extends BaseGetXController {
ValueAddedServicesRecordLogic();
@ -27,7 +24,7 @@ class ValueAddedServicesRecordLogic extends BaseGetXController {
type = data['type'];
}
//
//
Future<void> loadBuyRecordList(bool load) async {
if (!load) {
buyPageNo = 1;
@ -37,16 +34,15 @@ class ValueAddedServicesRecordLogic extends BaseGetXController {
recordType: 10,
pageNo: buyPageNo,
);
if (entity.errorCode!.codeIsSuccessful) {}
if (entity.errorCode!.codeIsSuccessful) {
state.buyRecordList.value = entity.data!.buyRecordlist!;
}
}
@override
void onReady() {
super.onReady();
}
@override
void onClose() {
super.onClose();
loadBuyRecordList(true);
}
}

View File

@ -1,12 +1,14 @@
import 'package:easy_refresh/easy_refresh.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:star_lock/mine/valueAddedServices/valueAddedServicesRecord/value_added_services_record_logic.dart';
import 'package:star_lock/tools/noData.dart';
import '../../../app_settings/app_colors.dart';
import '../../../tools/titleAppBar.dart';
class ValueAddedServicesRecordPage extends StatefulWidget {
ValueAddedServicesRecordPage({
const ValueAddedServicesRecordPage({
Key? key,
}) : super(key: key);
@ -33,15 +35,20 @@ class _ValueAddedServicesRealNamePageState
child: Column(
children: [
TabBar(
tabs: [
Text('购买记录'.tr),
Text('使用记录'.tr),
],
tabs: [tabTextItem('购买记录'.tr), tabTextItem('使用记录'.tr)],
indicatorColor: AppColors.mainColor,
indicatorSize: TabBarIndicatorSize.label,
labelColor: AppColors.mainColor,
unselectedLabelColor: AppColors.darkGrayTextColor,
),
Expanded(
child: TabBarView(children: [
_PurchaseRecords(),
Text('使用记录'),
_PurchaseRecords(
getRecordList: logic.state.buyRecordList.value,
),
_PurchaseRecords(
getRecordList: logic.state.useRecordList.value,
),
]),
),
],
@ -52,14 +59,26 @@ class _ValueAddedServicesRealNamePageState
}
}
Widget tabTextItem(String tabText) {
return Container(
margin: EdgeInsets.only(top: 16.h, bottom: 16.h),
child: Text(
tabText,
style: TextStyle(fontSize: 24.sp),
),
);
}
//使
class _PurchaseRecords extends StatefulWidget {
const _PurchaseRecords({key});
final List getRecordList;
const _PurchaseRecords({required this.getRecordList});
@override
State<_PurchaseRecords> createState() => _PurchaseRecordsState();
}
//
class _PurchaseRecordsState extends State<_PurchaseRecords> {
@override
Widget build(BuildContext context) {
@ -68,9 +87,13 @@ class _PurchaseRecordsState extends State<_PurchaseRecords> {
return EasyRefresh(
onRefresh: () async {},
onLoad: () async {},
child: ListView.builder(itemCount: 0,itemBuilder: (BuildContext context, int index) {
return SizedBox();
}),
child: widget.getRecordList.isNotEmpty
? ListView.builder(
itemCount: widget.getRecordList.length,
itemBuilder: (BuildContext context, int index) {
return const SizedBox();
})
: NoData(),
);
});
}

View File

@ -1,3 +1,7 @@
import 'package:get/get.dart';
class ValueAddedServicesRecordState {
int index = 0;
var buyRecordList = [].obs;
var useRecordList = [].obs;
}

View File

@ -37,7 +37,8 @@ class AdvancedFunctionHandle {
style: TextStyle(color: AppColors.mainColor),
),
onPressed: () async {
Get.toNamed(Routers.advancedFeaturesWebPage);
Get.toNamed(Routers.advancedFeaturesWebPage,
arguments: {'isShop': true});
},
),
],
@ -67,7 +68,9 @@ class AdvancedFunctionHandle {
backgroundColor: AppColors.vipFeatureBtnBgColor,
),
onPressed: () {
Get.toNamed(Routers.advancedFeaturesWebPage);
Get.toNamed(Routers.advancedFeaturesWebPage, arguments: {
'isShop': true,
});
},
child: Text(
'去开通'.tr,