添加 商品订单页面

商品下单前添加登陆验证
hmxc
张萌 4 years ago
parent 84e462b308
commit 888999e2e1

@ -0,0 +1,36 @@
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
class ASNUmericPainter extends CustomPainter {
final bool plus;
ASNUmericPainter.minus() : this.plus = false;
ASNUmericPainter.plus() : this.plus = true;
@override
void paint(Canvas canvas, Size size) {
double halfWidth = size.width / 2;
double halfHeight = size.height / 2;
Paint paint = Paint()
..color = Colors.black
..style = PaintingStyle.stroke
..strokeWidth = 1.w;
canvas.drawCircle(Offset(halfWidth, halfHeight), 16.w / 2, paint);
canvas.drawLine(
Offset(halfWidth - 3, halfHeight),
Offset(halfWidth + 3, halfHeight),
paint,
);
if (plus) {
canvas.drawLine(
Offset(halfWidth, halfHeight - 3),
Offset(halfWidth, halfHeight + 3),
paint,
);
}
}
@override
bool shouldRepaint(ASNUmericPainter oldDelegate) => false;
@override
bool shouldRebuildSemantics(ASNUmericPainter oldDelegate) => false;
}

@ -1,3 +1,4 @@
import 'package:aku_community/ui/market/goods/goods_order_detail_page.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
@ -223,31 +224,19 @@ class _GoodsDetailPageState extends State<GoodsDetailPage> {
color: kPrimaryColor,
height: 80.w,
onPressed: () async {
final cancel = BotToast.showLoading();
BaseModel baseModel = await NetUtil().post(
API.market.appointment,
params: {
'goodsId': widget.id,
'userName': _nameController.text,
'userTel': _phoneController.text,
'num': 1,
},
showMessage: true,
);
cancel();
if (baseModel.status == true) {
Get.back();
Get.back();
}
Get.to(GoodsOrderDetailPage(
model: _goodsModel,
name: _nameController.text,
phone: _phoneController.text));
},
child: Text('确认报名'),
child: Text('确认购买'),
),
],
),
),
));
},
child: Text('立即报名'),
child: Text('立即购买'),
),
);
}

@ -0,0 +1,293 @@
import 'package:aku_community/base/base_style.dart';
import 'package:aku_community/constants/api.dart';
import 'package:aku_community/model/common/img_model.dart';
import 'package:aku_community/models/market/goods_detail_model.dart';
import 'package:aku_community/pages/life_pay/pay_finish_page.dart';
import 'package:aku_community/pages/sign/sign_in_page.dart';
import 'package:aku_community/ui/profile/house/house_owners_page.dart';
import 'package:aku_community/utils/network/base_model.dart';
import 'package:aku_community/utils/network/net_util.dart';
import 'package:aku_community/widget/bee_divider.dart';
import 'package:aku_community/widget/bee_scaffold.dart';
import 'package:aku_community/widget/buttons/bee_numberic_button.dart';
import 'package:aku_community/widget/buttons/bottom_button.dart';
import 'package:aku_community/widget/others/user_tool.dart';
import 'package:bot_toast/bot_toast.dart';
import 'package:flutter/material.dart';
import 'package:flutter_easyrefresh/easy_refresh.dart';
import 'package:get/get.dart';
import 'package:velocity_x/velocity_x.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:aku_community/const/resource.dart';
import 'package:aku_community/extensions/widget_list_ext.dart';
class GoodsOrderDetailPage extends StatefulWidget {
final GoodsDetailModel model;
final String name;
final String phone;
GoodsOrderDetailPage(
{Key? key, required this.model, required this.name, required this.phone})
: super(key: key);
@override
_GoodsOrderDetailPageState createState() => _GoodsOrderDetailPageState();
}
class _GoodsOrderDetailPageState extends State<GoodsOrderDetailPage> {
late EasyRefreshController _refreshController;
bool _onload = true;
///
int _num = 0;
@override
void initState() {
super.initState();
_refreshController = EasyRefreshController();
}
@override
void dispose() {
_refreshController.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return BeeScaffold(
title: '确认订单',
actions: [
TextButton(
onPressed: () {
Get.to(() => HouseOwnersPage());
},
child: '切换房屋'.text.size(28.sp).color(ktextPrimary).make())
],
body: EasyRefresh(
header: MaterialHeader(),
firstRefresh: true,
onRefresh: () async {
_onload = false;
setState(() {});
},
child: _onload
? Container()
: ListView(
padding: EdgeInsets.symmetric(vertical: 32.w, horizontal: 32.w),
children: <Widget>[
_addressInfo(),
_goodsInfoWidget(),
].sepWidget(
separate: 24.w.heightBox,
),
),
),
bottomNavi: BottomButton(
onPressed: () async {
if (!UserTool.userProvider.isLogin) {
Get.offAll(SignInPage());
}
final cancel = BotToast.showLoading();
BaseModel baseModel = await NetUtil().post(
API.market.appointment,
params: {
'goodsId': widget.model.id,
'userName': widget.name,
'userTel': widget.phone,
'num': _num,
},
showMessage: true,
);
cancel();
if (baseModel.status == true) {
Get.off(() => PayFinishPage());
}
},
child: '立即支付'.text.size(32.sp).color(ktextPrimary).bold.make()),
);
}
Widget _addressInfo() {
return Container(
padding: EdgeInsets.all(24.w),
width: double.infinity,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(8.w),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
widget.model.title.text
.size(32.sp)
.color(ktextPrimary)
.bold
.maxLines(2)
.ellipsis
.make(),
20.w.heightBox,
Row(
children: [
widget.name.text.size(24.sp).color(ktextSubColor).make(),
24.w.widthBox,
widget.phone.text.size(24.sp).color(ktextSubColor).make(),
Spacer(),
'送出时间等待电话联系'.text.size(24.sp).color(ktextPrimary).bold.make(),
],
)
],
),
);
}
Widget _goodsInfoWidget() {
return Container(
width: double.infinity,
decoration: BoxDecoration(
color: Colors.white,
),
padding: EdgeInsets.symmetric(vertical: 32.w, horizontal: 32.w),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
'商品信息'.text.size(32.sp).bold.color(ktextPrimary).make(),
Spacer(),
// widget.model.statusString.text
// .size(30.sp)
// .bold
// .color(widget.model.statusColor)
// .make(),
],
),
16.w.heightBox,
BeeDivider.horizontal(),
24.w.heightBox,
Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
ClipRRect(
borderRadius: BorderRadius.circular(8.w),
clipBehavior: Clip.antiAlias,
child: FadeInImage.assetNetwork(
width: 160.w,
height: 160.w,
fit: BoxFit.cover,
placeholder: R.ASSETS_IMAGES_PLACEHOLDER_WEBP,
image:
API.image(ImgModel.first(widget.model.goodsImgList))),
),
24.w.widthBox,
SizedBox(
height: 160.w,
child: Column(
children: [
Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
widget.model.title.text
.size(28.sp)
.color(ktextPrimary)
.maxLines(2)
.overflow(TextOverflow.ellipsis)
.bold
.make(),
Spacer(),
'¥${widget.model.sellingPrice}'
.text
.size(28.sp)
.bold
.color(Color(0xFFE60E0E))
.make(),
],
),
Spacer(),
Row(
children: [
//|${widget.model.levelTwoCategory}
('${widget.model.categoryName}')
.text
.size(24.sp)
.color(ktextSubColor)
.make()
],
),
12.w.heightBox,
Row(
children: [
('${widget.model.recommend}')
.text
.size(24.sp)
.color(ktextSubColor)
.make()
],
),
],
),
).expand()
],
),
40.w.heightBox,
...<Widget>[
Row(
children: [
// (160 + 24).w.widthBox,
'数量'.text.size(24.sp).color(ktextSubColor).make(),
Spacer(),
BeeNumberPickerButton(
initValue: 1,
minValue: 1,
maxValue: 99,
onChange: (value) {
_num = value;
})
],
),
_rowTile('配送方式', '商家配送'),
_rowTile('订单备注', widget.model.arrivalTime),
].sepWidget(
separate: 20.w.heightBox,
),
],
),
);
}
// Widget _orderInfo() {
// return Container(
// width: double.infinity,
// padding: EdgeInsets.symmetric(vertical: 24.w, horizontal: 32.w),
// decoration: BoxDecoration(
// color: Colors.white, borderRadius: BorderRadius.circular(8.w)),
// child: Column(
// children: [
// Row(
// children: [
// '订单信息'.text.size(32.sp).bold.color(ktextPrimary).make(),
// ],
// ),
// 24.w.heightBox,
// ...<Widget>[
// _rowTile('配送方式', '商家配送'),
// ].sepWidget(
// separate: 20.w.heightBox,
// )
// ],
// ),
// );
// }
Widget _rowTile(
String title,
String content,
) {
return Row(
children: [
// (160 + 24).w.widthBox,
title.text.size(24.sp).color(ktextSubColor).make(),
Spacer(),
content.text.size(24.sp).color(ktextPrimary).make(),
],
);
}
}

@ -0,0 +1,228 @@
import 'package:aku_community/base/base_style.dart';
import 'package:aku_community/painters/as_numberic_painter.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
///##
class BeeNumberPickerButton extends StatefulWidget {
///
final int initValue;
///
///
///
///
///default value : `0`
final int minValue;
///
///
///
///
///default value : `9999`
final int maxValue;
///
final String? suffix;
///
final Function(int value)? reachMax;
///
final Function(int value)? reachMin;
///
final Function(int value) onChange;
///
final bool circle;
BeeNumberPickerButton({
Key? key,
required this.initValue,
this.suffix,
this.minValue = 0,
this.maxValue = 9999,
this.reachMax,
this.reachMin,
required this.onChange,
}) : this.circle = false,
super(key: key);
BeeNumberPickerButton.circle({
Key? key,
required this.initValue,
this.minValue = 0,
this.maxValue = 9999,
this.reachMax,
this.reachMin,
this.suffix,
required this.onChange,
}) : this.circle = true,
super(key: key);
@override
_ASNumericButtonState createState() => _ASNumericButtonState();
}
class _ASNumericButtonState extends State<BeeNumberPickerButton> {
FocusNode _focusNode = FocusNode();
TextEditingController? _controller;
BorderSide _outline = BorderSide(
color: Color(0xFFD8D4D4),
width: 1.w,
);
late int _displayValue;
Widget _buildButton({
required Widget painter,
required VoidCallback onPressed,
// required BorderRadius borderRadius,
}) {
return MaterialButton(
minWidth: 40.w,
elevation: 0,
focusElevation: 0,
hoverElevation: 0,
disabledElevation: 0,
highlightElevation: 0,
onPressed: onPressed,
padding: EdgeInsets.zero,
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
child: painter,
splashColor: kPrimaryColor,
highlightColor: kPrimaryColor.withOpacity(0.3),
// shape: RoundedRectangleBorder(
// borderRadius: borderRadius,
// ),
);
}
@override
void initState() {
super.initState();
_displayValue = widget.initValue;
_controller = TextEditingController(text: widget.initValue.toString());
}
@override
void dispose() {
_controller?.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return Container(
height: 40.w,
constraints: BoxConstraints(minWidth: (40 + 40 + 72).w),
alignment: Alignment.center,
clipBehavior: Clip.antiAlias,
decoration: BoxDecoration(
border: Border.all(
color: Color(0xFFD8D4D4),
width: 1.w,
),
borderRadius: BorderRadius.horizontal(
right: Radius.circular(widget.circle ? 20.w : 0.w),
left: Radius.circular(widget.circle ? 20.w : 0.w)),
),
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
_buildButton(
painter: widget.circle
? CustomPaint(
painter: ASNUmericPainter.minus(),
)
: Icon(CupertinoIcons.minus,size: 20.w, color: Color(0xFFC4C4C4)),
onPressed: () {
_focusNode.unfocus();
if (_displayValue > widget.minValue) {
_displayValue--;
widget.onChange(_displayValue);
_controller!.text = _displayValue.toString();
setState(() {});
} else {
if (widget.reachMin != null) widget.reachMin!(_displayValue);
}
},
// borderRadius: BorderRadius.horizontal(
// left: Radius.circular(widget.circle ? 16.w : 0.w)),
),
GestureDetector(
onTap: () {
_focusNode.requestFocus();
},
child: Container(
constraints: BoxConstraints(minWidth: 72.w),
alignment: Alignment.center,
child: IntrinsicWidth(
child: TextField(
keyboardType: TextInputType.number,
controller: _controller,
onChanged: (text) {
int? value = int.tryParse(text);
_displayValue = value ?? widget.initValue;
setState(() {});
widget.onChange(_displayValue);
},
focusNode: _focusNode,
style: TextStyle(
color: ktextPrimary,
fontSize: 20.sp,
),
cursorColor: kPrimaryColor,
textAlign: TextAlign.center,
decoration: InputDecoration(
contentPadding: EdgeInsets.zero,
border: InputBorder.none,
isDense: true,
hintText: _displayValue.toString(),
suffixText: widget.suffix,
suffixStyle: TextStyle(
color: Colors.black.withOpacity(0.32),
fontSize: 20.sp,
),
),
),
),
decoration: BoxDecoration(
border: Border(
left: _outline,
right: _outline,
),
color: Color(0xFFF7F7F7),
),
),
),
_buildButton(
painter: widget.circle
? CustomPaint(
painter: ASNUmericPainter.plus(),
)
: Icon(
CupertinoIcons.plus,
size: 20.w,
color: Color(0xFFC4C4C4),
),
onPressed: () {
_focusNode.unfocus();
if (_displayValue < widget.maxValue) {
_displayValue++;
widget.onChange(_displayValue);
_controller!.text = _displayValue.toString();
setState(() {});
} else {
if (widget.reachMax != null) widget.reachMax!(_displayValue);
}
},
// borderRadius: BorderRadius.horizontal(
// right: Radius.circular(widget.circle ? 16.w : 0.w)),
),
],
),
);
}
}
Loading…
Cancel
Save