diff --git a/lib/ui/market/search/good_detail_page.dart b/lib/ui/market/search/good_detail_page.dart index a6e9895b..682d9b52 100644 --- a/lib/ui/market/search/good_detail_page.dart +++ b/lib/ui/market/search/good_detail_page.dart @@ -123,7 +123,7 @@ class _GoodDetailPageState extends State { controller: _refreshController, onRefresh: () async { _goodDetail = await SearchFunc.getGoodDetail( - widget.goodId, _addressModel?.location); + widget.goodId, _addressModel?.id); // _imageList = await SearchFunc.getGoodDetailImage(widget.goodId); if (_goodDetail != GoodDetailModel.fail()) { _onload = false; diff --git a/lib/ui/market/search/search_func.dart b/lib/ui/market/search/search_func.dart index 26a785a3..bf8ba384 100644 --- a/lib/ui/market/search/search_func.dart +++ b/lib/ui/market/search/search_func.dart @@ -7,6 +7,7 @@ import 'package:aku_new_community/utils/network/base_list_model.dart'; import 'package:aku_new_community/utils/network/base_model.dart'; import 'package:aku_new_community/utils/network/net_util.dart'; import 'package:aku_new_community/utils/text_utils.dart'; +import 'package:bot_toast/bot_toast.dart'; class SearchFunc { /// 搜索商品 根据关键字 @@ -73,11 +74,15 @@ class SearchFunc { } ///加入购物车 - static Future addGoodsCar(int jcookGoodsId) async { - BaseModel model = await NetUtil().post(SAASAPI.market.shopCart.insert, - params: {'appGoodsPushId': jcookGoodsId}, showMessage: true); - if (model.msg == null) return ''; - return model.msg as String; + static Future addGoodsCar(int jcookGoodsId) async { + BaseModel model = await NetUtil().get( + SAASAPI.market.shopCart.insert, + params: {'appGoodsPushId': jcookGoodsId}, + ); + if (!model.success) { + BotToast.showText(text: model.msg); + } + return model.success; } ///确认收货 diff --git a/lib/ui/market/search/submit_order_page_normal.dart b/lib/ui/market/search/submit_order_page_normal.dart index 3081add0..e707eec6 100644 --- a/lib/ui/market/search/submit_order_page_normal.dart +++ b/lib/ui/market/search/submit_order_page_normal.dart @@ -9,6 +9,7 @@ import 'package:aku_new_community/pages/life_pay/pay_util.dart'; import 'package:aku_new_community/pages/personal/address/address_list_page.dart'; import 'package:aku_new_community/provider/app_provider.dart'; import 'package:aku_new_community/ui/market/order/order_page.dart'; +import 'package:aku_new_community/ui/market/search/search_func.dart'; import 'package:aku_new_community/ui/market/search/settlementGoodsDTO.dart'; import 'package:aku_new_community/ui/market/shop_car/shop_car_func.dart'; import 'package:aku_new_community/utils/headers.dart'; @@ -18,6 +19,7 @@ import 'package:aku_new_community/widget/bee_scaffold.dart'; import 'package:aku_new_community/widget/buttons/end_button.dart'; import 'package:aku_new_community/widget/others/user_tool.dart'; import 'package:bot_toast/bot_toast.dart'; +import 'package:common_utils/common_utils.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; @@ -46,7 +48,7 @@ class _SubmitOrderNormalPageState extends State { List _goodsList = []; AddressModel? _addressModel; CreateOrderModel? _createOrderModel; - double _allPrice = 0; + double totalPrice = 0; @override void initState() { @@ -73,11 +75,18 @@ class _SubmitOrderNormalPageState extends State { Future createOrder( int addressId, List goodsList) async { + try { + for (var item in goodsList) { + await SearchFunc.addGoodsCar(item.appGoodsPushId!); + } + } catch (e) { + print(e.toString()); + } BaseModel model = await NetUtil().post( SAASAPI.market.shopCart.settlement, params: { 'addressId': addressId, - 'settlementGoodsDTOList': goodsList.map((v) => v.toJson()).toList() + 'settlementGoodsList': goodsList.map((v) => v.toJson()).toList() }, ); if (model.data == null) { @@ -149,7 +158,7 @@ class _SubmitOrderNormalPageState extends State { "settlementGoodsDTOList": _goodsList.map((v) => v.toJson()).toList(), "payType": 10, //暂时写死 等待后续补充 - "payPrice": _allPrice, + "payPrice": totalPrice, 'points': widget.integral, }); if (baseModel.success) { @@ -185,7 +194,7 @@ class _SubmitOrderNormalPageState extends State { "settlementGoodsDTOList": _goodsList.map((v) => v.toJson()).toList(), "payType": 1, //暂时写死 等待后续补充 - "payPrice": _allPrice, + "payPrice": totalPrice, // 'points': widget.integral, "residentId": UserTool.userProvider.userInfoModel!.id, "payname": UserTool.userProvider.userInfoModel!.name, @@ -350,10 +359,11 @@ class _SubmitOrderNormalPageState extends State { } int num = int.parse(_controllers.text); - allNum += num; - allPrice += (widget.goodModel.sellPrice * num); + allNum = NumUtil.add(allNum, num).toInt(); + allPrice = NumUtil.add( + allPrice, NumUtil.multiply(widget.goodModel.sellPrice, num)); - _allPrice = allPrice + fee; + totalPrice = NumUtil.add(allPrice, fee); return Container( padding: @@ -400,7 +410,7 @@ class _SubmitOrderNormalPageState extends State { children: [ Spacer(), '应付金额:'.text.size(32.sp).color(Color(0xFF333333)).bold.make(), - '¥${allPrice + fee}' + '¥${totalPrice}' .text .size(32.sp) .color(Color(0xFFE52E2E)) diff --git a/lib/utils/network/net_util.dart b/lib/utils/network/net_util.dart index d93575f0..cc890137 100644 --- a/lib/utils/network/net_util.dart +++ b/lib/utils/network/net_util.dart @@ -124,9 +124,8 @@ class NetUtil { }) async { try { Response res = await _dio!.get(path, queryParameters: params); - var base = BaseModel.fromJson(res.data); - if (base.success) { - BaseListModel baseListModel = BaseListModel.fromJson(base.data); + if (res.data['success']) { + BaseListModel baseListModel = BaseListModel.fromJson(res.data['data']); return baseListModel; } else { return BaseListModel.err();