新增商城URL获取接口相关(预发布测试通过)
This commit is contained in:
parent
782fbfaa66
commit
63608b878b
@ -145,7 +145,7 @@ import 'mine/gateway/addGateway/selectGatewayTypeNextTip/selectGatewayTypeNextTi
|
||||
import 'mine/gateway/gatewayConnectionLock/gatewayConnectionLockList_page.dart';
|
||||
import 'mine/gateway/gatewayDetail/gatewayDetail_page.dart';
|
||||
import 'mine/gateway/gatewayList/gatewayList_page.dart';
|
||||
import 'mine/mall/mall_page.dart';
|
||||
import 'mine/mall/lockMall_page.dart';
|
||||
import 'mine/message/messageDetail/messageDetail_page.dart';
|
||||
import 'mine/message/messageList/messageList_page.dart';
|
||||
import 'mine/mine/starLockMine_page.dart';
|
||||
@ -1021,6 +1021,8 @@ abstract class AppRouters {
|
||||
GetPage(name: Routers.videoSlotPage, page: (() => const VideoSlotPage())),
|
||||
GetPage(name: Routers.liveVideoPage, page: (() => const LiveVideoPage())),
|
||||
GetPage(name: Routers.faceDetailPage, page: (() => const FaceDetailPage())),
|
||||
GetPage(name: Routers.messageDetailPage, page: (() => const MessageDetailPage())),
|
||||
GetPage(
|
||||
name: Routers.messageDetailPage,
|
||||
page: (() => const MessageDetailPage())),
|
||||
];
|
||||
}
|
||||
|
||||
43
star_lock/lib/mine/mall/lockMall_entity.dart
Normal file
43
star_lock/lib/mine/mall/lockMall_entity.dart
Normal file
@ -0,0 +1,43 @@
|
||||
class LockMallDataEntity {
|
||||
int? errorCode;
|
||||
String? description;
|
||||
String? errorMsg;
|
||||
Data? data;
|
||||
|
||||
LockMallDataEntity(
|
||||
{this.errorCode, this.description, this.errorMsg, this.data});
|
||||
|
||||
LockMallDataEntity.fromJson(Map<String, dynamic> json) {
|
||||
errorCode = json['errorCode'];
|
||||
description = json['description'];
|
||||
errorMsg = json['errorMsg'];
|
||||
data = json['data'] != null ? Data.fromJson(json['data']) : null;
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
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 Data {
|
||||
String? url;
|
||||
|
||||
Data({this.url});
|
||||
|
||||
Data.fromJson(Map<String, dynamic> json) {
|
||||
url = json['url'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = <String, dynamic>{};
|
||||
data['url'] = url;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
38
star_lock/lib/mine/mall/lockMall_logic.dart
Normal file
38
star_lock/lib/mine/mall/lockMall_logic.dart
Normal file
@ -0,0 +1,38 @@
|
||||
import 'package:star_lock/mine/mall/lockMall_entity.dart';
|
||||
import 'package:star_lock/mine/mall/lockMall_state.dart';
|
||||
import 'package:star_lock/network/api_repository.dart';
|
||||
|
||||
import '../../tools/baseGetXController.dart';
|
||||
|
||||
class LockMallLogic extends BaseGetXController {
|
||||
final LockMallState state = LockMallState();
|
||||
|
||||
//获取商城跳转地址
|
||||
Future<void> getMallURLRequest() async {
|
||||
LockMallDataEntity entity = await ApiRepository.to.getMallURLData();
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
state.lockMallUrl.value = entity.data!.url!;
|
||||
state.mallWebView.loadRequest(Uri.parse(state.lockMallUrl.value));
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> onReady() async {
|
||||
print("ready home");
|
||||
super.onReady();
|
||||
}
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
print("init home");
|
||||
super.onInit();
|
||||
|
||||
getMallURLRequest();
|
||||
}
|
||||
|
||||
@override
|
||||
void onClose() {
|
||||
print("close home");
|
||||
super.onClose();
|
||||
}
|
||||
}
|
||||
@ -1,6 +1,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/app_settings/app_colors.dart';
|
||||
import 'package:star_lock/mine/mall/lockMall_logic.dart';
|
||||
import 'package:star_lock/tools/titleAppBar.dart';
|
||||
import 'package:webview_flutter/webview_flutter.dart';
|
||||
|
||||
@ -14,21 +15,19 @@ class LockMallPage extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _LockMallPageState extends State<LockMallPage> {
|
||||
late WebViewController _webViewController;
|
||||
final logic = Get.put(LockMallLogic());
|
||||
final state = Get.find<LockMallLogic>().state;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
||||
_webViewController = WebViewController()
|
||||
..setJavaScriptMode(JavaScriptMode.unrestricted);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
// FIXME 如果未登录状态,应先跳转登录页
|
||||
// FIXME url应该使用接口获取,接口名称 “获取商城跳转地址:/mall/getUrl“ POST请求,无参数,需要登录
|
||||
String url = 'https://ge.mall.star-lock.cn/quick_login?id=4&key=1ffb9d37109b8351ebb04ccfcca02c8e';
|
||||
_webViewController.loadRequest(Uri.parse(url));
|
||||
// String url = 'https://ge.mall.star-lock.cn/quick_login?id=4&key=1ffb9d37109b8351ebb04ccfcca02c8e';
|
||||
return Scaffold(
|
||||
resizeToAvoidBottomInset: false,
|
||||
backgroundColor: const Color(0xFFFFFFFF),
|
||||
@ -37,12 +36,12 @@ class _LockMallPageState extends State<LockMallPage> {
|
||||
haveBack: true,
|
||||
backgroundColor: AppColors.mainColor,
|
||||
),
|
||||
body: WebViewWidget(controller: _webViewController));
|
||||
body: WebViewWidget(controller: state.mallWebView));
|
||||
}
|
||||
|
||||
String getWebTitle() {
|
||||
String webTitleStr = TranslationLoader.lanKeys!.shoppingCart!.tr;
|
||||
_webViewController.getTitle().then((result) {
|
||||
state.mallWebView.getTitle().then((result) {
|
||||
webTitleStr = result!;
|
||||
});
|
||||
return webTitleStr;
|
||||
8
star_lock/lib/mine/mall/lockMall_state.dart
Normal file
8
star_lock/lib/mine/mall/lockMall_state.dart
Normal file
@ -0,0 +1,8 @@
|
||||
import 'package:get/get.dart';
|
||||
import 'package:webview_flutter/webview_flutter.dart';
|
||||
|
||||
class LockMallState {
|
||||
var lockMallUrl = "".obs;
|
||||
late WebViewController mallWebView = WebViewController()
|
||||
..setJavaScriptMode(JavaScriptMode.unrestricted);
|
||||
}
|
||||
@ -1,6 +1,6 @@
|
||||
abstract class Api {
|
||||
// static String baseAddress = "https://pre.lock.star-lock.cn"; //预发布环境
|
||||
static String baseAddress = "https://dev.lock.star-lock.cn"; //联调环境
|
||||
static String baseAddress = "https://pre.lock.star-lock.cn"; //预发布环境
|
||||
// static String baseAddress = "https://dev.lock.star-lock.cn"; //联调环境
|
||||
// static String baseAddress = "http://192.168.1.15:8022"; //谢总本地
|
||||
// static String baseAddress = "https://ge.lock.star-lock.cn"; //葛工开发环境地址
|
||||
|
||||
@ -113,6 +113,7 @@ abstract class Api {
|
||||
final String updateFaceUserInfoURL = '/face/update'; // 更新人脸信息--有效期、名称
|
||||
final String deleteFaceURL = '/face/delete'; // 删除人脸
|
||||
final String clearFaceURL = '/face/clear'; // 清空人脸
|
||||
final String getMallURL = '/mall/getUrl'; // 获取商城跳转地址
|
||||
|
||||
final String getICCardListURL = '/identityCard/list'; // IC卡列表
|
||||
final String addICCardURL = '/identityCard/add'; // 添加IC卡
|
||||
|
||||
@ -1110,6 +1110,9 @@ class ApiProvider extends BaseProvider {
|
||||
'lockId': lockId,
|
||||
}));
|
||||
|
||||
// 获取商城跳转地址
|
||||
Future<Response> getMallURLData() => post(getMallURL.toUrl, jsonEncode({}));
|
||||
|
||||
// 获取IC卡列表
|
||||
Future<Response> getICCardListData(
|
||||
String lockId, String pageNo, String pageSize, String searchStr) =>
|
||||
@ -1494,20 +1497,19 @@ class ApiProvider extends BaseProvider {
|
||||
jsonEncode({"deviceId": deviceId, "deviceType": deviceType}));
|
||||
|
||||
// 消息列表
|
||||
Future<Response> messageListLoadData(String pageNo, String pageSize) =>
|
||||
post(messageListURL.toUrl,
|
||||
jsonEncode({
|
||||
'pageNo': pageNo,
|
||||
'pageSize': pageSize,
|
||||
}));
|
||||
Future<Response> messageListLoadData(String pageNo, String pageSize) => post(
|
||||
messageListURL.toUrl,
|
||||
jsonEncode({
|
||||
'pageNo': pageNo,
|
||||
'pageSize': pageSize,
|
||||
}));
|
||||
|
||||
// 读取消息
|
||||
Future<Response> readMessageLoadData(String messageId) =>
|
||||
post(readMessageURL.toUrl,
|
||||
jsonEncode({
|
||||
'id': messageId,
|
||||
}));
|
||||
|
||||
Future<Response> readMessageLoadData(String messageId) => post(
|
||||
readMessageURL.toUrl,
|
||||
jsonEncode({
|
||||
'id': messageId,
|
||||
}));
|
||||
}
|
||||
|
||||
extension ExtensionString on String {
|
||||
|
||||
@ -8,6 +8,7 @@ import 'package:star_lock/main/lockDetail/face/addFace/addFace_entity.dart';
|
||||
import 'package:star_lock/main/lockDetail/lockSet/basicInformation/basicInformation/KeyDetailEntity.dart';
|
||||
import 'package:star_lock/main/lockDetail/passwordKey/passwordKeyList/passwordKeyListEntity.dart';
|
||||
import 'package:star_lock/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKeyEntity.dart';
|
||||
import 'package:star_lock/mine/mall/lockMall_entity.dart';
|
||||
import 'package:star_lock/mine/minePersonInfo/minePersonInfoEditAccount/minePersonInfoEditAccount/mineUnbindPhoneOrEmail_entity.dart';
|
||||
import 'package:star_lock/mine/minePersonInfo/minePersonInfoPage/minePersonInfo_entity.dart';
|
||||
import 'package:star_lock/mine/minePersonInfo/minePersonInfoSetSafetyProblem/minePersonInfoSetSafetyProblem_entity.dart';
|
||||
@ -1250,6 +1251,12 @@ class ApiRepository {
|
||||
return LoginEntity.fromJson(res.body);
|
||||
}
|
||||
|
||||
// 获取商城跳转地址
|
||||
Future<LockMallDataEntity> getMallURLData() async {
|
||||
final res = await apiProvider.getMallURLData();
|
||||
return LockMallDataEntity.fromJson(res.body);
|
||||
}
|
||||
|
||||
// 获取Ic卡列表
|
||||
Future<FingerprintListDataEntity> getICCardListData({
|
||||
required String lockId,
|
||||
@ -1505,10 +1512,8 @@ class ApiRepository {
|
||||
}
|
||||
|
||||
// 消息列表
|
||||
Future<MessageListEntity> messageListLoadData({
|
||||
required String pageNo,
|
||||
required String pageSize
|
||||
}) async {
|
||||
Future<MessageListEntity> messageListLoadData(
|
||||
{required String pageNo, required String pageSize}) async {
|
||||
final res = await apiProvider.messageListLoadData(pageNo, pageSize);
|
||||
return MessageListEntity.fromJson(res.body);
|
||||
}
|
||||
@ -1520,5 +1525,4 @@ class ApiRepository {
|
||||
final res = await apiProvider.readMessageLoadData(messageId);
|
||||
return MessageListEntity.fromJson(res.body);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user