提交 5d50372a authored 作者: maodou's avatar maodou

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

...@@ -140,6 +140,9 @@ class BookPayController extends GetxController { ...@@ -140,6 +140,9 @@ class BookPayController extends GetxController {
if (useCouponModel.couponId !=0){ if (useCouponModel.couponId !=0){
finalPrice = finalPrice - Decimal.parse(useCouponModel.reducedPrice??'0.00'); finalPrice = finalPrice - Decimal.parse(useCouponModel.reducedPrice??'0.00');
} }
if(finalPrice.toDouble() < 0){
finalPrice = Decimal.zero;
}
update(); update();
} }
...@@ -182,11 +185,13 @@ class BookPayController extends GetxController { ...@@ -182,11 +185,13 @@ class BookPayController extends GetxController {
} }
} }
final result = await ShopAPI.createOrder( final result = await ShopAPI.createOrder(
bookIdsList:jsonEncode(bookIdsList) , bookIdsList:jsonEncode(bookIdsList) ,
totalPrice: finalPrice.toString(), totalPrice: finalPrice.toString(),
couponRecId: useCouponModel.couponRecId.toString(), couponRecId: useCouponModel.couponRecId.toString(),
integral: creditPointModel.deductibleIntegral.toString(), integral: useCreditPoint?creditPointModel.deductibleIntegral.toString():'0',
type: payModel.type.toString() type: payModel.type.toString()
); );
payOrderModel = result; payOrderModel = result;
...@@ -217,6 +222,10 @@ class BookPayController extends GetxController { ...@@ -217,6 +222,10 @@ class BookPayController extends GetxController {
} }
String orderNumber = payOrderModel.ordersnum.toString(); String orderNumber = payOrderModel.ordersnum.toString();
//TODO: 拿到订单编号进行后续操作 //TODO: 拿到订单编号进行后续操作
Toast.show('订单支付完成');
if(context.mounted){
context.pop(true);
}
} }
...@@ -231,6 +240,9 @@ class BookPayController extends GetxController { ...@@ -231,6 +240,9 @@ class BookPayController extends GetxController {
requestOrderStatus(); requestOrderStatus();
} else { } else {
Toast.show(payResult['memo'].toString()); Toast.show(payResult['memo'].toString());
if(context.mounted){
context.pop(true);
}
} }
}); });
} }
...@@ -253,6 +265,9 @@ class BookPayController extends GetxController { ...@@ -253,6 +265,9 @@ class BookPayController extends GetxController {
} }
else{ else{
Toast.show('${response.errStr}'); Toast.show('${response.errStr}');
if(context.mounted){
context.pop(true);
}
} }
}); });
} }
......
...@@ -15,29 +15,67 @@ class _BookPayPageState extends State<BookPayPage> { ...@@ -15,29 +15,67 @@ class _BookPayPageState extends State<BookPayPage> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return GetBuilder<BookPayController>( return WillPopScope(
init: BookPayController(buy: widget.buy,context: context), onWillPop: () async {
builder: (controller) => Stack( context.pop(true);
children: [ return false;
Scaffold( },
backgroundColor: Colours.cF9, child: GetBuilder<BookPayController>(
appBar: AppBar(title: const Text('支付'),), init: BookPayController(buy: widget.buy,context: context),
body: SingleChildScrollView( builder: (controller) => Stack(
child: Column( children: [
children: [ Scaffold(
ListView.builder( backgroundColor: Colours.cF9,
physics: const NeverScrollableScrollPhysics(), appBar: AppBar(title: const Text('支付'),),
shrinkWrap:true, body: SingleChildScrollView(
itemBuilder: (BuildContext context, int index){ child: Column(
return BuildItem(model: controller.buy![index],); children: [
}, ListView.builder(
itemCount: controller.buy!.length, physics: const NeverScrollableScrollPhysics(),
), shrinkWrap:true,
controller.showModel.couponSwitch =='0' && controller.showModel.integralSwitch =='0'?const SizedBox():SizedBox(height: 10.w,), itemBuilder: (BuildContext context, int index){
Visibility( return BuildItem(model: controller.buy![index],);
visible: controller.showModel.couponSwitch =='0' && controller.showModel.integralSwitch =='0'?false:true, },
child: Container( itemCount: controller.buy!.length,
margin: EdgeInsets.only(left: 10.w,right: 10.w), ),
controller.showModel.couponSwitch =='0' && controller.showModel.integralSwitch =='0'?const SizedBox():SizedBox(height: 10.w,),
Visibility(
visible: controller.showModel.couponSwitch =='0' && controller.showModel.integralSwitch =='0'?false:true,
child: Container(
margin: EdgeInsets.only(left: 10.w,right: 10.w),
decoration: BoxDecoration(
borderRadius:BorderRadius.circular(8.w),
color: Colors.white,
boxShadow: [
BoxShadow(
color: Colours.cC7.withOpacity(0.5),
spreadRadius: 2.w,
blurRadius: 5.w,
offset: Offset(3.w, 0), // changes the position of the shadow
),
]
),
child: Column(
children: [
controller.showModel.couponSwitch =='0'?const SizedBox():GestureDetector(
child: _buildCouponWidget(controller,title: '优惠券',icon: 'assets/images/pay_coupon.png',),
onTap: (){
context.pushNamed(Routes.payCoupon,extra: controller);
},
),
Container(height: 0.5.w,color: Colours.cF0,margin: EdgeInsets.only(left: 10.w),),
controller.showModel.integralSwitch =='0'?const SizedBox(): GestureDetector(
child: _buildPointWidget(controller,title: '积分抵扣',icon: 'assets/images/pay_point.png',),
onTap: (){
context.pushNamed(Routes.creditPoints);
},
),
],
),
),
),
Container(
margin: EdgeInsets.only(left: 10.w,right: 10.w,top: 10.w),
decoration: BoxDecoration( decoration: BoxDecoration(
borderRadius:BorderRadius.circular(8.w), borderRadius:BorderRadius.circular(8.w),
color: Colors.white, color: Colors.white,
...@@ -46,99 +84,67 @@ class _BookPayPageState extends State<BookPayPage> { ...@@ -46,99 +84,67 @@ class _BookPayPageState extends State<BookPayPage> {
color: Colours.cC7.withOpacity(0.5), color: Colours.cC7.withOpacity(0.5),
spreadRadius: 2.w, spreadRadius: 2.w,
blurRadius: 5.w, blurRadius: 5.w,
offset: Offset(3.w, 0), // changes the position of the shadow offset: const Offset(3, 0), // changes the position of the shadow
), ),
] ]
), ),
child: Column( child: ListView.builder(
children: [ physics: const NeverScrollableScrollPhysics(),
controller.showModel.couponSwitch =='0'?const SizedBox():GestureDetector( padding: const EdgeInsets.symmetric(horizontal: 10),
child: _buildCouponWidget(controller,title: '优惠券',icon: 'assets/images/pay_coupon.png',), shrinkWrap:true,
onTap: (){ itemBuilder: (BuildContext context, int index){
context.pushNamed(Routes.payCoupon,extra: controller); PayModel model = controller.pays[index];
}, return GestureDetector(
), onTap: (){
Container(height: 0.5.w,color: Colours.cF0,margin: EdgeInsets.only(left: 10.w),), controller.setPayModel(model);
controller.showModel.integralSwitch =='0'?const SizedBox(): GestureDetector( },
child: _buildPointWidget(controller,title: '积分抵扣',icon: 'assets/images/pay_point.png',), child: BuildPayWay(model:model,));
onTap: (){ },
context.pushNamed(Routes.creditPoints); itemCount: controller.pays.length,
},
),
],
), ),
), ),
), ],
Container( ),
margin: EdgeInsets.only(left: 10.w,right: 10.w,top: 10.w),
decoration: BoxDecoration(
borderRadius:BorderRadius.circular(8.w),
color: Colors.white,
boxShadow: [
BoxShadow(
color: Colours.cC7.withOpacity(0.5),
spreadRadius: 2.w,
blurRadius: 5.w,
offset: const Offset(3, 0), // changes the position of the shadow
),
]
),
child: ListView.builder(
physics: const NeverScrollableScrollPhysics(),
padding: const EdgeInsets.symmetric(horizontal: 10),
shrinkWrap:true,
itemBuilder: (BuildContext context, int index){
PayModel model = controller.pays[index];
return GestureDetector(
onTap: (){
controller.setPayModel(model);
},
child: BuildPayWay(model:model,));
},
itemCount: controller.pays.length,
),
),
],
), ),
bottomNavigationBar: SafeArea(child:BuildPayCount(
payTap: (){
Console.log('--------------支付------------------');
controller.createOrder();
},
showTap: (){
controller.show();
Console.log('--------------展示优惠详情------------------');
}, controller: controller,
)),
), ),
bottomNavigationBar: SafeArea(child:BuildPayCount( controller.showDetail?Positioned(
payTap: (){ left: 0.w,
Console.log('--------------支付------------------'); bottom: 50.w,
controller.createOrder(); right: 0.w,
}, top: 0.w,
showTap: (){ child: GestureDetector(
onTap: (){
controller.show(); controller.show();
Console.log('--------------展示优惠详情------------------'); },
}, controller: controller, child: Container(
)), color:const Color(0xFF000000).withOpacity(0.5),
), child: Align(
controller.showDetail?Positioned( alignment: Alignment.bottomCenter,
left: 0.w, child: ClipRRect(
bottom: 50.w, borderRadius: BorderRadius.only(topRight: Radius.circular(8.w),topLeft: Radius.circular(8.w)),
right: 0.w, child: Container(
top: 0.w, height: 210.w,
child: GestureDetector( color: Colors.white,
onTap: (){ child: _buildPayDetail(controller),
controller.show(); ),
},
child: Container(
color:const Color(0xFF000000).withOpacity(0.5),
child: Align(
alignment: Alignment.bottomCenter,
child: ClipRRect(
borderRadius: BorderRadius.only(topRight: Radius.circular(8.w),topLeft: Radius.circular(8.w)),
child: Container(
height: 210.w,
color: Colors.white,
child: _buildPayDetail(controller),
), ),
), ),
), ),
), ),
), ):const SizedBox()
):const SizedBox() ],
], )
) ),
); );
} }
......
...@@ -54,7 +54,7 @@ class BuildCounter extends StatelessWidget { ...@@ -54,7 +54,7 @@ class BuildCounter extends StatelessWidget {
if (controller.num > 0){ if (controller.num > 0){
final result = await context.pushNamed(Routes.bookPay,extra: controller.buy); final result = await context.pushNamed(Routes.bookPay,extra: controller.buy);
if (result == true) { if (result == true) {
controller.getCart(); controller.onRefresh();
} }
} }
}, },
......
...@@ -84,7 +84,7 @@ class _ReadPageState extends State<ReadPage> { ...@@ -84,7 +84,7 @@ class _ReadPageState extends State<ReadPage> {
}, },
onConsoleMessage: (controller, consoleMessage) { onConsoleMessage: (controller, consoleMessage) {
// 接收从 WebView 发送的消息 // 接收从 WebView 发送的消息
print("Received message from WebView: ${consoleMessage.message}"); Console.log("Received message from WebView-----------------------------: ${consoleMessage.message}");
}, },
onLoadStop: (controller, url) { onLoadStop: (controller, url) {
// flutter 主动给 js 传参数 // flutter 主动给 js 传参数
...@@ -94,6 +94,7 @@ class _ReadPageState extends State<ReadPage> { ...@@ -94,6 +94,7 @@ class _ReadPageState extends State<ReadPage> {
'token':UserStore.to.token 'token':UserStore.to.token
}; };
String str = '${readController.bookId},${readController.chapterId},${UserStore.to.token}'; String str = '${readController.bookId},${readController.chapterId},${UserStore.to.token}';
Console.log('传给前端的参数--------------------------------$str');
controller.evaluateJavascript(source: 'callbackInFlutterComponent("$str");'); controller.evaluateJavascript(source: 'callbackInFlutterComponent("$str");');
// 添加单击事件 // 添加单击事件
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论