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,24 +95,53 @@ class ListViewPage extends StatefulWidget { ...@@ -92,24 +95,53 @@ 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(
...@@ -122,7 +154,7 @@ class _ListViewPageState extends State<ListViewPage> { ...@@ -122,7 +154,7 @@ class _ListViewPageState extends State<ListViewPage> {
color: Colors.grey, color: Colors.grey,
offset: Offset(0.0, 1.0), //阴影y轴偏移量 offset: Offset(0.0, 1.0), //阴影y轴偏移量
blurRadius: 2.0, //阴影模糊程度 blurRadius: 2.0, //阴影模糊程度
spreadRadius: 0 //阴影扩散程度 spreadRadius: 0, //阴影扩散程度
) )
]), ]),
child: Column( child: Column(
...@@ -179,9 +211,6 @@ class _ListViewPageState extends State<ListViewPage> { ...@@ -179,9 +211,6 @@ class _ListViewPageState extends State<ListViewPage> {
], ],
), ),
), ),
// 加载提示
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