完善工作台

This commit is contained in:
2023-12-24 02:10:55 +08:00
parent d444a4c838
commit 55085ee563
11 changed files with 684 additions and 113 deletions

View File

@@ -1,7 +1,8 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<manifest xmlns:tools="http://schemas.android.com/tools"
xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.INTERNET"/>
<application
android:label="捷兑通-商家"
android:label="捷兑通-商家"
android:name="${applicationName}"
android:icon="@mipmap/ic_launcher">
<activity
@@ -11,7 +12,8 @@
android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">
android:windowSoftInputMode="adjustResize"
tools:targetApi="honeycomb">
<!-- Specifies an Android theme to apply to this Activity as soon as
the Android process has started. This theme is visible to the user
while the Flutter UI initializes. After that, this theme continues

View File

@@ -13,7 +13,7 @@
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>flutter_jdt_store</string>
<string>捷兑通-商家版</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>

View File

@@ -4,11 +4,16 @@ import 'package:flutter/services.dart';
import './utils/utils.dart';
class Global {
static String appName = "Flutter Demo";
static const String appName = "捷兑通-商家版";
// 是否 release
static bool get isRelease => const bool.fromEnvironment("dart.vm.product");
static final baseUrl = isRelease
? "https://www.wanzhuanyongcheng.cn/app"
: "https://test.wanzhuanyongcheng.cn/app";
static String tokenKey = "token";
static String firstOpenKey = "device_first_open";

View File

@@ -11,6 +11,7 @@ import 'utils/utils.dart';
import 'initial_binding.dart';
Future<void> main() async {
// debugPrint(const String.fromEnvironment('APP_ENV', defaultValue: 'dev'));
await Global.init();
// 强制竖屏
StatusBarKit.setPortrait().then((_) {
@@ -32,9 +33,10 @@ class MainApp extends StatelessWidget {
final botToastBuilder = BotToastInit();
return GetMaterialApp(
title: Global.appName,
debugShowCheckedModeBanner: false,
// 日志
enableLog: true,
enableLog: !Global.isRelease,
logWriterCallback: Logger.write,
defaultTransition: Transition.cupertino,
// 路由

View File

@@ -5,6 +5,56 @@ import 'home_state.dart';
class HomeLogic extends GetxController {
final HomeState state = HomeState();
final List<Map<String, String>> list = [
{
"title": "今日成交额",
"value": "100000",
},
{
"title": "昨日成交额",
"value": "2000",
},
{
"title": "本月成交额",
"value": "10000",
},
{
"title": "今日订单数",
"value": "100",
},
{
"title": "昨日订单数",
"value": "200",
},
{
"title": "本月订单数",
"value": "5000",
},
];
final List<Map<String, String>> list2 = [
{
"title": "全部",
"value": "2000",
},
{
"title": "待付款",
"value": "10",
},
{
"title": "待核销",
"value": "200",
},
{
"title": "已核销",
"value": "2000",
},
{
"title": "已过期",
"value": "100",
},
];
@override
void onReady() {
// TODO: implement onReady

View File

@@ -0,0 +1,441 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:tdesign_flutter/tdesign_flutter.dart';
import '../../../utils/utils.dart';
import 'home_logic.dart';
class HomePage extends StatelessWidget {
const HomePage({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
final logic = Get.find<HomeLogic>();
final state = Get.find<HomeLogic>().state;
double statusBarHeight = MediaQuery.of(context).padding.top;
return PopScope(
canPop: false,
onPopInvoked: (_) {
ToolFn().isExit();
},
child: Scaffold(
body: Stack(
fit: StackFit.expand,
children: [
Image.asset(
'assets/images/home-tab-normal-bg.png',
fit: BoxFit.fitWidth,
),
Padding(
padding:
EdgeInsets.only(top: statusBarHeight, left: 10, right: 10),
child: Column(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Row(
children: [
ClipRRect(
borderRadius: BorderRadius.circular(50),
child: Image.network(
"https://pic.ziyuan.wang/user/guest/2023/12/微信图片_20231109211458_c1a41ab0fd7dd.jpg",
width: 50.0,
)),
const SizedBox(
width: 5,
),
const Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
"商家: GAGA酒吧",
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w500),
),
Text(
"Huakk,欢迎回来!!!",
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w400),
)
],
)
],
),
Row(
children: [
GestureDetector(
onTap: () {
ToolFn.tips("点击了核销按钮");
},
child: const Icon(
Icons.qr_code_scanner,
size: 32,
),
),
],
)
],
),
const SizedBox(
height: 20,
),
Wrap(
direction: Axis.horizontal,
spacing: 70,
runSpacing: 10,
alignment: WrapAlignment.center,
children: logic.list.map((item) {
return Column(
children: [
Text(
item["title"]!,
style: const TextStyle(
color: Colors.grey,
fontSize: 15,
),
),
Text(
item["value"]!,
style: const TextStyle(
color: Colors.black,
fontSize: 20,
fontWeight: FontWeight.bold),
),
],
);
}).toList()),
// const SizedBox(
// height: 10,
// ),
ListView(shrinkWrap: true, children: [
Container(
constraints: const BoxConstraints.tightFor(
width: double.maxFinite,
),
decoration: BoxDecoration(
color: Colors.blueAccent,
borderRadius: BorderRadius.circular(15),
),
child: Wrap(
direction: Axis.horizontal,
spacing: 25,
runSpacing: 10,
alignment: WrapAlignment.center,
children: logic.list2.map((item) {
return GestureDetector(
onTap: () {
ToolFn.tips("点击了${item["title"]}");
},
child: SizedBox(
height: 100,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
item["value"]!,
style: const TextStyle(
color: Colors.white,
fontSize: 20,
fontWeight: FontWeight.bold),
),
Text(
item["title"]!,
style: const TextStyle(
color: Colors.white,
fontSize: 15,
),
),
],
),
),
);
}).toList()),
),
const SizedBox(
height: 10,
),
Container(
constraints: const BoxConstraints.tightFor(
width: double.maxFinite,
),
decoration: BoxDecoration(
color: Colors.blueAccent,
borderRadius: BorderRadius.circular(15),
),
child: Wrap(
direction: Axis.horizontal,
spacing: 25,
runSpacing: 10,
alignment: WrapAlignment.center,
children: logic.list2.map((item) {
return GestureDetector(
onTap: () {
ToolFn.tips("点击了${item["title"]}");
},
child: SizedBox(
height: 100,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
item["value"]!,
style: const TextStyle(
color: Colors.white,
fontSize: 20,
fontWeight: FontWeight.bold),
),
Text(
item["title"]!,
style: const TextStyle(
color: Colors.white,
fontSize: 15,
),
),
],
),
),
);
}).toList()),
),
const SizedBox(
height: 10,
),
Container(
constraints: const BoxConstraints.tightFor(
width: double.maxFinite,
),
decoration: BoxDecoration(
color: Colors.blueAccent,
borderRadius: BorderRadius.circular(15),
),
child: Wrap(
direction: Axis.horizontal,
spacing: 25,
runSpacing: 10,
alignment: WrapAlignment.center,
children: logic.list2.map((item) {
return GestureDetector(
onTap: () {
ToolFn.tips("点击了${item["title"]}");
},
child: SizedBox(
height: 100,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
item["value"]!,
style: const TextStyle(
color: Colors.white,
fontSize: 20,
fontWeight: FontWeight.bold),
),
Text(
item["title"]!,
style: const TextStyle(
color: Colors.white,
fontSize: 15,
),
),
],
),
),
);
}).toList()),
),
const SizedBox(
height: 10,
),
Container(
constraints: const BoxConstraints.tightFor(
width: double.maxFinite,
),
decoration: BoxDecoration(
color: Colors.blueAccent,
borderRadius: BorderRadius.circular(15),
),
child: Wrap(
direction: Axis.horizontal,
spacing: 25,
runSpacing: 10,
alignment: WrapAlignment.center,
children: logic.list2.map((item) {
return GestureDetector(
onTap: () {
ToolFn.tips("点击了${item["title"]}");
},
child: SizedBox(
height: 100,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
item["value"]!,
style: const TextStyle(
color: Colors.white,
fontSize: 20,
fontWeight: FontWeight.bold),
),
Text(
item["title"]!,
style: const TextStyle(
color: Colors.white,
fontSize: 15,
),
),
],
),
),
);
}).toList()),
),
const SizedBox(
height: 10,
),
Container(
constraints: const BoxConstraints.tightFor(
width: double.maxFinite,
),
decoration: BoxDecoration(
color: Colors.blueAccent,
borderRadius: BorderRadius.circular(15),
),
child: Wrap(
direction: Axis.horizontal,
spacing: 25,
runSpacing: 10,
alignment: WrapAlignment.center,
children: logic.list2.map((item) {
return GestureDetector(
onTap: () {
ToolFn.tips("点击了${item["title"]}");
},
child: SizedBox(
height: 100,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
item["value"]!,
style: const TextStyle(
color: Colors.white,
fontSize: 20,
fontWeight: FontWeight.bold),
),
Text(
item["title"]!,
style: const TextStyle(
color: Colors.white,
fontSize: 15,
),
),
],
),
),
);
}).toList()),
),
const SizedBox(
height: 10,
),
Container(
constraints: const BoxConstraints.tightFor(
width: double.maxFinite,
),
decoration: BoxDecoration(
color: Colors.blueAccent,
borderRadius: BorderRadius.circular(15),
),
child: Wrap(
direction: Axis.horizontal,
spacing: 25,
runSpacing: 10,
alignment: WrapAlignment.center,
children: logic.list2.map((item) {
return GestureDetector(
onTap: () {
ToolFn.tips("点击了${item["title"]}");
},
child: SizedBox(
height: 100,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
item["value"]!,
style: const TextStyle(
color: Colors.white,
fontSize: 20,
fontWeight: FontWeight.bold),
),
Text(
item["title"]!,
style: const TextStyle(
color: Colors.white,
fontSize: 15,
),
),
],
),
),
);
}).toList()),
),
const SizedBox(
height: 10,
),
Container(
constraints: const BoxConstraints.tightFor(
width: double.maxFinite,
),
decoration: BoxDecoration(
color: Colors.blueAccent,
borderRadius: BorderRadius.circular(15),
),
child: Wrap(
direction: Axis.horizontal,
spacing: 25,
runSpacing: 10,
alignment: WrapAlignment.center,
children: logic.list2.map((item) {
return GestureDetector(
onTap: () {
ToolFn.tips("点击了${item["title"]}");
},
child: SizedBox(
height: 100,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
item["value"]!,
style: const TextStyle(
color: Colors.white,
fontSize: 20,
fontWeight: FontWeight.bold),
),
Text(
item["title"]!,
style: const TextStyle(
color: Colors.white,
fontSize: 15,
),
),
],
),
),
);
}).toList()),
),
]),
],
))
],
)));
}
}

View File

@@ -13,80 +13,146 @@ class HomePage extends StatelessWidget {
final logic = Get.find<HomeLogic>();
final state = Get.find<HomeLogic>().state;
double statusBarHeight = MediaQuery.of(context).padding.top;
return PopScope(
canPop: false,
onPopInvoked: (_) {
ToolFn().isExit();
},
child: Scaffold(
body: Stack(
fit: StackFit.expand,
children: [
Image.asset(
'assets/images/home-tab-normal-bg.png',
fit: BoxFit.fitWidth,
body: Container(
padding: const EdgeInsets.only(top: 0, left: 10, right: 10),
decoration: const BoxDecoration(
image: DecorationImage(
image: AssetImage('assets/images/home-tab-normal-bg.png'),
fit: BoxFit.cover,
),
Padding(
padding:
EdgeInsets.only(top: statusBarHeight, left: 10, right: 10),
child: Column(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
),
child: ListView(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Row(
children: [
ClipRRect(
borderRadius: BorderRadius.circular(50),
child: Image.network(
"https://pic.ziyuan.wang/user/guest/2023/12/微信图片_20231109211458_c1a41ab0fd7dd.jpg",
width: 50.0,
)),
const SizedBox(
width: 5,
),
const Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
"商家: GAGA酒吧",
style: TextStyle(
fontSize: 16, fontWeight: FontWeight.w500),
),
Text(
"Huakk,欢迎回来!!!",
style: TextStyle(
fontSize: 16, fontWeight: FontWeight.w400),
)
],
)
],
),
Row(
children: [
IconButton(
onPressed: () {
ToolFn.tips("点击了核销按钮");
},
icon: const Icon(
Icons.qr_code_scanner,
size: 32,
))
],
)
],
),
const SizedBox(
height: 20,
),
Wrap(
direction: Axis.horizontal,
spacing: 70,
runSpacing: 10,
alignment: WrapAlignment.center,
children: logic.list.map((item) {
return Column(
children: [
Row(
children: [
ClipRRect(
borderRadius: BorderRadius.circular(50),
child: Image.network(
"https://pic.ziyuan.wang/user/guest/2023/12/微信图片_20231109211458_c1a41ab0fd7dd.jpg",
width: 50.0,
)),
const SizedBox(
width: 5,
),
const Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
"商家: GAGA酒吧",
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w500),
),
Text(
"Huakk,欢迎回来!!!",
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w400),
)
],
)
],
Text(
item["title"]!,
style: const TextStyle(
color: Colors.grey,
fontSize: 15,
),
),
Text(
item["value"]!,
style: const TextStyle(
color: Colors.black,
fontSize: 20,
fontWeight: FontWeight.bold),
),
const Row(
children: [
Icon(
TDIcons.search,
size: 35,
),
Icon(
TDIcons.scan,
size: 35,
),
Icon(
TDIcons.sound,
size: 35,
),
],
)
],
)
],
))
],
);
}).toList()),
const SizedBox(
height: 10,
),
Container(
constraints: const BoxConstraints.tightFor(
width: double.maxFinite,
),
decoration: BoxDecoration(
color: Colors.blueAccent,
borderRadius: BorderRadius.circular(15),
),
child: Wrap(
direction: Axis.horizontal,
spacing: 25,
runSpacing: 10,
alignment: WrapAlignment.center,
children: logic.list2.map((item) {
return GestureDetector(
onTap: () {
ToolFn.tips("点击了${item["title"]}");
},
child: SizedBox(
height: 100,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
item["value"]!,
style: const TextStyle(
color: Colors.white,
fontSize: 20,
fontWeight: FontWeight.bold),
),
Text(
item["title"]!,
style: const TextStyle(
color: Colors.white,
fontSize: 15,
),
),
],
),
),
);
}).toList()),
),
const SizedBox(
height: 10,
),
],
),
)));
}
}

View File

@@ -1,8 +1,10 @@
import 'package:flutter/cupertino.dart';
class TabState {
late int currentPage;
PageController? pageController;
late int currentPage;
TabState() {
///Initialize variables
currentPage = 0;

View File

@@ -17,17 +17,15 @@ class TabPage extends StatelessWidget {
/// 内容页
Widget buildPageView() {
return GetBuilder<TabLogic>(builder: (_) {
return PageView(
physics: const NeverScrollableScrollPhysics(),
controller: state.pageController,
onPageChanged: logic.handlePageChanged,
children: const <Widget>[
HomePage(),
UserPage(),
],
);
});
return PageView(
physics: const NeverScrollableScrollPhysics(),
controller: state.pageController,
onPageChanged: logic.handlePageChanged,
children: const <Widget>[
HomePage(),
UserPage(),
],
);
}
List<BottomNavigationBarItem> createBottomItems() {
@@ -60,30 +58,30 @@ class TabPage extends StatelessWidget {
/// 底部导航
Widget buildBottomNavigationBar() {
List<BottomNavigationBarItem> bottomItems = createBottomItems();
return GetBuilder<TabLogic>(builder: (_) {
return BottomNavigationBar(
items: bottomItems,
currentIndex: state.currentPage,
backgroundColor: Colors.white,
unselectedItemColor: Colors.grey,
selectedItemColor: const Color.fromRGBO(0, 82, 217, 1),
type: BottomNavigationBarType.fixed,
onTap: logic.handleNavBarTap,
selectedFontSize: 10.sp,
unselectedFontSize: 10.sp,
iconSize: 32.w,
);
});
return BottomNavigationBar(
items: bottomItems,
currentIndex: state.currentPage,
backgroundColor: Colors.white,
unselectedItemColor: Colors.grey,
selectedItemColor: const Color.fromRGBO(0, 82, 217, 1),
type: BottomNavigationBarType.fixed,
onTap: logic.handleNavBarTap,
selectedFontSize: 10.sp,
unselectedFontSize: 10.sp,
iconSize: 32.w,
);
}
return PopScope(
canPop: false,
onPopInvoked: (_) {
ToolFn().isExit();
},
child: Scaffold(
body: buildPageView(),
bottomNavigationBar: buildBottomNavigationBar(),
));
return GetBuilder<TabLogic>(builder: (_) {
return PopScope(
canPop: false,
onPopInvoked: (_) {
ToolFn().isExit();
},
child: Scaffold(
body: buildPageView(),
bottomNavigationBar: buildBottomNavigationBar(),
));
});
}
}

View File

@@ -18,10 +18,14 @@ class AppPages {
binding: SplashBinding()),
GetPage(
name: AppPages.login, page: () => LoginPage(), binding: LoginBinding()),
// GetPage(
// name: AppPages.home, page: () => HomePage(), binding: HomeBinding()),
// GetPage(
// name: AppPages.user, page: () => UserPage(), binding: UserBinding()),
GetPage(
name: AppPages.home,
page: () => const HomePage(),
binding: HomeBinding()),
GetPage(
name: AppPages.user,
page: () => const UserPage(),
binding: UserBinding()),
GetPage(
name: AppPages.tab, page: () => const TabPage(), binding: TabBinding()),
];

View File

@@ -1,5 +1,7 @@
import 'package:dio/dio.dart';
import 'package:flutter_jdt_store/global.dart';
import 'package:flutter_jdt_store/utils/utils.dart';
import '../global.dart';
class Request {
// 构造函数
@@ -11,10 +13,9 @@ class Request {
static void init() {
// 基本配置
_dio.options.baseUrl =
"https://www.wanzhuanyongcheng.cn/app"; // 替换为你的 API 地址
_dio.options.connectTimeout = const Duration(seconds: 15); // 连接超时时间,单位是毫秒
_dio.options.receiveTimeout = const Duration(seconds: 15); // 接收超时时间,单位是毫秒
_dio.options.baseUrl = Global.baseUrl;
_dio.options.connectTimeout = const Duration(seconds: 10);
_dio.options.receiveTimeout = const Duration(seconds: 10);
_dio.options.headers["Content-Type"] = "application/json; charset=utf-8";