fmk
3 years ago
23 changed files with 1888 additions and 1945 deletions
@ -0,0 +1,84 @@ |
|||||||
|
|
||||||
|
|
||||||
|
import 'package:fluwx/fluwx.dart'; |
||||||
|
import 'package:huixiang/retrofit/data/base_data.dart'; |
||||||
|
import 'package:huixiang/retrofit/data/order_info.dart'; |
||||||
|
import 'package:huixiang/retrofit/data/placeOrderFirst.dart'; |
||||||
|
import 'package:huixiang/retrofit/data/wx_pay.dart'; |
||||||
|
import 'package:huixiang/retrofit/min_api.dart'; |
||||||
|
import 'package:huixiang/utils/min.dart'; |
||||||
|
|
||||||
|
class OrderUtils { |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static carryOnPay(payChannel, MinApiService minService, OrderInfo orderInfo, Function queryDetails) async { |
||||||
|
PlaceOrderFirst placeOrderFirst = PlaceOrderFirst(); |
||||||
|
placeOrderFirst.addressId = orderInfo.addressExt.addressId; |
||||||
|
placeOrderFirst.isSubscribe = orderInfo.isSubscribe; |
||||||
|
placeOrderFirst.isTakeOut = orderInfo.isTakeOut; |
||||||
|
placeOrderFirst.notes = orderInfo.notes; |
||||||
|
placeOrderFirst.id = orderInfo.id; |
||||||
|
placeOrderFirst.orderProductVOList = orderInfo.orderDetail.orderProductList; |
||||||
|
placeOrderFirst.numberOfPeople = "0"; |
||||||
|
placeOrderFirst.orderSource = orderInfo.orderSource; |
||||||
|
placeOrderFirst.orderType = "${orderInfo.orderType}"; |
||||||
|
placeOrderFirst.orderTypeId = 0; |
||||||
|
placeOrderFirst.parentCode = orderInfo.parentCode; // 火锅加菜 |
||||||
|
placeOrderFirst.parentId = orderInfo.parentId; // 火锅加菜 |
||||||
|
placeOrderFirst.payChannel = payChannel; |
||||||
|
placeOrderFirst.promotionInfoDTO = PromotionInfoDTOBean(); |
||||||
|
placeOrderFirst.promotionInfoDTO.promotionId = orderInfo.promotionId; |
||||||
|
placeOrderFirst.promotionInfoDTO.couponId = orderInfo.couponId; |
||||||
|
placeOrderFirst.recMobile = ""; |
||||||
|
placeOrderFirst.shoppingCartSkuItemList = []; |
||||||
|
placeOrderFirst.skuItemDTOList = []; |
||||||
|
placeOrderFirst.source = 1; |
||||||
|
placeOrderFirst.storeId = orderInfo.storeId; |
||||||
|
placeOrderFirst.subcribeTime = null; |
||||||
|
placeOrderFirst.tableId = orderInfo.tableId; |
||||||
|
|
||||||
|
if (placeOrderFirst.payChannel == 1) { |
||||||
|
if (!(await Min.isInitialize())) { |
||||||
|
// 小程序的微信支付和app的充值支付使用同一个WXPayEntryActivity回调, |
||||||
|
// 然而充值时小程序未初始化会导致回调内部代码调用getPackage空指针, |
||||||
|
// 故而在此初始化一下 |
||||||
|
await Min.initialize(); |
||||||
|
} |
||||||
|
BaseData<WxPay> baseData = await minService |
||||||
|
.settlementWx(placeOrderFirst.toJson()) |
||||||
|
.catchError((error) {}); |
||||||
|
if (baseData != null && baseData.isSuccess) { |
||||||
|
WxPay wxPay = baseData.data; |
||||||
|
await registerWxApi( |
||||||
|
appId: wxPay.appId, |
||||||
|
doOnAndroid: true, |
||||||
|
universalLink: "https://hx.lotus-wallet.com/app/", |
||||||
|
); |
||||||
|
payWithWeChat( |
||||||
|
appId: wxPay.appId, |
||||||
|
partnerId: wxPay.partnerId, |
||||||
|
prepayId: wxPay.prepayId, |
||||||
|
packageValue: wxPay.packageValue, |
||||||
|
nonceStr: wxPay.nonceStr, |
||||||
|
timeStamp: int.tryParse(wxPay.timeStamp), |
||||||
|
sign: wxPay.sign, |
||||||
|
); |
||||||
|
weChatResponseEventHandler.listen((event) async { |
||||||
|
print("payCallback: ${event.errCode}"); |
||||||
|
queryDetails(); |
||||||
|
}); |
||||||
|
} |
||||||
|
} else { |
||||||
|
BaseData baseData = await minService |
||||||
|
.settlementApi(placeOrderFirst.toJson()) |
||||||
|
.catchError((error) {}); |
||||||
|
if (baseData != null && baseData.isSuccess) { |
||||||
|
queryDetails(); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
} |
@ -0,0 +1,147 @@ |
|||||||
|
import 'package:flutter/material.dart'; |
||||||
|
import 'package:flutter_screenutil/flutter_screenutil.dart'; |
||||||
|
import 'package:huixiang/generated/l10n.dart'; |
||||||
|
import 'package:huixiang/utils/font_weight.dart'; |
||||||
|
|
||||||
|
class OrderPaySelected extends StatefulWidget { |
||||||
|
|
||||||
|
@override |
||||||
|
State<StatefulWidget> createState() { |
||||||
|
return _OrderPaySelected(); |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
class _OrderPaySelected extends State<OrderPaySelected> { |
||||||
|
@override |
||||||
|
Widget build(BuildContext context) { |
||||||
|
return StatefulBuilder( |
||||||
|
builder: (BuildContext context, StateSetter setState) { |
||||||
|
return Container( |
||||||
|
width: double.infinity, |
||||||
|
height: 200, |
||||||
|
padding: EdgeInsets.only( |
||||||
|
left: 16.w, |
||||||
|
right: 16.w, |
||||||
|
top: 20.h, |
||||||
|
bottom: 20.h, |
||||||
|
), |
||||||
|
decoration: BoxDecoration( |
||||||
|
boxShadow: [ |
||||||
|
BoxShadow( |
||||||
|
color: Color(0x000000).withAlpha(25), |
||||||
|
offset: Offset(0, 1), |
||||||
|
blurRadius: 12.0, |
||||||
|
), |
||||||
|
], |
||||||
|
color: Colors.white, |
||||||
|
borderRadius: BorderRadius.circular(8), |
||||||
|
), |
||||||
|
child: Column( |
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceAround, |
||||||
|
crossAxisAlignment: CrossAxisAlignment.start, |
||||||
|
children: [ |
||||||
|
Padding( |
||||||
|
padding: EdgeInsets.only(bottom: 16.h), |
||||||
|
child: Text( |
||||||
|
S.of(context).zhifufangshi, |
||||||
|
style: TextStyle( |
||||||
|
fontSize: 16.sp, |
||||||
|
color: Colors.black, |
||||||
|
fontWeight: MyFontWeight.regular, |
||||||
|
), |
||||||
|
), |
||||||
|
), |
||||||
|
GestureDetector( |
||||||
|
onTap: () { |
||||||
|
Navigator.of(context).pop(4); |
||||||
|
}, |
||||||
|
child: Row( |
||||||
|
mainAxisAlignment: MainAxisAlignment.center, |
||||||
|
crossAxisAlignment: CrossAxisAlignment.start, |
||||||
|
children: [ |
||||||
|
Text( |
||||||
|
S.of(context).pingtaiyue, |
||||||
|
style: TextStyle( |
||||||
|
fontSize: 14.sp, |
||||||
|
color: Color(0xff353535), |
||||||
|
fontWeight: MyFontWeight.semi_bold,), |
||||||
|
), |
||||||
|
checkView(1), |
||||||
|
], |
||||||
|
), |
||||||
|
), |
||||||
|
SizedBox( |
||||||
|
height: 10, |
||||||
|
), |
||||||
|
GestureDetector( |
||||||
|
onTap: () { |
||||||
|
Navigator.of(context).pop(3); |
||||||
|
}, |
||||||
|
child: Row( |
||||||
|
mainAxisAlignment: MainAxisAlignment.center, |
||||||
|
crossAxisAlignment: CrossAxisAlignment.start, |
||||||
|
children: [ |
||||||
|
Text( |
||||||
|
S.of(context).dianpuyue, |
||||||
|
style: TextStyle( |
||||||
|
fontSize: 14.sp, |
||||||
|
color: Color(0xff353535), |
||||||
|
fontWeight: MyFontWeight.semi_bold, |
||||||
|
), |
||||||
|
), |
||||||
|
checkView(2), |
||||||
|
], |
||||||
|
), |
||||||
|
), |
||||||
|
SizedBox( |
||||||
|
height: 10, |
||||||
|
), |
||||||
|
GestureDetector( |
||||||
|
onTap: () { |
||||||
|
Navigator.of(context).pop(1); |
||||||
|
}, |
||||||
|
child: Row( |
||||||
|
mainAxisAlignment: MainAxisAlignment.center, |
||||||
|
crossAxisAlignment: CrossAxisAlignment.start, |
||||||
|
children: [ |
||||||
|
Image.asset("assets/image/icon_we_chat.png"), |
||||||
|
Padding( |
||||||
|
padding: EdgeInsets.only(left: 8.w), |
||||||
|
child: Text( |
||||||
|
S.of(context).weixinzhifu, |
||||||
|
style: TextStyle( |
||||||
|
fontSize: 14.sp, |
||||||
|
color: Color(0xff353535), |
||||||
|
fontWeight: MyFontWeight.semi_bold, |
||||||
|
), |
||||||
|
), |
||||||
|
), |
||||||
|
checkView(3), |
||||||
|
], |
||||||
|
), |
||||||
|
), |
||||||
|
], |
||||||
|
), |
||||||
|
); |
||||||
|
}, |
||||||
|
); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
Widget checkView(var index) { |
||||||
|
return Container( |
||||||
|
padding: EdgeInsets.only(left: 16.w), |
||||||
|
alignment: Alignment.center, |
||||||
|
child: Image.asset( |
||||||
|
/*checkIndex != index |
||||||
|
? */"assets/image/icon_radio_unselected.png", |
||||||
|
// : "assets/image/icon_radio_selected.png", |
||||||
|
width: 15.w, |
||||||
|
height: 15.h, |
||||||
|
), |
||||||
|
); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
} |
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,139 @@ |
|||||||
|
import 'package:flutter/material.dart'; |
||||||
|
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; |
||||||
|
import 'package:huixiang/utils/font_weight.dart'; |
||||||
|
import 'package:flutter_screenutil/flutter_screenutil.dart'; |
||||||
|
import 'package:huixiang/view_widget/round_button.dart'; |
||||||
|
|
||||||
|
class PeopleNumView extends StatefulWidget { |
||||||
|
final String tableName; |
||||||
|
|
||||||
|
// final Function(int peopleNum) callback; |
||||||
|
|
||||||
|
PeopleNumView(this.tableName); |
||||||
|
|
||||||
|
@override |
||||||
|
State<StatefulWidget> createState() { |
||||||
|
return _PeopleNumView(); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
class _PeopleNumView extends State<PeopleNumView> { |
||||||
|
int peopleNum = 1; |
||||||
|
|
||||||
|
@override |
||||||
|
Widget build(BuildContext context) { |
||||||
|
return SimpleDialog( |
||||||
|
titlePadding: EdgeInsets.all(10), |
||||||
|
backgroundColor: Colors.transparent, |
||||||
|
elevation: 0, |
||||||
|
shape: RoundedRectangleBorder( |
||||||
|
borderRadius: BorderRadius.circular(6), |
||||||
|
), |
||||||
|
children: [ |
||||||
|
Stack( |
||||||
|
alignment: Alignment.bottomCenter, |
||||||
|
children: [ |
||||||
|
Container( |
||||||
|
width: 295, |
||||||
|
height: 247, |
||||||
|
decoration: BoxDecoration( |
||||||
|
color: Colors.white, |
||||||
|
borderRadius: BorderRadius.circular(8), |
||||||
|
), |
||||||
|
padding: EdgeInsets.symmetric(vertical: 20, horizontal: 20), |
||||||
|
child: Column( |
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween, |
||||||
|
crossAxisAlignment: CrossAxisAlignment.center, |
||||||
|
children: [ |
||||||
|
Text( |
||||||
|
"桌位:${widget.tableName}", |
||||||
|
style: TextStyle( |
||||||
|
fontSize: 16.sp, |
||||||
|
fontWeight: MyFontWeight.regular, |
||||||
|
color: Color(0xFF171717), |
||||||
|
), |
||||||
|
), |
||||||
|
Text( |
||||||
|
"请选择用餐人数:$peopleNum人", |
||||||
|
style: TextStyle( |
||||||
|
fontSize: 16.sp, |
||||||
|
fontWeight: MyFontWeight.regular, |
||||||
|
color: Color(0xFF171717), |
||||||
|
), |
||||||
|
), |
||||||
|
SizedBox( |
||||||
|
height: 10, |
||||||
|
), |
||||||
|
Container( |
||||||
|
child: GridView.builder( |
||||||
|
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( |
||||||
|
crossAxisCount: 5, |
||||||
|
crossAxisSpacing: 24, |
||||||
|
mainAxisSpacing: 18, |
||||||
|
childAspectRatio: 1, |
||||||
|
), |
||||||
|
shrinkWrap: true, |
||||||
|
itemCount: 10, |
||||||
|
padding: EdgeInsets.zero, |
||||||
|
physics: NeverScrollableScrollPhysics(), |
||||||
|
itemBuilder: (context, position) { |
||||||
|
return InkWell( |
||||||
|
onTap: () { |
||||||
|
setState(() { |
||||||
|
peopleNum = position + 1; |
||||||
|
}); |
||||||
|
}, |
||||||
|
child: Container( |
||||||
|
decoration: BoxDecoration( |
||||||
|
color: peopleNum == (position + 1) |
||||||
|
? Color(0xFF32A060) |
||||||
|
: Colors.transparent, |
||||||
|
border: Border.all( |
||||||
|
color: Color(0xFF32A060), |
||||||
|
width: 1, |
||||||
|
), |
||||||
|
borderRadius: BorderRadius.circular(3), |
||||||
|
), |
||||||
|
alignment: Alignment.center, |
||||||
|
child: Text( |
||||||
|
"${position + 1}", |
||||||
|
style: TextStyle( |
||||||
|
color: peopleNum == (position + 1) |
||||||
|
? Colors.white |
||||||
|
: Color(0xFF32A060), |
||||||
|
fontWeight: MyFontWeight.regular, |
||||||
|
fontSize: 16.sp, |
||||||
|
), |
||||||
|
), |
||||||
|
), |
||||||
|
); |
||||||
|
}, |
||||||
|
), |
||||||
|
), |
||||||
|
SizedBox( |
||||||
|
height: 10, |
||||||
|
), |
||||||
|
RoundButton( |
||||||
|
text: "确定", |
||||||
|
width: 130.w, |
||||||
|
height: 34.h, |
||||||
|
textColor: Colors.white, |
||||||
|
fontSize: 16.sp, |
||||||
|
fontWeight: MyFontWeight.semi_bold, |
||||||
|
backgroup: Color(0xFF32A060), |
||||||
|
radius: 4.w, |
||||||
|
callback: () { |
||||||
|
// widget.callback(peopleNum); |
||||||
|
// SmartDialog.dismiss(); |
||||||
|
Navigator.of(context).pop(peopleNum); |
||||||
|
}, |
||||||
|
), |
||||||
|
], |
||||||
|
), |
||||||
|
), |
||||||
|
], |
||||||
|
), |
||||||
|
], |
||||||
|
); |
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue