提交 e92deee8 authored 作者: yueweilu's avatar yueweilu

支付前的逻辑

上级 0742a081
...@@ -4,5 +4,5 @@ keyPassword=123456 ...@@ -4,5 +4,5 @@ keyPassword=123456
keyAlias=zijing keyAlias=zijing
#storeFile=/Users/apple/zijiing_key.jks storeFile=/Users/apple/zijiing_key.jks
storeFile=zijiing_key.jks #storeFile=zijiing_key.jks
\ No newline at end of file \ No newline at end of file
...@@ -477,6 +477,7 @@ ...@@ -477,6 +477,7 @@
buildSettings = { buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
DEVELOPMENT_TEAM = MYN43C5WGE;
ENABLE_BITCODE = NO; ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist; INFOPLIST_FILE = Runner/Info.plist;
INFOPLIST_KEY_CFBundleDisplayName = "紫荆数智学堂"; INFOPLIST_KEY_CFBundleDisplayName = "紫荆数智学堂";
...@@ -644,6 +645,7 @@ ...@@ -644,6 +645,7 @@
buildSettings = { buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
DEVELOPMENT_TEAM = MYN43C5WGE;
ENABLE_BITCODE = NO; ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist; INFOPLIST_FILE = Runner/Info.plist;
INFOPLIST_KEY_CFBundleDisplayName = "紫荆数智学堂"; INFOPLIST_KEY_CFBundleDisplayName = "紫荆数智学堂";
...@@ -664,6 +666,7 @@ ...@@ -664,6 +666,7 @@
buildSettings = { buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
DEVELOPMENT_TEAM = MYN43C5WGE;
ENABLE_BITCODE = NO; ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist; INFOPLIST_FILE = Runner/Info.plist;
INFOPLIST_KEY_CFBundleDisplayName = "紫荆数智学堂"; INFOPLIST_KEY_CFBundleDisplayName = "紫荆数智学堂";
......
...@@ -52,9 +52,10 @@ class MyApp extends StatelessWidget { ...@@ -52,9 +52,10 @@ class MyApp extends StatelessWidget {
behavior: _NoShadowScrollBehavior(), behavior: _NoShadowScrollBehavior(),
child: OKToast( child: OKToast(
radius: 8.0, radius: 8.0,
backgroundColor: AppTheme.primary, backgroundColor: const Color(0xFF000000).withOpacity(0.2),
textPadding: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 10.0), textPadding: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 10.0),
position: ToastPosition.bottom, position: ToastPosition.bottom,
// textStyle: ,
child: child ?? const Material(), child: child ?? const Material(),
), ),
); );
......
...@@ -70,23 +70,30 @@ class CreditPointModel { ...@@ -70,23 +70,30 @@ class CreditPointModel {
class ShowModel { class ShowModel {
ShowModel({ ShowModel({
this.couponSwitch, this.couponSwitch,
this.integralSwitch,}); this.integralSwitch,
this.membersBean,
});
ShowModel.fromJson(dynamic json) { ShowModel.fromJson(dynamic json) {
couponSwitch = json['coupon_switch']; couponSwitch = json['coupon_switch'];
integralSwitch = json['integral_switch']; integralSwitch = json['integral_switch'];
membersBean = json['members_bean'];
} }
String? couponSwitch; String? couponSwitch;
String? integralSwitch; String? integralSwitch;
String? membersBean;
ShowModel copyWith({ String? couponSwitch, ShowModel copyWith({ String? couponSwitch,
String? integralSwitch, String? integralSwitch,
String? membersBean,
}) => ShowModel( couponSwitch: couponSwitch ?? this.couponSwitch, }) => ShowModel( couponSwitch: couponSwitch ?? this.couponSwitch,
integralSwitch: integralSwitch ?? this.integralSwitch, integralSwitch: integralSwitch ?? this.integralSwitch,
membersBean: membersBean ?? this.integralSwitch
); );
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
final map = <String, dynamic>{}; final map = <String, dynamic>{};
map['coupon_switch'] = couponSwitch; map['coupon_switch'] = couponSwitch;
map['integral_switch'] = integralSwitch; map['integral_switch'] = integralSwitch;
map['members_bean'] = membersBean;
return map; return map;
} }
...@@ -161,7 +168,10 @@ class PayOrderModel { ...@@ -161,7 +168,10 @@ class PayOrderModel {
this.timestamp, this.timestamp,
this.sign, this.sign,
this.ordersnum, this.ordersnum,
this.encryptionOrder,}); this.encryptionOrder,
this.code,
String? msg,
});
PayOrderModel.fromJson(dynamic json) { PayOrderModel.fromJson(dynamic json) {
appid = json['appid']; appid = json['appid'];
...@@ -173,6 +183,8 @@ class PayOrderModel { ...@@ -173,6 +183,8 @@ class PayOrderModel {
sign = json['sign']; sign = json['sign'];
ordersnum = json['ordersnum']; ordersnum = json['ordersnum'];
encryptionOrder = json['encryption_order']; encryptionOrder = json['encryption_order'];
code = json['code'];
msg = json['msg'];
} }
String? appid; String? appid;
String? partnerid; String? partnerid;
...@@ -183,6 +195,8 @@ class PayOrderModel { ...@@ -183,6 +195,8 @@ class PayOrderModel {
String? sign; String? sign;
String? ordersnum; String? ordersnum;
String? encryptionOrder; String? encryptionOrder;
num? code;
String? msg;
PayOrderModel copyWith({ String? appid, PayOrderModel copyWith({ String? appid,
String? partnerid, String? partnerid,
String? prepayid, String? prepayid,
...@@ -192,6 +206,8 @@ class PayOrderModel { ...@@ -192,6 +206,8 @@ class PayOrderModel {
String? sign, String? sign,
String? ordersnum, String? ordersnum,
String? encryptionOrder, String? encryptionOrder,
num? code,
String? msg,
}) => PayOrderModel( appid: appid ?? this.appid, }) => PayOrderModel( appid: appid ?? this.appid,
partnerid: partnerid ?? this.partnerid, partnerid: partnerid ?? this.partnerid,
prepayid: prepayid ?? this.prepayid, prepayid: prepayid ?? this.prepayid,
...@@ -201,6 +217,8 @@ class PayOrderModel { ...@@ -201,6 +217,8 @@ class PayOrderModel {
sign: sign ?? this.sign, sign: sign ?? this.sign,
ordersnum: ordersnum ?? this.ordersnum, ordersnum: ordersnum ?? this.ordersnum,
encryptionOrder: encryptionOrder ?? this.encryptionOrder, encryptionOrder: encryptionOrder ?? this.encryptionOrder,
code: code ?? this.code,
msg: msg?? this.msg,
); );
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
final map = <String, dynamic>{}; final map = <String, dynamic>{};
...@@ -213,6 +231,8 @@ class PayOrderModel { ...@@ -213,6 +231,8 @@ class PayOrderModel {
map['sign'] = sign; map['sign'] = sign;
map['ordersnum'] = ordersnum; map['ordersnum'] = ordersnum;
map['encryption_order'] = encryptionOrder; map['encryption_order'] = encryptionOrder;
map['code'] = code;
map['msg'] = msg;
return map; return map;
} }
......
...@@ -39,6 +39,14 @@ class BookDetailController extends GetxController with GetSingleTickerProviderSt ...@@ -39,6 +39,14 @@ class BookDetailController extends GetxController with GetSingleTickerProviderSt
super.onClose(); super.onClose();
} }
/// 加入书架
void addCart(String bookId) async {
final result = await ShopAPI.addCart(bookId: bookId);
if(result){
Toast.show('添加购物车成功');
}
}
/// 获取目录信息 /// 获取目录信息
void _getChapters() async { void _getChapters() async {
chapters = await LibraryAPI.chapters(bookId: bookId); chapters = await LibraryAPI.chapters(bookId: bookId);
......
...@@ -98,7 +98,12 @@ class _BookDetailPageState extends State<BookDetailPage> with SingleTickerProvid ...@@ -98,7 +98,12 @@ class _BookDetailPageState extends State<BookDetailPage> with SingleTickerProvid
Expanded( Expanded(
child: GestureDetector( child: GestureDetector(
onTap: (){ onTap: (){
context.pushNamed(Routes.studyReport,queryParameters: {'book_id':widget.bookId}); if(controller.bookDetails.isHave ==1){
context.pushNamed(Routes.studyReport,queryParameters: {'book_id':widget.bookId});
}
else{
controller.addCart(widget.bookId);
}
}, },
child: Container( child: Container(
alignment: Alignment.center, alignment: Alignment.center,
...@@ -126,7 +131,22 @@ class _BookDetailPageState extends State<BookDetailPage> with SingleTickerProvid ...@@ -126,7 +131,22 @@ class _BookDetailPageState extends State<BookDetailPage> with SingleTickerProvid
/// 没有购买并且没有试读直接跳转 购买页 /// 没有购买并且没有试读直接跳转 购买页
bool noTryRead = true; bool noTryRead = true;
if(controller.bookDetails.isHave == 0 && noTryRead){ if(controller.bookDetails.isHave == 0 && noTryRead){
context.pushNamed(Routes.bookPay); List<CourseModel> buy = [];
CourseModel model= CourseModel(
bookId: controller.bookDetails.bookId,
price: controller.bookDetails.price,
vipPrice: controller.bookDetails.vipPrice,
img: controller.bookDetails.img,
bookName: controller.bookDetails.bookName,
cartId: 0,
status: 1,
selected: true
);
buy.add(model);
context.pushNamed(Routes.bookPay,extra: buy);
}
else {
context.pushNamed(Routes.web);
} }
}, },
child: Container( child: Container(
......
...@@ -113,9 +113,11 @@ class BookPayController extends GetxController { ...@@ -113,9 +113,11 @@ class BookPayController extends GetxController {
if (model.status == 1){ if (model.status == 1){
if (model.selected == true){ if (model.selected == true){
price = price + Decimal.parse(model.vipPrice??'0.00'); price = price + Decimal.parse(model.vipPrice??'0.00');
print('==============11111111111==================$price');
} }
} }
} }
print('================================$price');
return price.toDouble(); return price.toDouble();
} }
...@@ -145,7 +147,11 @@ class BookPayController extends GetxController { ...@@ -145,7 +147,11 @@ class BookPayController extends GetxController {
bookIdsList.add(tempMap); bookIdsList.add(tempMap);
} }
// 书豆支付的话先判断书豆数量
if (finalPrice.toDouble() > double.parse(showModel.membersBean.toString())){
Toast.show('紫金币不足,请先充值紫荆币');
return;
}
final result = await CommonAPI.createOrder( final result = await CommonAPI.createOrder(
bookIdsList:jsonEncode(bookIdsList) , bookIdsList:jsonEncode(bookIdsList) ,
totalPrice: finalPrice.toString(), totalPrice: finalPrice.toString(),
...@@ -155,6 +161,26 @@ class BookPayController extends GetxController { ...@@ -155,6 +161,26 @@ class BookPayController extends GetxController {
); );
payOrderModel = result; payOrderModel = result;
// 微信
if(payModel.type == 1){
String orderNumber = payOrderModel.ordersnum.toString();
//TODO: 拿到订单编号进行微信支付操作
}
// 支付宝
else if(payModel.type == 2){
String orderNumber = payOrderModel.ordersnum.toString();
//TODO: 拿到订单编号进行支付宝支付操作
}
// 书豆
else if (payModel.type == 3){
if(payOrderModel.code == -1){
Toast.show('紫金币不足,请先充值紫荆币');
}
String orderNumber = payOrderModel.ordersnum.toString();
//TODO: 拿到订单编号进行后续操作
}
} }
......
...@@ -152,7 +152,7 @@ class BookshopController extends GetxController { ...@@ -152,7 +152,7 @@ class BookshopController extends GetxController {
); );
// 如果是刷新 清理数据 // 如果是刷新 清理数据
if (isRefresh) carts.clear(); if (isRefresh) carts.clear();
carts.addAll(_test()); // carts.addAll(_test());
carts.addAll(result); carts.addAll(result);
_page ++; _page ++;
_noMore = result.length < _limit; _noMore = result.length < _limit;
......
...@@ -26,8 +26,6 @@ class PayCouponController extends GetxController with GetSingleTickerProviderSta ...@@ -26,8 +26,6 @@ class PayCouponController extends GetxController with GetSingleTickerProviderSta
int _page = 1; int _page = 1;
bool _noMore = false; bool _noMore = false;
final String price = '200';
...@@ -38,7 +36,7 @@ class PayCouponController extends GetxController with GetSingleTickerProviderSta ...@@ -38,7 +36,7 @@ class PayCouponController extends GetxController with GetSingleTickerProviderSta
page: _page, page: _page,
limit: _limit, limit: _limit,
type: tag, type: tag,
price: price price: payController.finalPrice.toString()
); );
for(CouponModel model in result.list!) { for(CouponModel model in result.list!) {
print('================================${tag}'); print('================================${tag}');
......
...@@ -20,116 +20,119 @@ class _ReadPageState extends State<ReadPage> { ...@@ -20,116 +20,119 @@ class _ReadPageState extends State<ReadPage> {
return GetBuilder<ReadController>( return GetBuilder<ReadController>(
init: ReadController(), init: ReadController(),
builder: (readController) => Scaffold( builder: (readController) => Scaffold(
// appBar: AppBar(title:const Text('章节名称'),), appBar: AppBar(title:const Text('阅读'),),
body: Stack( body: Container(
children: [ color: Colors.white,
Container( child: Stack(
height: 40, children: [
width: double.infinity, Container(
color: Colors.lightBlue, height: 40,
), width: double.infinity,
InAppWebView( color: Colors.lightBlue,
initialUrlRequest: URLRequest(
url: Uri.parse('http://192.168.11.39:5500/'),
), ),
onWebViewCreated: (InAppWebViewController controller) { InAppWebView(
webViewController = controller; initialUrlRequest: URLRequest(
}, url: Uri.parse('http://192.168.11.39:5500/'),
// onLoadError: (InAppWebViewController controller, Uri url, int code ,String msg){ ),
// onWebViewCreated: (InAppWebViewController controller) {
// }, webViewController = controller;
contextMenu: ContextMenu( },
menuItems: [ // onLoadError: (InAppWebViewController controller, Uri url, int code ,String msg){
ContextMenuItem(title: '划线',androidId: 1,iosId: '1',action: (){ //
const snackBar = SnackBar( // },
content: Text("划线"), contextMenu: ContextMenu(
duration: Duration(seconds: 1), menuItems: [
ContextMenuItem(title: '划线',androidId: 1,iosId: '1',action: (){
const snackBar = SnackBar(
content: Text("划线"),
duration: Duration(seconds: 1),
);
ScaffoldMessenger.of(context).showSnackBar(snackBar);
}),
ContextMenuItem(title: '提问',androidId: 2,iosId: '2',action: (){
}),
ContextMenuItem(title: '笔记',androidId: 3,iosId: '3',action: (){
}),
],
onCreateContextMenu: (hitTestResult) async {
String selectedText = await webViewController?.getSelectedText() ?? "";
final snackBar = SnackBar(
content: Text(
"Selected text: '$selectedText', of type: ${hitTestResult.type.toString()}"),
duration: const Duration(seconds: 1),
);
ScaffoldMessenger.of(context).showSnackBar(snackBar);
},
// options: ContextMenuOptions(
// hideDefaultSystemContextMenuItems: true,
// ),
onContextMenuActionItemClicked: (ContextMenuItem menuItem) async {
final snackBar = SnackBar(
content: Text(
"Menu item with ID ${menuItem.iosId} and title '${menuItem.title}' clicked!"),
duration: const Duration(seconds: 1),
); );
ScaffoldMessenger.of(context).showSnackBar(snackBar); ScaffoldMessenger.of(context).showSnackBar(snackBar);
}),
ContextMenuItem(title: '提问',androidId: 2,iosId: '2',action: (){
}), // switch (item.title){
ContextMenuItem(title: '笔记',androidId: 3,iosId: '3',action: (){ // case '划线':
// Console.log('----------划线-----------');
// break;
// case '提问':
// Console.log('----------提问-----------');
// break;
// case '笔记':
// Console.log('----------笔记-----------');
// break;
//
// }
}
}), ),
onLoadStop: (controller, url) {
controller.addJavaScriptHandler(handlerName: 'onTap', callback: (args){
readController.setShow(readController.show);
], });
onCreateContextMenu: (hitTestResult) async { controller.evaluateJavascript(source: '''
String selectedText = await webViewController?.getSelectedText() ?? ""; document.addEventListener('click', function() {
final snackBar = SnackBar( window.flutter_inappwebview.callHandler('onTap');
content: Text( });
"Selected text: '$selectedText', of type: ${hitTestResult.type.toString()}"), ''');
duration: const Duration(seconds: 1),
);
ScaffoldMessenger.of(context).showSnackBar(snackBar);
}, },
// options: ContextMenuOptions(
// hideDefaultSystemContextMenuItems: true,
// ),
onContextMenuActionItemClicked: (ContextMenuItem menuItem) async {
final snackBar = SnackBar(
content: Text(
"Menu item with ID ${menuItem.iosId} and title '${menuItem.title}' clicked!"),
duration: const Duration(seconds: 1),
);
ScaffoldMessenger.of(context).showSnackBar(snackBar);
// switch (item.title){
// case '划线':
// Console.log('----------划线-----------');
// break;
// case '提问':
// Console.log('----------提问-----------');
// break;
// case '笔记':
// Console.log('----------笔记-----------');
// break;
//
// }
}
), ),
onLoadStop: (controller, url) { AnimatedPositioned(
controller.addJavaScriptHandler(handlerName: 'onTap', callback: (args){ duration: readController.controller.duration!,
readController.setShow(readController.show); curve: Curves.easeInOut,
top: readController.show ? 0 : -100, // 负值隐藏,0 显示
}); left: 0,
controller.evaluateJavascript(source: ''' right: 0,
document.addEventListener('click', function() { height: 100,
window.flutter_inappwebview.callHandler('onTap'); child: Container(
}); color: Colors.limeAccent,
'''); alignment: Alignment.center,
}, child: Text('top View'),
), ),
AnimatedPositioned(
duration: readController.controller.duration!,
curve: Curves.easeInOut,
top: readController.show ? 0 : -100, // 负值隐藏,0 显示
left: 0,
right: 0,
height: 100,
child: Container(
color: Colors.limeAccent,
alignment: Alignment.center,
child: Text('top View'),
), ),
), AnimatedPositioned(
AnimatedPositioned( duration: readController.controller.duration!,
duration: readController.controller.duration!, curve: Curves.easeInOut,
curve: Curves.easeInOut, bottom: readController.show ? 0 : -100, // 负值隐藏,0 显示
bottom: readController.show ? 0 : -100, // 负值隐藏,0 显示 left: 0,
left: 0, right: 0,
right: 0, height: 100,
height: 100, child: Container(
child: Container( color: Colors.limeAccent,
color: Colors.limeAccent, alignment: Alignment.center,
alignment: Alignment.center, child: Text('Bottom View'),
child: Text('Bottom View'), ),
), ),
),
], ],
),
), ),
), ),
); );
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论