Commit 523509f1 by liubohua

1

parent 9c46f08c
......@@ -2,14 +2,17 @@
* @Author: lbh
* @Date: 2022-04-07 10:07:36
* @LastEditors: lbh
* @LastEditTime: 2022-04-08 12:05:00
* @LastEditTime: 2022-04-08 20:08:20
* @Description: file content
*/
import 'dart:html';
import 'dart:developer';
import 'package:flutter/material.dart';
import 'package:fluttertoast/fluttertoast.dart';
import "./base/GlobalConfig.dart";
import 'package:dio/dio.dart';
import 'util/DioManager.dart';
main() {
runApp(const MyApp());
......@@ -56,8 +59,8 @@ class _HomePageState extends State<HomePage> {
backgroundColor: Colors.white,
bottom: TabBar(
labelColor: GlobalConfig.themeColor,
indicatorColor: GlobalConfig.themeColor,
unselectedLabelColor: GlobalConfig.fontColor,
indicatorColor: GlobalConfig.themeColor, //選中顏色
unselectedLabelColor: GlobalConfig.fontColor, // 未選中顏色
tabs: [
Tab(
text: '全部',
......@@ -92,96 +95,122 @@ class ListViewPage extends StatefulWidget {
}
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 {
print("下拉刷新");
// 持续两秒
await Future.delayed(Duration(milliseconds: 2000), () {});
await Future.delayed(Duration(milliseconds: 2000), () {
_getData();
});
}
@override
Widget build(BuildContext context) {
return RefreshIndicator(
child: ListView.builder(
itemCount: 10,
// 上拉加载控制器
itemBuilder: (context, index) {
Widget tip = const Text("");
return Column(
children: [
Container(
margin: EdgeInsets.fromLTRB(10.0, 10.0, 10.0, 0.0),
// color: Colors.white,
decoration: BoxDecoration(
borderRadius: BorderRadius.all(
Radius.circular(8.0),
return InkWell(
onTap: () {
log("$index");
},
child: Container(
margin: EdgeInsets.fromLTRB(10.0, 10.0, 10.0, 0.0),
// color: Colors.white,
decoration: BoxDecoration(
borderRadius: BorderRadius.all(
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: [
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,
),
// 標題
title: Row(
children: [
Text(
'好春光,不如夢一場!',
style: TextStyle(
fontWeight: FontWeight.w500,
fontSize: 14.0,
),
// 標題
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,
),
),
trailing: Text('自取 已取消'),
Icon(
Icons.arrow_forward_ios,
size: 12.0,
)
],
),
const Divider(),
Container(
padding: EdgeInsets.fromLTRB(70.0, 0.0, 16.0, 0.0),
child: Row(
children: [
Text('14'),
Text('x1'),
],
mainAxisAlignment: MainAxisAlignment.spaceBetween,
// 副標題
subtitle: Text(
'2022-4-7 16:53:19',
style: TextStyle(
fontSize: 12.0,
),
),
Container(
child: Text('共1份,總金額: \$ 14.0'),
alignment: Alignment.centerRight,
padding: EdgeInsets.all(16.0),
)
],
),
trailing: Text('自取 已取消'),
),
const Divider(),
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 @@
* @Author: lbh
* @Date: 2022-04-07 15:24:40
* @LastEditors: lbh
* @LastEditTime: 2022-04-07 16:05:11
* @LastEditTime: 2022-04-08 20:11:46
* @Description: file content
*/
import 'package:dio/dio.dart';
......@@ -15,7 +15,19 @@ import '../base/GlobalConfig.dart';
* 网络请求管理类
*/
class DioManager {
//写一个单例
//在 Dart 里,带下划线开头的变量是私有变量
static DioManager _instance = DioManager();
static DioManager getInstance() {
if (_instance == null) {
_instance = DioManager();
}
return _instance;
}
Dio dio = Dio();
// 屬性要寫在這個裡面
DioManager() {
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