Commit 523509f1 by liubohua

1

parent 9c46f08c
...@@ -2,14 +2,17 @@ ...@@ -2,14 +2,17 @@
* @Author: lbh * @Author: lbh
* @Date: 2022-04-07 10:07:36 * @Date: 2022-04-07 10:07:36
* @LastEditors: lbh * @LastEditors: lbh
* @LastEditTime: 2022-04-08 12:05:00 * @LastEditTime: 2022-04-08 20:08:20
* @Description: file content * @Description: file content
*/ */
import 'dart:html'; import 'dart:developer';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:fluttertoast/fluttertoast.dart';
import "./base/GlobalConfig.dart"; import "./base/GlobalConfig.dart";
import 'package:dio/dio.dart';
import 'util/DioManager.dart';
main() { main() {
runApp(const MyApp()); runApp(const MyApp());
...@@ -56,8 +59,8 @@ class _HomePageState extends State<HomePage> { ...@@ -56,8 +59,8 @@ class _HomePageState extends State<HomePage> {
backgroundColor: Colors.white, backgroundColor: Colors.white,
bottom: TabBar( bottom: TabBar(
labelColor: GlobalConfig.themeColor, labelColor: GlobalConfig.themeColor,
indicatorColor: GlobalConfig.themeColor, indicatorColor: GlobalConfig.themeColor, //選中顏色
unselectedLabelColor: GlobalConfig.fontColor, unselectedLabelColor: GlobalConfig.fontColor, // 未選中顏色
tabs: [ tabs: [
Tab( Tab(
text: '全部', text: '全部',
...@@ -92,96 +95,122 @@ class ListViewPage extends StatefulWidget { ...@@ -92,96 +95,122 @@ class ListViewPage extends StatefulWidget {
} }
class _ListViewPageState extends State<ListViewPage> { class _ListViewPageState extends State<ListViewPage> {
// 当前页数
int _page = 1;
// 页面数据
List _list = [];
// 是否还有
bool _hasMore = true;
void _getData() async {
if (this._hasMore) {
DioManager.getInstance().get(
'/calendar/otherFunction/getOnlineSpecialGoods', {},
//正常回调
(data) {
setState(() {
//更新UI等
print(data);
});
},
//错误回调
(error) {
print("网络异常,请稍后重试");
},
);
}
}
// 下拉刷新 // 下拉刷新
Future<void> _onRefresh() async { Future<void> _onRefresh() async {
print("下拉刷新"); print("下拉刷新");
// 持续两秒 // 持续两秒
await Future.delayed(Duration(milliseconds: 2000), () {}); await Future.delayed(Duration(milliseconds: 2000), () {
_getData();
});
} }
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return RefreshIndicator( return RefreshIndicator(
child: ListView.builder( child: ListView.builder(
itemCount: 10,
// 上拉加载控制器 // 上拉加载控制器
itemBuilder: (context, index) { itemBuilder: (context, index) {
Widget tip = const Text(""); return InkWell(
onTap: () {
return Column( log("$index");
children: [ },
Container( child: Container(
margin: EdgeInsets.fromLTRB(10.0, 10.0, 10.0, 0.0), margin: EdgeInsets.fromLTRB(10.0, 10.0, 10.0, 0.0),
// color: Colors.white, // color: Colors.white,
decoration: BoxDecoration( decoration: BoxDecoration(
borderRadius: BorderRadius.all( borderRadius: BorderRadius.all(
Radius.circular(8.0), Radius.circular(8.0),
),
color: Colors.white,
boxShadow: [
BoxShadow(
color: Colors.grey,
offset: Offset(0.0, 1.0), //阴影y轴偏移量
blurRadius: 2.0, //阴影模糊程度
spreadRadius: 0, //阴影扩散程度
)
]),
child: Column(
children: [
ListTile(
// 左邊
leading: Image.network(
'https://hk-ricepon.oss-cn-hongkong.aliyuncs.com/images/member//authority/202204/1648798010297.jpeg',
width: 40.0,
height: 40.0,
fit: BoxFit.cover,
), ),
color: Colors.white, // 標題
boxShadow: [ title: Row(
BoxShadow( children: [
color: Colors.grey, Text(
offset: Offset(0.0, 1.0), //阴影y轴偏移量 '好春光,不如夢一場!',
blurRadius: 2.0, //阴影模糊程度 style: TextStyle(
spreadRadius: 0 //阴影扩散程度 fontWeight: FontWeight.w500,
) fontSize: 14.0,
]),
child: Column(
children: [
ListTile(
// 左邊
leading: Image.network(
'https://hk-ricepon.oss-cn-hongkong.aliyuncs.com/images/member//authority/202204/1648798010297.jpeg',
width: 40.0,
height: 40.0,
fit: BoxFit.cover,
),
// 標題
title: Row(
children: [
Text(
'好春光,不如夢一場!',
style: TextStyle(
fontWeight: FontWeight.w500,
fontSize: 14.0,
),
), ),
Icon(
Icons.arrow_forward_ios,
size: 12.0,
)
],
),
// 副標題
subtitle: Text(
'2022-4-7 16:53:19',
style: TextStyle(
fontSize: 12.0,
), ),
), Icon(
trailing: Text('自取 已取消'), Icons.arrow_forward_ios,
size: 12.0,
)
],
), ),
const Divider(), // 副標題
Container( subtitle: Text(
padding: EdgeInsets.fromLTRB(70.0, 0.0, 16.0, 0.0), '2022-4-7 16:53:19',
child: Row( style: TextStyle(
children: [ fontSize: 12.0,
Text('14'),
Text('x1'),
],
mainAxisAlignment: MainAxisAlignment.spaceBetween,
), ),
), ),
Container( trailing: Text('自取 已取消'),
child: Text('共1份,總金額: \$ 14.0'), ),
alignment: Alignment.centerRight, const Divider(),
padding: EdgeInsets.all(16.0), Container(
) padding: EdgeInsets.fromLTRB(70.0, 0.0, 16.0, 0.0),
], child: Row(
), children: [
Text('14'),
Text('x1'),
],
mainAxisAlignment: MainAxisAlignment.spaceBetween,
),
),
Container(
child: Text('共1份,總金額: \$ 14.0'),
alignment: Alignment.centerRight,
padding: EdgeInsets.all(16.0),
)
],
), ),
// 加载提示 ),
tip
],
); );
}, },
), ),
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* @Author: lbh * @Author: lbh
* @Date: 2022-04-07 15:24:40 * @Date: 2022-04-07 15:24:40
* @LastEditors: lbh * @LastEditors: lbh
* @LastEditTime: 2022-04-07 16:05:11 * @LastEditTime: 2022-04-08 20:11:46
* @Description: file content * @Description: file content
*/ */
import 'package:dio/dio.dart'; import 'package:dio/dio.dart';
...@@ -15,7 +15,19 @@ import '../base/GlobalConfig.dart'; ...@@ -15,7 +15,19 @@ import '../base/GlobalConfig.dart';
* 网络请求管理类 * 网络请求管理类
*/ */
class DioManager { class DioManager {
//写一个单例
//在 Dart 里,带下划线开头的变量是私有变量
static DioManager _instance = DioManager();
static DioManager getInstance() {
if (_instance == null) {
_instance = DioManager();
}
return _instance;
}
Dio dio = Dio(); Dio dio = Dio();
// 屬性要寫在這個裡面 // 屬性要寫在這個裡面
DioManager() { DioManager() {
dio.options.headers = {"apptype": "7"}; dio.options.headers = {"apptype": "7"};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment