110 lines
4.2 KiB
Dart
110 lines
4.2 KiB
Dart
import 'package:dio/dio.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:go_router/go_router.dart';
|
|
import 'package:logistics_tools/utils/request.dart';
|
|
|
|
class Logistics extends StatefulWidget {
|
|
const Logistics({super.key});
|
|
|
|
@override
|
|
State<Logistics> createState() => _LogisticsState();
|
|
}
|
|
|
|
class _LogisticsState extends State<Logistics> {
|
|
List<dynamic> goodsList = [];
|
|
|
|
@override
|
|
void initState() {
|
|
// TODO: implement initState
|
|
super.initState();
|
|
}
|
|
|
|
Future<Response> fetchGoodsList(BuildContext context) async {
|
|
String? orderNumber =
|
|
GoRouterState.of(context).uri.queryParameters["orderNumber"];
|
|
String? orderPayWay =
|
|
GoRouterState.of(context).uri.queryParameters["orderPayWay"];
|
|
print(orderPayWay);
|
|
if (orderNumber?.isEmpty ?? true) {
|
|
context.pop();
|
|
}
|
|
Response response = await dio.get(
|
|
"https://www.sanpinhuicai.com/wisdommining/api/order/goodsOfOrder",
|
|
queryParameters: {"orderNumber": orderNumber});
|
|
goodsList = response.data["value"];
|
|
return response;
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
appBar: AppBar(
|
|
title: const Text("填写物流信息"),
|
|
),
|
|
body: Container(
|
|
padding: const EdgeInsets.all(40),
|
|
width: double.infinity,
|
|
child: FutureBuilder(
|
|
future: fetchGoodsList(context),
|
|
builder:
|
|
(BuildContext context, AsyncSnapshot<Response> snapshot) {
|
|
if (snapshot.hasData) {
|
|
return Card(
|
|
color: Colors.white,
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(20),
|
|
child: Row(
|
|
children: [
|
|
Expanded(
|
|
flex: 1,
|
|
child: ListView.builder(
|
|
itemCount: goodsList.length,
|
|
itemBuilder: (context, index) {
|
|
final goods = goodsList[index];
|
|
return ListTile(
|
|
trailing: IconButton(
|
|
icon: const Icon(Icons.add),
|
|
onPressed: () {},
|
|
),
|
|
leading: Image.network(
|
|
goods["goodsPhoto"],
|
|
width: 100,
|
|
height: 100,
|
|
),
|
|
title: Text(
|
|
"${goods["goodsName"]} - ${goods?["wisdGoodsSpec"]?["specName"] ?? ''}"),
|
|
subtitle:
|
|
Text("数量 : ${goods?["goodsNum"]}"),
|
|
);
|
|
})),
|
|
const Expanded(flex: 1, child: Placeholder())
|
|
/*
|
|
GridView.builder(
|
|
gridDelegate:
|
|
const SliverGridDelegateWithFixedCrossAxisCount(
|
|
crossAxisCount: 5,
|
|
childAspectRatio: 1.0),
|
|
itemCount: goodsList.length,
|
|
itemBuilder: (context, index) {
|
|
return Icon(Icons.add);
|
|
}),
|
|
*/
|
|
],
|
|
)),
|
|
);
|
|
} else if (snapshot.hasError) {
|
|
return const Center(
|
|
child: Icon(
|
|
Icons.error_outline,
|
|
color: Colors.red,
|
|
size: 60,
|
|
),
|
|
);
|
|
} else {
|
|
return const Center(child: CircularProgressIndicator());
|
|
}
|
|
},
|
|
)));
|
|
}
|
|
}
|