更新小e
This commit is contained in:
@@ -545,6 +545,23 @@ class THBindTelWidget extends GetView<AuthBindTelController> {
|
||||
.button_container_radius, // 统一圆角
|
||||
// 保留你原有的业务逻辑不变
|
||||
onTap: () async {
|
||||
String msg = await controller.bindTel();
|
||||
if (msg == null || msg.isEmpty) {
|
||||
MHTLoginController loginController =
|
||||
Get.find();
|
||||
//TODO 微信回调监听操作全部跳转页面前成功以后移除监听,防止重复监听,其他方式登录成功也需要移出监听
|
||||
loginController.fluwxCancelable?.cancel();
|
||||
// 登录成功移出网络检查监听
|
||||
Checknetwork.subscription?.cancel();
|
||||
final box = GetStorage();
|
||||
box.remove('countdown');
|
||||
CountdownController countdownController =
|
||||
Get.find();
|
||||
countdownController.countdown = 0.obs;
|
||||
Get.offAndToNamed("/mianPageBottomChange");
|
||||
} else {
|
||||
TopSlideNotification.show(context,text: msg!,textColor: themeController.currentColor.sc9);
|
||||
}
|
||||
ApiResponse apiResponse =
|
||||
await controller.updateUserPhone();
|
||||
|
||||
|
||||
@@ -1,16 +1,23 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:ef/ef.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:vbvs_app/common/color/appConstants.dart';
|
||||
import 'package:flutter_inappwebview/flutter_inappwebview.dart';
|
||||
import 'package:vbvs_app/common/color/app_uri_status.dart';
|
||||
import 'package:vbvs_app/common/util/FitTool.dart';
|
||||
import 'package:vbvs_app/common/util/MyUtils.dart';
|
||||
import 'package:vbvs_app/component/tool/ClickableContainer.dart';
|
||||
import 'package:vbvs_app/component/tool/TopSlideNotification.dart';
|
||||
import 'package:vbvs_app/controller/device/blueteeth_bind_controller.dart';
|
||||
import 'package:vbvs_app/controller/device/body_device_controller.dart';
|
||||
import 'package:vbvs_app/controller/device/device_type_controller.dart';
|
||||
import 'package:vbvs_app/controller/main_bottom/global_controller.dart';
|
||||
import 'package:vbvs_app/controller/theme_controller/ThemeController.dart';
|
||||
import 'package:vbvs_app/controller/user_info_controller.dart';
|
||||
import 'package:vbvs_app/enum/LoginStatus.dart';
|
||||
import 'package:vbvs_app/model/api_response.dart';
|
||||
|
||||
class EPage extends StatefulWidget {
|
||||
const EPage({super.key});
|
||||
final String sleepUri;
|
||||
const EPage({super.key, required this.sleepUri});
|
||||
|
||||
@override
|
||||
State<EPage> createState() => _EPageState();
|
||||
@@ -19,83 +26,207 @@ class EPage extends StatefulWidget {
|
||||
class _EPageState extends State<EPage> {
|
||||
GlobalController globalController = Get.find();
|
||||
UserInfoController userInfoController = Get.find();
|
||||
BlueteethBindController blueteethBindController = Get.find();
|
||||
ThemeController themeController = Get.find();
|
||||
DeviceTypeController deviceTypeController = Get.find();
|
||||
|
||||
ValueNotifier<bool> isPageLoading = ValueNotifier<bool>(true);
|
||||
RxList deviceList = [].obs;
|
||||
RxString finalUri = RxString('');
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
getDeviceList();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
isPageLoading.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
bool isLoggedIn = userInfoController.model.login == LoginStatus.LOGIN.code;
|
||||
|
||||
return LayoutBuilder(
|
||||
builder: (context, boxConstraints) => GestureDetector(
|
||||
// onTap: () => FocusScope.of(context).unfocus(),,
|
||||
builder: (context, bodySize) => GestureDetector(
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
image: DecorationImage(
|
||||
image: AssetImage('assets/img/bgNoImg.png'),
|
||||
fit: BoxFit.fill,
|
||||
),
|
||||
),
|
||||
child: Scaffold(
|
||||
backgroundColor: Colors.transparent,
|
||||
appBar: AppBar(
|
||||
backgroundColor: themeController.currentColor.sc17,
|
||||
// backgroundColor: Colors.transparent,
|
||||
automaticallyImplyLeading: false,
|
||||
iconTheme: IconThemeData(color: themeController.currentColor.sc3),
|
||||
titleSpacing: 0,
|
||||
// leading: returnIconButtom,
|
||||
title: Container(
|
||||
width: double.infinity,
|
||||
height: 180.rpx,
|
||||
child: Stack(
|
||||
alignment: Alignment.center,
|
||||
children: [
|
||||
/// 居中标题
|
||||
Text(
|
||||
'小e'.tr,
|
||||
style: TextStyle(
|
||||
fontFamily: 'Readex Pro',
|
||||
color: themeController.currentColor.sc3,
|
||||
letterSpacing: 0,
|
||||
fontSize: 30.rpx,
|
||||
),
|
||||
),
|
||||
|
||||
/// 左边返回按钮
|
||||
// Positioned(
|
||||
// left: 0,
|
||||
// child: returnIconButtom,
|
||||
// ),
|
||||
],
|
||||
),
|
||||
),
|
||||
actions: [],
|
||||
centerTitle: false,
|
||||
),
|
||||
backgroundColor: Colors.transparent,
|
||||
body: SafeArea(
|
||||
top: true,
|
||||
child: Column(children: [
|
||||
Expanded(
|
||||
child: ClickableContainer(
|
||||
backgroundColor: Colors.transparent,
|
||||
highlightColor: Colors.transparent,
|
||||
padding: EdgeInsets.all(0.rpx),
|
||||
onTap: () {
|
||||
UserInfoController userInfoController = Get.find();
|
||||
bool isLoggedIn =
|
||||
userInfoController.model.login == LoginStatus.LOGIN.code;
|
||||
if (!isLoggedIn) {
|
||||
TopSlideNotification.show(context,
|
||||
text: "必须登录提示".tr,
|
||||
textColor: themeController.currentColor.sc9);
|
||||
Get.toNamed("/otherLoginPage");
|
||||
} else {
|
||||
TopSlideNotification.show(context, text: "待开发功能".tr);
|
||||
}
|
||||
},
|
||||
child: Container(
|
||||
// child: widget.webView,
|
||||
decoration: BoxDecoration(
|
||||
image: DecorationImage(
|
||||
image: AssetImage('assets/img/xiaoe.png'), // 本地图片
|
||||
fit: BoxFit.fill, // 填满整个 Container
|
||||
child: isLoggedIn
|
||||
? _buildLoggedInContent()
|
||||
: _buildLoggedOutContent(),
|
||||
),
|
||||
),
|
||||
),
|
||||
)),
|
||||
]),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// Widget _buildLoggedInContent() {
|
||||
// return Obx(() {
|
||||
// if (finalUri.isEmpty) {
|
||||
// return Center(child: CircularProgressIndicator());
|
||||
// }
|
||||
|
||||
// return Stack(
|
||||
// children: [
|
||||
// InAppWebView(
|
||||
// initialUrlRequest: URLRequest(url: WebUri(finalUri.value)),
|
||||
// onLoadStart: (controller, url) {
|
||||
// isPageLoading.value = true;
|
||||
// },
|
||||
// onLoadStop: (controller, url) {
|
||||
// isPageLoading.value = false;
|
||||
// },
|
||||
// ),
|
||||
// ValueListenableBuilder<bool>(
|
||||
// valueListenable: isPageLoading,
|
||||
// builder: (context, isLoading, child) {
|
||||
// return isLoading
|
||||
// ? Center(child: CircularProgressIndicator())
|
||||
// : SizedBox.shrink();
|
||||
// },
|
||||
// ),
|
||||
// ],
|
||||
// );
|
||||
// });
|
||||
// }
|
||||
Widget _buildLoggedInContent() {
|
||||
return Obx(() {
|
||||
if (finalUri.isEmpty) {
|
||||
return Center(child: CircularProgressIndicator());
|
||||
}
|
||||
|
||||
// 如果设备列表为空
|
||||
if (deviceList.isEmpty) {
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
TopSlideNotification.show(
|
||||
context,
|
||||
text: "请先绑定设备".tr,
|
||||
textColor: themeController.currentColor.sc9,
|
||||
);
|
||||
},
|
||||
child: Center(
|
||||
child: Image.asset(
|
||||
"assets/img/xiaoe.png", // 可以显示默认背景
|
||||
fit: BoxFit.contain,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// 设备列表不为空,加载 WebView
|
||||
return Stack(
|
||||
children: [
|
||||
InAppWebView(
|
||||
initialUrlRequest: URLRequest(url: WebUri(finalUri.value)),
|
||||
onLoadStart: (controller, url) {
|
||||
isPageLoading.value = true;
|
||||
},
|
||||
onLoadStop: (controller, url) {
|
||||
isPageLoading.value = false;
|
||||
},
|
||||
),
|
||||
ValueListenableBuilder<bool>(
|
||||
valueListenable: isPageLoading,
|
||||
builder: (context, isLoading, child) {
|
||||
return isLoading
|
||||
? Center(child: CircularProgressIndicator())
|
||||
: SizedBox.shrink();
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
Widget _buildLoggedOutContent() {
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
TopSlideNotification.show(
|
||||
context,
|
||||
text: "必须登录提示".tr,
|
||||
textColor: themeController.currentColor.sc9,
|
||||
);
|
||||
Get.toNamed("/otherLoginPage");
|
||||
},
|
||||
child: Center(
|
||||
child: Image.asset(
|
||||
"assets/img/xiaoe.png",
|
||||
fit: BoxFit.contain,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> getDeviceList() async {
|
||||
BodyDeviceController bodyDeviceController = Get.find();
|
||||
ApiResponse apiResponse = await bodyDeviceController.getDeviceList();
|
||||
|
||||
if (apiResponse.code == HttpStatusCodes.ok) {
|
||||
List<dynamic> rawList = apiResponse.data;
|
||||
|
||||
// 提取 mac 和 person.name
|
||||
List<Map<String, dynamic>> newList = rawList.map((item) {
|
||||
String mac = item['mac'] ?? '';
|
||||
String name = (item['person'] != null &&
|
||||
item['person']['name'] != null &&
|
||||
item['person']['name'].toString().trim().isNotEmpty)
|
||||
? item['person']['name'] + "_${mac}"
|
||||
: '未命名'.tr + "_${mac}";
|
||||
return {
|
||||
'mac': mac,
|
||||
'name': name,
|
||||
};
|
||||
}).toList();
|
||||
|
||||
deviceList.value = newList;
|
||||
|
||||
// 拼接参数 person
|
||||
if (deviceList.isNotEmpty) {
|
||||
// JSON 编码整个 deviceList 对象数组
|
||||
String personParam = Uri.encodeComponent(jsonEncode(deviceList));
|
||||
finalUri.value = "${widget.sleepUri}?person=$personParam";
|
||||
} else {
|
||||
finalUri.value = widget.sleepUri;
|
||||
}
|
||||
}
|
||||
|
||||
ef.log("msg");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,7 +71,8 @@ class MainPageBottomChange extends GetView<MainPageController> {
|
||||
List arr = [
|
||||
HomePage(),
|
||||
// SleepReportPage(),
|
||||
EPage(),
|
||||
// EPage(),
|
||||
EPage(sleepUri:"https://xiaoe.he-info.cn/"),
|
||||
MessagePage(),
|
||||
MinePage(),
|
||||
];
|
||||
|
||||
@@ -309,7 +309,8 @@ class BindTelWidget extends GetView<AuthBindTelController> {
|
||||
}
|
||||
String msg =
|
||||
await controller
|
||||
.getCode(context,img);
|
||||
.getCode(
|
||||
context, img);
|
||||
if (msg.isNotEmpty) {
|
||||
return;
|
||||
}
|
||||
@@ -427,28 +428,30 @@ class BindTelWidget extends GetView<AuthBindTelController> {
|
||||
gradientDirection:
|
||||
GradientDirection.vertical,
|
||||
onTap: () async {
|
||||
// String msg = await controller.bindTel();
|
||||
// if (msg == null || msg.isEmpty) {
|
||||
// MHTLoginController loginController =
|
||||
// Get.find();
|
||||
// //TODO 微信回调监听操作全部跳转页面前成功以后移除监听,防止重复监听,其他方式登录成功也需要移出监听
|
||||
// loginController.fluwxCancelable
|
||||
// ?.cancel();
|
||||
// // 登录成功移出网络检查监听
|
||||
// Checknetwork.subscription?.cancel();
|
||||
// final box = GetStorage();
|
||||
// box.remove('countdown');
|
||||
// CountdownController
|
||||
// countdownController = Get.find();
|
||||
// countdownController.countdown = 0.obs;
|
||||
// Get.offAndToNamed(
|
||||
// "/mianPageBottomChange");
|
||||
// } else {
|
||||
// showToast(msg);
|
||||
// }
|
||||
String msg = await controller.bindTel();
|
||||
if (msg == null || msg.isEmpty) {
|
||||
MHTLoginController loginController =
|
||||
Get.find();
|
||||
//TODO 微信回调监听操作全部跳转页面前成功以后移除监听,防止重复监听,其他方式登录成功也需要移出监听
|
||||
loginController.fluwxCancelable
|
||||
?.cancel();
|
||||
// 登录成功移出网络检查监听
|
||||
Checknetwork.subscription?.cancel();
|
||||
final box = GetStorage();
|
||||
box.remove('countdown');
|
||||
CountdownController
|
||||
countdownController = Get.find();
|
||||
countdownController.countdown = 0.obs;
|
||||
Get.offAndToNamed(
|
||||
"/mianPageBottomChange");
|
||||
} else {
|
||||
TopSlideNotification.show(context,
|
||||
text: msg!,
|
||||
textColor: themeController
|
||||
.currentColor.sc9);
|
||||
}
|
||||
ApiResponse apiResponse =
|
||||
await controller.updateUserPhone();
|
||||
|
||||
if (apiResponse.code ==
|
||||
HttpStatusCodes.ok) {
|
||||
UserInfoController userInfoController =
|
||||
|
||||
@@ -55,7 +55,8 @@ var routes = {
|
||||
"/homePage": (contxt) => HomePage(),
|
||||
"/sleepReportPage": (contxt, {arguments}) =>
|
||||
SleepReportPage(sleepUri: arguments),
|
||||
"/ePage": (contxt) => EPage(),
|
||||
// "/ePage": (contxt) => EPage(),
|
||||
"/ePage": (contxt, {arguments}) => EPage(sleepUri: arguments),
|
||||
"/messagePage": (contxt) => MessagePage(),
|
||||
"/minePage": (contxt) => MinePage(),
|
||||
"/mianPageBottomChange": (contxt) => MainPageBottomChange(),
|
||||
|
||||
Reference in New Issue
Block a user