提交 8059be8c authored 作者: yueweilu's avatar yueweilu

Merge remote-tracking branch 'origin/test' into test

......@@ -400,5 +400,18 @@ abstract class MineAPI {
return OrderInfoModel.fromJson(result.data);
}
/// 24、上传订单评价
static Future<bool> UpOrderEvaluate(
{required String evaluate}) async {
final result = await HttpService.to.post(
'/v1/orders/Orders/rating',
params: {'rat_json': evaluate, },
);
if (result.data is Map && result.data['is_success'] == 1) {
return true;
}
return false;
}
}
......@@ -382,6 +382,7 @@ class OrderInfoModel {
class BookListModel {
BookListModel({
this.bookId,
this.recordId,
this.name,
this.img,
this.introduction,
......@@ -392,6 +393,7 @@ class BookListModel {
BookListModel.fromJson(dynamic json) {
bookId = json['book_id'];
recordId = json['record_id'];
name = json['name'];
img = json['img'];
introduction = json['introduction'];
......@@ -401,6 +403,7 @@ class BookListModel {
createTime = json['create_time'];
}
num? bookId;
num? recordId;
String? name;
String? img;
String? introduction;
......@@ -409,6 +412,7 @@ class BookListModel {
num? comments;
num? createTime;
BookListModel copyWith({ num? bookId,
num? recordId,
String? name,
String? img,
String? introduction,
......@@ -417,6 +421,7 @@ class BookListModel {
num? comments,
num? createTime,
}) => BookListModel( bookId: bookId ?? this.bookId,
recordId: recordId ?? this.recordId,
name: name ?? this.name,
img: img ?? this.img,
introduction: introduction ?? this.introduction,
......@@ -428,6 +433,7 @@ class BookListModel {
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['book_id'] = bookId;
map['record_id'] = recordId;
map['name'] = name;
map['img'] = img;
map['introduction'] = introduction;
......@@ -439,3 +445,40 @@ class BookListModel {
}
}
/// record_id : 11
/// rating : 1
/// comments : "内容"
/// 订单评价
class OrderEvaluate {
OrderEvaluate({
this.recordId,
this.rating,
this.comments,});
OrderEvaluate.fromJson(dynamic json) {
recordId = json['record_id'];
rating = json['rating'];
comments = json['comments'];
}
num? recordId;
num? rating;
String? comments;
OrderEvaluate copyWith({ num? recordId,
num? rating,
String? comments,
}) => OrderEvaluate( recordId: recordId ?? this.recordId,
rating: rating ?? this.rating,
comments: comments ?? this.comments,
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['record_id'] = recordId;
map['rating'] = rating;
map['comments'] = comments;
return map;
}
}
......@@ -160,7 +160,7 @@ class BuiltCompleted extends StatelessWidget {
child: GestureDetector(
onTap: () {
// print("保存昵称");
context.pushNamed(Routes.orderEvaluate,extra: model);
context.pushNamed(Routes.orderEvaluate,extra:OrderInfoModel(),queryParameters: {'orderNum':model.ordersnum});
},
child: Text(
'去评价',
......@@ -292,7 +292,7 @@ class BuiltCompleted extends StatelessWidget {
child: Center(
child: GestureDetector(
onTap: () {
context.pushNamed(Routes.orderEvaluate,extra: model);
context.pushNamed(Routes.orderEvaluate,extra:OrderInfoModel(),queryParameters: {'orderNum':model.ordersnum});
},
child: Text(
'继续评价',
......
......@@ -221,7 +221,7 @@ class _UserOrderCompletedState extends State<UserOrderCompletedPage> {
child: GestureDetector(
onTap: () {
// print("保存昵称");
context.pushNamed(Routes.orderEvaluate,);
context.pushNamed(Routes.orderEvaluate,extra:controller.model,queryParameters: {'orderNum':controller.model.ordersnum});
},
child: Text(
'去评价',
......
......@@ -3,24 +3,33 @@ part of user_order_evaluate;
/// 订单评价
class UserOrderEvaluateController extends GetxController {
OrderListModel orderListModel;
// 应付款、订单编号等
UserOrderEvaluateController(this.orderListModel); // 已完成订单
OrderInfoModel orderInfoModel;
String orderNum;
UserOrderEvaluateController(this.orderNum,this.orderInfoModel); // 已完成订单
@override
void onReady() {
getOrderInfo();
super.onReady();
}
/// 获取订单信息
void getOrderInfo() async {
// orderCompletedInfo = await MineAPI.userInfo();
Future<void> getOrderInfo() async {
orderInfoModel = await MineAPI.getOrderInfo(orderNum: orderNum);
update();
}
/// 上传评价
void UpOrderEvaluate(String evaluate) async {
final result = await MineAPI.UpOrderEvaluate(evaluate: evaluate);
if (result) {
Toast.show('评价成功');
update();
}
}
}
......@@ -5,6 +5,8 @@ import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_star/custom_rating.dart';
import 'package:flutter_star/star.dart';
import 'package:get/get.dart';
import 'package:get/get_core/src/get_main.dart';
import 'package:get/get_state_manager/src/simple/get_controllers.dart';
import 'package:get/get_state_manager/src/simple/get_state.dart';
......
......@@ -2,63 +2,102 @@ part of user_order_evaluate;
/// 用户订单评价
class UserOrderEvaluatePage extends StatefulWidget {
final OrderListModel orderListModel; // 订单
const UserOrderEvaluatePage({Key? key, required this.orderListModel,}) : super(key: key);
final String orderNum; // 订单号
final OrderInfoModel orderInfoModel; // 订单详情
const UserOrderEvaluatePage({
Key? key,
required this.orderNum,
required this.orderInfoModel,
}) : super(key: key);
@override
State<UserOrderEvaluatePage> createState() => _UserOrderEvaluatePageState();
}
class _UserOrderEvaluatePageState extends State<UserOrderEvaluatePage> {
late UserOrderEvaluateController myController;
List<TextEditingController> controllers = [];
List<OrderEvaluate> orderEvaluates = [];
List<double> ratings = [];
@override
void initState() {
myController = Get.put(UserOrderEvaluateController(widget.orderNum,widget.orderInfoModel));
super.initState();
}
@override
Widget build(BuildContext context) {
return GetBuilder<UserOrderEvaluateController>(
init: UserOrderEvaluateController(widget.orderListModel),
builder: (controller) =>
Scaffold(
appBar: AppBar(
centerTitle: true,
title: const Text('订单评价'),
),
body: Column(
children: [
Expanded(
child: SingleChildScrollView(
child: Column(
children: [
ListView.builder(
physics: const NeverScrollableScrollPhysics(),
shrinkWrap:true,
return FutureBuilder(future: myController.getOrderInfo(),
builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.waiting) {
return Scaffold(
appBar: AppBar(
centerTitle: true,
title: const Text('订单评价'),
),);
}else{
return GetBuilder<UserOrderEvaluateController>(
init:
UserOrderEvaluateController(widget.orderNum, widget.orderInfoModel),
builder: (controller) => Scaffold(
appBar: AppBar(
centerTitle: true,
title: const Text('订单评价'),
),
body: Column(
children: [
Expanded(
child: SingleChildScrollView(
child: Column(
children: [
ListView.builder(
physics: const NeverScrollableScrollPhysics(),
shrinkWrap: true,
itemBuilder: (BuildContext context, int index) {
return listItem(
controller.orderInfoModel.bookList![index],
orderEvaluates);
},
itemCount:
controller.orderInfoModel.bookList?.length,
),
],
),
),
),
SizedBox(
height: 26.w,
),
Container(
margin: EdgeInsets.symmetric(horizontal: 10.w),
child: CustomGradientButton(
text: '提交评价',
isEnabled: false,
onPressed: () {
print('11111111111111111');
},
),
),
SizedBox(
height: 41.w,
)
],
),
));
}
},);
itemBuilder: (BuildContext context, int index){
return listItem(widget.orderListModel.cartList![index]);
},
itemCount: widget.orderListModel.cartList?.length,
),
],
),
),
),
SizedBox(height: 26.w,),
Container(
margin: EdgeInsets.symmetric(horizontal: 10.w),
child: CustomGradientButton(
text: '提交评价',
isEnabled: false,
onPressed: () {
print('11111111111111111');
},
),
),
SizedBox(height: 41.w,)
],
),
));
}
Widget listItem(CartListModel cartList){
return Container(
margin: EdgeInsets.only(left:10.w,top:12.w,bottom:12.w,right: 23.5.w),
Widget listItem(BookListModel bookListModel, List<OrderEvaluate> orderEvaluates) {
OrderEvaluate evaluate = OrderEvaluate(recordId: bookListModel.recordId);
orderEvaluates.add(evaluate);
int index = orderEvaluates.length-1;
return Container(
margin:
EdgeInsets.only(left: 10.w, top: 10.w, right: 10.w),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8.w),
color: const Color(0xFFF9F9F9),
......@@ -79,7 +118,7 @@ class _UserOrderEvaluatePageState extends State<UserOrderEvaluatePage> {
// 图书容器
Container(
color: Colours.cF8,
padding: EdgeInsets.symmetric(horizontal: 11.w,vertical: 12.w),
padding: EdgeInsets.symmetric(horizontal: 11.w, vertical: 12.w),
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
......@@ -101,22 +140,32 @@ class _UserOrderEvaluatePageState extends State<UserOrderEvaluatePage> {
),
child: Image.network(
// 'http://zxts-book-file.zijingebook.com/2024-01/29/b91194564969b9151fa382807977282acdffa22d.jpg',
cartList.img.toString(),
bookListModel.img.toString(),
// 用实际图片链接替换
fit: BoxFit.cover,
),
),
Gaps.hGaps10,
Expanded(
child: Text(cartList.introduction.toString(),style: TextStyle(fontSize: 13.w,height: 1.5,fontWeight: Fonts.medium,color: Colours.c3),maxLines: 2,overflow: TextOverflow.ellipsis,),
child: Text(
bookListModel.introduction.toString(),
style: TextStyle(
fontSize: 13.w,
height: 1.5,
fontWeight: Fonts.medium,
color: Colours.c3),
maxLines: 2,
overflow: TextOverflow.ellipsis,
),
),
],
),
),
// 评价容器
Container(
padding: EdgeInsets.only(top: 1.w,),
padding: EdgeInsets.only(
top: 1.w,
),
width: double.infinity,
height: 160.w,
color: Colors.white,
......@@ -135,40 +184,40 @@ class _UserOrderEvaluatePageState extends State<UserOrderEvaluatePage> {
absorbing: false,
child: CustomRating(
max: 5,
score:0 ,
score: 0,
star: Star(
fat: 0.5,
progress: 7,
fillColor: AppTheme.primary,
size: 16.w,
emptyColor: Colours.cE2,
), onRating: (double ) {
),
onRating: (double) {
orderEvaluates[index].rating=double;
print(double);
},
},
),
),
],
),
Expanded(
// color: Colors.red,
child: CustomInput(
decoration: InputDecoration(
child: CustomInput(
decoration: InputDecoration(
focusedBorder: InputBorder.none,
border: InputBorder.none,
enabledBorder: InputBorder.none,
errorBorder: InputBorder.none,
fillColor:Colors.white,
hintStyle: TextStyle(fontSize: 14.w,height: 1.5,color: Colours.c6)
),
fillColor: Colors.white,
hintStyle: TextStyle(
fontSize: 14.w, height: 1.5, color: Colours.c6)),
maxLines: 5,
hintText: '请简要描述',
),
),
],
),
),
],
),
),
......
......@@ -483,7 +483,7 @@ abstract class Routes {
pageBuilder: (context, state) =>CupertinoPage(
name: state.uri.toString(),
key: state.pageKey,
child: UserOrderEvaluatePage(orderListModel: state.extra as OrderListModel,)
child: UserOrderEvaluatePage(orderNum:state.uri.queryParameters['orderNum'].toString(),orderInfoModel: state.extra as OrderInfoModel,)
)
),
GoRoute( // 帮助中心
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论