From f2bc6100200ceb0d927cc0f950a14ccb74eb13c3 Mon Sep 17 00:00:00 2001 From: fmk Date: Tue, 19 Oct 2021 19:00:17 +0800 Subject: [PATCH 01/20] safety --- lib/community/community_child_page.dart | 61 ++-- lib/retrofit/data/settlement_bean.dart | 8 +- lib/retrofit/data/shoppingCart.dart | 14 +- lib/retrofit/min_api.dart | 33 +- lib/retrofit/min_api.g.dart | 110 +++++- lib/retrofit/retrofit_api.dart | 8 +- lib/store/sku.dart | 71 ++++ lib/store/store_order.dart | 210 +++++------- lib/store/store_view/product_sku.dart | 75 +++-- lib/store/store_view/settlement.dart | 29 +- .../settlement_order_commodity.dart | 11 +- lib/store/store_view/shop_car.dart | 317 ++++++++---------- lib/store/store_view/shop_goods.dart | 36 +- lib/store/store_view/store_order_list.dart | 68 ++-- 14 files changed, 588 insertions(+), 463 deletions(-) create mode 100644 lib/store/sku.dart diff --git a/lib/community/community_child_page.dart b/lib/community/community_child_page.dart index 0f0660a5..cb1d5100 100644 --- a/lib/community/community_child_page.dart +++ b/lib/community/community_child_page.dart @@ -77,37 +77,38 @@ class _CommunityChildPage extends State { future: queryCommunity(), builder: (context, position) { return SmartRefresher( - controller: refreshController, - enablePullDown: true, - enablePullUp: true, - physics: BouncingScrollPhysics(), - header: MyHeader(), - footer: CustomFooter( - builder: (context, mode) { - return MyFooter(mode); - }, - ), - onRefresh: _onRefresh, - onLoading: () { - setState(() {}); + controller: refreshController, + enablePullDown: true, + enablePullUp: true, + physics: BouncingScrollPhysics(), + header: MyHeader(), + footer: CustomFooter( + builder: (context, mode) { + return MyFooter(mode); }, - child: ListView.builder( - physics: NeverScrollableScrollPhysics(), - itemBuilder: (context, position) { - return InkWell( - child: CommunityDynamic(comments[position]), - onTap: () { - Navigator.of(context).pushNamed( - '/router/community_details', - arguments: { - "comment": comments[position], - }, - ); - }, - ); - }, - itemCount: comments.length, - )); + ), + onRefresh: _onRefresh, + onLoading: () { + setState(() {}); + }, + child: ListView.builder( + physics: NeverScrollableScrollPhysics(), + itemBuilder: (context, position) { + return InkWell( + child: CommunityDynamic(comments[position]), + onTap: () { + Navigator.of(context).pushNamed( + '/router/community_details', + arguments: { + "comment": comments[position], + }, + ); + }, + ); + }, + itemCount: comments.length, + ), + ); }, ); } diff --git a/lib/retrofit/data/settlement_bean.dart b/lib/retrofit/data/settlement_bean.dart index 8315b8b5..5cee84b3 100644 --- a/lib/retrofit/data/settlement_bean.dart +++ b/lib/retrofit/data/settlement_bean.dart @@ -172,7 +172,7 @@ class OrderProductVOList { int returnStatus, int returnType, int sellPrice, - int skuId, + String skuId, String skuImg, String skuNameStr,}){ _actInfo = actInfo; @@ -227,7 +227,7 @@ class OrderProductVOList { int _returnStatus; int _returnType; int _sellPrice; - int _skuId; + String _skuId; String _skuImg; String _skuNameStr; @@ -245,7 +245,7 @@ class OrderProductVOList { int get returnStatus => _returnStatus; int get returnType => _returnType; int get sellPrice => _sellPrice; - int get skuId => _skuId; + String get skuId => _skuId; String get skuImg => _skuImg; String get skuNameStr => _skuNameStr; @@ -334,7 +334,7 @@ class OrderProductVOList { _sellPrice = value; } - set skuId(int value) { + set skuId(String value) { _skuId = value; } diff --git a/lib/retrofit/data/shoppingCart.dart b/lib/retrofit/data/shoppingCart.dart index fb69d382..78a1794a 100644 --- a/lib/retrofit/data/shoppingCart.dart +++ b/lib/retrofit/data/shoppingCart.dart @@ -7,13 +7,13 @@ /// tableId : 0 class ShoppingCart { - int cartSum; + String cartSum; int numberOfPeople; int selected; List shoppingCartSkuItemList; - int storeId; + String storeId; String storeName; - int tableId; + String tableId; static ShoppingCart fromJson(Map map) { if (map == null) return null; @@ -59,8 +59,8 @@ class ShoppingCart { class ShoppingCartSkuItemListBean { int buyNum; String createTime; - int groupId; - int id; + String groupId; + String id; List platterList; String productId; String productName; @@ -68,7 +68,7 @@ class ShoppingCartSkuItemListBean { int selected; String skuImg; String skuName; - int skuPrice; + String skuPrice; int skuStock; String storeId; int tableId; @@ -126,7 +126,7 @@ class PlatterListBean { int id; int productId; bool required; - int skuId; + String skuId; static PlatterListBean fromJson(Map map) { if (map == null) return null; diff --git a/lib/retrofit/min_api.dart b/lib/retrofit/min_api.dart index 53d6ccc9..a470375f 100644 --- a/lib/retrofit/min_api.dart +++ b/lib/retrofit/min_api.dart @@ -42,6 +42,7 @@ abstract class MinApiService { BuildContext context, String token, String tenant, + String storeId, bool showLoading = true, bool pay = false, }) { @@ -50,6 +51,9 @@ abstract class MinApiService { if (tenant != null && tenant != "") { headers["tenant"] = tenant; } + if (storeId != null && storeId != "") { + headers["store_id"] = storeId; + } if (pay) { headers["Environment"] = "app"; } @@ -83,10 +87,9 @@ abstract class MinApiService { EasyLoading.dismiss(); } debugPrint("code = ${response.statusCode}"); - // p(jsonEncode(response.data)); + p(jsonEncode(response.data)); - debugPrint(jsonEncode(response.data), - wrapWidth: response.data.toString().length); + // debugPrint(jsonEncode(response.data), wrapWidth: response.data.toString().length); Map map = response.data; if (map["code"] != 0) { @@ -124,10 +127,10 @@ abstract class MinApiService { static void p(String msg) { int maxStrLength = 900; while (msg.length > maxStrLength) { - debugPrint(msg.substring(0, maxStrLength)); + debugPrint(msg.substring(0, maxStrLength), wrapWidth: maxStrLength); msg = msg.substring(maxStrLength); } - debugPrint(msg); + debugPrint(msg, wrapWidth: maxStrLength); } ///小程序查询分组及商品列表 @@ -141,8 +144,23 @@ abstract class MinApiService { ///添加购物车 @POST("shoppingcart") - Future> shoppingCart( - @Body() Map param, Map header); + Future>> addShoppingCart(@Body() Map param); + + ///获取购物车商品 + @GET("shoppingcart") ///?tableId={tableId} + Future>> getShoppingCart(@Query("tableId") int tableId); + + ///清空购物车商品 + @GET("shoppingcart/delCart") + Future> clearShoppingCart(); + + ///修改购物车 + @PUT("shoppingcart") + Future>> shoppingCart1(@Body() Map param); + + ///修改购物车商品数量 + @PUT("shoppingcart/single") + Future>> shoppingCartSingle(@Body() Map param); ///订单结算信息 @POST("order/getOrderInfo") @@ -154,7 +172,6 @@ abstract class MinApiService { @POST("order/placeOrderFirst") Future placeOrderFirst(@Body() Map param); - /// 结算 @POST("order/settlement") Future settlementApi(@Body() Map param); diff --git a/lib/retrofit/min_api.g.dart b/lib/retrofit/min_api.g.dart index dbd499fb..efe149f7 100644 --- a/lib/retrofit/min_api.g.dart +++ b/lib/retrofit/min_api.g.dart @@ -64,9 +64,8 @@ class _MinApiService implements MinApiService { } @override - Future> shoppingCart(param, header) async { + Future>> addShoppingCart(param) async { ArgumentError.checkNotNull(param, 'param'); - ArgumentError.checkNotNull(header, 'header'); const _extra = {}; final queryParameters = {}; final _data = {}; @@ -79,13 +78,108 @@ class _MinApiService implements MinApiService { extra: _extra, baseUrl: baseUrl), data: _data); - final value = BaseData.fromJson( + final value = BaseData>.fromJson( + _result.data, + (json) => (json as List) + .map( + (i) => ShoppingCart.fromJson(i as Map)) + .toList()); + return value; + } + + @override + Future>> getShoppingCart(tableId) async { + ArgumentError.checkNotNull(tableId, 'tableId'); + const _extra = {}; + final queryParameters = {r'tableId': tableId}; + final _data = {}; + final _result = await _dio.request>('shoppingcart', + queryParameters: queryParameters, + options: RequestOptions( + method: 'GET', + headers: {}, + extra: _extra, + baseUrl: baseUrl), + data: _data); + final value = BaseData>.fromJson( + _result.data, + (json) => (json as List) + .map( + (i) => ShoppingCart.fromJson(i as Map)) + .toList()); + return value; + } + + @override + Future> clearShoppingCart() async { + const _extra = {}; + final queryParameters = {}; + final _data = {}; + final _result = await _dio.request>( + 'shoppingcart/delCart', + queryParameters: queryParameters, + options: RequestOptions( + method: 'GET', + headers: {}, + extra: _extra, + baseUrl: baseUrl), + data: _data); + final value = BaseData.fromJson( _result.data, - (json) => ShoppingCart.fromJson(json), + (json) => json as bool, ); return value; } + @override + Future>> shoppingCart1(param) async { + ArgumentError.checkNotNull(param, 'param'); + const _extra = {}; + final queryParameters = {}; + final _data = {}; + _data.addAll(param ?? {}); + final _result = await _dio.request>('shoppingcart', + queryParameters: queryParameters, + options: RequestOptions( + method: 'PUT', + headers: {}, + extra: _extra, + baseUrl: baseUrl), + data: _data); + final value = BaseData>.fromJson( + _result.data, + (json) => (json as List) + .map( + (i) => ShoppingCart.fromJson(i as Map)) + .toList()); + return value; + } + + @override + Future>> shoppingCartSingle(param) async { + ArgumentError.checkNotNull(param, 'param'); + const _extra = {}; + final queryParameters = {}; + final _data = {}; + _data.addAll(param ?? {}); + final _result = await _dio.request>( + 'shoppingcart/single', + queryParameters: queryParameters, + options: RequestOptions( + method: 'PUT', + headers: {}, + extra: _extra, + baseUrl: baseUrl), + data: _data); + final value = BaseData>.fromJson( + _result.data, + (json) => (json as List) + .map( + (i) => ShoppingCart.fromJson(i as Map)) + .toList()); + return value; + } + @override Future> getOrderInfo(param) async { ArgumentError.checkNotNull(param, 'param'); @@ -127,7 +221,7 @@ class _MinApiService implements MinApiService { data: _data); final value = BaseData.fromJson( _result.data, - (json) => json as dynamic, + (json) => json as dynamic, ); return value; } @@ -139,8 +233,7 @@ class _MinApiService implements MinApiService { final queryParameters = {}; final _data = {}; _data.addAll(param ?? {}); - final _result = await _dio.request>( - 'order/settlement', + final _result = await _dio.request>('order/settlement', queryParameters: queryParameters, options: RequestOptions( method: 'POST', @@ -150,9 +243,8 @@ class _MinApiService implements MinApiService { data: _data); final value = BaseData.fromJson( _result.data, - (json) => json as dynamic, + (json) => json as dynamic, ); return value; } - } diff --git a/lib/retrofit/retrofit_api.dart b/lib/retrofit/retrofit_api.dart index d9f4f607..73e259b0 100644 --- a/lib/retrofit/retrofit_api.dart +++ b/lib/retrofit/retrofit_api.dart @@ -90,9 +90,9 @@ abstract class ApiService { EasyLoading.dismiss(); } debugPrint("code = ${response.statusCode}"); - // p(jsonEncode(response.data)); + p(jsonEncode(response.data)); - debugPrint(jsonEncode(response.data), wrapWidth: response.data.toString().length); + // debugPrint(jsonEncode(response.data), wrapWidth: response.data.toString().length * 10); Map map = response.data; if (map["code"] != 0) { @@ -131,11 +131,11 @@ abstract class ApiService { int maxStrLength = 900; //大于1000时 while (msg.length > maxStrLength) { - debugPrint(msg.substring(0, maxStrLength)); + debugPrint(msg.substring(0, maxStrLength), wrapWidth: maxStrLength); msg = msg.substring(maxStrLength); } //剩余部分 - print(msg); + debugPrint(msg, wrapWidth: maxStrLength); } ///文件上传 diff --git a/lib/store/sku.dart b/lib/store/sku.dart new file mode 100644 index 00000000..997b7360 --- /dev/null +++ b/lib/store/sku.dart @@ -0,0 +1,71 @@ +class Sku { + Sku( + this.id, + this.count, + this.price, + ); + + String id; + int count; + String price; + String name; + String skuId; + String skuValue; + + List attr = []; + + bool compareTo(List attr) { + bool attrY = true; + for (int i = 0; i < this.attr.length; i++) { + if (!this.attr[i].compareTo(attr[i])) { + attrY = false; + return attrY; + } + } + return attrY; + } + + Map toJson() => { + "id": id, + "count": count, + "price": price, + "skuId": skuId, + "name": name, + "value": skuValue, + "attr": attr.map((e) => e.toJson()).toList(), + }; + + Sku copy() { + return Sku( + this.id, + this.count, + this.price, + ) + ..name = this.name + ..skuValue = this.skuValue + ..attr = attr.map((e) => e.copy()).toList(); + } +} + +class Attr { + Attr(this.attrId, this.attrValue); + + String attrId; + String attrValue; + + bool compareTo(Attr attr) { + return attrId == attr.attrId && attrValue == attr.attrValue; + } + + Map toJson() => { + "attrId": attrId, + "attrValue": attrValue, + }; + + Attr copy() { + return Attr( + this.attrId, + this.attrValue, + ); + } +} diff --git a/lib/store/store_order.dart b/lib/store/store_order.dart index 6c341117..3cffa6e2 100644 --- a/lib/store/store_order.dart +++ b/lib/store/store_order.dart @@ -11,9 +11,11 @@ import 'package:huixiang/retrofit/data/activity.dart'; import 'package:huixiang/retrofit/data/base_data.dart'; import 'package:huixiang/retrofit/data/findMiNiGroupList.dart'; import 'package:huixiang/retrofit/data/miNiDetail.dart'; +import 'package:huixiang/retrofit/data/shoppingCart.dart'; import 'package:huixiang/retrofit/data/store_info.dart'; import 'package:huixiang/retrofit/min_api.dart'; import 'package:huixiang/retrofit/retrofit_api.dart'; +import 'package:huixiang/store/sku.dart'; import 'package:huixiang/store/store_view/product_sku.dart'; import 'package:huixiang/store/store_view/shop_car.dart'; import 'package:huixiang/store/store_view/store_activity.dart'; @@ -48,17 +50,12 @@ class _StoreOrderPage extends State StoreInfo storeInfo; List activitys; RefreshController refreshController; - - int allCount = 0; - double allPrice = 0; StoreOrderListPage storeOrderListPage; - List> shopCarGoods = []; - List appletProducts = []; - List shopCar = []; - ScrollController controller = ScrollController(); + List shopCarGoods; + @override void initState() { super.initState(); @@ -74,16 +71,14 @@ class _StoreOrderPage extends State } _fc(int count, String productId, int allCount, double allPrice) { - if (count == 0) { - int index = - shopCarGoods.indexWhere((element) => element["id"] == productId); - shopCarGoods.removeAt(index); - } - - setState(() { - this.allCount = allCount; - this.allPrice = allPrice; - }); + // if (count == 0) { + // int index = shopCarGoods.indexWhere((element) => element.id == productId); + // shopCarGoods.removeAt(index); + // } + // setState(() { + // this.allCount = allCount; + // this.allPrice = allPrice; + // }); } /// 小程序登录 @@ -102,10 +97,12 @@ class _StoreOrderPage extends State Map minStoreInfo = baseData.data; String minToken = minStoreInfo["token"]; String tenant = widget.arguments["tenant"]; + String storeId = widget.arguments["id"]; SharedPreferences.getInstance().then( (value) => { value.setString('minToken', minToken), value.setString('tenant', tenant), + value.setString('storeId', storeId), }, ); minService = MinApiService( @@ -113,6 +110,7 @@ class _StoreOrderPage extends State context: context, token: minToken, tenant: tenant, + storeId: storeId, ); } }); @@ -400,7 +398,7 @@ class _StoreOrderPage extends State child: RoundButton( width: 17, height: 17, - text: "$allCount", + text: "${allCount}", textColor: Colors.white, fontWeight: MyFontWeight.regular, backgroup: Color(0xFF32A060), @@ -422,14 +420,12 @@ class _StoreOrderPage extends State SmartDialog.showToast("请选择要购买的商品~"); return; } - getShopCarGoods(); Navigator.of(context).pushNamed( '/router/settlement', arguments: { "storeInfo": storeInfo, "shopGoods": shopCarGoods, - "shopProduct": shopCar, }, ); } @@ -471,57 +467,35 @@ class _StoreOrderPage extends State ); } - _productListResult(List appletProducts) { - this.appletProducts = appletProducts; - } - - ///获取购物车内的商品 - getShopCarGoods() { - if (appletProducts == null || appletProducts.length == 0) return; - shopCar = []; - if (shopCarGoods != null && shopCarGoods.length > 0) { - shopCarGoods.forEach((element) { - appletProducts.forEach((element1) { - element1.productList.forEach((element2) { - if (element["id"] == element2.id) { - shopCar.add(element2); - } - }); - }); - }); - } - } - ///购物车弹窗 showShoppingCart() { - getShopCarGoods(); + queryShopCar().then((value) { + + showModalBottomSheet( + context: context, + backgroundColor: Colors.transparent, + builder: (context) { + return ShopCar( + value, + clearShopCar, + toDownOrder, + (int count, String productId, allCount, allPrice) { + // print("shopCarCount: $allCount allPrice: $allPrice "); + }, + ); + }, + ); - showModalBottomSheet( - context: context, - backgroundColor: Colors.transparent, - builder: (context) { - return ShopCar( - shopCar, - shopCarGoods, - clearShopCar, - toDownOrder, - (int count, String productId, allCount, allPrice) { - print("shopCarCount: $allCount allPrice: $allPrice "); - setState(() { - this.allCount = allCount; - this.allPrice = allPrice; - }); - }, - ); - }, - ); + }); } ///清空购物车 - clearShopCar() { - if (shopCarGoods != null) shopCarGoods.clear(); - calculatePrice(); - setState(() {}); + clearShopCar() async { + BaseData baseData = await minService.clearShoppingCart(); + if (baseData.isSuccess) { + + setState(() {}); + } } ///选规格 @@ -533,83 +507,53 @@ class _StoreOrderPage extends State } ///添加购物车 - addsShoppingCart() async { - BaseData baseDate = await apiService.creditOrder({ - "parentId": widget.arguments["parentId"], - "skuImg": null, - "skuNameStr": widget.arguments["skuNameStr"], - "skuPrice": widget.arguments["skuPrice"], - "skuStock": widget.arguments["skuStock"], - }); - if (baseDate != null && baseDate.isSuccess) {} + _addShopCar(Sku sku) async { + if (sku != null) { + BaseData> baseDate = await minService.addShoppingCart({ + "storeId": storeInfo.id, + "storeName": storeInfo.storeName ?? "", + "tableId": 0, + "shoppingCartSkuItemList": [ + { + "buyNum": sku.count, + "id": sku.skuId, + "platterList": [ + { + "skuId": sku.skuId + } + ], + "productId": sku.id, + "productName": sku.name, + "skuName": "", + "storeId": storeInfo.id, + } + ], + }); + if (baseDate != null && baseDate.isSuccess) { + queryShopCar(); + } + } + } + + ///查询购物车 + Future> queryShopCar() async { + BaseData> baseDate = await minService.getShoppingCart(0); + if (baseDate != null && baseDate.isSuccess) { + return baseDate.data; + } else { + return []; + } } ///选规格弹窗 showStoreSelector(MiNiDetail miNiDetail, String id) async { - var result = await showModalBottomSheet( + showModalBottomSheet( context: context, backgroundColor: Colors.transparent, builder: (context) { - return ProductSku(miNiDetail, id); + return ProductSku(miNiDetail, id, _addShopCar); }, ); - if (result != null) { - result["name"] = miNiDetail.productName; - miNiDetail.productSkuVOList.forEach((e0) { - String attr1 = ""; - String attr2 = ""; - e0.skuAttrList.forEach((e2) { - attr1 += e2.attrValueId; - }); - (result["attr"] as List).forEach((e1) { - attr2 += e1["attrValue"]; - }); - if(attr1 == attr2){ - result["skuId"] = e0.id; - return; - } - }); - if (shopCarGoods == null || shopCarGoods.length == 0) { - shopCarGoods = []; - shopCarGoods.add(result); - } else { - Map map; - shopCarGoods.forEach((element) { - if (element["id"] == result["id"]) { - map = element; - } - }); - if (map != null) { - int index = shopCarGoods - .indexWhere((element) => element["id"] == result["id"]); - shopCarGoods.removeAt(index); - shopCarGoods.insert(index, result); - } else { - shopCarGoods.add(result); - } - } - calculatePrice(); - } - } - - calculatePrice() { - AiDecimalAccuracy allPriceDecimal = AiDecimalAccuracy.zero; - int allCount = 0; - shopCarGoods.forEach((element2) { - if (element2["price"] != null && element2["price"] != "") { - double singlePrice = double.tryParse(element2["price"]); - allCount += element2["count"]; - - AiDecimalAccuracy aiDecimalAccuracy = - AiDecimalAccuracy.fromInt(element2["count"]); - AiDecimalAccuracy aiPrice = AiDecimalAccuracy.tryParse("$singlePrice"); - - allPriceDecimal += (aiPrice * aiDecimalAccuracy); - } - }); - this.allCount = allCount; - this.allPrice = allPriceDecimal.toDouble(); - setState(() {}); } // @override diff --git a/lib/store/store_view/product_sku.dart b/lib/store/store_view/product_sku.dart index 92706b81..efcec472 100644 --- a/lib/store/store_view/product_sku.dart +++ b/lib/store/store_view/product_sku.dart @@ -2,6 +2,7 @@ import 'package:flutter/material.dart'; import 'package:huixiang/generated/l10n.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:huixiang/retrofit/data/miNiDetail.dart'; +import 'package:huixiang/store/sku.dart'; import 'package:huixiang/utils/font_weight.dart'; import 'package:huixiang/view_widget/custom_image.dart'; import 'package:huixiang/view_widget/round_button.dart'; @@ -9,8 +10,8 @@ import 'package:huixiang/view_widget/round_button.dart'; class ProductSku extends StatefulWidget { final MiNiDetail miNiDetail; final String productId; - - ProductSku(this.miNiDetail, this.productId); + final Function(Sku sku) addShopCar; + ProductSku(this.miNiDetail, this.productId, this.addShopCar); @override State createState() { @@ -22,24 +23,23 @@ class _ProductSku extends State { List selectSkus = []; int selectCount = 1; - Map tempSelected = {}; - + Sku tempSelected; @override void initState() { super.initState(); if (widget.miNiDetail != null) { - tempSelected["id"] = widget.productId; - tempSelected["count"] = 1; - tempSelected["price"] = widget.miNiDetail.price; - if (tempSelected["attr"] == null) - tempSelected["attr"] = []; + tempSelected = Sku(widget.productId, 1, widget.miNiDetail.price); + tempSelected.name = widget.miNiDetail.productName; + widget.miNiDetail.attrList.forEach((element) { selectSkus.add(element.attrValueList[0].attrValue); - (tempSelected["attr"] as List).add({ - "attrId": "${element.id}", - "attrValue": "${element.attrValueList[0].id}", - }); + tempSelected.attr.add( + Attr( + "${element.id}", + "${element.attrValueList[0].id}", + ), + ); }); } } @@ -95,7 +95,8 @@ class _ProductSku extends State { Padding( padding: EdgeInsets.only(top: 4, bottom: 7), child: Text( - "已选: " + (selectSkus.map((e) => "$e").toList().toString()), + "已选: " + + (selectSkus.map((e) => "$e").toList().toString()), style: TextStyle( color: Color(0xFF727272), fontSize: 11.sp, @@ -149,21 +150,18 @@ class _ProductSku extends State { itemBuilder: (context, position) { return attrItem( (index) { - if (tempSelected["attr"] == null) { - tempSelected["attr"] = []; + if (tempSelected.attr == null) { + tempSelected.attr = []; } - bool flag = false; - (tempSelected["attr"] as List).forEach((e0) { - if(e0["attrId"] == widget.miNiDetail.attrList[position].id){ - e0["attrValue"] = widget.miNiDetail.attrList[position].attrValueList[index].id; - flag = true; + + tempSelected.attr.forEach((e0) { + if (e0.attrId == widget.miNiDetail.attrList[position].id) { + String valueId = widget.miNiDetail.attrList[position].attrValueList[index].id; + if (e0.attrValue != valueId) { + tempSelected.attr[tempSelected.attr.indexOf(e0)].attrValue = valueId; + } } }); - if(!flag) - (tempSelected["attr"] as List).add({ - "attrId": "${widget.miNiDetail.attrList[position].id}", - "attrValue": "${widget.miNiDetail.attrList[position].attrValueList[index].id}", - }); state(() { selectSkus[position] = widget.miNiDetail @@ -197,7 +195,7 @@ class _ProductSku extends State { state(() { if (selectCount > 1) selectCount--; }); - tempSelected["count"] = selectCount; + tempSelected.count = selectCount; }, child: Image.asset( "assets/image/reduce.png", @@ -220,7 +218,7 @@ class _ProductSku extends State { onTap: () { state(() { selectCount++; - tempSelected["count"] = selectCount; + tempSelected.count = selectCount; }); }, child: Image.asset( @@ -244,7 +242,7 @@ class _ProductSku extends State { backgroup: Color(0xFF32A060), fontSize: 16.sp, callback: () { - Navigator.of(context).pop(tempSelected); + _result(); }, ), SizedBox( @@ -256,6 +254,25 @@ class _ProductSku extends State { }); } + _result() async { + ProductSkuVOListBean productSku = widget.miNiDetail.productSkuVOList.firstWhere((element) { + bool gg = true; + selectSkus.forEach((element1) { + if (element.skuNameStr.indexOf(element1) < 0) { + gg = false; + return gg; + } + }); + return gg; + }); + // print("productSku: ${selectSkus.toString()}"); + print("productSku: ${tempSelected.toJson()}"); + if (productSku == null) return; + tempSelected.skuId = productSku.id; + tempSelected.skuValue = selectSkus.toString(); + widget.addShopCar(tempSelected); + } + Widget attrItem(Function fc, AttrListBean attrListBean, position) { return Column( crossAxisAlignment: CrossAxisAlignment.start, diff --git a/lib/store/store_view/settlement.dart b/lib/store/store_view/settlement.dart index 564a42d2..7b145c5c 100644 --- a/lib/store/store_view/settlement.dart +++ b/lib/store/store_view/settlement.dart @@ -15,6 +15,7 @@ import 'package:huixiang/retrofit/data/settlement_bean.dart'; import 'package:huixiang/retrofit/data/shoppingCart.dart'; import 'package:huixiang/retrofit/data/store_info.dart'; import 'package:huixiang/retrofit/min_api.dart'; +import 'package:huixiang/store/sku.dart'; import 'package:huixiang/store/store_view/settlement_order_commodity.dart'; import 'package:huixiang/utils/font_weight.dart'; import 'package:huixiang/view_widget/my_appbar.dart'; @@ -45,7 +46,7 @@ class _Settlement extends State { int selectedCouponIndex = -1; List shopCar = []; - List> shopCarGoods = []; + List shopCarGoods = []; TextEditingController _vc; List addressBgs = [ @@ -115,19 +116,19 @@ class _Settlement extends State { placeOrderFirst.skuItemDTOList = []; shopCarGoods.forEach((e0) { SkuItemDTOList skuItemDTOListBean = SkuItemDTOList(); - skuItemDTOListBean.skuId = e0["skuId"]; - skuItemDTOListBean.buyNum = e0["count"]; + skuItemDTOListBean.skuId = e0.skuId; + skuItemDTOListBean.buyNum = e0.count; PlatterList platterListBean = PlatterList(); - platterListBean.skuId = e0["skuId"]; - platterListBean.productId = e0["id"]; + platterListBean.skuId = e0.skuId; + platterListBean.productId = e0.id; skuItemDTOListBean.platterList = []; skuItemDTOListBean.platterList.add(platterListBean); placeOrderFirst.skuItemDTOList.add(skuItemDTOListBean); ShoppingCartSkuItemListBean shoppingCartSkuItemListBean = ShoppingCartSkuItemListBean(); - shoppingCartSkuItemListBean.buyNum = e0["count"]; - shoppingCartSkuItemListBean.productId = e0["id"]; - shoppingCartSkuItemListBean.productName = e0["name"]; - shoppingCartSkuItemListBean.skuId = e0["skuId"]; + shoppingCartSkuItemListBean.buyNum = e0.count; + shoppingCartSkuItemListBean.productId = e0.id; + shoppingCartSkuItemListBean.productName = e0.name; + shoppingCartSkuItemListBean.skuId = e0.skuId; placeOrderFirst.shoppingCartSkuItemList.add(shoppingCartSkuItemListBean); }); placeOrderFirst.source = 1; @@ -151,8 +152,8 @@ class _Settlement extends State { settlementBean.orderProductVOList = []; shopCarGoods.forEach((e0) { OrderProductVOList orderProductVOListBean = OrderProductVOList(); - orderProductVOListBean.skuId = e0["skuId"]; - orderProductVOListBean.buyNum = e0["count"]; + orderProductVOListBean.skuId = e0.skuId; + orderProductVOListBean.buyNum = e0.count; ActInfo actInfoBean = ActInfo(); actInfoBean.couponDiscountAmount = 0; actInfoBean.couponDiscountRate = 0; @@ -209,7 +210,7 @@ class _Settlement extends State { orderProductVOListBean.returnStatus = 0; orderProductVOListBean.returnType = 0; orderProductVOListBean.sellPrice = 0; - orderProductVOListBean.skuId = 0; + orderProductVOListBean.skuId = "0"; orderProductVOListBean.skuImg = ""; orderProductVOListBean.skuNameStr = ""; settlementBean.orderProductVOList.add(orderProductVOListBean); @@ -231,7 +232,7 @@ class _Settlement extends State { if (shopCarGoods == null) return ""; double totalPrice = 0; shopCarGoods.forEach((element) { - totalPrice += double.tryParse(element["price"]) * element["count"]; + totalPrice += double.tryParse(element.price) * element.count; }); if(selectedCouponIndex != -1 && discountFlag){ double discountA = double.parse(settleOrderInfo.couponList[selectedCouponIndex].discountAmount); @@ -280,7 +281,7 @@ class _Settlement extends State { phoneWidget(), ///订单商品 - SettlementOrderCommodity(shopCar, 0,shopCarGoods,settleOrderInfo), + SettlementOrderCommodity(shopCar, 0, shopCarGoods, settleOrderInfo), // if (payStatus == 0) couponRemarks(), /*(payStatus == 0) ? paySelector() : */ diff --git a/lib/store/store_view/settlement_order_commodity.dart b/lib/store/store_view/settlement_order_commodity.dart index 9b7f9d93..4a8d66c1 100644 --- a/lib/store/store_view/settlement_order_commodity.dart +++ b/lib/store/store_view/settlement_order_commodity.dart @@ -3,6 +3,7 @@ import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:huixiang/generated/l10n.dart'; import 'package:huixiang/retrofit/data/findMiNiGroupList.dart'; import 'package:huixiang/retrofit/data/settleOrderInfo.dart'; +import 'package:huixiang/store/sku.dart'; import 'package:huixiang/utils/font_weight.dart'; import 'package:huixiang/view_widget/custom_image.dart'; import 'package:huixiang/view_widget/separator.dart'; @@ -10,7 +11,7 @@ import 'package:huixiang/view_widget/separator.dart'; class SettlementOrderCommodity extends StatefulWidget { final int isTakeOut; final List orderInfo; - final List> shopCarGood; + final List shopCarGood; final SettleOrderInfo settleOrderInfo; SettlementOrderCommodity(this.orderInfo, this.isTakeOut,this.shopCarGood,this.settleOrderInfo); @@ -102,9 +103,9 @@ class _SettlementOrderCommodity extends State { } Widget commodityItem(ProductListBean productList) { - Map goodsBuyInfo; + Sku goodsBuyInfo; widget.shopCarGood.forEach((element) { - if(element["id"] == productList.id){ + if(element.id == productList.id){ goodsBuyInfo = element; return; } @@ -145,7 +146,7 @@ class _SettlementOrderCommodity extends State { ), ), Text( - "x${goodsBuyInfo["count"]}", + "x${goodsBuyInfo.count}", style: TextStyle( fontSize: 12.sp, color: Color(0xFF727272), @@ -358,7 +359,7 @@ class _SettlementOrderCommodity extends State { if (widget.shopCarGood == null) return ""; double totalPrice = 0; widget.shopCarGood.forEach((element) { - totalPrice += double.tryParse(element["price"]) * element["count"]; + totalPrice += double.tryParse(element.price) * element.count; }); return "$totalPrice"; } diff --git a/lib/store/store_view/shop_car.dart b/lib/store/store_view/shop_car.dart index 90fa6e1b..5432770c 100644 --- a/lib/store/store_view/shop_car.dart +++ b/lib/store/store_view/shop_car.dart @@ -2,23 +2,24 @@ import 'package:ai_decimal_accuracy/ai_decimal_accuracy.dart'; import 'package:flutter/material.dart'; import 'package:huixiang/generated/l10n.dart'; import 'package:huixiang/retrofit/data/findMiNiGroupList.dart'; +import 'package:huixiang/retrofit/data/shoppingCart.dart'; +import 'package:huixiang/store/sku.dart'; import 'package:huixiang/store/store_view/shop_goods.dart'; import 'package:huixiang/utils/font_weight.dart'; import 'package:huixiang/view_widget/round_button.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; class ShopCar extends StatefulWidget { - final List productLists; final Function(String id) queryMiNiDetail; final Function() clearShopCar; final Function() toDownOrder; - final List> shopCarGoods; + + final List shopingCar; final Function(int count, String productId, int allCount, double allPrice) fc; ShopCar( - this.productLists, - this.shopCarGoods, + this.shopingCar, this.clearShopCar, this.toDownOrder, this.fc, { @@ -27,7 +28,7 @@ class ShopCar extends StatefulWidget { @override State createState() { - return _ShopCar(this.shopCarGoods); + return _ShopCar(); } } @@ -35,30 +36,9 @@ class _ShopCar extends State { int allCount = 0; double allPrice = 0.0; - final List> shopCarGoods; - - _ShopCar(this.shopCarGoods); - @override void initState() { super.initState(); - - if (shopCarGoods != null) { - AiDecimalAccuracy allPriceDecimal = AiDecimalAccuracy.zero; - shopCarGoods.forEach((element) { - if (element["price"] != null && element["price"] != "") { - double singlePrice = double.tryParse(element["price"]); - allCount += element["count"]; - - AiDecimalAccuracy aiDecimalAccuracy = AiDecimalAccuracy.fromInt(element["count"]); - AiDecimalAccuracy aiPrice = AiDecimalAccuracy.tryParse("$singlePrice"); - - allPriceDecimal += (aiPrice * aiDecimalAccuracy); - } - }); - allPrice = allPriceDecimal.toDouble(); - } - } @override @@ -103,8 +83,8 @@ class _ShopCar extends State { onTap: () { allPrice = 0; allCount = 0; - widget.productLists.clear(); - state((){}); + + state(() {}); widget.clearShopCar(); }, child: Image.asset( @@ -117,152 +97,144 @@ class _ShopCar extends State { ), ), Expanded( - child: Container( - padding: EdgeInsets.only( - top: 8, - left: 16, - right: 16, - ), - child: ListView.builder( - itemCount: widget.productLists == null - ? 0 - : widget.productLists.length, - physics: BouncingScrollPhysics(), - itemBuilder: (context, position) { - return GestureDetector( - onTap: () {}, - child: ShopGoods( - widget.productLists[position], - (int count, String productId) { - int index = shopCarGoods.indexWhere((element) => element["id"] == productId); - if (count == 0) { - shopCarGoods.removeAt(index); - int index1 = widget.productLists.indexWhere((element) => element.id == productId); - widget.productLists.removeAt(index1); - } else { - Map map; - print("productId: $productId"); - shopCarGoods.forEach((element) { - if (element["id"] == productId) { - map = element; - } - }); - map["count"] = count; - shopCarGoods[index] = map; - } + child: Stack( + children: [ + Positioned( + top: 0, + left: 0, + right: 0, + bottom: 54, + child: Container( + padding: EdgeInsets.only( + top: 8, + left: 16, + right: 16, + ), + child: ListView.builder( + itemCount: widget.shopingCar == null + ? 0 + : widget.shopingCar.length, + physics: BouncingScrollPhysics(), + itemBuilder: (context, position) { + return GestureDetector( + onTap: () {}, + child: ShopGoods( + widget.shopingCar[position], + (int count, List attr, String productId) { - allCount = 0; - allPrice = 0; - shopCarGoods.forEach((element) { - if (element["price"] != null && - element["price"] != "") { - double singlePrice = - double.tryParse(element["price"]); - allCount += element["count"]; - allPrice += (singlePrice * element["count"]); - } - }); - widget.fc(count, productId, allCount, allPrice); + widget.fc( + count, productId, allCount, allPrice); - state(() {}); + state(() {}); + }, + count: _shopCarGoods(position).count, + shopCarGoods: _shopCarGoods(position), + queryMiNiDetail: widget.queryMiNiDetail, + ), + ); }, - shopCarGoods: _shopCarGoods(position), - queryMiNiDetail: widget.queryMiNiDetail, ), - ); - }, - ), - ), - ), - Stack( - alignment: Alignment.bottomLeft, - children: [ - Container( - height: 54.h, - decoration: BoxDecoration( - color: Color(0xFFFAFAFA), - boxShadow: [ - BoxShadow( - color: Colors.black.withAlpha(8), - offset: Offset(0, -1), - blurRadius: 3, - spreadRadius: 0, - ), - ], + ), ), - child: Row( - children: [ - Spacer(), - Text( - S.of(context).heji, - style: TextStyle( - fontSize: 12.sp, - fontWeight: MyFontWeight.regular, - color: Colors.black, - ), - ), - Text( - "¥" + allPrice.toString(), - style: TextStyle( - fontSize: 20.sp, - fontWeight: MyFontWeight.medium, - color: Color(0xFF32A060), - ), - ), - Spacer(), - GestureDetector( - onTap: () { - widget.toDownOrder(); - }, - child: RoundButton( - width: 103.w, + Positioned( + bottom: 0, + left: 0, + right: 0, + child: Stack( + alignment: Alignment.bottomLeft, + children: [ + Container( height: 54.h, - text: S.current.jiesuan, - textColor: Colors.white, - fontWeight: MyFontWeight.regular, - backgroup: Color(0xFF32A060), - radius: 0, - fontSize: 16.sp, - padding: EdgeInsets.symmetric(vertical: 5.h), + decoration: BoxDecoration( + color: Color(0xFFFAFAFA), + boxShadow: [ + BoxShadow( + color: Colors.black.withAlpha(8), + offset: Offset(0, -1), + blurRadius: 3, + spreadRadius: 0, + ), + ], + ), + child: Row( + children: [ + Spacer(), + Text( + S.of(context).heji, + style: TextStyle( + fontSize: 12.sp, + fontWeight: MyFontWeight.regular, + color: Colors.black, + ), + ), + Text( + "¥" + allPrice.toString(), + style: TextStyle( + fontSize: 20.sp, + fontWeight: MyFontWeight.medium, + color: Color(0xFF32A060), + ), + ), + Spacer(), + GestureDetector( + onTap: () { + widget.toDownOrder(); + }, + child: RoundButton( + width: 103.w, + height: 54.h, + text: S.current.jiesuan, + textColor: Colors.white, + fontWeight: MyFontWeight.regular, + backgroup: Color(0xFF32A060), + radius: 0, + fontSize: 16.sp, + padding: + EdgeInsets.symmetric(vertical: 5.h), + ), + ), + ], + ), ), - ), - ], - ), - ), - Stack( - children: [ - InkWell( - onTap: () { - Navigator.of(context).pop(); - }, - child: Image.asset( - "assets/image/shopp.png", - width: 88, - height: 88, - ), - ), - Positioned( - right: 15, - top: 14, - child: RoundButton( - width: 17, - height: 17, - text: allCount.toString(), - textColor: Colors.white, - fontWeight: MyFontWeight.regular, - backgroup: Color(0xFF32A060), - fontSize: 12.sp, - radius: 100, - callback: () { - Navigator.of(context) - .pushNamed('/router/test_page'); - }, - ), + Stack( + children: [ + InkWell( + onTap: () { + Navigator.of(context).pop(); + }, + child: Image.asset( + "assets/image/shopp.png", + width: 88, + height: 88, + ), + ), + Positioned( + right: 15, + top: 14, + child: RoundButton( + width: 17, + height: 17, + text: allCount.toString(), + textColor: Colors.white, + fontWeight: MyFontWeight.regular, + backgroup: Color(0xFF32A060), + fontSize: 12.sp, + radius: 100, + callback: () { + Navigator.of(context) + .pushNamed('/router/test_page'); + }, + ), + ), + ], + ), + ], ), - ], - ), - ], + ), + ], + ), + flex: 1, ), ], ), @@ -271,13 +243,14 @@ class _ShopCar extends State { ); } - Map _shopCarGoods(int position) { - Map map; - widget.shopCarGoods.forEach((element) { - if (widget.productLists[position].id == element["id"]) { - map = element; - } - }); + Sku _shopCarGoods(int position) { + Sku map = widget.shopCarGoods[position]; + // widget.shopCarGoods.forEach((element) { + // if (widget.productLists[position].id == element.id) { + // map = element; + // } + // }); + // print("shopCarGoods123123: ${map.toJson()}"); return map; } } diff --git a/lib/store/store_view/shop_goods.dart b/lib/store/store_view/shop_goods.dart index b2ce482f..728de675 100644 --- a/lib/store/store_view/shop_goods.dart +++ b/lib/store/store_view/shop_goods.dart @@ -1,6 +1,7 @@ import 'package:flutter/material.dart'; import 'package:huixiang/generated/l10n.dart'; import 'package:huixiang/retrofit/data/findMiNiGroupList.dart'; +import 'package:huixiang/store/sku.dart'; import 'package:huixiang/utils/font_weight.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:huixiang/view_widget/custom_image.dart'; @@ -9,12 +10,14 @@ import 'package:huixiang/view_widget/round_button.dart'; class ShopGoods extends StatefulWidget { final ProductListBean product; final Function(String id) queryMiNiDetail; - final Function(int count, String productId) fc; - final Map shopCarGoods; + final Function(int count, List attr, String productId) fc; + final Sku shopCarGoods; + final int count; ShopGoods( this.product, this.fc, { + this.count = 0, this.queryMiNiDetail, this.shopCarGoods, }); @@ -23,13 +26,13 @@ class ShopGoods extends StatefulWidget { State createState() { return _ShopGoods(); } + } class _ShopGoods extends State { @override Widget build(BuildContext context) { - int buyNum = _count(); return Container( color: Colors.white, padding: EdgeInsets.only( @@ -145,7 +148,7 @@ class _ShopGoods extends State { ], ), Spacer(), - if (buyNum == 0) + if (widget.count == 0) RoundButton( width: 49.w, text: S.of(context).xuanguige, @@ -159,11 +162,11 @@ class _ShopGoods extends State { widget.queryMiNiDetail(widget.product.id); }, ), - if (buyNum > 0) + if (widget.count > 0) InkWell( onTap: () { reduceCount(); - widget.fc(widget.shopCarGoods["count"], widget.product.id); + widget.fc(widget.shopCarGoods.count, widget.shopCarGoods.attr, widget.product.id); setState(() {}); }, child: Image.asset( @@ -172,12 +175,12 @@ class _ShopGoods extends State { height: 22, ), ), - if (buyNum > 0) + if (widget.count > 0) Container( width: 30, alignment: Alignment.center, child: Text( - "$buyNum", + "${widget.count}", style: TextStyle( color: Colors.black, fontSize: 14.sp, @@ -185,11 +188,11 @@ class _ShopGoods extends State { ), ), ), - if (buyNum > 0) + if (widget.count > 0) InkWell( onTap: () { addCount(); - widget.fc(widget.shopCarGoods["count"], widget.product.id); + widget.fc(widget.shopCarGoods.count, widget.shopCarGoods.attr, widget.product.id); setState(() {}); }, child: Image.asset( @@ -209,21 +212,12 @@ class _ShopGoods extends State { } addCount() { - widget.shopCarGoods["count"] += 1; + widget.shopCarGoods.count += 1; } reduceCount() { - widget.shopCarGoods["count"] -= 1; + widget.shopCarGoods.count -= 1; } - int _count() { - if (widget.shopCarGoods == null) return 0; - - if (widget.product.id == widget.shopCarGoods["id"]) { - return widget.shopCarGoods["count"]; - } - - return 0; - } } diff --git a/lib/store/store_view/store_order_list.dart b/lib/store/store_view/store_order_list.dart index 695b7874..b3c5464c 100644 --- a/lib/store/store_view/store_order_list.dart +++ b/lib/store/store_view/store_order_list.dart @@ -4,9 +4,11 @@ import 'package:flutter/material.dart'; import 'package:huixiang/retrofit/data/activity.dart'; import 'package:huixiang/retrofit/data/base_data.dart'; import 'package:huixiang/retrofit/data/findMiNiGroupList.dart'; +import 'package:huixiang/retrofit/data/shoppingCart.dart'; import 'package:huixiang/retrofit/data/store_info.dart'; import 'package:huixiang/retrofit/min_api.dart'; import 'package:huixiang/retrofit/retrofit_api.dart'; +import 'package:huixiang/store/sku.dart'; import 'package:huixiang/store/store_view/shop_goods.dart'; import 'package:huixiang/utils/font_weight.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; @@ -21,7 +23,7 @@ class StoreOrderListPage extends StatefulWidget { final Function(int count, String productId, int allCount, double allPrice) fc; final Function(String id) queryMiNiDetail; final Function(List appletProducts) productListResult; - List> shopCarGoods; + List shopCarGoods; StoreOrderListPage( this.arguments, @@ -199,8 +201,8 @@ class _StoreOrderListPage extends State { int count = 0; findMiNiGroupList.productList.forEach((element) { widget.shopCarGoods.forEach((element1) { - if (element.id == element1["id"]) { - count += element1["count"]; + if (element.id == element1.id) { + count += element1.count; } }); }); @@ -208,35 +210,47 @@ class _StoreOrderListPage extends State { } Widget goodsItem(position) { - Map map; + Sku map; + int count = 0; widget.shopCarGoods.forEach((element) { - if (productListBeans[position].id == element["id"]) { - map = element; + if (productListBeans[position].id == element.id) { + if (map == null) { + map = element; + count = map.count; + } else { + count += element.count; + } } }); - return ShopGoods( - productListBeans[position], - (int count, String productId) { - int allCount = 0; - AiDecimalAccuracy allPrice = AiDecimalAccuracy.zero; - widget.shopCarGoods.forEach((element2) { - if (element2["price"] != null && element2["price"] != "") { - double singlePrice = double.tryParse(element2["price"]); - allCount += element2["count"]; + return InkWell( + onTap: () { + widget.queryMiNiDetail(productListBeans[position].id); + }, + child: ShopGoods( + productListBeans[position], + (int count, List attr, String productId) { + int allCount = 0; + AiDecimalAccuracy allPrice = AiDecimalAccuracy.zero; + widget.shopCarGoods.forEach((element2) { + if (element2.price != null && element2.price != "") { + double singlePrice = double.tryParse(element2.price); + allCount += element2.count; - AiDecimalAccuracy aiDecimalAccuracy = - AiDecimalAccuracy.fromInt(element2["count"]); - AiDecimalAccuracy aiPrice = - AiDecimalAccuracy.tryParse("$singlePrice"); + AiDecimalAccuracy aiDecimalAccuracy = + AiDecimalAccuracy.fromInt(element2.count); + AiDecimalAccuracy aiPrice = + AiDecimalAccuracy.tryParse("$singlePrice"); - allPrice += (aiPrice * aiDecimalAccuracy); - } - }); - widget.fc(count, productId, allCount, allPrice.toDouble()); - setState(() {}); - }, - queryMiNiDetail: widget.queryMiNiDetail, - shopCarGoods: map, + allPrice += (aiPrice * aiDecimalAccuracy); + } + }); + widget.fc(count, productId, allCount, allPrice.toDouble()); + setState(() {}); + }, + count: count, + queryMiNiDetail: widget.queryMiNiDetail, + shopCarGoods: map, + ), ); } } From 6388601314032b9e55dab25545cb7cb71e9c706b Mon Sep 17 00:00:00 2001 From: fmk Date: Wed, 20 Oct 2021 18:58:11 +0800 Subject: [PATCH 02/20] safety --- lib/main.dart | 2 +- lib/retrofit/data/settlement_bean.dart | 1 + lib/retrofit/data/shoppingCart.dart | 4 +- lib/retrofit/min_api.dart | 8 +- lib/retrofit/min_api.g.dart | 22 + .../store_view => settlement}/settlement.dart | 635 +++++++++--------- .../settlement_order_commodity.dart | 41 +- lib/store/sku.dart | 71 -- lib/store/store_order.dart | 248 +++++-- lib/store/store_view/product_sku.dart | 116 ++-- lib/store/store_view/shop_car.dart | 89 ++- lib/store/store_view/shop_goods.dart | 55 +- lib/store/store_view/store_order_list.dart | 65 +- 13 files changed, 720 insertions(+), 637 deletions(-) rename lib/{store/store_view => settlement}/settlement.dart (74%) rename lib/{store/store_view => settlement/settlement_view}/settlement_order_commodity.dart (89%) delete mode 100644 lib/store/sku.dart diff --git a/lib/main.dart b/lib/main.dart index c8cf3cd4..9dd5c659 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -54,7 +54,7 @@ import 'package:huixiang/setting/permission_setting_page.dart'; import 'package:huixiang/setting/setting_page.dart'; import 'package:huixiang/setting/treaty_page.dart'; import 'package:huixiang/store/store_order.dart'; -import 'package:huixiang/store/store_view/settlement.dart'; +import 'package:huixiang/settlement/settlement.dart'; import 'package:huixiang/test_page.dart'; import 'package:huixiang/union/location_map_page.dart'; diff --git a/lib/retrofit/data/settlement_bean.dart b/lib/retrofit/data/settlement_bean.dart index 5cee84b3..d612b14d 100644 --- a/lib/retrofit/data/settlement_bean.dart +++ b/lib/retrofit/data/settlement_bean.dart @@ -7,6 +7,7 @@ /// promotionInfoDTO : {"couponId":0,"promotionId":0} class SettlementBean { + SettlementBean({ int addressId, int buyNum, diff --git a/lib/retrofit/data/shoppingCart.dart b/lib/retrofit/data/shoppingCart.dart index 78a1794a..9f5b9bc7 100644 --- a/lib/retrofit/data/shoppingCart.dart +++ b/lib/retrofit/data/shoppingCart.dart @@ -30,7 +30,7 @@ class ShoppingCart { return shoppingCartBean; } - Map toJson() => { + Map toJson() => { "cartSum": cartSum, "numberOfPeople": numberOfPeople, "selected": selected, @@ -71,7 +71,7 @@ class ShoppingCartSkuItemListBean { String skuPrice; int skuStock; String storeId; - int tableId; + String tableId; static ShoppingCartSkuItemListBean fromJson(Map map) { if (map == null) return null; diff --git a/lib/retrofit/min_api.dart b/lib/retrofit/min_api.dart index a470375f..59c1a1e8 100644 --- a/lib/retrofit/min_api.dart +++ b/lib/retrofit/min_api.dart @@ -7,6 +7,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_easyloading/flutter_easyloading.dart'; import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:huixiang/generated/l10n.dart'; +import 'package:huixiang/retrofit/data/address.dart'; import 'package:huixiang/retrofit/data/base_data.dart'; import 'package:huixiang/retrofit/data/placeOrderFirst.dart'; import 'package:huixiang/retrofit/data/settlement_bean.dart'; @@ -164,9 +165,11 @@ abstract class MinApiService { ///订单结算信息 @POST("order/getOrderInfo") - Future> getOrderInfo( - @Body() Map param); + Future> getOrderInfo(@Body() Map param); + ///查询用户所有收货地址 + @GET("address/queryMemberAddress") + Future>> queryAddress(); ///小程序下单 @POST("order/placeOrderFirst") @@ -175,4 +178,5 @@ abstract class MinApiService { /// 结算 @POST("order/settlement") Future settlementApi(@Body() Map param); + } diff --git a/lib/retrofit/min_api.g.dart b/lib/retrofit/min_api.g.dart index efe149f7..1d33c8eb 100644 --- a/lib/retrofit/min_api.g.dart +++ b/lib/retrofit/min_api.g.dart @@ -203,6 +203,28 @@ class _MinApiService implements MinApiService { return value; } + @override + Future>> queryAddress() async { + const _extra = {}; + final queryParameters = {}; + final _data = {}; + final _result = await _dio.request>( + 'address/queryMemberAddress', + queryParameters: queryParameters, + options: RequestOptions( + method: 'GET', + headers: {}, + extra: _extra, + baseUrl: baseUrl), + data: _data); + final value = BaseData>.fromJson( + _result.data, + (json) => (json as List) + .map
((i) => Address.fromJson(i as Map)) + .toList()); + return value; + } + @override Future> placeOrderFirst(param) async { ArgumentError.checkNotNull(param, 'param'); diff --git a/lib/store/store_view/settlement.dart b/lib/settlement/settlement.dart similarity index 74% rename from lib/store/store_view/settlement.dart rename to lib/settlement/settlement.dart index 7b145c5c..89cb8947 100644 --- a/lib/store/store_view/settlement.dart +++ b/lib/settlement/settlement.dart @@ -2,11 +2,12 @@ import 'package:dio/dio.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; +import 'package:flutter_baidu_mapapi_base/flutter_baidu_mapapi_base.dart'; +import 'package:flutter_baidu_mapapi_utils/flutter_baidu_mapapi_utils.dart'; import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:huixiang/generated/l10n.dart'; -import 'package:huixiang/order/order_view/order_commodity.dart'; -import 'package:huixiang/order/order_view/order_info.dart'; +import 'package:huixiang/retrofit/data/address.dart'; import 'package:huixiang/retrofit/data/base_data.dart'; import 'package:huixiang/retrofit/data/findMiNiGroupList.dart'; import 'package:huixiang/retrofit/data/placeOrderFirst.dart'; @@ -15,14 +16,13 @@ import 'package:huixiang/retrofit/data/settlement_bean.dart'; import 'package:huixiang/retrofit/data/shoppingCart.dart'; import 'package:huixiang/retrofit/data/store_info.dart'; import 'package:huixiang/retrofit/min_api.dart'; -import 'package:huixiang/store/sku.dart'; -import 'package:huixiang/store/store_view/settlement_order_commodity.dart'; +import 'package:huixiang/settlement/settlement_view/settlement_order_commodity.dart'; import 'package:huixiang/utils/font_weight.dart'; +import 'package:huixiang/utils/location.dart'; import 'package:huixiang/view_widget/my_appbar.dart'; -import 'package:huixiang/view_widget/rename_dialog.dart'; -import 'package:huixiang/view_widget/rename_dialog_content.dart'; import 'package:huixiang/view_widget/round_button.dart'; import 'package:huixiang/view_widget/separator.dart'; +import 'package:intl/intl.dart'; import 'package:shared_preferences/shared_preferences.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; @@ -45,9 +45,6 @@ class _Settlement extends State { SettleOrderInfo settleOrderInfo; int selectedCouponIndex = -1; - List shopCar = []; - List shopCarGoods = []; - TextEditingController _vc; List addressBgs = [ "assets/svg/dingdan_ziqu.svg", @@ -59,8 +56,6 @@ class _Settlement extends State { void initState() { super.initState(); storeInfo = widget.arguments["storeInfo"]; - shopCar = widget.arguments["shopProduct"]; - shopCarGoods = widget.arguments["shopGoods"]; _vc = TextEditingController( text: storeInfo != null ? storeInfo.headMobile : ""); @@ -68,24 +63,69 @@ class _Settlement extends State { SharedPreferences.getInstance().then((value) { String minToken = value.getString("minToken"); String tenant = value.getString("tenant"); + String storeId = value.getString("storeId"); minService = MinApiService( Dio(), context: context, token: minToken, tenant: tenant, + storeId: storeId, ); - queryOrderInfo(); + queryOrderInfo(null, selectedBtn, null, 0, null); + }); + + startLocation(); + } + + BMFCoordinate myLatLng; + String distance = "0"; + + ///定位获取当前的位置 + void startLocation() async { + Location.getInstance() + .aMapFlutterLocation + .onResultCallback() + .listen((event) { + if (event != null && + event["latitude"] != null && + event["longitude"] != null) { + print("location: $event"); + if (event["latitude"] is String && event["longitude"] is String) { + myLatLng = BMFCoordinate(double.tryParse(event["latitude"]), + double.tryParse(event["longitude"])); + } else { + myLatLng = BMFCoordinate(event["latitude"], event["longitude"]); + } + calculateDistance(); + } }); + Location.getInstance().prepareLoc(); + Location.getInstance().startLocation(context); + } + + ///计算距离(当前位置到店位置直线距离) + calculateDistance() async { + BMFCoordinate bmfCoordinate = BMFCoordinate( + double.tryParse(storeInfo.latitude), + double.tryParse(storeInfo.longitude)); + double mi = + await BMFCalculateUtils.getLocationDistance(bmfCoordinate, myLatLng); + NumberFormat numberFormat = NumberFormat("#.#"); + distance = "${numberFormat.format(mi / 1000)}"; + print("distance: $distance"); + setState(() {}); + Location.getInstance().stopLocation(); } ///订单结算信息 - queryOrderInfo() async { + queryOrderInfo( + addressId, isTake, memberCouponId, orderId, promotionId) async { BaseData baseData = await minService.getOrderInfo({ - "addressId": null, - "isTake": 0, - "memberCouponId": null, - "orderId": 0, - "promotionId": null + "addressId": addressId, + "isTake": isTake, + "memberCouponId": memberCouponId, + "orderId": orderId, + "promotionId": promotionId }); if (baseData != null && baseData.isSuccess) { setState(() { @@ -94,6 +134,55 @@ class _Settlement extends State { } } + Address address; + + queryAddress() async { + if (address != null) { + queryOrderInfo(address.id, selectedBtn, null, 0, null); + return; + } + BaseData> baseDate = + await minService.queryAddress().catchError((error) {}); + + BMFCoordinate bmfCoordinate = BMFCoordinate( + double.tryParse(storeInfo.latitude), + double.tryParse(storeInfo.longitude), + ); + if (baseDate != null && baseDate.isSuccess) { + address = baseDate.data[0]; + for (int i = 1; i < baseDate.data.length; i++) { + Address address1 = baseDate.data[i]; + + BMFCoordinate coordinate = await BMFCalculateUtils.coordConvert( + coordinate: BMFCoordinate( + double.tryParse(address.longitude), + double.tryParse(address.latitude), + ), + fromType: BMF_COORD_TYPE.COMMON, + toType: BMF_COORD_TYPE.BD09LL); + BMFCoordinate coordinate1 = await BMFCalculateUtils.coordConvert( + coordinate: BMFCoordinate( + double.tryParse(address1.longitude), + double.tryParse(address1.latitude), + ), + fromType: BMF_COORD_TYPE.COMMON, + toType: BMF_COORD_TYPE.BD09LL); + + double mi = await BMFCalculateUtils.getLocationDistance( + bmfCoordinate, coordinate); + double mi1 = await BMFCalculateUtils.getLocationDistance( + bmfCoordinate, coordinate1); + print("address 1111: $mi"); + print("address 11: $mi1"); + if (mi1 < mi) { + address = address1; + } + } + + queryOrderInfo(address.id, selectedBtn, null, 0, null); + } + } + ///小程序下单 queryPlaceOrderFirst() async { PlaceOrderFirst placeOrderFirst = PlaceOrderFirst(); @@ -109,34 +198,21 @@ class _Settlement extends State { placeOrderFirst.parentId = 0; placeOrderFirst.payChannel = 1; placeOrderFirst.promotionInfoDTO = PlaceOrderFirstPromotionInfoDTO(); - placeOrderFirst.promotionInfoDTO.couponId = selectedCouponIndex == -1?null : settleOrderInfo.couponList[selectedCouponIndex].couponId; + placeOrderFirst.promotionInfoDTO.couponId = selectedCouponIndex == -1 + ? null + : settleOrderInfo.couponList[selectedCouponIndex].couponId; placeOrderFirst.promotionInfoDTO.promotionId = "0"; placeOrderFirst.recMobile = storeInfo.headMobile; placeOrderFirst.shoppingCartSkuItemList = []; placeOrderFirst.skuItemDTOList = []; - shopCarGoods.forEach((e0) { - SkuItemDTOList skuItemDTOListBean = SkuItemDTOList(); - skuItemDTOListBean.skuId = e0.skuId; - skuItemDTOListBean.buyNum = e0.count; - PlatterList platterListBean = PlatterList(); - platterListBean.skuId = e0.skuId; - platterListBean.productId = e0.id; - skuItemDTOListBean.platterList = []; - skuItemDTOListBean.platterList.add(platterListBean); - placeOrderFirst.skuItemDTOList.add(skuItemDTOListBean); - ShoppingCartSkuItemListBean shoppingCartSkuItemListBean = ShoppingCartSkuItemListBean(); - shoppingCartSkuItemListBean.buyNum = e0.count; - shoppingCartSkuItemListBean.productId = e0.id; - shoppingCartSkuItemListBean.productName = e0.name; - shoppingCartSkuItemListBean.skuId = e0.skuId; - placeOrderFirst.shoppingCartSkuItemList.add(shoppingCartSkuItemListBean); - }); + placeOrderFirst.source = 1; placeOrderFirst.storeId = storeInfo.id; placeOrderFirst.subcribeTime = null; placeOrderFirst.tableId = 0; - BaseData baseData = await minService.placeOrderFirst( - placeOrderFirst.toJson()).catchError((error) {}); + BaseData baseData = await minService + .placeOrderFirst(placeOrderFirst.toJson()) + .catchError((error) {}); if (baseData != null && baseData.isSuccess) { querySettlement(); } @@ -150,97 +226,18 @@ class _Settlement extends State { settlementBean.id = 0; settlementBean.isLogistics = true; settlementBean.orderProductVOList = []; - shopCarGoods.forEach((e0) { - OrderProductVOList orderProductVOListBean = OrderProductVOList(); - orderProductVOListBean.skuId = e0.skuId; - orderProductVOListBean.buyNum = e0.count; - ActInfo actInfoBean = ActInfo(); - actInfoBean.couponDiscountAmount = 0; - actInfoBean.couponDiscountRate = 0; - actInfoBean.couponId = 0; - actInfoBean.couponType = 0; - actInfoBean.discountAmount = 0; - actInfoBean.discountRate = 0; - actInfoBean.promotionId = 0; - actInfoBean.promotionType = 0; - AdditionalComment additionalCommentBean = AdditionalComment(); - additionalCommentBean.bizType = 0; - additionalCommentBean.commentImgs = ""; - additionalCommentBean.commentImgsFlag = false; - additionalCommentBean.commentStar = 0; - additionalCommentBean.commentText = ""; - additionalCommentBean.descStar = 0; - additionalCommentBean.hideFlag = true; - additionalCommentBean.id = 0; - additionalCommentBean.isDelete = true; - additionalCommentBean.likeNum = 0; - additionalCommentBean.logisticsStar = 0; - additionalCommentBean.mid = 0; - additionalCommentBean.orderProductId = 0; - additionalCommentBean.parentId = 0; - additionalCommentBean.productId = 0; - additionalCommentBean.sensitiveFlag = true; - additionalCommentBean.serviceStar = 0; - additionalCommentBean.storeId = 0; - settlementBean.buyNum = 0; - Comment commentBean = Comment(); - commentBean.bizType = 0; - commentBean.commentImgs = ""; - commentBean.commentImgsFlag = true; - commentBean.commentStar = 0; - commentBean.commentText = ""; - commentBean.descStar = 0; - commentBean.hideFlag = true; - commentBean.id = 0; - commentBean.isDelete = true; - commentBean.logisticsStar = 0; - commentBean.mid = 0; - commentBean.orderProductId = 0; - commentBean.parentId = 0; - commentBean.productId = 0; - commentBean.sensitiveFlag = true; - commentBean.serviceStar = 0; - commentBean.storeId = 0; - orderProductVOListBean.commentStatus = 0; - orderProductVOListBean.discountAmount = 0; - orderProductVOListBean.id = 0; - orderProductVOListBean.productId = 0; - orderProductVOListBean.productName = ""; - orderProductVOListBean.returnCode = ""; - orderProductVOListBean.returnStatus = 0; - orderProductVOListBean.returnType = 0; - orderProductVOListBean.sellPrice = 0; - orderProductVOListBean.skuId = "0"; - orderProductVOListBean.skuImg = ""; - orderProductVOListBean.skuNameStr = ""; - settlementBean.orderProductVOList.add(orderProductVOListBean); - }); + settlementBean.payChannel = 0; settlementBean.promotionInfoDTO = PromotionInfoDTO(); settlementBean.promotionInfoDTO.couponId = 0; settlementBean.promotionInfoDTO.promotionId = 0; - BaseData baseData = await minService.settlementApi({ - }).catchError((error) {}); - if (baseData != null && baseData.isSuccess) { - - } + BaseData baseData = + await minService.settlementApi({}).catchError((error) {}); + if (baseData != null && baseData.isSuccess) {} } bool isEdit = false; - String totalPrice(bool discountFlag) { - if (shopCarGoods == null) return ""; - double totalPrice = 0; - shopCarGoods.forEach((element) { - totalPrice += double.tryParse(element.price) * element.count; - }); - if(selectedCouponIndex != -1 && discountFlag){ - double discountA = double.parse(settleOrderInfo.couponList[selectedCouponIndex].discountAmount); - totalPrice -= discountA; - } - return totalPrice.toStringAsFixed(2); - } - @override Widget build(BuildContext context) { return Stack( @@ -267,32 +264,86 @@ class _Settlement extends State { titleSize: 18.sp, ), body: Container( - child: SingleChildScrollView( - physics: BouncingScrollPhysics(), - child: Container( - child: Column( - children: [ - distributionMode(), - SizedBox( - height: 16, - ), + child: Column( + children: [ + Expanded( + child: Container( + child: SingleChildScrollView( + physics: BouncingScrollPhysics(), + child: Container( + child: Column( + children: [ + distributionMode(), + SizedBox( + height: 16, + ), - /// 预留的手机号, 可修改 - phoneWidget(), + /// 预留的手机号, 可修改 + phoneWidget(), - ///订单商品 - SettlementOrderCommodity(shopCar, 0, shopCarGoods, settleOrderInfo), - // if (payStatus == 0) couponRemarks(), - /*(payStatus == 0) ? paySelector() : */ + ///订单商品 + SettlementOrderCommodity( + 0, + settleOrderInfo, + ), + // if (payStatus == 0) couponRemarks(), + /*(payStatus == 0) ? paySelector() : */ - ///优惠券/备注 - activityRemarks(), + ///优惠券/备注 + activityRemarks(), - ///支付方式 - payMethod(), - ], + ///支付方式 + payMethod(), + ], + ), + ), + ), + ), + flex: 1, ), - ), + Container( + height: 54.h, + color: Colors.white, + child: Row( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Spacer(), + Text( + S.of(context).heji, + style: TextStyle( + fontSize: 12.sp, + fontWeight: MyFontWeight.regular, + color: Colors.black, + ), + ), + Text( + "¥${settleOrderInfo.orderSum}", + style: TextStyle( + fontSize: 20.sp, + fontWeight: MyFontWeight.semi_bold, + color: Color(0xFF32A060), + ), + ), + SizedBox( + width: 28, + ), + RoundButton( + width: 103.w, + height: 54.h, + text: S.current.jiesuan, + textColor: Colors.white, + fontWeight: MyFontWeight.regular, + backgroup: Color(0xFF32A060), + fontSize: 16.sp, + padding: EdgeInsets.symmetric( + vertical: 5.h, + ), + callback: () {}, + ), + ], + ), + ), + ], ), ), ), @@ -301,51 +352,6 @@ class _Settlement extends State { top: 0, bottom: 0, ), - Positioned( - bottom: 0, - left: 0, - right: 0, - child: Container( - height: 54.h, - color: Colors.white, - child: Row( - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Spacer(), - Text( - S.of(context).heji, - style: TextStyle( - fontSize: 12.sp, - fontWeight: MyFontWeight.regular, - color: Colors.black, - ), - ), - Text( - "¥19.00", - style: TextStyle( - fontSize: 20.sp, - fontWeight: MyFontWeight.semi_bold, - color: Color(0xFF32A060), - ), - ), - SizedBox( - width: 28, - ), - RoundButton( - width: 103.w, - height: 54.h, - text: S.current.jiesuan, - textColor: Colors.white, - fontWeight: MyFontWeight.regular, - backgroup: Color(0xFF32A060), - fontSize: 16.sp, - padding: EdgeInsets.symmetric(vertical: 5.h,), - callback: () {}, - ), - ], - ), - ), - ) ], ); } @@ -504,9 +510,8 @@ class _Settlement extends State { flex: 1, child: GestureDetector( onTap: () { - setState(() { - selectedBtn = 0; - }); + selectedBtn = 0; + queryOrderInfo(null, selectedBtn, null, 0, null); }, child: Container( height: 50.h, @@ -526,9 +531,8 @@ class _Settlement extends State { flex: 1, child: GestureDetector( onTap: () { - setState(() { - selectedBtn = 1; - }); + selectedBtn = 1; + queryAddress(); }, child: Container( height: 50.h, @@ -579,8 +583,9 @@ class _Settlement extends State { Expanded( child: Column( mainAxisAlignment: - MainAxisAlignment.spaceBetween, + MainAxisAlignment.spaceEvenly, crossAxisAlignment: CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.max, children: [ Text( storeInfo != null @@ -594,7 +599,7 @@ class _Settlement extends State { ), ), SizedBox( - height: 4, + height: 6, ), Text( storeInfo != null @@ -608,9 +613,6 @@ class _Settlement extends State { color: Color(0xFF727272), ), ), - SizedBox( - height: 12, - ), ], ), ), @@ -634,7 +636,9 @@ class _Settlement extends State { RoundButton( width: 41.w, height: 13, - text: "距离您11m", + text: distance.length > 3 + ? "${distance}km" + : "距离您${distance}km", textColor: Color(0xFF34A262), fontWeight: MyFontWeight.semi_bold, radius: 7.5, @@ -649,8 +653,11 @@ class _Settlement extends State { ], ), ], - ) + ), ], + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + mainAxisSize: MainAxisSize.max, ), ], ), @@ -692,13 +699,15 @@ class _Settlement extends State { color: Color(0xFF4C4C4C), ), ), - ), InkWell( + ), + InkWell( onTap: () { setState(() { - Navigator.of(context).popAndPushNamed('/router/manage_address_page'); + Navigator.of(context).popAndPushNamed( + '/router/manage_address_page'); }); }, - child:Icon( + child: Icon( Icons.keyboard_arrow_right, size: 24, ), @@ -772,10 +781,13 @@ class _Settlement extends State { ), ), Text( - (settleOrderInfo?.couponList == null || settleOrderInfo.couponList.length == 0) - ? "暂无可用优惠券" : (selectedCouponIndex == -1 - ? "拥有${settleOrderInfo.couponList.length}张优惠券": - settleOrderInfo.couponList[selectedCouponIndex].promotionName), + (settleOrderInfo?.couponList == null || + settleOrderInfo.couponList.length == 0) + ? "暂无可用优惠券" + : (selectedCouponIndex == -1 + ? "拥有${settleOrderInfo.couponList.length}张优惠券" + : settleOrderInfo + .couponList[selectedCouponIndex].promotionName), textAlign: TextAlign.end, style: TextStyle( fontSize: 14.sp, @@ -956,117 +968,105 @@ class _Settlement extends State { ); } - ///手机号编辑 - // showAlertDialog() { - // //显示对话框 - // showDialog( - // barrierDismissible: false, - // context: context, - // builder: (context) { - // return RenameDialog( - // contentWidget: RenameDialogContent( - // title: "请输入新的手机号码", - // okBtnTap: () { - // // print( - // // "输入框中的文字为:${_vc.text}", - // // ); - // }, - // vc: _vc, - // cancelBtnTap: () {}, - // ), - // ); - // }); - // } - ///优惠券弹窗 couponCart() { showModalBottomSheet( context: context, backgroundColor: Colors.transparent, builder: (context) { - return StatefulBuilder(builder: (context1, state) { - return Container( - alignment: Alignment.topCenter, - width: double.infinity, - height: MediaQuery.of(context).size.height / 2, - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.only( - topLeft: Radius.circular(8), - topRight: Radius.circular(8), + return StatefulBuilder( + builder: (context1, state) { + return Container( + alignment: Alignment.topCenter, + width: double.infinity, + height: MediaQuery.of(context).size.height / 2, + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.only( + topLeft: Radius.circular(8), + topRight: Radius.circular(8), + ), ), - ), - child: Column( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Container( - padding: EdgeInsets.only( - top: 16, - left: 16, - right: 16, - bottom: 8, - ), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Expanded( - child: Text( - (settleOrderInfo?.couponList == null || settleOrderInfo.couponList.length == 0) - ? "暂无可用优惠券" : (selectedCouponIndex == -1 - ? "拥有${settleOrderInfo.couponList.length}张优惠券": - settleOrderInfo.couponList[selectedCouponIndex].promotionName), - style: TextStyle( - color: Color(0xFF000000), - fontSize: 14.sp, - fontWeight: MyFontWeight.medium, + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + padding: EdgeInsets.only( + top: 16, + left: 16, + right: 16, + bottom: 8, + ), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded( + child: Text( + (settleOrderInfo?.couponList == null || + settleOrderInfo.couponList.length == 0) + ? "暂无可用优惠券" + : (selectedCouponIndex == -1 + ? "拥有${settleOrderInfo.couponList.length}张优惠券" + : settleOrderInfo + .couponList[selectedCouponIndex] + .promotionName), + style: TextStyle( + color: Color(0xFF000000), + fontSize: 14.sp, + fontWeight: MyFontWeight.medium, + ), ), ), + InkWell( + onTap: () { + Navigator.of(context).pop(); + }, + child: Image.asset( + "assets/image/cancel.png", + width: 24, + height: 24, + ), + ), + ], + ), + ), + Expanded( + child: Container( + padding: EdgeInsets.only( + top: 8, + left: 16, + right: 16, ), - InkWell( - onTap: () { - Navigator.of(context).pop(); + child: ListView.builder( + itemCount: settleOrderInfo == null + ? 0 + : settleOrderInfo.couponList.length, + physics: BouncingScrollPhysics(), + itemBuilder: (context, position) { + return GestureDetector( + onTap: () {}, + child: couponItem( + settleOrderInfo.couponList[position], + position, + ), + ); }, - child: Image.asset( - "assets/image/cancel.png", - width: 24, - height: 24, - ), ), - ], - ), - ), - Expanded( - child: Container( - padding: EdgeInsets.only( - top: 8, - left: 16, - right: 16, - ), - child: ListView.builder( - itemCount:settleOrderInfo == null ? 0 : settleOrderInfo.couponList.length, - physics: BouncingScrollPhysics(), - itemBuilder: (context, position) { - // return shoppGoodsItem(); - return GestureDetector( - onTap: () {}, - child: couponItem(settleOrderInfo.couponList[position],position), - ); - }, ), ), - ), - ], - ), - ); - }); + ], + ), + ); + }, + ); }, ); } ///优惠券列表 - Widget couponItem(CouponListBean couponList,int index) { + Widget couponItem(CouponListBean couponList, int index) { return StatefulBuilder(builder: (context1, state) { return Container( height: 170, @@ -1212,16 +1212,20 @@ class _Settlement extends State { // SmartDialog.showToast("当前优惠券不可用", alignment: Alignment.center); // return; // } - double toPrice = double.parse(totalPrice(false)); - double amount = double.parse(couponList.fullAmount); - if(toPrice <= amount){ - SmartDialog.showToast("当前金额不够使用优惠券", alignment: Alignment.center); + double toPrice = double.parse("0"); + double amount = + double.parse(couponList.fullAmount); + if (toPrice <= amount) { + SmartDialog.showToast("当前金额不够使用优惠券", + alignment: Alignment.center); return; } state(() { - if(selectedCouponIndex == index) + if (selectedCouponIndex == index) selectedCouponIndex = -1; - else {selectedCouponIndex = index;} + else { + selectedCouponIndex = index; + } }); Navigator.of(context).pop(); }); @@ -1243,7 +1247,7 @@ class _Settlement extends State { ], ), ), - flex: (couponList?.isEx??false) ? 97 : 97, + flex: (couponList?.isEx ?? false) ? 97 : 97, ), Container( padding: EdgeInsets.symmetric(horizontal: 23.w), @@ -1254,7 +1258,7 @@ class _Settlement extends State { ), ), Expanded( - flex: (couponList?.isEx??false) ? 56 : 42, + flex: (couponList?.isEx ?? false) ? 56 : 42, child: Container( margin: EdgeInsets.symmetric(horizontal: 23.w, vertical: 8.h), child: Column( @@ -1273,23 +1277,28 @@ class _Settlement extends State { ), GestureDetector( child: Icon( - (!(couponList?.isEx??false)) + (!(couponList?.isEx ?? false)) ? Icons.keyboard_arrow_down : Icons.keyboard_arrow_up, color: Colors.black, size: 18, ), //点击按钮布局 - onTap: (){ + onTap: () { setState(() { - state((){ - this.settleOrderInfo.couponList[index].isEx = !(this.settleOrderInfo.couponList[index].isEx??false); + state(() { + this.settleOrderInfo.couponList[index].isEx = + !(this + .settleOrderInfo + .couponList[index] + .isEx ?? + false); }); }); }, ), ], ), - if (couponList?.isEx??false) + if (couponList?.isEx ?? false) Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ @@ -1302,7 +1311,7 @@ class _Settlement extends State { ), Text( (couponList.useStartTime == null && - couponList.useEndTime == null) + couponList.useEndTime == null) ? S.of(context).quantian : "${couponList.useStartTime.replaceAll("-", ".").split(" ")[0]} - ${couponList.useEndTime.replaceAll("-", ".").split(" ")[0]}", style: TextStyle( diff --git a/lib/store/store_view/settlement_order_commodity.dart b/lib/settlement/settlement_view/settlement_order_commodity.dart similarity index 89% rename from lib/store/store_view/settlement_order_commodity.dart rename to lib/settlement/settlement_view/settlement_order_commodity.dart index 4a8d66c1..51286a0b 100644 --- a/lib/store/store_view/settlement_order_commodity.dart +++ b/lib/settlement/settlement_view/settlement_order_commodity.dart @@ -3,18 +3,16 @@ import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:huixiang/generated/l10n.dart'; import 'package:huixiang/retrofit/data/findMiNiGroupList.dart'; import 'package:huixiang/retrofit/data/settleOrderInfo.dart'; -import 'package:huixiang/store/sku.dart'; import 'package:huixiang/utils/font_weight.dart'; import 'package:huixiang/view_widget/custom_image.dart'; import 'package:huixiang/view_widget/separator.dart'; class SettlementOrderCommodity extends StatefulWidget { final int isTakeOut; - final List orderInfo; - final List shopCarGood; + final SettleOrderInfo settleOrderInfo; - SettlementOrderCommodity(this.orderInfo, this.isTakeOut,this.shopCarGood,this.settleOrderInfo); + SettlementOrderCommodity(this.isTakeOut,this.settleOrderInfo); @override State createState() { @@ -67,11 +65,11 @@ class _SettlementOrderCommodity extends State { } List commodityList() { - if (widget.orderInfo == null) return []; + if (widget.settleOrderInfo == null) return []; List widgets = []; - if (widget.orderInfo != null) { + if (widget.settleOrderInfo != null) { widgets.addAll( - widget.orderInfo.map((e) => commodityItem(e)).toList()); + widget.settleOrderInfo.orderProductList.map((e) => commodityItem(e)).toList()); } widgets.add(SizedBox(height: 20.h)); @@ -102,20 +100,14 @@ class _SettlementOrderCommodity extends State { return widgets; } - Widget commodityItem(ProductListBean productList) { - Sku goodsBuyInfo; - widget.shopCarGood.forEach((element) { - if(element.id == productList.id){ - goodsBuyInfo = element; - return; - } - }); + Widget commodityItem(OrderProductListBean productList) { + return Container( margin: EdgeInsets.only(top: 8.h, bottom: 8.h), child: Row( children: [ MImage( - productList.imgPath, + productList.skuImg, width: 44.w, height: 44, fit: BoxFit.cover, @@ -146,7 +138,7 @@ class _SettlementOrderCommodity extends State { ), ), Text( - "x${goodsBuyInfo.count}", + "x${productList.buyNum}", style: TextStyle( fontSize: 12.sp, color: Color(0xFF727272), @@ -172,7 +164,7 @@ class _SettlementOrderCommodity extends State { ), ), Text( - S.of(context).yuan_(productList.price), + S.of(context).yuan_(productList.sellPrice), style: TextStyle( fontWeight: FontWeight.bold, fontSize: 12.sp, @@ -319,9 +311,8 @@ class _SettlementOrderCommodity extends State { children: [ Expanded( child: Text( - S.of(context).gongjijianshangpin((widget.orderInfo != null && - widget.orderInfo != null) - ? widget.orderInfo.length + S.of(context).gongjijianshangpin((widget.settleOrderInfo != null) + ? widget.settleOrderInfo.orderProductList.length : "0"), style: TextStyle( fontSize: 10.sp, @@ -356,11 +347,7 @@ class _SettlementOrderCommodity extends State { } String totalPrice() { - if (widget.shopCarGood == null) return ""; - double totalPrice = 0; - widget.shopCarGood.forEach((element) { - totalPrice += double.tryParse(element.price) * element.count; - }); - return "$totalPrice"; + if (widget.settleOrderInfo.orderProductList == null) return ""; + return "${widget.settleOrderInfo.price}"; } } diff --git a/lib/store/sku.dart b/lib/store/sku.dart deleted file mode 100644 index 997b7360..00000000 --- a/lib/store/sku.dart +++ /dev/null @@ -1,71 +0,0 @@ -class Sku { - Sku( - this.id, - this.count, - this.price, - ); - - String id; - int count; - String price; - String name; - String skuId; - String skuValue; - - List attr = []; - - bool compareTo(List attr) { - bool attrY = true; - for (int i = 0; i < this.attr.length; i++) { - if (!this.attr[i].compareTo(attr[i])) { - attrY = false; - return attrY; - } - } - return attrY; - } - - Map toJson() => { - "id": id, - "count": count, - "price": price, - "skuId": skuId, - "name": name, - "value": skuValue, - "attr": attr.map((e) => e.toJson()).toList(), - }; - - Sku copy() { - return Sku( - this.id, - this.count, - this.price, - ) - ..name = this.name - ..skuValue = this.skuValue - ..attr = attr.map((e) => e.copy()).toList(); - } -} - -class Attr { - Attr(this.attrId, this.attrValue); - - String attrId; - String attrValue; - - bool compareTo(Attr attr) { - return attrId == attr.attrId && attrValue == attr.attrValue; - } - - Map toJson() => { - "attrId": attrId, - "attrValue": attrValue, - }; - - Attr copy() { - return Attr( - this.attrId, - this.attrValue, - ); - } -} diff --git a/lib/store/store_order.dart b/lib/store/store_order.dart index 3cffa6e2..015a3936 100644 --- a/lib/store/store_order.dart +++ b/lib/store/store_order.dart @@ -9,13 +9,11 @@ import 'package:flutter_swiper/flutter_swiper.dart'; import 'package:huixiang/generated/l10n.dart'; import 'package:huixiang/retrofit/data/activity.dart'; import 'package:huixiang/retrofit/data/base_data.dart'; -import 'package:huixiang/retrofit/data/findMiNiGroupList.dart'; import 'package:huixiang/retrofit/data/miNiDetail.dart'; import 'package:huixiang/retrofit/data/shoppingCart.dart'; import 'package:huixiang/retrofit/data/store_info.dart'; import 'package:huixiang/retrofit/min_api.dart'; import 'package:huixiang/retrofit/retrofit_api.dart'; -import 'package:huixiang/store/sku.dart'; import 'package:huixiang/store/store_view/product_sku.dart'; import 'package:huixiang/store/store_view/shop_car.dart'; import 'package:huixiang/store/store_view/store_activity.dart'; @@ -53,8 +51,7 @@ class _StoreOrderPage extends State StoreOrderListPage storeOrderListPage; ScrollController controller = ScrollController(); - - List shopCarGoods; + ShoppingCart shopCarGoods; @override void initState() { @@ -112,6 +109,10 @@ class _StoreOrderPage extends State tenant: tenant, storeId: storeId, ); + queryShopCar().then((value) { + this.shopCarGoods = value; + setState(() {}); + }); } }); } @@ -314,7 +315,7 @@ class _StoreOrderPage extends State shopCarGoods, controller, _queryMiNiDetail, - _productListResult, + // _productListResult, _fc, ), @@ -352,7 +353,7 @@ class _StoreOrderPage extends State ), ), Text( - "¥$allPrice", + "¥${shopCarGoods != null ? shopCarGoods.cartSum : "0.0"}", style: TextStyle( fontSize: 20.sp, fontWeight: MyFontWeight.medium, @@ -398,7 +399,7 @@ class _StoreOrderPage extends State child: RoundButton( width: 17, height: 17, - text: "${allCount}", + text: "${count()}", textColor: Colors.white, fontWeight: MyFontWeight.regular, backgroup: Color(0xFF32A060), @@ -415,9 +416,24 @@ class _StoreOrderPage extends State ); } + ///计算个数 + int count() { + if (shopCarGoods == null || + shopCarGoods.shoppingCartSkuItemList == null || + shopCarGoods.shoppingCartSkuItemList.length == 0) return 0; + int count = 0; + shopCarGoods.shoppingCartSkuItemList.forEach((element) { + count += element.buyNum; + }); + return count; + } + + ///去下单结算页面 toDownOrder() { - if (shopCarGoods == null || shopCarGoods.length == 0) { - SmartDialog.showToast("请选择要购买的商品~"); + int num = count(); + + if (num == 0) { + SmartDialog.showToast("请先选择您要购买的商品!~"); return; } @@ -425,7 +441,6 @@ class _StoreOrderPage extends State '/router/settlement', arguments: { "storeInfo": storeInfo, - "shopGoods": shopCarGoods, }, ); } @@ -467,25 +482,26 @@ class _StoreOrderPage extends State ); } + GlobalKey shopCartKey = GlobalKey(); + ///购物车弹窗 showShoppingCart() { queryShopCar().then((value) { - + this.shopCarGoods = value; showModalBottomSheet( context: context, backgroundColor: Colors.transparent, builder: (context) { return ShopCar( - value, + shopCartKey, + this.shopCarGoods, clearShopCar, toDownOrder, - (int count, String productId, allCount, allPrice) { - // print("shopCarCount: $allCount allPrice: $allPrice "); - }, + shopCartAdd, + shopCartReduce, ); }, ); - }); } @@ -493,7 +509,7 @@ class _StoreOrderPage extends State clearShopCar() async { BaseData baseData = await minService.clearShoppingCart(); if (baseData.isSuccess) { - + shopCarGoods = null; setState(() {}); } } @@ -506,58 +522,198 @@ class _StoreOrderPage extends State } } + ///选规格弹窗 + showStoreSelector(MiNiDetail miNiDetail, String id) async { + showModalBottomSheet( + context: context, + backgroundColor: Colors.transparent, + builder: (context) { + return ProductSku( + miNiDetail, + shopCarGoods, + id, + _addShopCar, + add, + reduce, + ); + }, + ); + } + ///添加购物车 - _addShopCar(Sku sku) async { - if (sku != null) { + Future _addShopCar(MiNiDetail miNiDetail, selectSkus, int count) async { + ProductSkuVOListBean productSku = miNiDetail.productSkuVOList.firstWhere((element) { + bool gg = true; + selectSkus.forEach((element1) { + if (element.skuNameStr.indexOf(element1) < 0) { + gg = false; + return gg; + } + }); + return gg; + }); + if (productSku == null) return; + String skuId = productSku.id; + String skuValue = selectSkus.toString().replaceAll("[", "").replaceAll("]", "").replaceAll(",", ""); + + if (miNiDetail != null) { BaseData> baseDate = await minService.addShoppingCart({ "storeId": storeInfo.id, "storeName": storeInfo.storeName ?? "", "tableId": 0, "shoppingCartSkuItemList": [ { - "buyNum": sku.count, - "id": sku.skuId, - "platterList": [ - { - "skuId": sku.skuId - } - ], - "productId": sku.id, - "productName": sku.name, - "skuName": "", + "buyNum": count, + "id": skuId, + "productId": miNiDetail.id, + "productName": miNiDetail.productName, + "skuName": skuValue, "storeId": storeInfo.id, - } + "skuPrice": productSku.applyPrice, + "skuStock": productSku.skuStock, + "tableId": 0, + }, ], }); if (baseDate != null && baseDate.isSuccess) { - queryShopCar(); + queryShopCar().then((value) { + this.shopCarGoods = value; + setState(() {}); + }); } } } ///查询购物车 - Future> queryShopCar() async { + Future queryShopCar() async { BaseData> baseDate = await minService.getShoppingCart(0); - if (baseDate != null && baseDate.isSuccess) { - return baseDate.data; + if (baseDate != null && + baseDate.isSuccess && + baseDate.data != null && + baseDate.data.length > 0) { + return baseDate.data[0]; } else { - return []; + return null; } } - ///选规格弹窗 - showStoreSelector(MiNiDetail miNiDetail, String id) async { - showModalBottomSheet( - context: context, - backgroundColor: Colors.transparent, - builder: (context) { - return ProductSku(miNiDetail, id, _addShopCar); - }, - ); + ///购物车➕1 + shopCartAdd(ShoppingCartSkuItemListBean cartSkuItem) async { + Map shopCarTemp = shopCarGoods.toJson(); + cartSkuItem.buyNum += 1; + shopCarTemp["shoppingCartSkuItemList"] = [cartSkuItem.toJson()]; + BaseData> baseDate = await minService.shoppingCartSingle(shopCarTemp); + if (baseDate.isSuccess) { + queryShopCar().then((value) { + this.shopCarGoods = value; + if (shopCartKey != null) { + shopCartKey.currentState.setState(() {}); + } + setState(() {}); + }); + } + } + + ///购物车➖1 + shopCartReduce(ShoppingCartSkuItemListBean cartSkuItem) async { + Map shopCarTemp = shopCarGoods.toJson(); + cartSkuItem.buyNum -= 1; + shopCarTemp["shoppingCartSkuItemList"] = [cartSkuItem.toJson()]; + BaseData> baseDate = await minService.shoppingCartSingle(shopCarTemp); + if (baseDate.isSuccess) { + queryShopCar().then((value) { + this.shopCarGoods = value; + if (shopCartKey != null) { + shopCartKey.currentState.setState(() {}); + } + setState(() {}); + }); + } + } + + ///商品➕1 + add(MiNiDetail miNiDetail, selectSkus) async { + ProductSkuVOListBean productSku = miNiDetail.productSkuVOList.firstWhere((element) { + return skuY(element, selectSkus); + }); + + if (productSku == null) return; + String skuId = productSku.id; + if (shopCarGoods == null) { + await _addShopCar(miNiDetail, selectSkus, 2); + return; + } + int shopSkuIndex = shopCarGoods.shoppingCartSkuItemList.indexWhere((element) => skuId == element.id); + Map shopCarTemp = shopCarGoods.toJson(); + shopCarGoods.tableId = "0"; + + if (shopSkuIndex >= 0) { + shopCarGoods.shoppingCartSkuItemList[shopSkuIndex].buyNum += 1; + ShoppingCartSkuItemListBean cartSkuItem = shopCarGoods.shoppingCartSkuItemList.firstWhere((element) => skuId == element.id); + shopCarTemp["shoppingCartSkuItemList"] = [cartSkuItem.toJson()]; + } else { + await _addShopCar(miNiDetail, selectSkus, 2); + return; + } + + BaseData> baseDate = await minService.shoppingCartSingle(shopCarTemp); + if (baseDate.isSuccess) { + queryShopCar().then((value) { + this.shopCarGoods = value; + setState(() {}); + }); + } + } + + ///商品➖1 + reduce(MiNiDetail miNiDetail, selectSkus) async { + ProductSkuVOListBean productSku = miNiDetail.productSkuVOList.firstWhere((element) { + return skuY(element, selectSkus); + }); + + if (productSku == null) return; + String skuId = productSku.id; + if (shopCarGoods == null) { + await _addShopCar(miNiDetail, selectSkus, 2); + return; + } + ShoppingCartSkuItemListBean shopSkuItem = shopCarGoods.shoppingCartSkuItemList.firstWhere((element) => skuId == element.skuId); + int shopSkuIndex = shopCarGoods.shoppingCartSkuItemList.indexWhere((element) => skuId == element.skuId); + + if (shopSkuItem != null) { + if (shopSkuItem.buyNum > 1) { + shopCarGoods.shoppingCartSkuItemList[shopSkuIndex].buyNum -= 1; + } + } else { + await _addShopCar(miNiDetail, selectSkus, 2); + return; + } + shopCarGoods.tableId = "0"; + + Map shopCarTemp = shopCarGoods.toJson(); + ShoppingCartSkuItemListBean cartSkuItem = shopCarGoods.shoppingCartSkuItemList.firstWhere((element) => skuId == element.id); + shopCarTemp["shoppingCartSkuItemList"] = [cartSkuItem.toJson()]; + + BaseData> baseDate = await minService.shoppingCartSingle(shopCarTemp); + if (baseDate.isSuccess) { + queryShopCar().then((value) { + this.shopCarGoods = value; + setState(() {}); + }); + } + } + + bool skuY(ProductSkuVOListBean productSku, selectSkus) { + bool gg = true; + selectSkus.forEach((element1) { + if (productSku.skuNameStr.indexOf(element1) < 0) { + gg = false; + return gg; + } + }); + return gg; } -// @override -// bool get wantKeepAlive => true; } class Title extends StatefulWidget { diff --git a/lib/store/store_view/product_sku.dart b/lib/store/store_view/product_sku.dart index efcec472..7d8a6a59 100644 --- a/lib/store/store_view/product_sku.dart +++ b/lib/store/store_view/product_sku.dart @@ -2,16 +2,28 @@ import 'package:flutter/material.dart'; import 'package:huixiang/generated/l10n.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:huixiang/retrofit/data/miNiDetail.dart'; -import 'package:huixiang/store/sku.dart'; +import 'package:huixiang/retrofit/data/shoppingCart.dart'; import 'package:huixiang/utils/font_weight.dart'; import 'package:huixiang/view_widget/custom_image.dart'; import 'package:huixiang/view_widget/round_button.dart'; class ProductSku extends StatefulWidget { + final MiNiDetail miNiDetail; final String productId; - final Function(Sku sku) addShopCar; - ProductSku(this.miNiDetail, this.productId, this.addShopCar); + final Function(MiNiDetail miNiDetail, List selectSkus, int count) addShopCar; + final Function(MiNiDetail miNiDetail, List selectSkus) add; + final Function(MiNiDetail miNiDetail, List selectSkus) reduce; + final ShoppingCart shopCarGoods; + + ProductSku( + this.miNiDetail, + this.shopCarGoods, + this.productId, + this.addShopCar, + this.add, + this.reduce, + ); @override State createState() { @@ -21,29 +33,47 @@ class ProductSku extends StatefulWidget { class _ProductSku extends State { List selectSkus = []; - int selectCount = 1; - Sku tempSelected; + int count = 1; + @override void initState() { super.initState(); - if (widget.miNiDetail != null) { - tempSelected = Sku(widget.productId, 1, widget.miNiDetail.price); - tempSelected.name = widget.miNiDetail.productName; + widget.miNiDetail.attrList.forEach((element) { + selectSkus.add(element.attrValueList[0].attrValue); + }); - widget.miNiDetail.attrList.forEach((element) { - selectSkus.add(element.attrValueList[0].attrValue); - tempSelected.attr.add( - Attr( - "${element.id}", - "${element.attrValueList[0].id}", - ), - ); - }); + buildCount(); + } + + buildCount() { + count = 1; + ProductSkuVOListBean productSku = widget.miNiDetail.productSkuVOList.firstWhere((element) { + return skuY(element, selectSkus); + }); + if (productSku == null) return; + String skuId = productSku.id; + if (widget.shopCarGoods == null || widget.shopCarGoods.shoppingCartSkuItemList == null) return; + int shopSkuIndex = widget.shopCarGoods.shoppingCartSkuItemList.indexWhere((element) => skuId == element.id); + if (shopSkuIndex >= 0) { + count = widget.shopCarGoods.shoppingCartSkuItemList[shopSkuIndex].buyNum; } + + } + + bool skuY(ProductSkuVOListBean productSku, selectSkus) { + bool gg = true; + selectSkus.forEach((element1) { + if (productSku.skuNameStr.indexOf(element1) < 0) { + gg = false; + return gg; + } + }); + return gg; } + @override Widget build(BuildContext context) { return StatefulBuilder(builder: (context1, state) { @@ -150,22 +180,10 @@ class _ProductSku extends State { itemBuilder: (context, position) { return attrItem( (index) { - if (tempSelected.attr == null) { - tempSelected.attr = []; - } - - tempSelected.attr.forEach((e0) { - if (e0.attrId == widget.miNiDetail.attrList[position].id) { - String valueId = widget.miNiDetail.attrList[position].attrValueList[index].id; - if (e0.attrValue != valueId) { - tempSelected.attr[tempSelected.attr.indexOf(e0)].attrValue = valueId; - } - } - }); - state(() { selectSkus[position] = widget.miNiDetail .attrList[position].attrValueList[index].attrValue; + buildCount(); }); }, widget.miNiDetail.attrList[position], @@ -192,10 +210,11 @@ class _ProductSku extends State { ), InkWell( onTap: () { - state(() { - if (selectCount > 1) selectCount--; - }); - tempSelected.count = selectCount; + if (count > 1) + setState(() { + count -= 1; + }); + widget.reduce(widget.miNiDetail, selectSkus); }, child: Image.asset( "assets/image/reduce.png", @@ -206,7 +225,7 @@ class _ProductSku extends State { Padding( padding: EdgeInsets.only(left: 8, right: 8), child: Text( - selectCount.toString(), + "$count", style: TextStyle( color: Colors.black, fontSize: 14.sp, @@ -216,10 +235,10 @@ class _ProductSku extends State { ), InkWell( onTap: () { - state(() { - selectCount++; - tempSelected.count = selectCount; + setState(() { + count += 1; }); + widget.add(widget.miNiDetail, selectSkus); }, child: Image.asset( "assets/image/add.png", @@ -242,7 +261,7 @@ class _ProductSku extends State { backgroup: Color(0xFF32A060), fontSize: 16.sp, callback: () { - _result(); + widget.addShopCar(widget.miNiDetail, selectSkus, 1); }, ), SizedBox( @@ -254,25 +273,6 @@ class _ProductSku extends State { }); } - _result() async { - ProductSkuVOListBean productSku = widget.miNiDetail.productSkuVOList.firstWhere((element) { - bool gg = true; - selectSkus.forEach((element1) { - if (element.skuNameStr.indexOf(element1) < 0) { - gg = false; - return gg; - } - }); - return gg; - }); - // print("productSku: ${selectSkus.toString()}"); - print("productSku: ${tempSelected.toJson()}"); - if (productSku == null) return; - tempSelected.skuId = productSku.id; - tempSelected.skuValue = selectSkus.toString(); - widget.addShopCar(tempSelected); - } - Widget attrItem(Function fc, AttrListBean attrListBean, position) { return Column( crossAxisAlignment: CrossAxisAlignment.start, diff --git a/lib/store/store_view/shop_car.dart b/lib/store/store_view/shop_car.dart index 5432770c..90e7a1da 100644 --- a/lib/store/store_view/shop_car.dart +++ b/lib/store/store_view/shop_car.dart @@ -1,9 +1,6 @@ -import 'package:ai_decimal_accuracy/ai_decimal_accuracy.dart'; import 'package:flutter/material.dart'; import 'package:huixiang/generated/l10n.dart'; -import 'package:huixiang/retrofit/data/findMiNiGroupList.dart'; import 'package:huixiang/retrofit/data/shoppingCart.dart'; -import 'package:huixiang/store/sku.dart'; import 'package:huixiang/store/store_view/shop_goods.dart'; import 'package:huixiang/utils/font_weight.dart'; import 'package:huixiang/view_widget/round_button.dart'; @@ -13,18 +10,20 @@ class ShopCar extends StatefulWidget { final Function(String id) queryMiNiDetail; final Function() clearShopCar; final Function() toDownOrder; + final Function(ShoppingCartSkuItemListBean cart) shopCartAdd; + final Function(ShoppingCartSkuItemListBean cart) shopCartReduce; - final List shopingCar; - - final Function(int count, String productId, int allCount, double allPrice) fc; + ShoppingCart shopingCar; ShopCar( + Key key, this.shopingCar, this.clearShopCar, this.toDownOrder, - this.fc, { + this.shopCartAdd, + this.shopCartReduce, { this.queryMiNiDetail, - }); + }) : super(key: key); @override State createState() { @@ -33,13 +32,6 @@ class ShopCar extends StatefulWidget { } class _ShopCar extends State { - int allCount = 0; - double allPrice = 0.0; - - @override - void initState() { - super.initState(); - } @override Widget build(BuildContext context) { @@ -81,9 +73,7 @@ class _ShopCar extends State { ), InkWell( onTap: () { - allPrice = 0; - allCount = 0; - + widget.shopingCar.shoppingCartSkuItemList.clear(); state(() {}); widget.clearShopCar(); }, @@ -111,27 +101,17 @@ class _ShopCar extends State { right: 16, ), child: ListView.builder( - itemCount: widget.shopingCar == null - ? 0 - : widget.shopingCar.length, + itemCount: itemCount(), physics: BouncingScrollPhysics(), itemBuilder: (context, position) { - return GestureDetector( - onTap: () {}, - child: ShopGoods( - widget.shopingCar[position], - (int count, List attr, String productId) { - - - widget.fc( - count, productId, allCount, allPrice); - - state(() {}); - }, - count: _shopCarGoods(position).count, - shopCarGoods: _shopCarGoods(position), - queryMiNiDetail: widget.queryMiNiDetail, - ), + return ShopGoods( + widget.shopCartAdd, + widget.shopCartReduce, + count: widget.shopingCar + .shoppingCartSkuItemList[position].buyNum, + shoppingCartSkuItemListBean: + widget.shopingCar.shoppingCartSkuItemList[position], + queryMiNiDetail: widget.queryMiNiDetail, ); }, ), @@ -169,7 +149,10 @@ class _ShopCar extends State { ), ), Text( - "¥" + allPrice.toString(), + "¥" + + (widget.shopingCar == null + ? "0.0" + : widget.shopingCar.cartSum), style: TextStyle( fontSize: 20.sp, fontWeight: MyFontWeight.medium, @@ -215,7 +198,7 @@ class _ShopCar extends State { child: RoundButton( width: 17, height: 17, - text: allCount.toString(), + text: "${count()}", textColor: Colors.white, fontWeight: MyFontWeight.regular, backgroup: Color(0xFF32A060), @@ -243,14 +226,24 @@ class _ShopCar extends State { ); } - Sku _shopCarGoods(int position) { - Sku map = widget.shopCarGoods[position]; - // widget.shopCarGoods.forEach((element) { - // if (widget.productLists[position].id == element.id) { - // map = element; - // } - // }); - // print("shopCarGoods123123: ${map.toJson()}"); - return map; + int itemCount() { + if (widget.shopingCar == null || widget.shopingCar.shoppingCartSkuItemList == null || widget.shopingCar.shoppingCartSkuItemList.length == 0) return 0; + int index = widget.shopingCar.shoppingCartSkuItemList.indexWhere((element) => element.buyNum == 0); + if (index >= 0) { + widget.shopingCar.shoppingCartSkuItemList.removeAt(index); + } + int count = widget.shopingCar.shoppingCartSkuItemList.length; + return count; + } + + int count() { + if (widget.shopingCar == null || + widget.shopingCar.shoppingCartSkuItemList == null || + widget.shopingCar.shoppingCartSkuItemList.length == 0) return 0; + int count = 0; + widget.shopingCar.shoppingCartSkuItemList.forEach((element) { + count += element.buyNum; + }); + return count; } } diff --git a/lib/store/store_view/shop_goods.dart b/lib/store/store_view/shop_goods.dart index 728de675..806db92c 100644 --- a/lib/store/store_view/shop_goods.dart +++ b/lib/store/store_view/shop_goods.dart @@ -1,36 +1,37 @@ import 'package:flutter/material.dart'; import 'package:huixiang/generated/l10n.dart'; import 'package:huixiang/retrofit/data/findMiNiGroupList.dart'; -import 'package:huixiang/store/sku.dart'; +import 'package:huixiang/retrofit/data/shoppingCart.dart'; import 'package:huixiang/utils/font_weight.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:huixiang/view_widget/custom_image.dart'; import 'package:huixiang/view_widget/round_button.dart'; class ShopGoods extends StatefulWidget { - final ProductListBean product; + final Function(String id) queryMiNiDetail; - final Function(int count, List attr, String productId) fc; - final Sku shopCarGoods; + final Function(ShoppingCartSkuItemListBean shoppingCartSkuItemListBean) add; + final Function(ShoppingCartSkuItemListBean shoppingCartSkuItemListBean) reduce; + final ProductListBean productListBean; + final ShoppingCartSkuItemListBean shoppingCartSkuItemListBean; final int count; ShopGoods( - this.product, - this.fc, { + this.add, + this.reduce, { + this.productListBean, this.count = 0, this.queryMiNiDetail, - this.shopCarGoods, + this.shoppingCartSkuItemListBean, }); @override State createState() { return _ShopGoods(); } - } class _ShopGoods extends State { - @override Widget build(BuildContext context) { return Container( @@ -47,7 +48,10 @@ class _ShopGoods extends State { children: [ SizedBox(width: 12.w), MImage( - widget.product != null ? widget.product.imgPath : "", + widget.productListBean != null ? widget.productListBean.imgPath : + (widget.shoppingCartSkuItemListBean != null + ? widget.shoppingCartSkuItemListBean.skuImg + : ""), width: 70, height: 70, fit: BoxFit.cover, @@ -62,7 +66,7 @@ class _ShopGoods extends State { crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( - widget.product.productName, + widget.productListBean != null ? widget.productListBean.productName : widget.shoppingCartSkuItemListBean.productName, style: TextStyle( color: Colors.black, fontSize: 13.sp, @@ -72,11 +76,13 @@ class _ShopGoods extends State { SizedBox( height: 2, ), + ///{"id":"1442420413828169728","productId":"1432652566000304128","productName":"桂花乌龙茶","skuName":null,"buyNum":1,"skuStock":1000,"skuImg":"https://pos.upload.gznl.top/1177/2021/08/f855ffb8-d473-4f5f-93c9-5907b539b2fd.jpg", + ///"skuPrice":"0.00","selected":1,"storeId":null,"groupId":"1426067376096411648","createTime":"2021-10-20 10:27:46","tableId":null,"platterList":null} Row( children: [ Expanded( child: Text( - widget.product.shortName, + (widget.productListBean != null ? widget.productListBean.shortName : widget.shoppingCartSkuItemListBean.skuName ?? ""), overflow: TextOverflow.ellipsis, maxLines: 2, style: TextStyle( @@ -113,7 +119,7 @@ class _ShopGoods extends State { width: 4, ), Text( - "¥${widget.product.price}", + "¥${widget.productListBean != null ? widget.productListBean.price : widget.shoppingCartSkuItemListBean.skuPrice}", style: TextStyle( color: Color(0xFFFF7A1A), fontSize: 11.sp, @@ -136,7 +142,7 @@ class _ShopGoods extends State { width: 4, ), Text( - "¥${widget.product.applyPrice}", + "¥${widget.productListBean != null ? widget.productListBean.applyPrice : widget.shoppingCartSkuItemListBean.skuPrice}", style: TextStyle( color: Color(0xFFA29E9E), fontSize: 10.sp, @@ -159,15 +165,14 @@ class _ShopGoods extends State { fontSize: 11.sp, padding: EdgeInsets.symmetric(vertical: 5.h), callback: () { - widget.queryMiNiDetail(widget.product.id); + widget.queryMiNiDetail( + widget.productListBean != null ? widget.productListBean.id : widget.shoppingCartSkuItemListBean.productId); }, ), if (widget.count > 0) InkWell( onTap: () { - reduceCount(); - widget.fc(widget.shopCarGoods.count, widget.shopCarGoods.attr, widget.product.id); - setState(() {}); + widget.reduce(widget.shoppingCartSkuItemListBean); }, child: Image.asset( "assets/image/reduce.png", @@ -191,9 +196,7 @@ class _ShopGoods extends State { if (widget.count > 0) InkWell( onTap: () { - addCount(); - widget.fc(widget.shopCarGoods.count, widget.shopCarGoods.attr, widget.product.id); - setState(() {}); + widget.add(widget.shoppingCartSkuItemListBean); }, child: Image.asset( "assets/image/add.png", @@ -210,14 +213,4 @@ class _ShopGoods extends State { ), ); } - - addCount() { - widget.shopCarGoods.count += 1; - } - - reduceCount() { - widget.shopCarGoods.count -= 1; - } - - } diff --git a/lib/store/store_view/store_order_list.dart b/lib/store/store_view/store_order_list.dart index b3c5464c..aacfef32 100644 --- a/lib/store/store_view/store_order_list.dart +++ b/lib/store/store_view/store_order_list.dart @@ -8,7 +8,6 @@ import 'package:huixiang/retrofit/data/shoppingCart.dart'; import 'package:huixiang/retrofit/data/store_info.dart'; import 'package:huixiang/retrofit/min_api.dart'; import 'package:huixiang/retrofit/retrofit_api.dart'; -import 'package:huixiang/store/sku.dart'; import 'package:huixiang/store/store_view/shop_goods.dart'; import 'package:huixiang/utils/font_weight.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; @@ -22,8 +21,8 @@ class StoreOrderListPage extends StatefulWidget { final ScrollController controller; final Function(int count, String productId, int allCount, double allPrice) fc; final Function(String id) queryMiNiDetail; - final Function(List appletProducts) productListResult; - List shopCarGoods; + // final Function(List appletProducts) productListResult; + ShoppingCart shopCarGoods; StoreOrderListPage( this.arguments, @@ -32,7 +31,7 @@ class StoreOrderListPage extends StatefulWidget { this.shopCarGoods, this.controller, this.queryMiNiDetail, - this.productListResult, + // this.productListResult, this.fc); @override @@ -77,7 +76,7 @@ class _StoreOrderListPage extends State { if (baseData != null && baseData.isSuccess) { setState(() { appletProducts = baseData.data; - widget.productListResult(appletProducts); + // widget.productListResult(appletProducts); productListBeans.clear(); if (appletProducts.length > 0) productListBeans.addAll(appletProducts[0].productList); @@ -198,11 +197,12 @@ class _StoreOrderListPage extends State { } int calculateItemCount(FindMiNiGroupList findMiNiGroupList) { + if (widget.shopCarGoods == null) return 0; int count = 0; findMiNiGroupList.productList.forEach((element) { - widget.shopCarGoods.forEach((element1) { - if (element.id == element1.id) { - count += element1.count; + widget.shopCarGoods.shoppingCartSkuItemList.forEach((element1) { + if (element.id == element1.productId) { + count += element1.buyNum; } }); }); @@ -210,46 +210,35 @@ class _StoreOrderListPage extends State { } Widget goodsItem(position) { - Sku map; + ShoppingCartSkuItemListBean shoppingCartSkuItemListBean; int count = 0; - widget.shopCarGoods.forEach((element) { - if (productListBeans[position].id == element.id) { - if (map == null) { - map = element; - count = map.count; - } else { - count += element.count; + if (widget.shopCarGoods != null) { + widget.shopCarGoods.shoppingCartSkuItemList.forEach((element) { + if (productListBeans[position].id == element.productId) { + if (shoppingCartSkuItemListBean == null) { + shoppingCartSkuItemListBean = element; + count = shoppingCartSkuItemListBean.buyNum; + } else { + count += element.buyNum; + } } - } - }); + }); + } return InkWell( onTap: () { widget.queryMiNiDetail(productListBeans[position].id); }, child: ShopGoods( - productListBeans[position], - (int count, List attr, String productId) { - int allCount = 0; - AiDecimalAccuracy allPrice = AiDecimalAccuracy.zero; - widget.shopCarGoods.forEach((element2) { - if (element2.price != null && element2.price != "") { - double singlePrice = double.tryParse(element2.price); - allCount += element2.count; - - AiDecimalAccuracy aiDecimalAccuracy = - AiDecimalAccuracy.fromInt(element2.count); - AiDecimalAccuracy aiPrice = - AiDecimalAccuracy.tryParse("$singlePrice"); - - allPrice += (aiPrice * aiDecimalAccuracy); - } - }); - widget.fc(count, productId, allCount, allPrice.toDouble()); - setState(() {}); + (ShoppingCartSkuItemListBean shoppingCartSkuItemListBean) { + widget.queryMiNiDetail(productListBeans[position].id); + }, + (ShoppingCartSkuItemListBean shoppingCartSkuItemListBean) { + widget.queryMiNiDetail(productListBeans[position].id); }, + productListBean: productListBeans[position], count: count, queryMiNiDetail: widget.queryMiNiDetail, - shopCarGoods: map, + shoppingCartSkuItemListBean: shoppingCartSkuItemListBean, ), ); } From 5ea6c2d46217d271d53b7b177b17b51e17475908 Mon Sep 17 00:00:00 2001 From: fmk Date: Thu, 21 Oct 2021 16:15:37 +0800 Subject: [PATCH 03/20] safety --- lib/settlement/settlement.dart | 1128 ++--------------- lib/settlement/settlement_view/activity.dart | 165 +++ .../activity_coupon_remarks.dart | 173 +++ lib/settlement/settlement_view/coupon.dart | 268 ++++ .../settlement_view/distribution.dart | 357 ++++++ .../settlement_view/edit_phone.dart | 150 +++ .../settlement_view/pay_method.dart | 156 +++ .../settlement_view/settlement_activity.dart | 174 +++ .../settlement_view/settlement_coupon.dart | 166 +++ .../settlement_order_commodity.dart | 51 +- lib/store/store_order.dart | 24 +- lib/utils/flutter_utils.dart | 14 + lib/utils/location.dart | 52 +- 13 files changed, 1781 insertions(+), 1097 deletions(-) create mode 100644 lib/settlement/settlement_view/activity.dart create mode 100644 lib/settlement/settlement_view/activity_coupon_remarks.dart create mode 100644 lib/settlement/settlement_view/coupon.dart create mode 100644 lib/settlement/settlement_view/distribution.dart create mode 100644 lib/settlement/settlement_view/edit_phone.dart create mode 100644 lib/settlement/settlement_view/pay_method.dart create mode 100644 lib/settlement/settlement_view/settlement_activity.dart create mode 100644 lib/settlement/settlement_view/settlement_coupon.dart diff --git a/lib/settlement/settlement.dart b/lib/settlement/settlement.dart index 89cb8947..b5f6df9b 100644 --- a/lib/settlement/settlement.dart +++ b/lib/settlement/settlement.dart @@ -16,12 +16,17 @@ import 'package:huixiang/retrofit/data/settlement_bean.dart'; import 'package:huixiang/retrofit/data/shoppingCart.dart'; import 'package:huixiang/retrofit/data/store_info.dart'; import 'package:huixiang/retrofit/min_api.dart'; +import 'package:huixiang/settlement/settlement_view/activity_coupon_remarks.dart'; +import 'package:huixiang/settlement/settlement_view/distribution.dart'; +import 'package:huixiang/settlement/settlement_view/edit_phone.dart'; +import 'package:huixiang/settlement/settlement_view/pay_method.dart'; +import 'package:huixiang/settlement/settlement_view/settlement_activity.dart'; +import 'package:huixiang/settlement/settlement_view/settlement_coupon.dart'; import 'package:huixiang/settlement/settlement_view/settlement_order_commodity.dart'; import 'package:huixiang/utils/font_weight.dart'; import 'package:huixiang/utils/location.dart'; import 'package:huixiang/view_widget/my_appbar.dart'; import 'package:huixiang/view_widget/round_button.dart'; -import 'package:huixiang/view_widget/separator.dart'; import 'package:intl/intl.dart'; import 'package:shared_preferences/shared_preferences.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; @@ -39,27 +44,20 @@ class Settlement extends StatefulWidget { class _Settlement extends State { MinApiService minService; - int selectedBtn = 0; Function(int type) callback; StoreInfo storeInfo; SettleOrderInfo settleOrderInfo; - int selectedCouponIndex = -1; + int selectedBtn = 0; - TextEditingController _vc; - List addressBgs = [ - "assets/svg/dingdan_ziqu.svg", - "assets/svg/dingdan_waimai.svg", - "assets/svg/dingdan_wuliu.svg", - ]; + CouponListBean couponListBean; + PromotionInfoListBean promotion; + String mobile; @override void initState() { super.initState(); storeInfo = widget.arguments["storeInfo"]; - _vc = TextEditingController( - text: storeInfo != null ? storeInfo.headMobile : ""); - SharedPreferences.getInstance().then((value) { String minToken = value.getString("minToken"); String tenant = value.getString("tenant"); @@ -73,48 +71,6 @@ class _Settlement extends State { ); queryOrderInfo(null, selectedBtn, null, 0, null); }); - - startLocation(); - } - - BMFCoordinate myLatLng; - String distance = "0"; - - ///定位获取当前的位置 - void startLocation() async { - Location.getInstance() - .aMapFlutterLocation - .onResultCallback() - .listen((event) { - if (event != null && - event["latitude"] != null && - event["longitude"] != null) { - print("location: $event"); - if (event["latitude"] is String && event["longitude"] is String) { - myLatLng = BMFCoordinate(double.tryParse(event["latitude"]), - double.tryParse(event["longitude"])); - } else { - myLatLng = BMFCoordinate(event["latitude"], event["longitude"]); - } - calculateDistance(); - } - }); - Location.getInstance().prepareLoc(); - Location.getInstance().startLocation(context); - } - - ///计算距离(当前位置到店位置直线距离) - calculateDistance() async { - BMFCoordinate bmfCoordinate = BMFCoordinate( - double.tryParse(storeInfo.latitude), - double.tryParse(storeInfo.longitude)); - double mi = - await BMFCalculateUtils.getLocationDistance(bmfCoordinate, myLatLng); - NumberFormat numberFormat = NumberFormat("#.#"); - distance = "${numberFormat.format(mi / 1000)}"; - print("distance: $distance"); - setState(() {}); - Location.getInstance().stopLocation(); } ///订单结算信息 @@ -136,7 +92,8 @@ class _Settlement extends State { Address address; - queryAddress() async { + queryAddress(int selectedBtn) async { + this.selectedBtn = selectedBtn; if (address != null) { queryOrderInfo(address.id, selectedBtn, null, 0, null); return; @@ -172,8 +129,6 @@ class _Settlement extends State { bmfCoordinate, coordinate); double mi1 = await BMFCalculateUtils.getLocationDistance( bmfCoordinate, coordinate1); - print("address 1111: $mi"); - print("address 11: $mi1"); if (mi1 < mi) { address = address1; } @@ -198,9 +153,9 @@ class _Settlement extends State { placeOrderFirst.parentId = 0; placeOrderFirst.payChannel = 1; placeOrderFirst.promotionInfoDTO = PlaceOrderFirstPromotionInfoDTO(); - placeOrderFirst.promotionInfoDTO.couponId = selectedCouponIndex == -1 - ? null - : settleOrderInfo.couponList[selectedCouponIndex].couponId; + // placeOrderFirst.promotionInfoDTO.couponId = selectedCouponIndex == -1 + // ? null + // : settleOrderInfo.couponList[selectedCouponIndex].couponId; placeOrderFirst.promotionInfoDTO.promotionId = "0"; placeOrderFirst.recMobile = storeInfo.headMobile; placeOrderFirst.shoppingCartSkuItemList = []; @@ -236,8 +191,6 @@ class _Settlement extends State { if (baseData != null && baseData.isSuccess) {} } - bool isEdit = false; - @override Widget build(BuildContext context) { return Stack( @@ -273,27 +226,40 @@ class _Settlement extends State { child: Container( child: Column( children: [ - distributionMode(), + DistributionMode( + queryOrderInfo, + queryAddress, + storeInfo, + address, + ), + SizedBox( height: 16, ), /// 预留的手机号, 可修改 - phoneWidget(), + EditPhoneWidget( + storeInfo, + mobileChange, + ), ///订单商品 SettlementOrderCommodity( - 0, + selectedBtn, settleOrderInfo, ), - // if (payStatus == 0) couponRemarks(), - /*(payStatus == 0) ? paySelector() : */ ///优惠券/备注 - activityRemarks(), + ActivityCouponRemarks( + couponCart, + activityCart, + couponListBean, + promotion, + couponCount(), + ), ///支付方式 - payMethod(), + PayMethod(), ], ), ), @@ -317,7 +283,7 @@ class _Settlement extends State { ), ), Text( - "¥${settleOrderInfo.orderSum}", + "¥${settleOrderInfo == null ? "" : settleOrderInfo.price}", style: TextStyle( fontSize: 20.sp, fontWeight: MyFontWeight.semi_bold, @@ -356,994 +322,64 @@ class _Settlement extends State { ); } - /// 预留的手机号, 可修改 - Widget phoneWidget() { - return Container( - margin: EdgeInsets.only( - left: 16, - right: 16, - ), - decoration: BoxDecoration( - color: Colors.white, - boxShadow: [ - BoxShadow( - color: Color(0x0D000000), - offset: Offset(0, 3), - blurRadius: 14, - spreadRadius: 0, - ), - ], - borderRadius: BorderRadius.circular(8), - ), - padding: EdgeInsets.symmetric( - horizontal: 12.w, - vertical: 15.h, - ), - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Text( - S.of(context).yuliudianhua, - overflow: TextOverflow.ellipsis, - style: TextStyle( - fontSize: 14.sp, - fontWeight: MyFontWeight.regular, - color: Color(0xFF4C4C4C), - ), - ), - SizedBox( - width: 50, - ), - Expanded( - child: isEdit - ? Container( - height: 25.h, - alignment: Alignment.centerRight, - child: TextField( - controller: _vc, - style: TextStyle( - fontSize: 14.sp, - fontWeight: MyFontWeight.medium, - color: Color(0xFF4C4C4C), - ), - textAlign: TextAlign.right, - textAlignVertical: TextAlignVertical.center, - keyboardType: TextInputType.phone, - decoration: InputDecoration( - errorBorder: InputBorder.none, - focusedBorder: InputBorder.none, - enabledBorder: InputBorder.none, - hintText: "", - hintStyle: TextStyle( - fontSize: 10.sp, - color: Color(0xFFA29E9E), - ), - ), - textInputAction: TextInputAction.next, - inputFormatters: [LengthLimitingTextInputFormatter(11)], - cursorColor: Colors.grey, - ), - ) - : Container( - height: 25.h, - alignment: Alignment.centerRight, - child: Text( - storeInfo != null ? storeInfo.headMobile : "", - overflow: TextOverflow.ellipsis, - textAlign: TextAlign.end, - style: TextStyle( - fontSize: 14.sp, - fontWeight: MyFontWeight.regular, - color: Color(0xFF4C4C4C), - ), - ), - ), - ), - GestureDetector( - onTap: () { - setState(() { - this.isEdit = !this.isEdit; - }); - }, - child: Container( - padding: EdgeInsets.all(8), - child: isEdit - ? Icon( - Icons.check, - size: 14.w, - color: Color(0xFF32A060), - ) - : Image.asset( - "assets/image/pen.png", - height: 14.h, - width: 14.w, - ), - ), - ), - ], - ), - ); - } - - ///配送方式+地址 - Widget distributionMode() { - return Container( - height: 143.h, - margin: EdgeInsets.only( - left: 16, - right: 16, - top: 10, - ), - child: Stack( - children: [ - Container( - decoration: BoxDecoration( - color: Color(0x80FFFFFF), - boxShadow: [ - BoxShadow( - color: Color(0x0D000000), - offset: Offset(0, 3), - blurRadius: 14, - spreadRadius: 0, - ), - ], - borderRadius: BorderRadius.circular(8), - ), - child: SvgPicture.asset( - addressBgs[selectedBtn], - width: double.infinity, - height: double.infinity, - fit: BoxFit.fill, - ), - ), - Column( - children: [ - Container( - height: 50.h, - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - crossAxisAlignment: CrossAxisAlignment.center, - mainAxisSize: MainAxisSize.max, - children: [ - Expanded( - flex: 1, - child: GestureDetector( - onTap: () { - selectedBtn = 0; - queryOrderInfo(null, selectedBtn, null, 0, null); - }, - child: Container( - height: 50.h, - alignment: Alignment.center, - child: Text( - S.of(context).daodianziqu, - style: TextStyle( - fontSize: 14.sp, - fontWeight: MyFontWeight.semi_bold, - color: Colors.black, - ), - ), - ), - ), - ), - Expanded( - flex: 1, - child: GestureDetector( - onTap: () { - selectedBtn = 1; - queryAddress(); - }, - child: Container( - height: 50.h, - alignment: Alignment.center, - child: Text( - S.of(context).waimaipeisong, - style: TextStyle( - fontSize: 14.sp, - fontWeight: MyFontWeight.regular, - color: Colors.black, - ), - ), - ), - ), - ), - Expanded( - flex: 1, - child: GestureDetector( - onTap: () { - SmartDialog.showToast("该功能暂未开放!", - alignment: Alignment.center); - }, - child: Container( - height: 50.h, - alignment: Alignment.center, - child: Text( - S.of(context).kuaidiwuliu, - style: TextStyle( - fontSize: 14.sp, - fontWeight: MyFontWeight.regular, - color: Colors.black, - ), - ), - ), - ), - ), - ], - ), - ), - selectedBtn == 0 - ? Container( - width: double.infinity, - padding: EdgeInsets.only(left: 16, right: 16, top: 15), - child: Column( - children: [ - Row( - children: [ - Expanded( - child: Column( - mainAxisAlignment: - MainAxisAlignment.spaceEvenly, - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisSize: MainAxisSize.max, - children: [ - Text( - storeInfo != null - ? (storeInfo.storeName ?? "") - : "", - overflow: TextOverflow.ellipsis, - style: TextStyle( - fontSize: 14.sp, - fontWeight: MyFontWeight.semi_bold, - color: Color(0xFF4C4C4C), - ), - ), - SizedBox( - height: 6, - ), - Text( - storeInfo != null - ? storeInfo.address - : "", - overflow: TextOverflow.ellipsis, - maxLines: 2, - style: TextStyle( - fontSize: 12.sp, - fontWeight: MyFontWeight.regular, - color: Color(0xFF727272), - ), - ), - ], - ), - ), - SizedBox( - width: 18, - ), - Stack( - alignment: Alignment.center, - children: [ - Column( - children: [ - Image.asset( - "assets/image/map.png", - height: 61.h, - width: 61.w, - ), - ], - ), - Column( - children: [ - RoundButton( - width: 41.w, - height: 13, - text: distance.length > 3 - ? "${distance}km" - : "距离您${distance}km", - textColor: Color(0xFF34A262), - fontWeight: MyFontWeight.semi_bold, - radius: 7.5, - backgroup: Colors.white, - fontSize: 7.sp, - ), - Image.asset( - "assets/image/landmark.png", - height: 24.h, - width: 24.w, - ), - ], - ), - ], - ), - ], - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.center, - mainAxisSize: MainAxisSize.max, - ), - ], - ), - ) - : Container( - width: double.infinity, - padding: EdgeInsets.only(left: 16, right: 16, top: 15), - child: Column( - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Image.asset( - "assets/image/icon_permission_location.png", - height: 24.h, - width: 24.w, - ), - Text( - "张先生", - overflow: TextOverflow.ellipsis, - style: TextStyle( - fontSize: 15.sp, - fontWeight: MyFontWeight.medium, - color: Color(0xFF4C4C4C), - ), - ), - SizedBox( - width: 13, - ), - Expanded( - child: Text( - "12309090909", - overflow: TextOverflow.ellipsis, - maxLines: 2, - style: TextStyle( - fontSize: 15.sp, - fontWeight: MyFontWeight.medium, - color: Color(0xFF4C4C4C), - ), - ), - ), - InkWell( - onTap: () { - setState(() { - Navigator.of(context).popAndPushNamed( - '/router/manage_address_page'); - }); - }, - child: Icon( - Icons.keyboard_arrow_right, - size: 24, - ), - ), - ], - ), - Padding( - padding: EdgeInsets.only(top: 4, left: 25), - child: Text( - "武昌区中国铁建凯德1818蓝调步行街中北路109附33门牌号05", - overflow: TextOverflow.ellipsis, - maxLines: 2, - style: TextStyle( - fontSize: 12.sp, - fontWeight: MyFontWeight.regular, - color: Color(0xFF727272), - ), - ), - ), - ], - ), - ), - ], - ), - ], - ), - ); - } - - ///活动备注 - Widget activityRemarks() { - return Container( - decoration: BoxDecoration( - color: Colors.white, - boxShadow: [ - BoxShadow( - color: Color(0x0D000000), - offset: Offset(0, 3), - blurRadius: 14, - spreadRadius: 0, - ), - ], - borderRadius: BorderRadius.circular(8), - ), - height: 86.h, - margin: EdgeInsets.only( - left: 16, - right: 16, - top: 15, - ), - padding: EdgeInsets.only( - left: 16, - right: 16, - top: 16, - ), - child: Column( - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Expanded( - flex: 1, - child: Text( - S.of(context).youhuiquan, - style: TextStyle( - fontWeight: MyFontWeight.regular, - fontSize: 14.sp, - color: Color(0xFF353535), - ), - ), - ), - Text( - (settleOrderInfo?.couponList == null || - settleOrderInfo.couponList.length == 0) - ? "暂无可用优惠券" - : (selectedCouponIndex == -1 - ? "拥有${settleOrderInfo.couponList.length}张优惠券" - : settleOrderInfo - .couponList[selectedCouponIndex].promotionName), - textAlign: TextAlign.end, - style: TextStyle( - fontSize: 14.sp, - color: Color(0xFF32A060), - fontWeight: MyFontWeight.semi_bold, - ), - ), - InkWell( - onTap: () { - setState(() { - couponCart(); - }); - }, - child: Icon( - Icons.keyboard_arrow_right, - size: 16, - ), - ), - ], - ), - SizedBox( - height: 13, - ), - Row( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Expanded( - flex: 1, - child: Text( - S.of(context).beizhu, - style: TextStyle( - fontWeight: MyFontWeight.regular, - fontSize: 14.sp, - color: Color(0xFF353535), - ), - ), - ), - Text( - "口味、面包硬度等", - textAlign: TextAlign.end, - style: TextStyle( - fontSize: 14.sp, - color: Color(0xFF353535), - fontWeight: MyFontWeight.semi_bold, - ), - ), - Icon( - Icons.keyboard_arrow_right, - size: 16, - ), - ], - ), - ], - ), - ); + mobileChange(String mobile) { + this.mobile = mobile; } - Widget payMethod() { - return Container( - width: double.infinity, - margin: EdgeInsets.only( - left: 16.w, - right: 16.w, - top: 12.h, - bottom: 4.h, - ), - 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: () { - setState(() { - checkIndex = 1; - }); - }, - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - checkView(1), - Text( - S.of(context).pingtaiyue, - style: TextStyle( - fontSize: 14.sp, - color: Color(0xff353535), - fontWeight: MyFontWeight.semi_bold), - ), - ], - ), - ), - SizedBox( - height: 10, - ), - GestureDetector( - onTap: () { - setState(() { - checkIndex = 2; - }); - }, - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - checkView(2), - Text( - S.of(context).dianpuyue, - style: TextStyle( - fontSize: 14.sp, - color: Color(0xff353535), - fontWeight: MyFontWeight.semi_bold, - ), - ), - ], - ), - ), - SizedBox( - height: 10, - ), - GestureDetector( - onTap: () { - setState(() { - checkIndex = 3; - }); - }, - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - checkView(3), - Spacer(), - 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, - ), - ), - ), - ], - ), - ), - ], - ), - ); + int couponCount() { + if (settleOrderInfo == null || + settleOrderInfo.couponList == null || + settleOrderInfo.couponList.length == 0) return 0; + int count = 0; + settleOrderInfo.couponList.forEach((element) { + if (element.tenantCode == "") { + count++; + } + }); + return count; } ///优惠券弹窗 - couponCart() { - showModalBottomSheet( + couponCart() async { + CouponListBean couponBean = await showModalBottomSheet( context: context, backgroundColor: Colors.transparent, builder: (context) { - return StatefulBuilder( - builder: (context1, state) { - return Container( - alignment: Alignment.topCenter, - width: double.infinity, - height: MediaQuery.of(context).size.height / 2, - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.only( - topLeft: Radius.circular(8), - topRight: Radius.circular(8), - ), - ), - child: Column( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Container( - padding: EdgeInsets.only( - top: 16, - left: 16, - right: 16, - bottom: 8, - ), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Expanded( - child: Text( - (settleOrderInfo?.couponList == null || - settleOrderInfo.couponList.length == 0) - ? "暂无可用优惠券" - : (selectedCouponIndex == -1 - ? "拥有${settleOrderInfo.couponList.length}张优惠券" - : settleOrderInfo - .couponList[selectedCouponIndex] - .promotionName), - style: TextStyle( - color: Color(0xFF000000), - fontSize: 14.sp, - fontWeight: MyFontWeight.medium, - ), - ), - ), - InkWell( - onTap: () { - Navigator.of(context).pop(); - }, - child: Image.asset( - "assets/image/cancel.png", - width: 24, - height: 24, - ), - ), - ], - ), - ), - Expanded( - child: Container( - padding: EdgeInsets.only( - top: 8, - left: 16, - right: 16, - ), - child: ListView.builder( - itemCount: settleOrderInfo == null - ? 0 - : settleOrderInfo.couponList.length, - physics: BouncingScrollPhysics(), - itemBuilder: (context, position) { - return GestureDetector( - onTap: () {}, - child: couponItem( - settleOrderInfo.couponList[position], - position, - ), - ); - }, - ), - ), - ), - ], - ), - ); - }, - ); + return SettlementCoupon(settleOrderInfo, storeInfo, + couponBean: couponListBean); }, ); + if (couponBean != null) { + this.couponListBean = couponBean; + this.promotion = null; + queryOrderInfo( + address != null ? address.id : null, + selectedBtn, + couponListBean != null ? couponListBean.id : null, + 0, + promotion != null ? promotion.id : null); + } } - ///优惠券列表 - Widget couponItem(CouponListBean couponList, int index) { - return StatefulBuilder(builder: (context1, state) { - return Container( - height: 170, - width: double.infinity, - margin: EdgeInsets.fromLTRB(14.w, 6.h, 14.w, 6.h), - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.circular(8), - boxShadow: [ - BoxShadow( - color: Colors.black.withAlpha(12), - offset: Offset(0, 3), - blurRadius: 14, - spreadRadius: 0, - ) - ], - ), - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Expanded( - child: Container( - margin: EdgeInsets.only(top: 14.h, bottom: 8.h), - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Expanded( - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Expanded( - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.baseline, - textBaseline: TextBaseline.alphabetic, - children: [ - Text( - "¥", - style: TextStyle( - fontSize: 22.sp, - fontWeight: MyFontWeight.medium, - color: Color(0xff32A060), - ), - ), - SizedBox( - height: 4.h, - ), - Text( - couponList.discountAmount, - style: TextStyle( - fontSize: 40.sp, - fontWeight: MyFontWeight.semi_bold, - color: Color(0xff32A060), - ), - ), - ], - ), - ), - Text( - S.of(context).manyuankeyong(couponList.fullAmount), - style: TextStyle( - fontSize: 12.sp, - fontWeight: MyFontWeight.semi_bold, - color: Color(0xff32A060), - ), - ), - ], - ), - flex: 1, - ), - Expanded( - flex: 2, - child: Column( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( - children: [ - Container( - padding: EdgeInsets.fromLTRB(4, 2, 4, 2), - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(2), - border: Border.all( - width: 1, - color: Color(0xFFFF7A1A), - style: BorderStyle.solid, - ), - ), - child: Text( - S.of(context).shangjiaquan, - style: TextStyle( - fontSize: 10.sp, - fontWeight: MyFontWeight.medium, - color: Color(0xFFFF7A1A), - ), - ), - ), - SizedBox( - width: 8.w, - ), - Expanded( - child: Text( - storeInfo.storeName, - overflow: TextOverflow.ellipsis, - style: TextStyle( - fontSize: 16.sp, - fontWeight: MyFontWeight.semi_bold, - color: Color(0xff353535), - ), - ), - flex: 1, - ) - ], - ), - Text( - couponList.promotionName, - overflow: TextOverflow.ellipsis, - style: TextStyle( - fontSize: 14.sp, - color: Color(0xff727272), - ), - ), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - crossAxisAlignment: CrossAxisAlignment.end, - children: [ - Text( - S.of(context).quanchangtongyong, - style: TextStyle( - color: Color(0xFF353535), - fontSize: 12.sp, - ), - ), - Container( - margin: EdgeInsets.only(right: 23.w), - child: GestureDetector( - onTap: () { - setState(() { - // if (!couponList.usable){ - // SmartDialog.showToast("当前优惠券不可用", alignment: Alignment.center); - // return; - // } - double toPrice = double.parse("0"); - double amount = - double.parse(couponList.fullAmount); - if (toPrice <= amount) { - SmartDialog.showToast("当前金额不够使用优惠券", - alignment: Alignment.center); - return; - } - state(() { - if (selectedCouponIndex == index) - selectedCouponIndex = -1; - else { - selectedCouponIndex = index; - } - }); - Navigator.of(context).pop(); - }); - }, - child: Image.asset( - selectedCouponIndex != index - ? "assets/image/icon_radio_unselected.png" - : "assets/image/icon_radio_selected.png", - width: 24, - height: 24, - ), - ), - ), - ], - ), - ], - ), - ), - ], - ), - ), - flex: (couponList?.isEx ?? false) ? 97 : 97, - ), - Container( - padding: EdgeInsets.symmetric(horizontal: 23.w), - child: MySeparator( - width: 5.w, - height: 1.h, - color: Color(0xFF353535), - ), - ), - Expanded( - flex: (couponList?.isEx ?? false) ? 56 : 42, - child: Container( - margin: EdgeInsets.symmetric(horizontal: 23.w, vertical: 8.h), - child: Column( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Text( - S.of(context).xiangqing, - style: TextStyle( - color: Color(0xFF353535), - fontSize: 10.sp, - ), - ), - GestureDetector( - child: Icon( - (!(couponList?.isEx ?? false)) - ? Icons.keyboard_arrow_down - : Icons.keyboard_arrow_up, - color: Colors.black, - size: 18, - ), //点击按钮布局 - onTap: () { - setState(() { - state(() { - this.settleOrderInfo.couponList[index].isEx = - !(this - .settleOrderInfo - .couponList[index] - .isEx ?? - false); - }); - }); - }, - ), - ], - ), - if (couponList?.isEx ?? false) - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Text( - S.of(context).shiyongriqi, - style: TextStyle( - color: Color(0xFF353535), - fontSize: 10.sp, - ), - ), - Text( - (couponList.useStartTime == null && - couponList.useEndTime == null) - ? S.of(context).quantian - : "${couponList.useStartTime.replaceAll("-", ".").split(" ")[0]} - ${couponList.useEndTime.replaceAll("-", ".").split(" ")[0]}", - style: TextStyle( - color: Color(0xFF353535), - fontSize: 10.sp, - ), - ), - ], - ), - ], - ), - ), - ), - ], - ), - ); - }); - } - - var checkIndex = 1; - - Widget checkView(var index) { - return Container( - padding: EdgeInsets.only(right: 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, - ), + ///活动弹窗 + activityCart() async { + // if (couponListBean != null) return; + PromotionInfoListBean pro = await showModalBottomSheet( + context: context, + backgroundColor: Colors.transparent, + builder: (context) { + return SettlementActivity(settleOrderInfo, storeInfo); + }, ); + if (pro != null) { + this.promotion = pro; + this.couponListBean = null; + queryOrderInfo( + address != null ? address.id : null, + selectedBtn, + couponListBean != null ? couponListBean.id : null, + 0, + promotion != null ? promotion.id : null); + } } } diff --git a/lib/settlement/settlement_view/activity.dart b/lib/settlement/settlement_view/activity.dart new file mode 100644 index 00000000..199f2346 --- /dev/null +++ b/lib/settlement/settlement_view/activity.dart @@ -0,0 +1,165 @@ +import 'package:flutter/material.dart'; +import 'package:huixiang/retrofit/data/settleOrderInfo.dart'; +import 'package:huixiang/retrofit/data/store_info.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:huixiang/utils/font_weight.dart'; +import 'package:huixiang/view_widget/custom_image.dart'; +import 'package:huixiang/view_widget/icon_text.dart'; +import 'package:huixiang/view_widget/round_button.dart'; + +class ActivityWidget extends StatefulWidget { + final PromotionInfoListBean promotionInfoListBean; + final StoreInfo storeInfo; + final int index; + + final Function() callback; + + ActivityWidget(this.promotionInfoListBean, this.storeInfo, this.index, { this.callback, }); + + @override + State createState() { + return _ActivityWidget(); + } +} + +class _ActivityWidget extends State { + @override + Widget build(BuildContext context) { + return Container( + height: 177, + width: double.infinity, + padding: EdgeInsets.all(16), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(8), + boxShadow: [ + BoxShadow( + color: Colors.black.withAlpha(12), + offset: Offset(0, 3), + blurRadius: 14, + spreadRadius: 0, + ), + ], + ), + child: Column( + children: [ + Expanded( + child: Row( + children: [ + MImage( + widget.promotionInfoListBean != null + ? widget.promotionInfoListBean.image + : "", + fit: BoxFit.cover, + aspectRatio: 1, + errorSrc: "assets/image/default_1.png", + fadeSrc: "assets/image/default_1.png", + ), + SizedBox( + width: 12.w, + ), + Expanded( + child: Column( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + widget.promotionInfoListBean != null + ? (widget.promotionInfoListBean.name ?? "") + : "", + style: TextStyle( + fontWeight: MyFontWeight.medium, + fontSize: 14.sp, + color: Colors.black, + ), + ), + Text( + widget.promotionInfoListBean != null + ? (widget.promotionInfoListBean.description ?? "") + : "", + maxLines: 2, + overflow: TextOverflow.ellipsis, + style: TextStyle( + color: Color(0xFF727272), + fontSize: 12.sp, + fontWeight: MyFontWeight.medium, + ), + ), + SizedBox( + height: 8.w, + ), + IconText( + "全场通用", + leftIcon: Icons.circle, + iconColor: Color(0xFF32A060), + iconSize: 6, + textStyle: TextStyle( + fontSize: 12.sp, + fontWeight: MyFontWeight.regular, + color: Color(0xFF181818), + ), + ), + IconText( + widget.promotionInfoListBean != null + ? ("${widget.promotionInfoListBean.activityStartTime.split(" ")[0].replaceAll("-", ".")}-${widget.promotionInfoListBean.activityEndTime.split(" ")[0].replaceAll("-", ".")}") + : "", + leftIcon: Icons.circle, + iconColor: Color(0xFF32A060), + iconSize: 6, + textStyle: TextStyle( + fontSize: 12.sp, + fontWeight: MyFontWeight.regular, + color: Color(0xFF181818), + ), + ), + ], + ), + ), + ], + ), + flex: 1, + ), + SizedBox( + height: 12.w, + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Text( + "*优惠券与活动不可同时选择", + style: TextStyle( + fontSize: 12.sp, + fontWeight: MyFontWeight.regular, + color: Color(0xFFACACAC), + ), + ), + if (widget.promotionInfoListBean != null && + widget.promotionInfoListBean.canPartake) + RoundButton( + text: "选择活动", + textColor: Colors.white, + padding: EdgeInsets.symmetric( + vertical: 4, + horizontal: 8, + ), + backgroup: Color(0xFF32A060), + radius: 12, + callback: widget.callback, + ) + else + Text( + "条件未达", + style: TextStyle( + color: Color(0xFF868686), + fontWeight: MyFontWeight.medium, + fontSize: 12.sp, + ), + ), + ], + ), + ], + ), + ); + } +} diff --git a/lib/settlement/settlement_view/activity_coupon_remarks.dart b/lib/settlement/settlement_view/activity_coupon_remarks.dart new file mode 100644 index 00000000..cf33dcfb --- /dev/null +++ b/lib/settlement/settlement_view/activity_coupon_remarks.dart @@ -0,0 +1,173 @@ +import 'package:flutter/material.dart'; +import 'package:huixiang/generated/l10n.dart'; +import 'package:huixiang/retrofit/data/settleOrderInfo.dart'; +import 'package:huixiang/utils/font_weight.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; + +class ActivityCouponRemarks extends StatefulWidget { + final Function() couponCart; + final Function() activityCart; + final CouponListBean couponListBean; + final PromotionInfoListBean promotion; + final int couponCount; + + ActivityCouponRemarks( + this.couponCart, + this.activityCart, + this.couponListBean, + this.promotion, + this.couponCount, + ); + + @override + State createState() { + return _ActivityCouponRemarks(); + } +} + +class _ActivityCouponRemarks extends State { + + @override + Widget build(BuildContext context) { + return Container( + decoration: BoxDecoration( + color: Colors.white, + boxShadow: [ + BoxShadow( + color: Color(0x0D000000), + offset: Offset(0, 3), + blurRadius: 14, + spreadRadius: 0, + ), + ], + borderRadius: BorderRadius.circular(8), + ), + height: 122.h, + margin: EdgeInsets.only( + left: 16, + right: 16, + top: 15, + ), + padding: EdgeInsets.only( + left: 16, + right: 16, + top: 14, + bottom: 14, + ), + child: Column( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + InkWell( + onTap: () { + widget.activityCart(); + }, + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Expanded( + flex: 1, + child: Text( + S.of(context).huodong, + style: TextStyle( + fontWeight: MyFontWeight.regular, + fontSize: 14.sp, + color: Color(0xFF353535), + ), + ), + ), + Text( + widget.promotion == null ? "*优惠券与活动不可同时选择" : widget.promotion.name, + textAlign: TextAlign.end, + style: TextStyle( + fontSize: 14.sp, + color: Color(0xFF32A060), + fontWeight: MyFontWeight.semi_bold, + ), + ), + Icon( + Icons.keyboard_arrow_right, + size: 16, + ), + ], + ), + ), + SizedBox( + height: 13, + ), + InkWell( + onTap: () { + widget.couponCart(); + }, + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Expanded( + flex: 1, + child: Text( + S.of(context).youhuiquan, + style: TextStyle( + fontWeight: MyFontWeight.regular, + fontSize: 14.sp, + color: Color(0xFF353535), + ), + ), + ), + Text( + (widget.couponListBean == null) + ? ("未使用优惠券") + : widget.couponListBean.promotionName, + textAlign: TextAlign.end, + style: TextStyle( + fontSize: 14.sp, + color: Color(0xFF32A060), + fontWeight: MyFontWeight.semi_bold, + ), + ), + Icon( + Icons.keyboard_arrow_right, + size: 16, + ), + ], + ), + ), + SizedBox( + height: 13, + ), + Row( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Expanded( + flex: 1, + child: Text( + S.of(context).beizhu, + style: TextStyle( + fontWeight: MyFontWeight.regular, + fontSize: 14.sp, + color: Color(0xFF353535), + ), + ), + ), + Text( + "口味、面包硬度等", + textAlign: TextAlign.end, + style: TextStyle( + fontSize: 14.sp, + color: Color(0xFF353535), + fontWeight: MyFontWeight.semi_bold, + ), + ), + Icon( + Icons.keyboard_arrow_right, + size: 16, + ), + ], + ), + ], + ), + ); + } +} diff --git a/lib/settlement/settlement_view/coupon.dart b/lib/settlement/settlement_view/coupon.dart new file mode 100644 index 00000000..bae2b62b --- /dev/null +++ b/lib/settlement/settlement_view/coupon.dart @@ -0,0 +1,268 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:huixiang/generated/l10n.dart'; +import 'package:huixiang/retrofit/data/settleOrderInfo.dart'; +import 'package:huixiang/retrofit/data/store_info.dart'; +import 'package:huixiang/utils/font_weight.dart'; +import 'package:huixiang/view_widget/separator.dart'; + +class CouponWidget extends StatefulWidget { + final CouponListBean couponList; + final StoreInfo storeInfo; + final bool selected; + + CouponWidget( + this.couponList, + this.storeInfo, { + this.selected = false, + }); + + @override + State createState() { + return _CouponWidget(); + } +} + +class _CouponWidget extends State { + @override + Widget build(BuildContext context) { + return Container( + height: 170, + width: double.infinity, + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(8), + boxShadow: [ + BoxShadow( + color: Colors.black.withAlpha(12), + offset: Offset(0, 3), + blurRadius: 14, + spreadRadius: 0, + ), + ], + ), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Expanded( + child: Container( + margin: EdgeInsets.only(top: 14.h, bottom: 8.h), + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Expanded( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Expanded( + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.baseline, + textBaseline: TextBaseline.alphabetic, + children: [ + Text( + "¥", + style: TextStyle( + fontSize: 22.sp, + fontWeight: MyFontWeight.medium, + color: Color(0xff32A060), + ), + ), + SizedBox( + height: 4.h, + ), + Text( + "${double.tryParse(widget.couponList.discountAmount).toInt()}", + style: TextStyle( + fontSize: 40.sp, + fontWeight: MyFontWeight.semi_bold, + color: Color(0xff32A060), + ), + ), + ], + ), + ), + Text( + S + .of(context) + .manyuankeyong(widget.couponList.fullAmount), + style: TextStyle( + fontSize: 12.sp, + fontWeight: MyFontWeight.semi_bold, + color: Color(0xff32A060), + ), + ), + ], + ), + flex: 1, + ), + Expanded( + flex: 2, + child: Column( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + children: [ + Container( + padding: EdgeInsets.fromLTRB(4, 2, 4, 2), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(2), + border: Border.all( + width: 1, + color: Color(0xFFFF7A1A), + style: BorderStyle.solid, + ), + ), + child: Text( + S.of(context).shangjiaquan, + style: TextStyle( + fontSize: 10.sp, + fontWeight: MyFontWeight.medium, + color: Color(0xFFFF7A1A), + ), + ), + ), + SizedBox( + width: 8.w, + ), + Expanded( + child: Text( + widget.storeInfo.storeName, + overflow: TextOverflow.ellipsis, + style: TextStyle( + fontSize: 16.sp, + fontWeight: MyFontWeight.semi_bold, + color: Color(0xff353535), + ), + ), + flex: 1, + ), + ], + ), + Text( + widget.couponList.promotionName, + overflow: TextOverflow.ellipsis, + style: TextStyle( + fontSize: 14.sp, + color: Color(0xff727272), + ), + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.end, + children: [ + Text( + S.of(context).quanchangtongyong, + style: TextStyle( + color: Color(0xFF353535), + fontSize: 12.sp, + ), + ), + if (widget.couponList.usable) + Container( + margin: EdgeInsets.only(right: 23.w), + child: GestureDetector( + onTap: () { + Navigator.of(context).pop(widget.couponList); + }, + child: Image.asset( + widget.selected + ? "assets/image/icon_radio_unselected.png" + : "assets/image/icon_radio_selected.png", + width: 24, + height: 24, + ), + ), + ), + ], + ), + ], + ), + ), + ], + ), + ), + flex: (widget.couponList?.isEx ?? false) ? 97 : 97, + ), + Container( + padding: EdgeInsets.symmetric(horizontal: 23.w), + child: MySeparator( + width: 5.w, + height: 1.h, + color: Color(0xFF353535), + ), + ), + Expanded( + flex: (widget.couponList?.isEx ?? false) ? 56 : 42, + child: Container( + margin: EdgeInsets.symmetric( + horizontal: 23.w, + vertical: 8.h, + ), + child: Column( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Text( + S.of(context).xiangqing, + style: TextStyle( + color: Color(0xFF353535), + fontSize: 10.sp, + ), + ), + GestureDetector( + child: Icon( + (!(widget.couponList?.isEx ?? false)) + ? Icons.keyboard_arrow_down + : Icons.keyboard_arrow_up, + color: Colors.black, + size: 18, + ), //点击按钮布局 + onTap: () { + setState(() { + widget.couponList.isEx = + !(widget.couponList.isEx ?? false); + }); + }, + ), + ], + ), + if (widget.couponList?.isEx ?? false) + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + S.of(context).shiyongriqi, + style: TextStyle( + color: Color(0xFF353535), + fontSize: 10.sp, + ), + ), + Text( + (widget.couponList.useStartTime == null && + widget.couponList.useEndTime == null) + ? S.of(context).quantian + : "${widget.couponList.useStartTime.replaceAll("-", ".").split(" ")[0]} - ${widget.couponList.useEndTime.replaceAll("-", ".").split(" ")[0]}", + style: TextStyle( + color: Color(0xFF353535), + fontSize: 10.sp, + ), + ), + ], + ), + ], + ), + ), + ), + ], + ), + ); + } +} diff --git a/lib/settlement/settlement_view/distribution.dart b/lib/settlement/settlement_view/distribution.dart new file mode 100644 index 00000000..474906e9 --- /dev/null +++ b/lib/settlement/settlement_view/distribution.dart @@ -0,0 +1,357 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_baidu_mapapi_base/flutter_baidu_mapapi_base.dart'; +import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; +import 'package:flutter_svg/flutter_svg.dart'; +import 'package:huixiang/generated/l10n.dart'; +import 'package:huixiang/retrofit/data/address.dart'; +import 'package:huixiang/retrofit/data/store_info.dart'; +import 'package:huixiang/utils/flutter_utils.dart'; +import 'package:huixiang/utils/font_weight.dart'; +import 'package:huixiang/utils/location.dart'; +import 'package:huixiang/view_widget/round_button.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; + +class DistributionMode extends StatefulWidget { + final Function( + String addressId, + int isTake, + String memberCouponId, + int orderId, + String promotionId, + ) queryOrderInfo; + final Function(int selectedBtn) queryAddress; + final StoreInfo storeInfo; + final Address address; + + DistributionMode( + this.queryOrderInfo, this.queryAddress, this.storeInfo, this.address); + + @override + State createState() { + return _DistributionMode(); + } +} + +class _DistributionMode extends State { + List addressBgs = [ + "assets/svg/dingdan_ziqu.svg", + "assets/svg/dingdan_waimai.svg", + "assets/svg/dingdan_wuliu.svg", + ]; + + BMFCoordinate myLatLng; + String distance = "0"; + int selectedBtn = 0; + + @override + void initState() { + super.initState(); + + startLocation(); + } + + ///定位获取当前的位置 + void startLocation() async { + Location.getInstance() + .aMapFlutterLocation + .onResultCallback() + .listen((event) { + if (event != null && + event["latitude"] != null && + event["longitude"] != null) { + print("location: $event"); + if (event["latitude"] is String && event["longitude"] is String) { + myLatLng = BMFCoordinate(double.tryParse(event["latitude"]), + double.tryParse(event["longitude"])); + } else { + myLatLng = BMFCoordinate(event["latitude"], event["longitude"]); + } + calculate(); + Location.getInstance().stopLocation(); + } + }); + Location.getInstance().prepareLoc(); + Location.getInstance().startLocation(context); + } + + calculate() async { + BMFCoordinate bmfCoordinate = BMFCoordinate( + double.tryParse(widget.storeInfo.latitude), + double.tryParse(widget.storeInfo.longitude), + ); + distance = await AppUtils.calculateDistance(bmfCoordinate, myLatLng); + setState(() {}); + } + + @override + Widget build(BuildContext context) { + return Container( + height: 143.h, + margin: EdgeInsets.only( + left: 16, + right: 16, + top: 10, + ), + child: Stack( + children: [ + Container( + decoration: BoxDecoration( + color: Color(0x80FFFFFF), + boxShadow: [ + BoxShadow( + color: Color(0x0D000000), + offset: Offset(0, 3), + blurRadius: 14, + spreadRadius: 0, + ), + ], + borderRadius: BorderRadius.circular(8), + ), + child: SvgPicture.asset( + addressBgs[selectedBtn], + width: double.infinity, + height: double.infinity, + fit: BoxFit.fill, + ), + ), + Column( + children: [ + Container( + height: 50.h, + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.center, + mainAxisSize: MainAxisSize.max, + children: [ + Expanded( + flex: 1, + child: GestureDetector( + onTap: () { + selectedBtn = 0; + widget.queryOrderInfo( + null, selectedBtn, null, 0, null); + }, + child: Container( + height: 50.h, + alignment: Alignment.center, + child: Text( + S.of(context).daodianziqu, + style: TextStyle( + fontSize: 14.sp, + fontWeight: MyFontWeight.semi_bold, + color: Colors.black, + ), + ), + ), + ), + ), + Expanded( + flex: 1, + child: GestureDetector( + onTap: () { + selectedBtn = 1; + widget.queryAddress(selectedBtn); + }, + child: Container( + height: 50.h, + alignment: Alignment.center, + child: Text( + S.of(context).waimaipeisong, + style: TextStyle( + fontSize: 14.sp, + fontWeight: MyFontWeight.regular, + color: Colors.black, + ), + ), + ), + ), + ), + Expanded( + flex: 1, + child: GestureDetector( + onTap: () { + SmartDialog.showToast("该功能暂未开放!", + alignment: Alignment.center); + }, + child: Container( + height: 50.h, + alignment: Alignment.center, + child: Text( + S.of(context).kuaidiwuliu, + style: TextStyle( + fontSize: 14.sp, + fontWeight: MyFontWeight.regular, + color: Colors.black, + ), + ), + ), + ), + ), + ], + ), + ), + selectedBtn == 0 + ? Container( + width: double.infinity, + padding: EdgeInsets.only(left: 16, right: 16, top: 15), + child: Column( + children: [ + Row( + children: [ + Expanded( + child: Column( + mainAxisAlignment: + MainAxisAlignment.spaceEvenly, + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.max, + children: [ + Text( + widget.storeInfo != null + ? (widget.storeInfo.storeName ?? "") + : "", + overflow: TextOverflow.ellipsis, + style: TextStyle( + fontSize: 14.sp, + fontWeight: MyFontWeight.semi_bold, + color: Color(0xFF4C4C4C), + ), + ), + SizedBox( + height: 6, + ), + Text( + widget.storeInfo != null + ? widget.storeInfo.address + : "", + overflow: TextOverflow.ellipsis, + maxLines: 2, + style: TextStyle( + fontSize: 12.sp, + fontWeight: MyFontWeight.regular, + color: Color(0xFF727272), + ), + ), + ], + ), + ), + SizedBox( + width: 18, + ), + Stack( + alignment: Alignment.center, + children: [ + Column( + children: [ + Image.asset( + "assets/image/map.png", + height: 61.h, + width: 61.w, + ), + ], + ), + Column( + children: [ + RoundButton( + width: 41.w, + height: 13, + text: distance.length > 3 + ? "${distance}km" + : "距离您${distance}km", + textColor: Color(0xFF34A262), + fontWeight: MyFontWeight.semi_bold, + radius: 7.5, + backgroup: Colors.white, + fontSize: 7.sp, + ), + Image.asset( + "assets/image/landmark.png", + height: 24.h, + width: 24.w, + ), + ], + ), + ], + ), + ], + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + mainAxisSize: MainAxisSize.max, + ), + ], + ), + ) + : Container( + width: double.infinity, + padding: EdgeInsets.only(left: 16, right: 16, top: 15), + child: Column( + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Image.asset( + "assets/image/icon_permission_location.png", + height: 24.h, + width: 24.w, + ), + Text( + "张先生", + overflow: TextOverflow.ellipsis, + style: TextStyle( + fontSize: 15.sp, + fontWeight: MyFontWeight.medium, + color: Color(0xFF4C4C4C), + ), + ), + SizedBox( + width: 13, + ), + Expanded( + child: Text( + "12309090909", + overflow: TextOverflow.ellipsis, + maxLines: 2, + style: TextStyle( + fontSize: 15.sp, + fontWeight: MyFontWeight.medium, + color: Color(0xFF4C4C4C), + ), + ), + ), + InkWell( + onTap: () { + setState(() { + Navigator.of(context).popAndPushNamed( + '/router/manage_address_page'); + }); + }, + child: Icon( + Icons.keyboard_arrow_right, + size: 24, + ), + ), + ], + ), + Padding( + padding: EdgeInsets.only(top: 4, left: 25), + child: Text( + "武昌区中国铁建凯德1818蓝调步行街中北路109附33门牌号05", + overflow: TextOverflow.ellipsis, + maxLines: 2, + style: TextStyle( + fontSize: 12.sp, + fontWeight: MyFontWeight.regular, + color: Color(0xFF727272), + ), + ), + ), + ], + ), + ), + ], + ), + ], + ), + ); + } +} diff --git a/lib/settlement/settlement_view/edit_phone.dart b/lib/settlement/settlement_view/edit_phone.dart new file mode 100644 index 00000000..9d3ea619 --- /dev/null +++ b/lib/settlement/settlement_view/edit_phone.dart @@ -0,0 +1,150 @@ +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; +import 'package:huixiang/generated/l10n.dart'; +import 'package:huixiang/retrofit/data/store_info.dart'; +import 'package:huixiang/utils/flutter_utils.dart'; +import 'package:huixiang/utils/font_weight.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; + +class EditPhoneWidget extends StatefulWidget { + + final StoreInfo storeInfo; + final Function(String headMobile) mobileChange; + + EditPhoneWidget(this.storeInfo, this.mobileChange); + + @override + State createState() { + return _EditPhoneWidget(); + } +} + +class _EditPhoneWidget extends State { + bool isEdit = false; + TextEditingController _vc; + + @override + void initState() { + // TODO: implement initState + super.initState(); + _vc = TextEditingController( + text: widget.storeInfo != null ? widget.storeInfo.headMobile : ""); + } + + @override + Widget build(BuildContext context) { + return Container( + margin: EdgeInsets.only( + left: 16, + right: 16, + ), + decoration: BoxDecoration( + color: Colors.white, + boxShadow: [ + BoxShadow( + color: Color(0x0D000000), + offset: Offset(0, 3), + blurRadius: 14, + spreadRadius: 0, + ), + ], + borderRadius: BorderRadius.circular(8), + ), + padding: EdgeInsets.symmetric( + horizontal: 12.w, + vertical: 15.h, + ), + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Text( + S.of(context).yuliudianhua, + overflow: TextOverflow.ellipsis, + style: TextStyle( + fontSize: 14.sp, + fontWeight: MyFontWeight.regular, + color: Color(0xFF4C4C4C), + ), + ), + SizedBox( + width: 50, + ), + Expanded( + child: isEdit + ? Container( + height: 25.h, + alignment: Alignment.centerRight, + child: TextField( + controller: _vc, + style: TextStyle( + fontSize: 14.sp, + fontWeight: MyFontWeight.medium, + color: Color(0xFF4C4C4C), + ), + textAlign: TextAlign.right, + textAlignVertical: TextAlignVertical.center, + keyboardType: TextInputType.phone, + decoration: InputDecoration( + errorBorder: InputBorder.none, + focusedBorder: InputBorder.none, + enabledBorder: InputBorder.none, + hintText: "", + hintStyle: TextStyle( + fontSize: 10.sp, + color: Color(0xFFA29E9E), + ), + ), + textInputAction: TextInputAction.next, + inputFormatters: [LengthLimitingTextInputFormatter(11)], + cursorColor: Colors.grey, + ), + ) + : Container( + height: 25.h, + alignment: Alignment.centerRight, + child: Text( + widget.storeInfo != null + ? widget.storeInfo.headMobile + : "", + overflow: TextOverflow.ellipsis, + textAlign: TextAlign.end, + style: TextStyle( + fontSize: 14.sp, + fontWeight: MyFontWeight.regular, + color: Color(0xFF4C4C4C), + ), + ), + ), + ), + GestureDetector( + onTap: () { + String mobile = _vc.text; + if (mobile != null && AppUtils.isPhone(mobile)) { + widget.mobileChange(mobile); + widget.storeInfo.headMobile = mobile; + } + setState(() { + this.isEdit = !this.isEdit; + }); + }, + child: Container( + padding: EdgeInsets.all(8), + child: isEdit + ? Icon( + Icons.check, + size: 14.w, + color: Color(0xFF32A060), + ) + : Image.asset( + "assets/image/pen.png", + height: 14.h, + width: 14.w, + ), + ), + ), + ], + ), + ); + } +} diff --git a/lib/settlement/settlement_view/pay_method.dart b/lib/settlement/settlement_view/pay_method.dart new file mode 100644 index 00000000..d1598eee --- /dev/null +++ b/lib/settlement/settlement_view/pay_method.dart @@ -0,0 +1,156 @@ + +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 PayMethod extends StatefulWidget { + + @override + State createState() { + return _PayMethod(); + } + +} + +class _PayMethod extends State { + @override + Widget build(BuildContext context) { + return Container( + width: double.infinity, + margin: EdgeInsets.only( + left: 16.w, + right: 16.w, + top: 12.h, + bottom: 4.h, + ), + 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: () { + setState(() { + checkIndex = 1; + }); + }, + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + checkView(1), + Text( + S.of(context).pingtaiyue, + style: TextStyle( + fontSize: 14.sp, + color: Color(0xff353535), + fontWeight: MyFontWeight.semi_bold,), + ), + ], + ), + ), + SizedBox( + height: 10, + ), + GestureDetector( + onTap: () { + setState(() { + checkIndex = 2; + }); + }, + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + checkView(2), + Text( + S.of(context).dianpuyue, + style: TextStyle( + fontSize: 14.sp, + color: Color(0xff353535), + fontWeight: MyFontWeight.semi_bold, + ), + ), + ], + ), + ), + SizedBox( + height: 10, + ), + GestureDetector( + onTap: () { + setState(() { + checkIndex = 3; + }); + }, + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + checkView(3), + Spacer(), + 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, + ), + ), + ), + ], + ), + ), + ], + ), + ); + } + + var checkIndex = 1; + + Widget checkView(var index) { + return Container( + padding: EdgeInsets.only(right: 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, + ), + ); + } + +} \ No newline at end of file diff --git a/lib/settlement/settlement_view/settlement_activity.dart b/lib/settlement/settlement_view/settlement_activity.dart new file mode 100644 index 00000000..088a4844 --- /dev/null +++ b/lib/settlement/settlement_view/settlement_activity.dart @@ -0,0 +1,174 @@ +import 'package:flutter/material.dart'; +import 'package:huixiang/retrofit/data/settleOrderInfo.dart'; +import 'package:huixiang/retrofit/data/store_info.dart'; +import 'package:huixiang/settlement/settlement_view/activity.dart'; +import 'package:huixiang/settlement/settlement_view/coupon.dart'; +import 'package:huixiang/utils/font_weight.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; + +class SettlementActivity extends StatefulWidget { + + final StoreInfo storeInfo; + final SettleOrderInfo settleOrderInfo; + + SettlementActivity(this.settleOrderInfo, this.storeInfo); + + @override + State createState() { + return _SettlementActivity(); + } +} + +class _SettlementActivity extends State { + List promotionInfoCan = []; + List promotionInfoNo = []; + + @override + void initState() { + super.initState(); + + promotionInfoCan.clear(); + promotionInfoNo.clear(); + + if (widget.settleOrderInfo != null && + widget.settleOrderInfo.promotionInfoList != null && + widget.settleOrderInfo.promotionInfoList.length > 0) { + widget.settleOrderInfo.promotionInfoList.forEach((element) { + if (element.canPartake) { + promotionInfoCan.add(element); + } else { + promotionInfoNo.add(element); + } + }); + setState(() {}); + } + } + + @override + Widget build(BuildContext context) { + return StatefulBuilder( + builder: (context1, state) { + return Container( + alignment: Alignment.topCenter, + width: double.infinity, + height: MediaQuery.of(context).size.height / 3 * 2, + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.only( + topLeft: Radius.circular(8), + topRight: Radius.circular(8), + ), + ), + child: SingleChildScrollView( + physics: BouncingScrollPhysics(), + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + padding: EdgeInsets.only( + top: 16, + left: 16, + right: 16, + bottom: 8, + ), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded( + child: Text( + "可参加的活动(${promotionInfoCan.length})", + style: TextStyle( + color: Color(0xFF000000), + fontSize: 14.sp, + fontWeight: MyFontWeight.medium, + ), + ), + ), + InkWell( + onTap: () { + Navigator.of(context).pop(); + }, + child: Image.asset( + "assets/image/cancel.png", + width: 24, + height: 24, + ), + ), + ], + ), + ), + Container( + padding: EdgeInsets.only( + top: 8, + left: 16, + right: 16, + ), + child: ListView.builder( + itemCount: (promotionInfoCan == null || + promotionInfoCan.length == 0) + ? 0 + : promotionInfoCan.length, + shrinkWrap: true, + physics: NeverScrollableScrollPhysics(), + itemBuilder: (context, position) { + return ActivityWidget( + promotionInfoCan[position], + widget.storeInfo, + position, + callback: (){ + Navigator.of(context).pop(promotionInfoCan[position]); + }, + ); + }, + ), + ), + if (promotionInfoNo != null || promotionInfoNo.length > 0) + Container( + padding: EdgeInsets.only( + top: 16, + left: 16, + right: 16, + bottom: 8, + ), + child: Text( + "不可参加的活动", + style: TextStyle( + color: Color(0xFF000000), + fontSize: 14.sp, + fontWeight: MyFontWeight.medium, + ), + ), + ), + if (promotionInfoNo != null || promotionInfoNo.length > 0) + Container( + padding: EdgeInsets.only( + top: 8, + left: 16, + right: 16, + ), + child: ListView.builder( + itemCount: (promotionInfoNo == null || + promotionInfoNo.length == 0) + ? 0 + : promotionInfoNo.length, + shrinkWrap: true, + physics: NeverScrollableScrollPhysics(), + itemBuilder: (context, position) { + return ActivityWidget( + promotionInfoNo[position], + widget.storeInfo, + position, + ); + }, + ), + ), + ], + ), + ), + ); + }, + ); + } +} diff --git a/lib/settlement/settlement_view/settlement_coupon.dart b/lib/settlement/settlement_view/settlement_coupon.dart new file mode 100644 index 00000000..d9bf735f --- /dev/null +++ b/lib/settlement/settlement_view/settlement_coupon.dart @@ -0,0 +1,166 @@ +import 'package:flutter/material.dart'; +import 'package:huixiang/retrofit/data/settleOrderInfo.dart'; +import 'package:huixiang/retrofit/data/store_info.dart'; +import 'package:huixiang/settlement/settlement_view/coupon.dart'; +import 'package:huixiang/utils/font_weight.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; + +class SettlementCoupon extends StatefulWidget { + final StoreInfo storeInfo; + final SettleOrderInfo settleOrderInfo; + final CouponListBean couponBean; + + SettlementCoupon( + this.settleOrderInfo, + this.storeInfo, { + this.couponBean, + }); + + @override + State createState() { + return _SettlementCoupon(); + } +} + +class _SettlementCoupon extends State { + List couponCan = []; + List couponNo = []; + + @override + void initState() { + super.initState(); + + couponCan.clear(); + couponNo.clear(); + + if (widget.settleOrderInfo != null && + widget.settleOrderInfo.couponList != null && + widget.settleOrderInfo.couponList.length > 0) { + widget.settleOrderInfo.couponList.forEach((element) { + if (element.usable) { + couponCan.add(element); + } else { + couponNo.add(element); + } + }); + setState(() {}); + } + } + + @override + Widget build(BuildContext context) { + return StatefulBuilder( + builder: (context1, state) { + return Container( + alignment: Alignment.topCenter, + width: double.infinity, + height: MediaQuery.of(context).size.height / 3 * 2, + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.only( + topLeft: Radius.circular(8), + topRight: Radius.circular(8), + ), + ), + child: SingleChildScrollView( + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + padding: EdgeInsets.only( + top: 16, + left: 16, + right: 16, + bottom: 8, + ), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded( + child: Text( + "可用优惠券(${couponCan.length})", + style: TextStyle( + color: Color(0xFF000000), + fontSize: 14.sp, + fontWeight: MyFontWeight.medium, + ), + ), + ), + InkWell( + onTap: () { + Navigator.of(context).pop(); + }, + child: Image.asset( + "assets/image/cancel.png", + width: 24, + height: 24, + ), + ), + ], + ), + ), + Container( + padding: EdgeInsets.only( + top: 8, + left: 16, + right: 16, + ), + child: ListView.builder( + itemCount: couponCan == null ? 0 : couponCan.length, + physics: NeverScrollableScrollPhysics(), + shrinkWrap: true, + itemBuilder: (context, position) { + return CouponWidget( + couponCan[position], + widget.storeInfo, + selected: widget.couponBean == couponCan[position], + ); + }, + ), + ), + if (couponNo != null || couponNo.length > 0) + Container( + padding: EdgeInsets.only( + top: 16, + left: 16, + right: 16, + bottom: 8, + ), + child: Text( + "不可用优惠券", + style: TextStyle( + color: Color(0xFF000000), + fontSize: 14.sp, + fontWeight: MyFontWeight.medium, + ), + ), + ), + if (couponNo != null || couponNo.length > 0) + Container( + padding: EdgeInsets.only( + top: 8, + left: 16, + right: 16, + ), + child: ListView.builder( + itemCount: couponNo == null ? 0 : couponNo.length, + physics: NeverScrollableScrollPhysics(), + shrinkWrap: true, + itemBuilder: (context, position) { + return CouponWidget( + couponNo[position], + widget.storeInfo, + ); + }, + ), + ), + ], + ), + ), + ); + }, + ); + } +} diff --git a/lib/settlement/settlement_view/settlement_order_commodity.dart b/lib/settlement/settlement_view/settlement_order_commodity.dart index 51286a0b..f4c18d19 100644 --- a/lib/settlement/settlement_view/settlement_order_commodity.dart +++ b/lib/settlement/settlement_view/settlement_order_commodity.dart @@ -12,7 +12,7 @@ class SettlementOrderCommodity extends StatefulWidget { final SettleOrderInfo settleOrderInfo; - SettlementOrderCommodity(this.isTakeOut,this.settleOrderInfo); + SettlementOrderCommodity(this.isTakeOut, this.settleOrderInfo); @override State createState() { @@ -68,8 +68,9 @@ class _SettlementOrderCommodity extends State { if (widget.settleOrderInfo == null) return []; List widgets = []; if (widget.settleOrderInfo != null) { - widgets.addAll( - widget.settleOrderInfo.orderProductList.map((e) => commodityItem(e)).toList()); + widgets.addAll(widget.settleOrderInfo.orderProductList + .map((e) => commodityItem(e)) + .toList()); } widgets.add(SizedBox(height: 20.h)); @@ -81,8 +82,7 @@ class _SettlementOrderCommodity extends State { ? S.of(context).peisongfei : S.of(context).yunfei, "", - "+${widget.settleOrderInfo?.postAge??"0"}" - )); + "+${widget.settleOrderInfo?.postAge ?? "0"}")); } widgets.add(Container( @@ -101,7 +101,6 @@ class _SettlementOrderCommodity extends State { } Widget commodityItem(OrderProductListBean productList) { - return Container( margin: EdgeInsets.only(top: 8.h, bottom: 8.h), child: Row( @@ -153,8 +152,8 @@ class _SettlementOrderCommodity extends State { Expanded( flex: 1, child: Text( - productList.weight != null - ? "${productList.weight}kg" + productList.skuNameStr != null + ? "${productList.skuNameStr ?? ""}" : "", overflow: TextOverflow.ellipsis, style: TextStyle( @@ -315,19 +314,34 @@ class _SettlementOrderCommodity extends State { ? widget.settleOrderInfo.orderProductList.length : "0"), style: TextStyle( - fontSize: 10.sp, - color: Color(0xFFA29E9E), - fontWeight: MyFontWeight.semi_bold), + fontSize: 10.sp, + color: Color(0xFFA29E9E), + fontWeight: MyFontWeight.semi_bold, + ), ), flex: 1, ), + Container( + child: Text( + "已优惠:¥${widget.settleOrderInfo.discountAmount}", + style: TextStyle( + fontSize: 12.sp, + color: Color(0xFF7B7B7B), + fontWeight: MyFontWeight.medium, + ), + ), + ), + SizedBox( + width: 15.w, + ), Container( child: Text( S.of(context).jiesuanjine, style: TextStyle( - fontSize: 12.sp, - color: Color(0xFF353535), - fontWeight: MyFontWeight.semi_bold), + fontSize: 12.sp, + color: Color(0xFF353535), + fontWeight: MyFontWeight.semi_bold, + ), ), ), SizedBox( @@ -337,10 +351,11 @@ class _SettlementOrderCommodity extends State { totalPrice(), textAlign: TextAlign.end, style: TextStyle( - fontSize: 14.sp, - color: Color(0xFF32A060), - fontWeight: MyFontWeight.semi_bold), - ) + fontSize: 14.sp, + color: Color(0xFF32A060), + fontWeight: MyFontWeight.semi_bold, + ), + ), ], ), ); diff --git a/lib/store/store_order.dart b/lib/store/store_order.dart index 015a3936..bc340880 100644 --- a/lib/store/store_order.dart +++ b/lib/store/store_order.dart @@ -25,6 +25,7 @@ import 'package:huixiang/utils/font_weight.dart'; import 'package:huixiang/view_widget/classic_header.dart'; import 'package:huixiang/view_widget/custom_image.dart'; import 'package:huixiang/view_widget/my_tab.dart'; +import 'package:huixiang/view_widget/receive_success.dart'; import 'package:huixiang/view_widget/round_button.dart'; import 'package:pull_to_refresh/pull_to_refresh.dart'; import 'package:shared_preferences/shared_preferences.dart'; @@ -239,7 +240,7 @@ class _StoreOrderPage extends State storeInfo.couponVOList != null) UnionCoupon( storeInfo, - (a) {}, + _receiveCoupon, coupon: true, ), @@ -315,7 +316,6 @@ class _StoreOrderPage extends State shopCarGoods, controller, _queryMiNiDetail, - // _productListResult, _fc, ), @@ -416,6 +416,26 @@ class _StoreOrderPage extends State ); } + ///领取优惠券 + _receiveCoupon(couponId) async { + BaseData baseData = await apiService.receiveCoupon(couponId); + if (baseData != null && baseData.isSuccess) { + queryStoreInfo(); + showAlertDialog(); + } + } + + /// 领取成功弹窗 + showAlertDialog() { + //显示对话框 + showDialog( + context: context, + builder: (BuildContext context) { + return ReceiveSuccess(); + }, + ); + } + ///计算个数 int count() { if (shopCarGoods == null || diff --git a/lib/utils/flutter_utils.dart b/lib/utils/flutter_utils.dart index 494bd722..95a524be 100644 --- a/lib/utils/flutter_utils.dart +++ b/lib/utils/flutter_utils.dart @@ -8,6 +8,14 @@ import 'package:path_provider/path_provider.dart'; class AppUtils { + ///计算距离(当前位置到店位置直线距离) + static Future calculateDistance(BMFCoordinate bmfCoordinate, BMFCoordinate myLatLng) async { + double mi = await BMFCalculateUtils.getLocationDistance(bmfCoordinate, myLatLng); + NumberFormat numberFormat = NumberFormat("#.#"); + return "${numberFormat.format(mi / 1000)}"; + } + + static Future coordConvert(BMFCoordinate latLng) async { return BMFCalculateUtils.coordConvert( coordinate: latLng, @@ -15,6 +23,12 @@ class AppUtils { toType: BMF_COORD_TYPE.COMMON); } + static bool isPhone(mobile) { + RegExp exp = RegExp( + r'^((13[0-9])|(14[0-9])|(15[0-9])|(16[0-9])|(17[0-9])|(18[0-9])|(19[0-9]))\d{8}$'); + return exp.hasMatch(mobile); + } + static double textScale(context) { double textScaleFactor = MediaQuery.of(context).textScaleFactor; // print("textScaleFactor: $textScaleFactor"); diff --git a/lib/utils/location.dart b/lib/utils/location.dart index 404ed9fd..316e5775 100644 --- a/lib/utils/location.dart +++ b/lib/utils/location.dart @@ -1,6 +1,3 @@ - - - import 'dart:io'; import 'package:android_intent_plus/android_intent.dart'; @@ -11,7 +8,6 @@ import 'package:huixiang/view_widget/request_permission.dart'; import 'package:permission_handler/permission_handler.dart'; class Location { - static Location _instance; Location._internal() { @@ -74,8 +70,7 @@ class Location { } void stopLocation() { - if (aMapFlutterLocation != null) - aMapFlutterLocation.stopLocation(); + if (aMapFlutterLocation != null) aMapFlutterLocation.stopLocation(); } enableLocation(context) { @@ -87,8 +82,8 @@ class Location { S.of(context).nindingweigongnengweikaiqi, S.of(context).weilexiangnintuijianfujindemendianxinxi, S.of(context).dakaidingwei, - (result) async { - if(result) { + (result) async { + if (result) { final AndroidIntent intent = AndroidIntent( action: 'action_location_source_settings', package: "com.zsw.huixiang"); @@ -104,29 +99,24 @@ class Location { requestDialog(context) { showCupertinoDialog( - context: context, - builder: (context) { - return RequestPermission( - "assets/image/icon_permission_location_bg.png", - S.of(context).nindingweiquanxianweiyunxu, - S.of(context).weilexiangnintuijianfujindemendianxinxi, - S.of(context).kaiqiquanxian, - (result) async { - if (result) { - await openAppSettings(); - if (await Permission.location.isGranted) { - startLocation(context); - } + context: context, + builder: (context) { + return RequestPermission( + "assets/image/icon_permission_location_bg.png", + S.of(context).nindingweiquanxianweiyunxu, + S.of(context).weilexiangnintuijianfujindemendianxinxi, + S.of(context).kaiqiquanxian, + (result) async { + if (result) { + await openAppSettings(); + if (await Permission.location.isGranted) { + startLocation(context); } - }, - heightRatioWithWidth: 0.82, - ); - }); + } + }, + heightRatioWithWidth: 0.82, + ); + }, + ); } - } - - - - - From f0594426f3f458f912cfdeaf8ce63acfc9f0dd32 Mon Sep 17 00:00:00 2001 From: fmk Date: Thu, 21 Oct 2021 16:19:55 +0800 Subject: [PATCH 04/20] safety --- lib/settlement/settlement.dart | 12 +- lib/store/store_view/settlement.dart | 1339 -------------------------- 2 files changed, 2 insertions(+), 1349 deletions(-) delete mode 100644 lib/store/store_view/settlement.dart diff --git a/lib/settlement/settlement.dart b/lib/settlement/settlement.dart index b5f6df9b..fa5be140 100644 --- a/lib/settlement/settlement.dart +++ b/lib/settlement/settlement.dart @@ -4,16 +4,12 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_baidu_mapapi_base/flutter_baidu_mapapi_base.dart'; import 'package:flutter_baidu_mapapi_utils/flutter_baidu_mapapi_utils.dart'; -import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; -import 'package:flutter_svg/flutter_svg.dart'; import 'package:huixiang/generated/l10n.dart'; import 'package:huixiang/retrofit/data/address.dart'; import 'package:huixiang/retrofit/data/base_data.dart'; -import 'package:huixiang/retrofit/data/findMiNiGroupList.dart'; import 'package:huixiang/retrofit/data/placeOrderFirst.dart'; import 'package:huixiang/retrofit/data/settleOrderInfo.dart'; import 'package:huixiang/retrofit/data/settlement_bean.dart'; -import 'package:huixiang/retrofit/data/shoppingCart.dart'; import 'package:huixiang/retrofit/data/store_info.dart'; import 'package:huixiang/retrofit/min_api.dart'; import 'package:huixiang/settlement/settlement_view/activity_coupon_remarks.dart'; @@ -24,10 +20,8 @@ import 'package:huixiang/settlement/settlement_view/settlement_activity.dart'; import 'package:huixiang/settlement/settlement_view/settlement_coupon.dart'; import 'package:huixiang/settlement/settlement_view/settlement_order_commodity.dart'; import 'package:huixiang/utils/font_weight.dart'; -import 'package:huixiang/utils/location.dart'; import 'package:huixiang/view_widget/my_appbar.dart'; import 'package:huixiang/view_widget/round_button.dart'; -import 'package:intl/intl.dart'; import 'package:shared_preferences/shared_preferences.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; @@ -165,8 +159,7 @@ class _Settlement extends State { placeOrderFirst.storeId = storeInfo.id; placeOrderFirst.subcribeTime = null; placeOrderFirst.tableId = 0; - BaseData baseData = await minService - .placeOrderFirst(placeOrderFirst.toJson()) + BaseData baseData = await minService.placeOrderFirst(placeOrderFirst.toJson()) .catchError((error) {}); if (baseData != null && baseData.isSuccess) { querySettlement(); @@ -186,8 +179,7 @@ class _Settlement extends State { settlementBean.promotionInfoDTO = PromotionInfoDTO(); settlementBean.promotionInfoDTO.couponId = 0; settlementBean.promotionInfoDTO.promotionId = 0; - BaseData baseData = - await minService.settlementApi({}).catchError((error) {}); + BaseData baseData = await minService.settlementApi({}).catchError((error) {}); if (baseData != null && baseData.isSuccess) {} } diff --git a/lib/store/store_view/settlement.dart b/lib/store/store_view/settlement.dart deleted file mode 100644 index 564a42d2..00000000 --- a/lib/store/store_view/settlement.dart +++ /dev/null @@ -1,1339 +0,0 @@ -import 'package:dio/dio.dart'; -import 'package:flutter/cupertino.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter/services.dart'; -import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; -import 'package:flutter_svg/flutter_svg.dart'; -import 'package:huixiang/generated/l10n.dart'; -import 'package:huixiang/order/order_view/order_commodity.dart'; -import 'package:huixiang/order/order_view/order_info.dart'; -import 'package:huixiang/retrofit/data/base_data.dart'; -import 'package:huixiang/retrofit/data/findMiNiGroupList.dart'; -import 'package:huixiang/retrofit/data/placeOrderFirst.dart'; -import 'package:huixiang/retrofit/data/settleOrderInfo.dart'; -import 'package:huixiang/retrofit/data/settlement_bean.dart'; -import 'package:huixiang/retrofit/data/shoppingCart.dart'; -import 'package:huixiang/retrofit/data/store_info.dart'; -import 'package:huixiang/retrofit/min_api.dart'; -import 'package:huixiang/store/store_view/settlement_order_commodity.dart'; -import 'package:huixiang/utils/font_weight.dart'; -import 'package:huixiang/view_widget/my_appbar.dart'; -import 'package:huixiang/view_widget/rename_dialog.dart'; -import 'package:huixiang/view_widget/rename_dialog_content.dart'; -import 'package:huixiang/view_widget/round_button.dart'; -import 'package:huixiang/view_widget/separator.dart'; -import 'package:shared_preferences/shared_preferences.dart'; -import 'package:flutter_screenutil/flutter_screenutil.dart'; - -class Settlement extends StatefulWidget { - final arguments; - - Settlement({this.arguments}); - - @override - State createState() { - return _Settlement(); - } -} - -class _Settlement extends State { - MinApiService minService; - int selectedBtn = 0; - Function(int type) callback; - StoreInfo storeInfo; - SettleOrderInfo settleOrderInfo; - int selectedCouponIndex = -1; - - List shopCar = []; - List> shopCarGoods = []; - - TextEditingController _vc; - List addressBgs = [ - "assets/svg/dingdan_ziqu.svg", - "assets/svg/dingdan_waimai.svg", - "assets/svg/dingdan_wuliu.svg", - ]; - - @override - void initState() { - super.initState(); - storeInfo = widget.arguments["storeInfo"]; - shopCar = widget.arguments["shopProduct"]; - shopCarGoods = widget.arguments["shopGoods"]; - - _vc = TextEditingController( - text: storeInfo != null ? storeInfo.headMobile : ""); - - SharedPreferences.getInstance().then((value) { - String minToken = value.getString("minToken"); - String tenant = value.getString("tenant"); - minService = MinApiService( - Dio(), - context: context, - token: minToken, - tenant: tenant, - ); - queryOrderInfo(); - }); - } - - ///订单结算信息 - queryOrderInfo() async { - BaseData baseData = await minService.getOrderInfo({ - "addressId": null, - "isTake": 0, - "memberCouponId": null, - "orderId": 0, - "promotionId": null - }); - if (baseData != null && baseData.isSuccess) { - setState(() { - settleOrderInfo = baseData.data; - }); - } - } - - ///小程序下单 - queryPlaceOrderFirst() async { - PlaceOrderFirst placeOrderFirst = PlaceOrderFirst(); - placeOrderFirst.addressId = null; - placeOrderFirst.isSubscribe = false; - placeOrderFirst.isTakeOut = 0; - placeOrderFirst.notes = ""; - placeOrderFirst.numberOfPeople = null; - placeOrderFirst.orderSource = 0; - placeOrderFirst.orderType = 0; - placeOrderFirst.orderTypeId = 0; - placeOrderFirst.parentCode = ""; - placeOrderFirst.parentId = 0; - placeOrderFirst.payChannel = 1; - placeOrderFirst.promotionInfoDTO = PlaceOrderFirstPromotionInfoDTO(); - placeOrderFirst.promotionInfoDTO.couponId = selectedCouponIndex == -1?null : settleOrderInfo.couponList[selectedCouponIndex].couponId; - placeOrderFirst.promotionInfoDTO.promotionId = "0"; - placeOrderFirst.recMobile = storeInfo.headMobile; - placeOrderFirst.shoppingCartSkuItemList = []; - placeOrderFirst.skuItemDTOList = []; - shopCarGoods.forEach((e0) { - SkuItemDTOList skuItemDTOListBean = SkuItemDTOList(); - skuItemDTOListBean.skuId = e0["skuId"]; - skuItemDTOListBean.buyNum = e0["count"]; - PlatterList platterListBean = PlatterList(); - platterListBean.skuId = e0["skuId"]; - platterListBean.productId = e0["id"]; - skuItemDTOListBean.platterList = []; - skuItemDTOListBean.platterList.add(platterListBean); - placeOrderFirst.skuItemDTOList.add(skuItemDTOListBean); - ShoppingCartSkuItemListBean shoppingCartSkuItemListBean = ShoppingCartSkuItemListBean(); - shoppingCartSkuItemListBean.buyNum = e0["count"]; - shoppingCartSkuItemListBean.productId = e0["id"]; - shoppingCartSkuItemListBean.productName = e0["name"]; - shoppingCartSkuItemListBean.skuId = e0["skuId"]; - placeOrderFirst.shoppingCartSkuItemList.add(shoppingCartSkuItemListBean); - }); - placeOrderFirst.source = 1; - placeOrderFirst.storeId = storeInfo.id; - placeOrderFirst.subcribeTime = null; - placeOrderFirst.tableId = 0; - BaseData baseData = await minService.placeOrderFirst( - placeOrderFirst.toJson()).catchError((error) {}); - if (baseData != null && baseData.isSuccess) { - querySettlement(); - } - } - - ///结算 - querySettlement() async { - SettlementBean settlementBean = SettlementBean(); - settlementBean.addressId = 0; - settlementBean.buyNum = 0; - settlementBean.id = 0; - settlementBean.isLogistics = true; - settlementBean.orderProductVOList = []; - shopCarGoods.forEach((e0) { - OrderProductVOList orderProductVOListBean = OrderProductVOList(); - orderProductVOListBean.skuId = e0["skuId"]; - orderProductVOListBean.buyNum = e0["count"]; - ActInfo actInfoBean = ActInfo(); - actInfoBean.couponDiscountAmount = 0; - actInfoBean.couponDiscountRate = 0; - actInfoBean.couponId = 0; - actInfoBean.couponType = 0; - actInfoBean.discountAmount = 0; - actInfoBean.discountRate = 0; - actInfoBean.promotionId = 0; - actInfoBean.promotionType = 0; - AdditionalComment additionalCommentBean = AdditionalComment(); - additionalCommentBean.bizType = 0; - additionalCommentBean.commentImgs = ""; - additionalCommentBean.commentImgsFlag = false; - additionalCommentBean.commentStar = 0; - additionalCommentBean.commentText = ""; - additionalCommentBean.descStar = 0; - additionalCommentBean.hideFlag = true; - additionalCommentBean.id = 0; - additionalCommentBean.isDelete = true; - additionalCommentBean.likeNum = 0; - additionalCommentBean.logisticsStar = 0; - additionalCommentBean.mid = 0; - additionalCommentBean.orderProductId = 0; - additionalCommentBean.parentId = 0; - additionalCommentBean.productId = 0; - additionalCommentBean.sensitiveFlag = true; - additionalCommentBean.serviceStar = 0; - additionalCommentBean.storeId = 0; - settlementBean.buyNum = 0; - Comment commentBean = Comment(); - commentBean.bizType = 0; - commentBean.commentImgs = ""; - commentBean.commentImgsFlag = true; - commentBean.commentStar = 0; - commentBean.commentText = ""; - commentBean.descStar = 0; - commentBean.hideFlag = true; - commentBean.id = 0; - commentBean.isDelete = true; - commentBean.logisticsStar = 0; - commentBean.mid = 0; - commentBean.orderProductId = 0; - commentBean.parentId = 0; - commentBean.productId = 0; - commentBean.sensitiveFlag = true; - commentBean.serviceStar = 0; - commentBean.storeId = 0; - orderProductVOListBean.commentStatus = 0; - orderProductVOListBean.discountAmount = 0; - orderProductVOListBean.id = 0; - orderProductVOListBean.productId = 0; - orderProductVOListBean.productName = ""; - orderProductVOListBean.returnCode = ""; - orderProductVOListBean.returnStatus = 0; - orderProductVOListBean.returnType = 0; - orderProductVOListBean.sellPrice = 0; - orderProductVOListBean.skuId = 0; - orderProductVOListBean.skuImg = ""; - orderProductVOListBean.skuNameStr = ""; - settlementBean.orderProductVOList.add(orderProductVOListBean); - }); - settlementBean.payChannel = 0; - settlementBean.promotionInfoDTO = PromotionInfoDTO(); - settlementBean.promotionInfoDTO.couponId = 0; - settlementBean.promotionInfoDTO.promotionId = 0; - BaseData baseData = await minService.settlementApi({ - }).catchError((error) {}); - if (baseData != null && baseData.isSuccess) { - - } - } - - bool isEdit = false; - - String totalPrice(bool discountFlag) { - if (shopCarGoods == null) return ""; - double totalPrice = 0; - shopCarGoods.forEach((element) { - totalPrice += double.tryParse(element["price"]) * element["count"]; - }); - if(selectedCouponIndex != -1 && discountFlag){ - double discountA = double.parse(settleOrderInfo.couponList[selectedCouponIndex].discountAmount); - totalPrice -= discountA; - } - return totalPrice.toStringAsFixed(2); - } - - @override - Widget build(BuildContext context) { - return Stack( - children: [ - Positioned( - top: 0, - left: 0, - right: 0, - child: Container( - height: 175.h, - color: Color(0xFF3A405A), - width: MediaQuery.of(context).size.width, - ), - ), - Positioned( - child: Scaffold( - backgroundColor: Colors.transparent, - appBar: MyAppBar( - background: Color(0xFF3A405A), - leadingColor: Colors.white, - title: S.of(context).dingdanjiesuan, - titleColor: Colors.white, - brightness: Brightness.dark, - titleSize: 18.sp, - ), - body: Container( - child: SingleChildScrollView( - physics: BouncingScrollPhysics(), - child: Container( - child: Column( - children: [ - distributionMode(), - SizedBox( - height: 16, - ), - - /// 预留的手机号, 可修改 - phoneWidget(), - - ///订单商品 - SettlementOrderCommodity(shopCar, 0,shopCarGoods,settleOrderInfo), - // if (payStatus == 0) couponRemarks(), - /*(payStatus == 0) ? paySelector() : */ - - ///优惠券/备注 - activityRemarks(), - - ///支付方式 - payMethod(), - ], - ), - ), - ), - ), - ), - left: 0, - right: 0, - top: 0, - bottom: 0, - ), - Positioned( - bottom: 0, - left: 0, - right: 0, - child: Container( - height: 54.h, - color: Colors.white, - child: Row( - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Spacer(), - Text( - S.of(context).heji, - style: TextStyle( - fontSize: 12.sp, - fontWeight: MyFontWeight.regular, - color: Colors.black, - ), - ), - Text( - "¥19.00", - style: TextStyle( - fontSize: 20.sp, - fontWeight: MyFontWeight.semi_bold, - color: Color(0xFF32A060), - ), - ), - SizedBox( - width: 28, - ), - RoundButton( - width: 103.w, - height: 54.h, - text: S.current.jiesuan, - textColor: Colors.white, - fontWeight: MyFontWeight.regular, - backgroup: Color(0xFF32A060), - fontSize: 16.sp, - padding: EdgeInsets.symmetric(vertical: 5.h,), - callback: () {}, - ), - ], - ), - ), - ) - ], - ); - } - - /// 预留的手机号, 可修改 - Widget phoneWidget() { - return Container( - margin: EdgeInsets.only( - left: 16, - right: 16, - ), - decoration: BoxDecoration( - color: Colors.white, - boxShadow: [ - BoxShadow( - color: Color(0x0D000000), - offset: Offset(0, 3), - blurRadius: 14, - spreadRadius: 0, - ), - ], - borderRadius: BorderRadius.circular(8), - ), - padding: EdgeInsets.symmetric( - horizontal: 12.w, - vertical: 15.h, - ), - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Text( - S.of(context).yuliudianhua, - overflow: TextOverflow.ellipsis, - style: TextStyle( - fontSize: 14.sp, - fontWeight: MyFontWeight.regular, - color: Color(0xFF4C4C4C), - ), - ), - SizedBox( - width: 50, - ), - Expanded( - child: isEdit - ? Container( - height: 25.h, - alignment: Alignment.centerRight, - child: TextField( - controller: _vc, - style: TextStyle( - fontSize: 14.sp, - fontWeight: MyFontWeight.medium, - color: Color(0xFF4C4C4C), - ), - textAlign: TextAlign.right, - textAlignVertical: TextAlignVertical.center, - keyboardType: TextInputType.phone, - decoration: InputDecoration( - errorBorder: InputBorder.none, - focusedBorder: InputBorder.none, - enabledBorder: InputBorder.none, - hintText: "", - hintStyle: TextStyle( - fontSize: 10.sp, - color: Color(0xFFA29E9E), - ), - ), - textInputAction: TextInputAction.next, - inputFormatters: [LengthLimitingTextInputFormatter(11)], - cursorColor: Colors.grey, - ), - ) - : Container( - height: 25.h, - alignment: Alignment.centerRight, - child: Text( - storeInfo != null ? storeInfo.headMobile : "", - overflow: TextOverflow.ellipsis, - textAlign: TextAlign.end, - style: TextStyle( - fontSize: 14.sp, - fontWeight: MyFontWeight.regular, - color: Color(0xFF4C4C4C), - ), - ), - ), - ), - GestureDetector( - onTap: () { - setState(() { - this.isEdit = !this.isEdit; - }); - }, - child: Container( - padding: EdgeInsets.all(8), - child: isEdit - ? Icon( - Icons.check, - size: 14.w, - color: Color(0xFF32A060), - ) - : Image.asset( - "assets/image/pen.png", - height: 14.h, - width: 14.w, - ), - ), - ), - ], - ), - ); - } - - ///配送方式+地址 - Widget distributionMode() { - return Container( - height: 143.h, - margin: EdgeInsets.only( - left: 16, - right: 16, - top: 10, - ), - child: Stack( - children: [ - Container( - decoration: BoxDecoration( - color: Color(0x80FFFFFF), - boxShadow: [ - BoxShadow( - color: Color(0x0D000000), - offset: Offset(0, 3), - blurRadius: 14, - spreadRadius: 0, - ), - ], - borderRadius: BorderRadius.circular(8), - ), - child: SvgPicture.asset( - addressBgs[selectedBtn], - width: double.infinity, - height: double.infinity, - fit: BoxFit.fill, - ), - ), - Column( - children: [ - Container( - height: 50.h, - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - crossAxisAlignment: CrossAxisAlignment.center, - mainAxisSize: MainAxisSize.max, - children: [ - Expanded( - flex: 1, - child: GestureDetector( - onTap: () { - setState(() { - selectedBtn = 0; - }); - }, - child: Container( - height: 50.h, - alignment: Alignment.center, - child: Text( - S.of(context).daodianziqu, - style: TextStyle( - fontSize: 14.sp, - fontWeight: MyFontWeight.semi_bold, - color: Colors.black, - ), - ), - ), - ), - ), - Expanded( - flex: 1, - child: GestureDetector( - onTap: () { - setState(() { - selectedBtn = 1; - }); - }, - child: Container( - height: 50.h, - alignment: Alignment.center, - child: Text( - S.of(context).waimaipeisong, - style: TextStyle( - fontSize: 14.sp, - fontWeight: MyFontWeight.regular, - color: Colors.black, - ), - ), - ), - ), - ), - Expanded( - flex: 1, - child: GestureDetector( - onTap: () { - SmartDialog.showToast("该功能暂未开放!", - alignment: Alignment.center); - }, - child: Container( - height: 50.h, - alignment: Alignment.center, - child: Text( - S.of(context).kuaidiwuliu, - style: TextStyle( - fontSize: 14.sp, - fontWeight: MyFontWeight.regular, - color: Colors.black, - ), - ), - ), - ), - ), - ], - ), - ), - selectedBtn == 0 - ? Container( - width: double.infinity, - padding: EdgeInsets.only(left: 16, right: 16, top: 15), - child: Column( - children: [ - Row( - children: [ - Expanded( - child: Column( - mainAxisAlignment: - MainAxisAlignment.spaceBetween, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - storeInfo != null - ? (storeInfo.storeName ?? "") - : "", - overflow: TextOverflow.ellipsis, - style: TextStyle( - fontSize: 14.sp, - fontWeight: MyFontWeight.semi_bold, - color: Color(0xFF4C4C4C), - ), - ), - SizedBox( - height: 4, - ), - Text( - storeInfo != null - ? storeInfo.address - : "", - overflow: TextOverflow.ellipsis, - maxLines: 2, - style: TextStyle( - fontSize: 12.sp, - fontWeight: MyFontWeight.regular, - color: Color(0xFF727272), - ), - ), - SizedBox( - height: 12, - ), - ], - ), - ), - SizedBox( - width: 18, - ), - Stack( - alignment: Alignment.center, - children: [ - Column( - children: [ - Image.asset( - "assets/image/map.png", - height: 61.h, - width: 61.w, - ), - ], - ), - Column( - children: [ - RoundButton( - width: 41.w, - height: 13, - text: "距离您11m", - textColor: Color(0xFF34A262), - fontWeight: MyFontWeight.semi_bold, - radius: 7.5, - backgroup: Colors.white, - fontSize: 7.sp, - ), - Image.asset( - "assets/image/landmark.png", - height: 24.h, - width: 24.w, - ), - ], - ), - ], - ) - ], - ), - ], - ), - ) - : Container( - width: double.infinity, - padding: EdgeInsets.only(left: 16, right: 16, top: 15), - child: Column( - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Image.asset( - "assets/image/icon_permission_location.png", - height: 24.h, - width: 24.w, - ), - Text( - "张先生", - overflow: TextOverflow.ellipsis, - style: TextStyle( - fontSize: 15.sp, - fontWeight: MyFontWeight.medium, - color: Color(0xFF4C4C4C), - ), - ), - SizedBox( - width: 13, - ), - Expanded( - child: Text( - "12309090909", - overflow: TextOverflow.ellipsis, - maxLines: 2, - style: TextStyle( - fontSize: 15.sp, - fontWeight: MyFontWeight.medium, - color: Color(0xFF4C4C4C), - ), - ), - ), InkWell( - onTap: () { - setState(() { - Navigator.of(context).popAndPushNamed('/router/manage_address_page'); - }); - }, - child:Icon( - Icons.keyboard_arrow_right, - size: 24, - ), - ), - ], - ), - Padding( - padding: EdgeInsets.only(top: 4, left: 25), - child: Text( - "武昌区中国铁建凯德1818蓝调步行街中北路109附33门牌号05", - overflow: TextOverflow.ellipsis, - maxLines: 2, - style: TextStyle( - fontSize: 12.sp, - fontWeight: MyFontWeight.regular, - color: Color(0xFF727272), - ), - ), - ), - ], - ), - ), - ], - ), - ], - ), - ); - } - - ///活动备注 - Widget activityRemarks() { - return Container( - decoration: BoxDecoration( - color: Colors.white, - boxShadow: [ - BoxShadow( - color: Color(0x0D000000), - offset: Offset(0, 3), - blurRadius: 14, - spreadRadius: 0, - ), - ], - borderRadius: BorderRadius.circular(8), - ), - height: 86.h, - margin: EdgeInsets.only( - left: 16, - right: 16, - top: 15, - ), - padding: EdgeInsets.only( - left: 16, - right: 16, - top: 16, - ), - child: Column( - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Expanded( - flex: 1, - child: Text( - S.of(context).youhuiquan, - style: TextStyle( - fontWeight: MyFontWeight.regular, - fontSize: 14.sp, - color: Color(0xFF353535), - ), - ), - ), - Text( - (settleOrderInfo?.couponList == null || settleOrderInfo.couponList.length == 0) - ? "暂无可用优惠券" : (selectedCouponIndex == -1 - ? "拥有${settleOrderInfo.couponList.length}张优惠券": - settleOrderInfo.couponList[selectedCouponIndex].promotionName), - textAlign: TextAlign.end, - style: TextStyle( - fontSize: 14.sp, - color: Color(0xFF32A060), - fontWeight: MyFontWeight.semi_bold, - ), - ), - InkWell( - onTap: () { - setState(() { - couponCart(); - }); - }, - child: Icon( - Icons.keyboard_arrow_right, - size: 16, - ), - ), - ], - ), - SizedBox( - height: 13, - ), - Row( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Expanded( - flex: 1, - child: Text( - S.of(context).beizhu, - style: TextStyle( - fontWeight: MyFontWeight.regular, - fontSize: 14.sp, - color: Color(0xFF353535), - ), - ), - ), - Text( - "口味、面包硬度等", - textAlign: TextAlign.end, - style: TextStyle( - fontSize: 14.sp, - color: Color(0xFF353535), - fontWeight: MyFontWeight.semi_bold, - ), - ), - Icon( - Icons.keyboard_arrow_right, - size: 16, - ), - ], - ), - ], - ), - ); - } - - Widget payMethod() { - return Container( - width: double.infinity, - margin: EdgeInsets.only( - left: 16.w, - right: 16.w, - top: 12.h, - bottom: 4.h, - ), - 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: () { - setState(() { - checkIndex = 1; - }); - }, - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - checkView(1), - Text( - S.of(context).pingtaiyue, - style: TextStyle( - fontSize: 14.sp, - color: Color(0xff353535), - fontWeight: MyFontWeight.semi_bold), - ), - ], - ), - ), - SizedBox( - height: 10, - ), - GestureDetector( - onTap: () { - setState(() { - checkIndex = 2; - }); - }, - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - checkView(2), - Text( - S.of(context).dianpuyue, - style: TextStyle( - fontSize: 14.sp, - color: Color(0xff353535), - fontWeight: MyFontWeight.semi_bold, - ), - ), - ], - ), - ), - SizedBox( - height: 10, - ), - GestureDetector( - onTap: () { - setState(() { - checkIndex = 3; - }); - }, - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - checkView(3), - Spacer(), - 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, - ), - ), - ), - ], - ), - ), - ], - ), - ); - } - - ///手机号编辑 - // showAlertDialog() { - // //显示对话框 - // showDialog( - // barrierDismissible: false, - // context: context, - // builder: (context) { - // return RenameDialog( - // contentWidget: RenameDialogContent( - // title: "请输入新的手机号码", - // okBtnTap: () { - // // print( - // // "输入框中的文字为:${_vc.text}", - // // ); - // }, - // vc: _vc, - // cancelBtnTap: () {}, - // ), - // ); - // }); - // } - - ///优惠券弹窗 - couponCart() { - showModalBottomSheet( - context: context, - backgroundColor: Colors.transparent, - builder: (context) { - return StatefulBuilder(builder: (context1, state) { - return Container( - alignment: Alignment.topCenter, - width: double.infinity, - height: MediaQuery.of(context).size.height / 2, - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.only( - topLeft: Radius.circular(8), - topRight: Radius.circular(8), - ), - ), - child: Column( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Container( - padding: EdgeInsets.only( - top: 16, - left: 16, - right: 16, - bottom: 8, - ), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Expanded( - child: Text( - (settleOrderInfo?.couponList == null || settleOrderInfo.couponList.length == 0) - ? "暂无可用优惠券" : (selectedCouponIndex == -1 - ? "拥有${settleOrderInfo.couponList.length}张优惠券": - settleOrderInfo.couponList[selectedCouponIndex].promotionName), - style: TextStyle( - color: Color(0xFF000000), - fontSize: 14.sp, - fontWeight: MyFontWeight.medium, - ), - ), - ), - InkWell( - onTap: () { - Navigator.of(context).pop(); - }, - child: Image.asset( - "assets/image/cancel.png", - width: 24, - height: 24, - ), - ), - ], - ), - ), - Expanded( - child: Container( - padding: EdgeInsets.only( - top: 8, - left: 16, - right: 16, - ), - child: ListView.builder( - itemCount:settleOrderInfo == null ? 0 : settleOrderInfo.couponList.length, - physics: BouncingScrollPhysics(), - itemBuilder: (context, position) { - // return shoppGoodsItem(); - return GestureDetector( - onTap: () {}, - child: couponItem(settleOrderInfo.couponList[position],position), - ); - }, - ), - ), - ), - ], - ), - ); - }); - }, - ); - } - - ///优惠券列表 - Widget couponItem(CouponListBean couponList,int index) { - return StatefulBuilder(builder: (context1, state) { - return Container( - height: 170, - width: double.infinity, - margin: EdgeInsets.fromLTRB(14.w, 6.h, 14.w, 6.h), - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.circular(8), - boxShadow: [ - BoxShadow( - color: Colors.black.withAlpha(12), - offset: Offset(0, 3), - blurRadius: 14, - spreadRadius: 0, - ) - ], - ), - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Expanded( - child: Container( - margin: EdgeInsets.only(top: 14.h, bottom: 8.h), - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Expanded( - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Expanded( - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.baseline, - textBaseline: TextBaseline.alphabetic, - children: [ - Text( - "¥", - style: TextStyle( - fontSize: 22.sp, - fontWeight: MyFontWeight.medium, - color: Color(0xff32A060), - ), - ), - SizedBox( - height: 4.h, - ), - Text( - couponList.discountAmount, - style: TextStyle( - fontSize: 40.sp, - fontWeight: MyFontWeight.semi_bold, - color: Color(0xff32A060), - ), - ), - ], - ), - ), - Text( - S.of(context).manyuankeyong(couponList.fullAmount), - style: TextStyle( - fontSize: 12.sp, - fontWeight: MyFontWeight.semi_bold, - color: Color(0xff32A060), - ), - ), - ], - ), - flex: 1, - ), - Expanded( - flex: 2, - child: Column( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( - children: [ - Container( - padding: EdgeInsets.fromLTRB(4, 2, 4, 2), - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(2), - border: Border.all( - width: 1, - color: Color(0xFFFF7A1A), - style: BorderStyle.solid, - ), - ), - child: Text( - S.of(context).shangjiaquan, - style: TextStyle( - fontSize: 10.sp, - fontWeight: MyFontWeight.medium, - color: Color(0xFFFF7A1A), - ), - ), - ), - SizedBox( - width: 8.w, - ), - Expanded( - child: Text( - storeInfo.storeName, - overflow: TextOverflow.ellipsis, - style: TextStyle( - fontSize: 16.sp, - fontWeight: MyFontWeight.semi_bold, - color: Color(0xff353535), - ), - ), - flex: 1, - ) - ], - ), - Text( - couponList.promotionName, - overflow: TextOverflow.ellipsis, - style: TextStyle( - fontSize: 14.sp, - color: Color(0xff727272), - ), - ), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - crossAxisAlignment: CrossAxisAlignment.end, - children: [ - Text( - S.of(context).quanchangtongyong, - style: TextStyle( - color: Color(0xFF353535), - fontSize: 12.sp, - ), - ), - Container( - margin: EdgeInsets.only(right: 23.w), - child: GestureDetector( - onTap: () { - setState(() { - // if (!couponList.usable){ - // SmartDialog.showToast("当前优惠券不可用", alignment: Alignment.center); - // return; - // } - double toPrice = double.parse(totalPrice(false)); - double amount = double.parse(couponList.fullAmount); - if(toPrice <= amount){ - SmartDialog.showToast("当前金额不够使用优惠券", alignment: Alignment.center); - return; - } - state(() { - if(selectedCouponIndex == index) - selectedCouponIndex = -1; - else {selectedCouponIndex = index;} - }); - Navigator.of(context).pop(); - }); - }, - child: Image.asset( - selectedCouponIndex != index - ? "assets/image/icon_radio_unselected.png" - : "assets/image/icon_radio_selected.png", - width: 24, - height: 24, - ), - ), - ), - ], - ), - ], - ), - ), - ], - ), - ), - flex: (couponList?.isEx??false) ? 97 : 97, - ), - Container( - padding: EdgeInsets.symmetric(horizontal: 23.w), - child: MySeparator( - width: 5.w, - height: 1.h, - color: Color(0xFF353535), - ), - ), - Expanded( - flex: (couponList?.isEx??false) ? 56 : 42, - child: Container( - margin: EdgeInsets.symmetric(horizontal: 23.w, vertical: 8.h), - child: Column( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Text( - S.of(context).xiangqing, - style: TextStyle( - color: Color(0xFF353535), - fontSize: 10.sp, - ), - ), - GestureDetector( - child: Icon( - (!(couponList?.isEx??false)) - ? Icons.keyboard_arrow_down - : Icons.keyboard_arrow_up, - color: Colors.black, - size: 18, - ), //点击按钮布局 - onTap: (){ - setState(() { - state((){ - this.settleOrderInfo.couponList[index].isEx = !(this.settleOrderInfo.couponList[index].isEx??false); - }); - }); - }, - ), - ], - ), - if (couponList?.isEx??false) - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Text( - S.of(context).shiyongriqi, - style: TextStyle( - color: Color(0xFF353535), - fontSize: 10.sp, - ), - ), - Text( - (couponList.useStartTime == null && - couponList.useEndTime == null) - ? S.of(context).quantian - : "${couponList.useStartTime.replaceAll("-", ".").split(" ")[0]} - ${couponList.useEndTime.replaceAll("-", ".").split(" ")[0]}", - style: TextStyle( - color: Color(0xFF353535), - fontSize: 10.sp, - ), - ), - ], - ), - ], - ), - ), - ), - ], - ), - ); - }); - } - - var checkIndex = 1; - - Widget checkView(var index) { - return Container( - padding: EdgeInsets.only(right: 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, - ), - ); - } -} From a0d056ccab47ea54633efa3b86dd744f98e14137 Mon Sep 17 00:00:00 2001 From: fmk Date: Thu, 21 Oct 2021 19:20:25 +0800 Subject: [PATCH 05/20] safety --- lib/mine/recharge_page.dart | 29 +- lib/mine/vip_detail_page.dart | 2 +- lib/order/order_detail_page.dart | 129 ++- lib/order/order_history_page.dart | 4 +- lib/order/order_view/order_address.dart | 152 ++-- lib/order/order_view/order_commodity.dart | 98 ++- lib/retrofit/data/down_order.dart | 135 ++++ lib/retrofit/data/order_info.dart | 463 ++++------- lib/retrofit/data/order_product_vo.dart | 685 ++++++++++++++++ lib/retrofit/data/placeOrderFirst.dart | 606 +++----------- lib/retrofit/data/product.dart | 182 +++++ lib/retrofit/data/settlement_bean.dart | 742 +----------------- lib/retrofit/min_api.dart | 13 +- lib/retrofit/min_api.g.dart | 28 +- lib/settlement/settlement.dart | 130 ++- .../settlement_view/pay_method.dart | 7 + lib/store/store_order.dart | 21 +- lib/store/store_view/store_order_list.dart | 6 +- 18 files changed, 1666 insertions(+), 1766 deletions(-) create mode 100644 lib/retrofit/data/down_order.dart create mode 100644 lib/retrofit/data/order_product_vo.dart create mode 100644 lib/retrofit/data/product.dart diff --git a/lib/mine/recharge_page.dart b/lib/mine/recharge_page.dart index ffb33f3b..55a6cc8b 100644 --- a/lib/mine/recharge_page.dart +++ b/lib/mine/recharge_page.dart @@ -207,9 +207,9 @@ class _RechargePage extends State { } int amount = int.tryParse(money); if (checkIndex == 1) { - if (amount < 10) { - SmartDialog.showToast(S.of(context).chongzhizuixiaojine(10), alignment: Alignment.center); + SmartDialog.showToast(S.of(context).chongzhizuixiaojine(10), + alignment: Alignment.center); return; } @@ -220,21 +220,24 @@ class _RechargePage extends State { await Min.initialize(); } - BaseData baseData = await apiService.recharge({"amount": amount, "rechargeType": 2}); + BaseData baseData = + await apiService.recharge({"amount": amount, "rechargeType": 2}); if (baseData != null && baseData.isSuccess) { WxPay wxPay = baseData.data; await registerWxApi( - appId: wxPay.appId, - doOnAndroid: true, - universalLink: "https://hx.lotus-wallet.com/app/"); + 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); + 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}"); }); diff --git a/lib/mine/vip_detail_page.dart b/lib/mine/vip_detail_page.dart index 9efd6443..d6e0794a 100644 --- a/lib/mine/vip_detail_page.dart +++ b/lib/mine/vip_detail_page.dart @@ -4,7 +4,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_easyloading/flutter_easyloading.dart'; import 'package:huixiang/generated/l10n.dart'; import 'package:huixiang/retrofit/data/base_data.dart'; -import 'package:huixiang/retrofit/data/order_info.dart'; +import 'package:huixiang/retrofit/data/product.dart'; import 'package:huixiang/retrofit/data/vip_card.dart'; import 'package:huixiang/retrofit/retrofit_api.dart'; import 'package:huixiang/utils/font_weight.dart'; diff --git a/lib/order/order_detail_page.dart b/lib/order/order_detail_page.dart index 727e2725..9a2acd07 100644 --- a/lib/order/order_detail_page.dart +++ b/lib/order/order_detail_page.dart @@ -8,6 +8,8 @@ import 'package:huixiang/order/order_view/order_info.dart'; import 'package:huixiang/order/order_view/order_status.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/min_api.dart'; import 'package:huixiang/retrofit/retrofit_api.dart'; import 'package:huixiang/view_widget/icon_text.dart'; import 'package:huixiang/view_widget/my_appbar.dart'; @@ -27,6 +29,7 @@ class OrderDetailPage extends StatefulWidget { class _OrderDetailPage extends State { ApiService apiService; + MinApiService minService; @override void initState() { @@ -38,10 +41,40 @@ class _OrderDetailPage extends State { context: context, token: value.getString("token"), ); + minLogin(); queryDetails(); }); } + /// 小程序登录 + minLogin() async { + apiService + .minLogin(widget.arguments["id"]) + .catchError((onError) {}) + .then((baseData) { + if (baseData != null && baseData.isSuccess) { + Map minStoreInfo = baseData.data; + String minToken = minStoreInfo["token"]; + String tenant = widget.arguments["tenant"]; + String storeId = widget.arguments["id"]; + SharedPreferences.getInstance().then( + (value) => { + value.setString('minToken', minToken), + value.setString('tenant', tenant), + value.setString('storeId', storeId), + }, + ); + minService = MinApiService( + Dio(), + context: context, + token: minToken, + tenant: tenant, + storeId: storeId, + ); + } + }); + } + OrderInfo orderInfo; int payStatus = 0; int orderStatus = 0; @@ -52,8 +85,9 @@ class _OrderDetailPage extends State { // String storeType = "NORMALSTORE"; //NORMALSTORE FASTSTORE RETAILSTORE queryDetails() async { - BaseData baseData = - await apiService.orderDetail(widget.arguments["id"]); + BaseData baseData = await apiService + .orderDetail(widget.arguments["id"]) + .catchError((error) {}); if (baseData != null && baseData.isSuccess) { orderInfo = baseData.data; payStatus = orderInfo.payStatus; @@ -70,7 +104,6 @@ class _OrderDetailPage extends State { if (mounted) setState(() { statusTitle(); - }); } } @@ -100,49 +133,42 @@ class _OrderDetailPage extends State { titleColor: Colors.white, background: Colors.transparent, leadingColor: Colors.white, - // toolbarHeight: (orderStatus >= 4 ? 118.h : 118.h) + - // MediaQuery.of(context).padding.top + - // kToolbarHeight, brightness: Brightness.dark, - // bottom: PreferredSize( - // preferredSize: Size( - // double.infinity, - // orderStatus >= 4 ? 118.h : 118, - // ), - // child: - // ), ), body: Container( - child: - /*Column( - children: [ - Expanded( - child:*/ - SingleChildScrollView( + child: SingleChildScrollView( physics: BouncingScrollPhysics(), child: Container( child: Column( children: [ ///订单状态显示 - OrderStatus(orderStatus, isTakeOut, sendStatus, payStatus, - refundStatus, title, center, orderInfo), + OrderStatus( + orderStatus, + isTakeOut, + sendStatus, + payStatus, + refundStatus, + title, + center, + orderInfo, + ), ///订单取货地址,或, 收货地址 OrderAddress( - orderStatus, - isTakeOut, - sendStatus, - payStatus, - refundStatus, - title, - center, - _orderCancel, - orderInfo), + orderStatus, + isTakeOut, + sendStatus, + payStatus, + refundStatus, + title, + center, + carryOnPay, + _orderCancel, + orderInfo, + ), ///订单商品 OrderCommodity(orderInfo), - // if (payStatus == 0) couponRemarks(), - /*(payStatus == 0) ? paySelector() : */ ///显示订单信息 OrderInfoView(orderInfo), @@ -154,19 +180,13 @@ class _OrderDetailPage extends State { ), ), ), - // flex: 1, - // ), - // if (payStatus == 0) - // bottomPay(), - // ], - // ), ), ), left: 0, right: 0, top: 0, bottom: 0, - ) + ), ], ); } @@ -174,6 +194,36 @@ class _OrderDetailPage extends State { String title = ""; String center = ""; + carryOnPay() { + 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 = orderInfo.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; + + + + } + statusTitle() { if (isTakeOut == 0) { if (payStatus == 0) { @@ -261,7 +311,6 @@ class _OrderDetailPage extends State { } } - Widget couponRemarks() { return Container( margin: EdgeInsets.only(left: 16.w, right: 16.w, top: 8.h, bottom: 2.h), diff --git a/lib/order/order_history_page.dart b/lib/order/order_history_page.dart index a78061cf..a57f32aa 100644 --- a/lib/order/order_history_page.dart +++ b/lib/order/order_history_page.dart @@ -4,7 +4,9 @@ import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:huixiang/generated/l10n.dart'; import 'package:huixiang/retrofit/data/base_data.dart'; import 'package:huixiang/retrofit/data/order_info.dart'; +import 'package:huixiang/retrofit/data/order_product_vo.dart'; import 'package:huixiang/retrofit/data/page.dart'; +import 'package:huixiang/retrofit/data/product.dart'; import 'package:huixiang/retrofit/retrofit_api.dart'; import 'package:huixiang/utils/status_utils.dart'; import 'package:huixiang/view_widget/classic_header.dart'; @@ -528,7 +530,7 @@ class _OrderHistoryList extends State return "$totalPrice"; } - List goodsItem(List products) { + List goodsItem(List products) { if (products == null) return []; if (products.length > 3) { products = products.sublist(0, 3); diff --git a/lib/order/order_view/order_address.dart b/lib/order/order_view/order_address.dart index 94618ef2..ac601059 100644 --- a/lib/order/order_view/order_address.dart +++ b/lib/order/order_view/order_address.dart @@ -19,6 +19,7 @@ class OrderAddress extends StatefulWidget { final String title; final String center; final Function orderCancel; + final Function carryOnPay; final OrderInfo orderInfo; OrderAddress( @@ -29,8 +30,9 @@ class OrderAddress extends StatefulWidget { this.refundStatus, this.title, this.center, + this.carryOnPay, this.orderCancel, - this.orderInfo); + this.orderInfo,); @override State createState() { @@ -195,7 +197,7 @@ class _OrderAddress extends State { GestureDetector( onTap: () { if (widget.payStatus == 0) { - carryOnPay(); + widget.carryOnPay(); } else { String storeId = (widget.orderInfo != null && widget.orderInfo.storeVO != null) @@ -258,77 +260,77 @@ class _OrderAddress extends State { arguments: {"id": storeId, "storeName": storeName}); } - carryOnPay() async { - showDialog( - context: context, - builder: (context) { - return AlertDialog( - content: Container( - width: MediaQuery.of(context).size.width - 84.w, - height: 140.h, - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Text( - "app暂不支持支付,\n请前往对应小程序处理", - textAlign: TextAlign.center, - style: TextStyle( - fontSize: 16.sp, - fontWeight: FontWeight.bold, - color: Colors.black, - ), - ), - SizedBox( - height: 30.h, - ), - Row( - children: [ - Expanded( - child: InkWell( - child: BorderText( - text: "取消", - textColor: Color(0xFF32A060), - fontSize: 16.sp, - fontWeight: FontWeight.bold, - borderColor: Color(0xFF32A060), - radius: 4, - padding: EdgeInsets.all(12), - borderWidth: 1, - ), - onTap: () { - Navigator.of(context).pop(); - }, - ), - flex: 1, - ), - SizedBox( - width: 16.w, - ), - Expanded( - child: InkWell( - child: RoundButton( - text: "好的", - textColor: Colors.white, - radius: 4, - padding: EdgeInsets.all(12), - backgroup: Color(0xFF32A060), - fontSize: 16.sp, - fontWeight: FontWeight.bold, - ), - onTap: () { - Navigator.of(context).pop(); - }, - ), - flex: 1, - ), - ], - ), - ], - ), - ), - ); - }, - ); - } + // carryOnPay() async { + // showDialog( + // context: context, + // builder: (context) { + // return AlertDialog( + // content: Container( + // width: MediaQuery.of(context).size.width - 84.w, + // height: 140.h, + // child: Column( + // mainAxisAlignment: MainAxisAlignment.center, + // crossAxisAlignment: CrossAxisAlignment.center, + // children: [ + // Text( + // "app暂不支持支付,\n请前往对应小程序处理", + // textAlign: TextAlign.center, + // style: TextStyle( + // fontSize: 16.sp, + // fontWeight: FontWeight.bold, + // color: Colors.black, + // ), + // ), + // SizedBox( + // height: 30.h, + // ), + // Row( + // children: [ + // Expanded( + // child: InkWell( + // child: BorderText( + // text: "取消", + // textColor: Color(0xFF32A060), + // fontSize: 16.sp, + // fontWeight: FontWeight.bold, + // borderColor: Color(0xFF32A060), + // radius: 4, + // padding: EdgeInsets.all(12), + // borderWidth: 1, + // ), + // onTap: () { + // Navigator.of(context).pop(); + // }, + // ), + // flex: 1, + // ), + // SizedBox( + // width: 16.w, + // ), + // Expanded( + // child: InkWell( + // child: RoundButton( + // text: "好的", + // textColor: Colors.white, + // radius: 4, + // padding: EdgeInsets.all(12), + // backgroup: Color(0xFF32A060), + // fontSize: 16.sp, + // fontWeight: FontWeight.bold, + // ), + // onTap: () { + // Navigator.of(context).pop(); + // }, + // ), + // flex: 1, + // ), + // ], + // ), + // ], + // ), + // ), + // ); + // }, + // ); + // } } diff --git a/lib/order/order_view/order_commodity.dart b/lib/order/order_view/order_commodity.dart index c677350b..3e41e806 100644 --- a/lib/order/order_view/order_commodity.dart +++ b/lib/order/order_view/order_commodity.dart @@ -1,16 +1,15 @@ - - import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:huixiang/generated/l10n.dart'; import 'package:huixiang/retrofit/data/order_info.dart'; +import 'package:huixiang/retrofit/data/order_product_vo.dart'; +import 'package:huixiang/retrofit/data/product.dart'; +import 'package:huixiang/retrofit/data/settlement_bean.dart'; import 'package:huixiang/utils/font_weight.dart'; import 'package:huixiang/view_widget/custom_image.dart'; import 'package:huixiang/view_widget/separator.dart'; class OrderCommodity extends StatefulWidget { - - final OrderInfo orderInfo; OrderCommodity(this.orderInfo); @@ -19,7 +18,6 @@ class OrderCommodity extends StatefulWidget { State createState() { return _OrderCommodity(); } - } class _OrderCommodity extends State { @@ -66,38 +64,57 @@ class _OrderCommodity extends State { ); } - List commodityList() { if (widget.orderInfo == null) return []; List widgets = []; if (widget.orderInfo.productList != null) { - widgets - .addAll(widget.orderInfo.productList.map((e) => commodityItem(e)).toList()); + widgets.addAll( + widget.orderInfo.productList.map((e) => commodityItem(e)).toList()); } widgets.add(SizedBox(height: 20.h)); if (widget.orderInfo.isTakeOut != 0) { // 配送费 - widgets.add(discountItem( + widgets.add( + discountItem( Color(0xFFFF7A1A), widget.orderInfo.isTakeOut == 1 ? S.of(context).peisongfei : S.of(context).yunfei, "", - "+${widget.orderInfo.postFee}")); + "+${widget.orderInfo.postFee}", + ), + ); } if (widget.orderInfo.orderDetail != null && widget.orderInfo.orderDetail.couponDTO != null) { // 配送费 - widgets.add(discountItem( + widgets.add( + discountItem( Color(0xFFFF7A1A), S.of(context).youhuiquan, widget.orderInfo.orderDetail.couponDTO.name, - widget.orderInfo.orderDetail.couponDTO.money)); + widget.orderInfo.orderDetail.couponDTO.money, + ), + ); + } + if (widget.orderInfo.orderDetail != null && + widget.orderInfo.orderDetail.activityPrice != null && + double.tryParse(widget.orderInfo.orderDetail.activityPrice ?? "0") > 0) { + // 配送费 + widgets.add( + discountItem( + Color(0xFFFF7A1A), + "活动", + widget.orderInfo.orderDetail.promotionName, + "- ${widget.orderInfo.orderDetail.activityPrice}", + ), + ); } - if (widget.orderInfo.storeVO != null && widget.orderInfo.storeVO.couponVO != null) { + if (widget.orderInfo.storeVO != null && + widget.orderInfo.storeVO.couponVO != null) { // widgets.add(discountItem(Color(0xFF32A060), // orderInfo.storeVO.couponVO.storeName, // S.of(context).huodongjianmianpeisongfei(orderInfo.storeVO.couponVO.discountAmount), @@ -119,7 +136,7 @@ class _OrderCommodity extends State { return widgets; } - Widget commodityItem(ProductList productList) { + Widget commodityItem(OrderProductVOList productList) { return Container( margin: EdgeInsets.only(top: 8.h, bottom: 8.h), child: Row( @@ -171,8 +188,8 @@ class _OrderCommodity extends State { Expanded( flex: 1, child: Text( - productList.weight != null - ? "${productList.weight}kg" + productList.skuNameStr != null + ? "${productList.skuNameStr}" : "", overflow: TextOverflow.ellipsis, style: TextStyle( @@ -329,39 +346,50 @@ class _OrderCommodity extends State { children: [ Expanded( child: Text( - S.of(context).gongjijianshangpin( - (widget.orderInfo != null && widget.orderInfo.productList != null) - ? widget.orderInfo.productList.length - : "0"), + S.of(context).gongjijianshangpin((widget.orderInfo != null && + widget.orderInfo.productList != null) + ? widget.orderInfo.productList.length + : "0"), style: TextStyle( - fontSize: 10.sp, - color: Color(0xFFA29E9E), - fontWeight: MyFontWeight.semi_bold - ), + fontSize: 10.sp, + color: Color(0xFFA29E9E), + fontWeight: MyFontWeight.semi_bold), ), flex: 1, ), Container( child: Text( - S.of(context).jiesuanjine, + "已优惠:¥${widget.orderInfo.orderDetail.activityPrice}", style: TextStyle( fontSize: 12.sp, - color: Color(0xFF353535), - fontWeight:MyFontWeight.semi_bold + color: Color(0xFF7B7B7B), + fontWeight: MyFontWeight.medium, ), ), ), + SizedBox( + width: 15.w, + ), + Container( + child: Text( + S.of(context).jiesuanjine, + style: TextStyle( + fontSize: 12.sp, + color: Color(0xFF353535), + fontWeight: MyFontWeight.semi_bold), + ), + ), SizedBox( width: 5.w, ), Text( - totalPrice(), + "${widget.orderInfo.orderDetail.paySumPrice}" + /*totalPrice()*/, textAlign: TextAlign.end, style: TextStyle( - fontSize:14.sp, - color: Color(0xFF32A060), - fontWeight: MyFontWeight.semi_bold - ), + fontSize: 14.sp, + color: Color(0xFF32A060), + fontWeight: MyFontWeight.semi_bold), ) ], ), @@ -374,9 +402,9 @@ class _OrderCommodity extends State { double.tryParse(widget.orderInfo.postFee)); if (widget.orderInfo.orderDetail != null && widget.orderInfo.orderDetail.couponDTO != null) { - totalPrice -= double.tryParse(widget.orderInfo.orderDetail.couponDTO.money); + totalPrice -= + double.tryParse(widget.orderInfo.orderDetail.couponDTO.money); } return "$totalPrice"; } - -} \ No newline at end of file +} diff --git a/lib/retrofit/data/down_order.dart b/lib/retrofit/data/down_order.dart new file mode 100644 index 00000000..3c5d84bc --- /dev/null +++ b/lib/retrofit/data/down_order.dart @@ -0,0 +1,135 @@ +import 'package:huixiang/retrofit/data/order_product_vo.dart'; + +class DownOrder { + DownOrder({ + String id, + String orderCode, + dynamic storeId, + dynamic storeName, + dynamic orderStatus, + dynamic returnType, + dynamic shipperCode, + dynamic logisticsNum, + String orderSum, + dynamic accountPay, + dynamic discountAmount, + dynamic postFee, + dynamic paySum, + dynamic overTime, + List orderProductVOList, + dynamic moneyReturnList, + dynamic goodsReturnList, + dynamic tablePrice, + dynamic parentCode, + String parentId, + dynamic peopleNum, + int orderSource, + }) { + this.id = id; + this.orderCode = orderCode; + this.storeId = storeId; + this.storeName = storeName; + this.orderStatus = orderStatus; + this.returnType = returnType; + this.shipperCode = shipperCode; + this.logisticsNum = logisticsNum; + this.orderSum = orderSum; + this.accountPay = accountPay; + this.discountAmount = discountAmount; + this.postFee = postFee; + this.paySum = paySum; + this.overTime = overTime; + this.orderProductVOList = orderProductVOList; + this.moneyReturnList = moneyReturnList; + this.goodsReturnList = goodsReturnList; + this.tablePrice = tablePrice; + this.parentCode = parentCode; + this.parentId = parentId; + this.peopleNum = peopleNum; + this.orderSource = orderSource; + } + + DownOrder.fromJson(dynamic json) { + this.id = json['id']; + this.orderCode = json['orderCode']; + this.storeId = json['storeId']; + this.storeName = json['storeName']; + this.orderStatus = json['orderStatus']; + this.returnType = json['returnType']; + this.shipperCode = json['shipperCode']; + this.logisticsNum = json['logisticsNum']; + this.orderSum = json['orderSum']; + this.accountPay = json['accountPay']; + this.discountAmount = json['discountAmount']; + this.postFee = json['postFee']; + this.paySum = json['paySum']; + this.overTime = json['overTime']; + if (json['orderProductVOList'] != null) { + this.orderProductVOList = []; + json['orderProductVOList'].forEach((v) { + this.orderProductVOList.add(OrderProductVOList.fromJson(v)); + }); + } + this.moneyReturnList = json['moneyReturnList']; + this.goodsReturnList = json['goodsReturnList']; + this.tablePrice = json['tablePrice']; + this.parentCode = json['parentCode']; + this.parentId = json['parentId']; + this.peopleNum = json['peopleNum']; + this.orderSource = json['orderSource']; + } + + String id; + String orderCode; + dynamic storeId; + dynamic storeName; + dynamic orderStatus; + dynamic returnType; + dynamic shipperCode; + dynamic logisticsNum; + String orderSum; + dynamic accountPay; + dynamic discountAmount; + dynamic postFee; + dynamic paySum; + dynamic overTime; + List orderProductVOList; + dynamic moneyReturnList; + dynamic goodsReturnList; + dynamic tablePrice; + dynamic parentCode; + String parentId; + dynamic peopleNum; + int orderSource; + + Map toJson() { + final map = {}; + map['id'] = this.id; + map['orderCode'] = this.orderCode; + map['storeId'] = this.storeId; + map['storeName'] = this.storeName; + map['orderStatus'] = this.orderStatus; + map['returnType'] = this.returnType; + map['shipperCode'] = this.shipperCode; + map['logisticsNum'] = this.logisticsNum; + map['orderSum'] = this.orderSum; + map['accountPay'] = this.accountPay; + map['discountAmount'] = this.discountAmount; + map['postFee'] = this.postFee; + map['paySum'] = this.paySum; + map['overTime'] = this.overTime; + if (this.orderProductVOList != null) { + map['orderProductVOList'] = + this.orderProductVOList.map((v) => v.toJson()).toList(); + } + map['moneyReturnList'] = this.moneyReturnList; + map['goodsReturnList'] = this.goodsReturnList; + map['tablePrice'] = this.tablePrice; + map['parentCode'] = this.parentCode; + map['parentId'] = this.parentId; + map['peopleNum'] = this.peopleNum; + map['orderSource'] = this.orderSource; + return map; + } +} + diff --git a/lib/retrofit/data/order_info.dart b/lib/retrofit/data/order_info.dart index 20a0757e..12628ffe 100644 --- a/lib/retrofit/data/order_info.dart +++ b/lib/retrofit/data/order_info.dart @@ -1,4 +1,8 @@ +import 'package:huixiang/retrofit/data/down_order.dart'; +import 'package:huixiang/retrofit/data/order_product_vo.dart'; +import 'package:huixiang/retrofit/data/shoppingCart.dart'; + /// id : "1408358257373741056" /// createTime : "2021-06-25 17:35:49" /// createUser : "1404743858104827904" @@ -73,6 +77,7 @@ class OrderInfo { String _parentId; String _parentCode; String _orderCode; + String _orderType; String _dayFlowCode; int _orderStatus; int _sendStatus; @@ -118,7 +123,7 @@ class OrderInfo { int _orderSource; StoreVO _storeVO; OrderDetail _orderDetail; - List _productList; + List _productList; String get id => _id; @@ -145,6 +150,7 @@ class OrderInfo { String get parentCode => _parentCode; String get orderCode => _orderCode; + String get orderType => _orderType; String get dayFlowCode => _dayFlowCode; @@ -236,68 +242,68 @@ class OrderInfo { OrderDetail get orderDetail => _orderDetail; - List get productList => _productList; + List get productList => _productList; OrderInfo( {String id, - String createTime, - String createUser, - String updateTime, - String updateUser, - String tenantCode, - String storeId, - String storeName, - String tableId, - String mid, - String parentId, - String parentCode, - String orderCode, - String dayFlowCode, - int orderStatus, - int sendStatus, - int payStatus, - String memberAccount, - String logisticsId, - String shipperCode, - String logisticsName, - String logisticsNum, - dynamic logisticsCase, - int refundStatus, - AddressExt addressExt, - String postFee, - String orderSum, - String paySum, - String paySumSub, - String accountPay, - String couponSubPrice, - String customPrice, - String removeDecimal, - bool isSubscribe, - dynamic subcribeTime, - dynamic sendTime, - dynamic confirmTime, - dynamic returnMoneyTime, - String notes, - dynamic prepayId, - String payTime, - int payChannel, - String payNum, - String promotionId, - String couponId, - int isDelete, - int isTakeOut, - int batch, - String orderDiscountPrice, - String dishesDiscountPrice, - String orderPercentPrice, - String finalPayPrice, - String activityNoPrice, - String activityDiscountPrice, - String totalDiscountPrice, - int orderSource, - StoreVO storeVO, - OrderDetail orderDetail, - List productList}) { + String createTime, + String createUser, + String updateTime, + String updateUser, + String tenantCode, + String storeId, + String storeName, + String tableId, + String mid, + String parentId, + String parentCode, + String orderCode, + String dayFlowCode, + int orderStatus, + int sendStatus, + int payStatus, + String memberAccount, + String logisticsId, + String shipperCode, + String logisticsName, + String logisticsNum, + dynamic logisticsCase, + int refundStatus, + AddressExt addressExt, + String postFee, + String orderSum, + String paySum, + String paySumSub, + String accountPay, + String couponSubPrice, + String customPrice, + String removeDecimal, + bool isSubscribe, + dynamic subcribeTime, + dynamic sendTime, + dynamic confirmTime, + dynamic returnMoneyTime, + String notes, + dynamic prepayId, + String payTime, + int payChannel, + String payNum, + String promotionId, + String couponId, + int isDelete, + int isTakeOut, + int batch, + String orderDiscountPrice, + String dishesDiscountPrice, + String orderPercentPrice, + String finalPayPrice, + String activityNoPrice, + String activityDiscountPrice, + String totalDiscountPrice, + int orderSource, + StoreVO storeVO, + OrderDetail orderDetail, + List< OrderProductVOList> productList}) { _id = id; _createTime = createTime; _createUser = createUser; @@ -311,6 +317,7 @@ class OrderInfo { _parentId = parentId; _parentCode = parentCode; _orderCode = orderCode; + _orderType = orderType; _dayFlowCode = dayFlowCode; _orderStatus = orderStatus; _sendStatus = sendStatus; @@ -373,6 +380,7 @@ class OrderInfo { _parentId = json["parentId"]; _parentCode = json["parentCode"]; _orderCode = json["orderCode"]; + _orderType = json["orderType"]; _dayFlowCode = json["dayFlowCode"]; _orderStatus = json["orderStatus"]; _sendStatus = json["sendStatus"]; @@ -419,14 +427,14 @@ class OrderInfo { _totalDiscountPrice = json["totalDiscountPrice"]; _orderSource = json["orderSource"]; _storeVO = - json["storeVO"] != null ? StoreVO.fromJson(json["storeVO"]) : null; + json["storeVO"] != null ? StoreVO.fromJson(json["storeVO"]) : null; _orderDetail = json["orderDetail"] != null ? OrderDetail.fromJson(json["orderDetail"]) : null; if (json["productList"] != null) { _productList = []; json["productList"].forEach((v) { - _productList.add(ProductList.fromJson(v)); + _productList.add( OrderProductVOList.fromJson(v)); }); } } @@ -446,6 +454,7 @@ class OrderInfo { map["parentId"] = _parentId; map["parentCode"] = _parentCode; map["orderCode"] = _orderCode; + map["orderType"] = _orderType; map["dayFlowCode"] = _dayFlowCode; map["orderStatus"] = _orderStatus; map["sendStatus"] = _sendStatus; @@ -529,187 +538,6 @@ class OrderInfo { /// status : true /// batch : 1 -class ProductList { - String _id; - String _createTime; - String _createUser; - String _updateTime; - String _updateUser; - dynamic _tenantCode; - String _storeId; - String _orderId; - String _productId; - String _productName; - String _skuId; - String _skuNameStr; - String _skuImg; - int _buyNum; - int _refundNum; - double _weight; - String _applyPrice; - String _sellPrice; - String _postPay; - int _isDelete; - String _discountAmount; - int _discountPercent; - bool _status; - int _batch; - - String get id => _id; - - String get createTime => _createTime; - - String get createUser => _createUser; - - String get updateTime => _updateTime; - - String get updateUser => _updateUser; - - dynamic get tenantCode => _tenantCode; - - String get storeId => _storeId; - - String get orderId => _orderId; - - String get productId => _productId; - - String get productName => _productName; - - String get skuId => _skuId; - - String get skuNameStr => _skuNameStr; - - String get skuImg => _skuImg; - - int get buyNum => _buyNum; - - int get refundNum => _refundNum; - - double get weight => _weight; - - String get applyPrice => _applyPrice; - - String get sellPrice => _sellPrice; - - String get postPay => _postPay; - - int get isDelete => _isDelete; - - String get discountAmount => _discountAmount; - - int get discountPercent => _discountPercent; - - bool get status => _status; - - int get batch => _batch; - - ProductList( - {String id, - String createTime, - String createUser, - String updateTime, - String updateUser, - dynamic tenantCode, - String storeId, - String orderId, - String productId, - String productName, - String skuId, - String skuNameStr, - String skuImg, - int buyNum, - int refundNum, - double weight, - String applyPrice, - String sellPrice, - String postPay, - int isDelete, - String discountAmount, - int discountPercent, - bool status, - int batch}) { - _id = id; - _createTime = createTime; - _createUser = createUser; - _updateTime = updateTime; - _updateUser = updateUser; - _tenantCode = tenantCode; - _storeId = storeId; - _orderId = orderId; - _productId = productId; - _productName = productName; - _skuId = skuId; - _skuNameStr = skuNameStr; - _skuImg = skuImg; - _buyNum = buyNum; - _refundNum = refundNum; - _weight = weight; - _applyPrice = applyPrice; - _sellPrice = sellPrice; - _postPay = postPay; - _isDelete = isDelete; - _discountAmount = discountAmount; - _discountPercent = discountPercent; - _status = status; - _batch = batch; - } - - ProductList.fromJson(dynamic json) { - _id = json["id"]; - _createTime = json["createTime"]; - _createUser = json["createUser"]; - _updateTime = json["updateTime"]; - _updateUser = json["updateUser"]; - _tenantCode = json["tenantCode"]; - _storeId = json["storeId"]; - _orderId = json["orderId"]; - _productId = json["productId"]; - _productName = json["productName"]; - _skuId = json["skuId"]; - _skuNameStr = json["skuNameStr"]; - _skuImg = json["skuImg"]; - _buyNum = json["buyNum"]; - _refundNum = json["refundNum"]; - _weight = json["weight"]; - _applyPrice = json["applyPrice"]; - _sellPrice = json["sellPrice"]; - _postPay = json["postPay"]; - _isDelete = json["isDelete"]; - _discountAmount = json["discountAmount"]; - _discountPercent = json["discountPercent"]; - _status = json["status"]; - _batch = json["batch"]; - } - - Map toJson() { - var map = {}; - map["id"] = _id; - map["createTime"] = _createTime; - map["createUser"] = _createUser; - map["updateTime"] = _updateTime; - map["updateUser"] = _updateUser; - map["tenantCode"] = _tenantCode; - map["storeId"] = _storeId; - map["orderId"] = _orderId; - map["productId"] = _productId; - map["productName"] = _productName; - map["skuId"] = _skuId; - map["skuNameStr"] = _skuNameStr; - map["skuImg"] = _skuImg; - map["buyNum"] = _buyNum; - map["refundNum"] = _refundNum; - map["weight"] = _weight; - map["applyPrice"] = _applyPrice; - map["sellPrice"] = _sellPrice; - map["postPay"] = _postPay; - map["isDelete"] = _isDelete; - map["discountAmount"] = _discountAmount; - map["discountPercent"] = _discountPercent; - map["status"] = _status; - map["batch"] = _batch; - return map; - } -} /// orderProductList : [{"id":"1408358257390518272","platterList":null,"tenantCode":"1177","storeId":"1344490596986781696","orderId":"1408358257373741056","productId":"1404742074535772160","productName":"商品1","skuId":"1404744485652398080","skuNameStr":"中","skuImg":"","buyNum":2,"refundNum":0,"weight":0,"applyPrice":"0.00","sellPrice":"10.00","postPay":"0.00","isDelete":0,"discountAmount":"2.20","discountPercent":100}] /// discountName : null @@ -738,7 +566,7 @@ class ProductList { /// predictTime : null class OrderDetail { - List _orderProductList; + List< OrderProductVOList> _orderProductList; dynamic _discountName; dynamic _discountMoney; dynamic _discountNumber; @@ -748,6 +576,7 @@ class OrderDetail { String _paySumPrice; String _activityNoPrice; String _activityPrice; + String _promotionName; List _dishesList; String _customPrice; String _nextPerson; @@ -764,7 +593,7 @@ class OrderDetail { int _mins; dynamic _predictTime; - List get orderProductList => _orderProductList; + List< OrderProductVOList> get orderProductList => _orderProductList; dynamic get discountName => _discountName; @@ -783,6 +612,7 @@ class OrderDetail { String get activityNoPrice => _activityNoPrice; String get activityPrice => _activityPrice; + String get promotionName => _promotionName; List get dishesList => _dishesList; @@ -815,31 +645,32 @@ class OrderDetail { dynamic get predictTime => _predictTime; OrderDetail( - {List orderProductList, - dynamic discountName, - dynamic discountMoney, - dynamic discountNumber, - dynamic activityName, - CouponDTO couponDTO, - String orderSumPrice, - String paySumPrice, - String activityNoPrice, - String activityPrice, - List dishesList, - String customPrice, - String nextPerson, - int isTakeOut, - dynamic memberRec, - dynamic isSubscribe, - dynamic subcribeTime, - String postFee, - String shipperCode, - String logisticsName, - String logisticsNum, - int orderNum, - int productNum, - int mins, - dynamic predictTime}) { + {List< OrderProductVOList> orderProductList, + dynamic discountName, + dynamic discountMoney, + dynamic discountNumber, + dynamic activityName, + CouponDTO couponDTO, + String orderSumPrice, + String paySumPrice, + String activityNoPrice, + String activityPrice, + String promotionName, + List dishesList, + String customPrice, + String nextPerson, + int isTakeOut, + dynamic memberRec, + dynamic isSubscribe, + dynamic subcribeTime, + String postFee, + String shipperCode, + String logisticsName, + String logisticsNum, + int orderNum, + int productNum, + int mins, + dynamic predictTime}) { _orderProductList = orderProductList; _discountName = discountName; _discountMoney = discountMoney; @@ -850,6 +681,7 @@ class OrderDetail { _paySumPrice = paySumPrice; _activityNoPrice = activityNoPrice; _activityPrice = activityPrice; + _promotionName = promotionName; _dishesList = dishesList; _customPrice = customPrice; _nextPerson = nextPerson; @@ -871,7 +703,7 @@ class OrderDetail { if (json["orderProductList"] != null) { _orderProductList = []; json["orderProductList"].forEach((v) { - _orderProductList.add(ProductList.fromJson(v)); + _orderProductList.add( OrderProductVOList.fromJson(v)); }); } _discountName = json["discountName"]; @@ -883,6 +715,7 @@ class OrderDetail { _paySumPrice = json["paySumPrice"]; _activityNoPrice = json["activityNoPrice"]; _activityPrice = json["activityPrice"]; + _promotionName = json["promotionName"]; if (json["dishesList"] != null) { _dishesList = []; json["dishesList"].forEach((v) { @@ -1070,36 +903,36 @@ class StoreVO { StoreVO( {String id, - String storeName, - String nickName, - String businessService, - String businessType, - String logo, - String openStartTime, - String openEndTime, - String shipAddress, - dynamic remark, - String mobile, - dynamic refundAddress, - dynamic refundTel, - dynamic refundContact, - int isAutoSendRefundAddress, - dynamic soldNum, - dynamic storeTemplateConfig, - dynamic storeTable, - dynamic threshold, - dynamic freePostAge, - dynamic logisticsThreshold, - dynamic logisticsFreePostAge, - String longitude, - String latitude, - dynamic deliveryDistance, - dynamic couponVO, - PosType posType, - dynamic banners, - dynamic tips, - dynamic storeBrandImg, - dynamic defaultPostAge}) { + String storeName, + String nickName, + String businessService, + String businessType, + String logo, + String openStartTime, + String openEndTime, + String shipAddress, + dynamic remark, + String mobile, + dynamic refundAddress, + dynamic refundTel, + dynamic refundContact, + int isAutoSendRefundAddress, + dynamic soldNum, + dynamic storeTemplateConfig, + dynamic storeTable, + dynamic threshold, + dynamic freePostAge, + dynamic logisticsThreshold, + dynamic logisticsFreePostAge, + String longitude, + String latitude, + dynamic deliveryDistance, + dynamic couponVO, + PosType posType, + dynamic banners, + dynamic tips, + dynamic storeBrandImg, + dynamic defaultPostAge}) { _id = id; _storeName = storeName; _nickName = nickName; @@ -1161,7 +994,7 @@ class StoreVO { _deliveryDistance = json["deliveryDistance"]; _couponVO = json["couponVO"]; _posType = - json["posType"] != null ? PosType.fromJson(json["posType"]) : null; + json["posType"] != null ? PosType.fromJson(json["posType"]) : null; _banners = json["banners"]; _tips = json["tips"]; _storeBrandImg = json["storeBrandImg"]; @@ -1297,19 +1130,19 @@ class AddressExt { AddressExt( {dynamic addressId, - dynamic country, - dynamic countryId, - String province, - dynamic provinceId, - String city, - dynamic cityId, - String district, - dynamic districtId, - String address, - dynamic recName, - dynamic recMobile, - String longitude, - String latitude}) { + dynamic country, + dynamic countryId, + String province, + dynamic provinceId, + String city, + dynamic cityId, + String district, + dynamic districtId, + String address, + dynamic recName, + dynamic recMobile, + String longitude, + String latitude}) { _addressId = addressId; _country = country; _countryId = countryId; diff --git a/lib/retrofit/data/order_product_vo.dart b/lib/retrofit/data/order_product_vo.dart new file mode 100644 index 00000000..5b150446 --- /dev/null +++ b/lib/retrofit/data/order_product_vo.dart @@ -0,0 +1,685 @@ + +class OrderProductVOList { + OrderProductVOList({ + ActInfo actInfo, + AdditionalComment additionalComment, + int buyNum, + int canApplyIntervention, + Comment comment, + int commentStatus, + int discountAmount, + int id, + int productId, + String productName, + String returnCode, + int returnStatus, + int returnType, + int sellPrice, + String skuId, + String skuImg, + String skuNameStr,}){ + _actInfo = actInfo; + _additionalComment = additionalComment; + _buyNum = buyNum; + _canApplyIntervention = canApplyIntervention; + _comment = comment; + _commentStatus = commentStatus; + _discountAmount = discountAmount; + _id = id; + _productId = productId; + _productName = productName; + _returnCode = returnCode; + _returnStatus = returnStatus; + _returnType = returnType; + _sellPrice = sellPrice; + _skuId = skuId; + _skuImg = skuImg; + _skuNameStr = skuNameStr; + } + + OrderProductVOList.fromJson(dynamic json) { + _actInfo = json['actInfo'] != null ? ActInfo.fromJson(json['actInfo']) : null; + _additionalComment = json['additionalComment'] != null ? AdditionalComment.fromJson(json['additionalComment']) : null; + _buyNum = json['buyNum']; + _canApplyIntervention = json['canApplyIntervention']; + _comment = json['comment'] != null ? Comment.fromJson(json['comment']) : null; + _commentStatus = json['commentStatus']; + _discountAmount = json['discountAmount']; + _id = json['id']; + _productId = json['productId']; + _productName = json['productName']; + _returnCode = json['returnCode']; + _returnStatus = json['returnStatus']; + _returnType = json['returnType']; + _sellPrice = json['sellPrice']; + _skuId = json['skuId']; + _skuImg = json['skuImg']; + _skuNameStr = json['skuNameStr']; + } + ActInfo _actInfo; + AdditionalComment _additionalComment; + int _buyNum; + int _canApplyIntervention; + Comment _comment; + int _commentStatus; + int _discountAmount; + int _id; + int _productId; + String _productName; + String _returnCode; + int _returnStatus; + int _returnType; + int _sellPrice; + String _skuId; + String _skuImg; + String _skuNameStr; + + ActInfo get actInfo => _actInfo; + AdditionalComment get additionalComment => _additionalComment; + int get buyNum => _buyNum; + int get canApplyIntervention => _canApplyIntervention; + Comment get comment => _comment; + int get commentStatus => _commentStatus; + int get discountAmount => _discountAmount; + int get id => _id; + int get productId => _productId; + String get productName => _productName; + String get returnCode => _returnCode; + int get returnStatus => _returnStatus; + int get returnType => _returnType; + int get sellPrice => _sellPrice; + String get skuId => _skuId; + String get skuImg => _skuImg; + String get skuNameStr => _skuNameStr; + + + set actInfo(ActInfo value) { + _actInfo = value; + } + + Map toJson() { + final map = {}; + if (_actInfo != null) { + map['actInfo'] = _actInfo.toJson(); + } + if (_additionalComment != null) { + map['additionalComment'] = _additionalComment.toJson(); + } + map['buyNum'] = _buyNum; + map['canApplyIntervention'] = _canApplyIntervention; + if (_comment != null) { + map['comment'] = _comment.toJson(); + } + map['commentStatus'] = _commentStatus; + map['discountAmount'] = _discountAmount; + map['id'] = _id; + map['productId'] = _productId; + map['productName'] = _productName; + map['returnCode'] = _returnCode; + map['returnStatus'] = _returnStatus; + map['returnType'] = _returnType; + map['sellPrice'] = _sellPrice; + map['skuId'] = _skuId; + map['skuImg'] = _skuImg; + map['skuNameStr'] = _skuNameStr; + return map; + } + + set additionalComment(AdditionalComment value) { + _additionalComment = value; + } + + set buyNum(int value) { + _buyNum = value; + } + + set canApplyIntervention(int value) { + _canApplyIntervention = value; + } + + set comment(Comment value) { + _comment = value; + } + + set commentStatus(int value) { + _commentStatus = value; + } + + set discountAmount(int value) { + _discountAmount = value; + } + + set id(int value) { + _id = value; + } + + set productId(int value) { + _productId = value; + } + + set productName(String value) { + _productName = value; + } + + set returnCode(String value) { + _returnCode = value; + } + + set returnStatus(int value) { + _returnStatus = value; + } + + set returnType(int value) { + _returnType = value; + } + + set sellPrice(int value) { + _sellPrice = value; + } + + set skuId(String value) { + _skuId = value; + } + + set skuImg(String value) { + _skuImg = value; + } + + set skuNameStr(String value) { + _skuNameStr = value; + } +} + +/// couponDiscountAmount : 0 +/// couponDiscountRate : 0 +/// couponId : 0 +/// couponType : 0 +/// discountAmount : 0 +/// discountRate : 0 +/// promotionId : 0 +/// promotionType : 0 + +class ActInfo { + ActInfo({ + int couponDiscountAmount, + int couponDiscountRate, + int couponId, + int couponType, + int discountAmount, + int discountRate, + int promotionId, + int promotionType,}){ + _couponDiscountAmount = couponDiscountAmount; + _couponDiscountRate = couponDiscountRate; + _couponId = couponId; + _couponType = couponType; + _discountAmount = discountAmount; + _discountRate = discountRate; + _promotionId = promotionId; + _promotionType = promotionType; + } + + ActInfo.fromJson(dynamic json) { + _couponDiscountAmount = json['couponDiscountAmount']; + _couponDiscountRate = json['couponDiscountRate']; + _couponId = json['couponId']; + _couponType = json['couponType']; + _discountAmount = json['discountAmount']; + _discountRate = json['discountRate']; + _promotionId = json['promotionId']; + _promotionType = json['promotionType']; + } + int _couponDiscountAmount; + int _couponDiscountRate; + int _couponId; + int _couponType; + int _discountAmount; + int _discountRate; + int _promotionId; + int _promotionType; + + int get couponDiscountAmount => _couponDiscountAmount; + int get couponDiscountRate => _couponDiscountRate; + int get couponId => _couponId; + int get couponType => _couponType; + int get discountAmount => _discountAmount; + int get discountRate => _discountRate; + int get promotionId => _promotionId; + int get promotionType => _promotionType; + + + set couponDiscountAmount(int value) { + _couponDiscountAmount = value; + } + + Map toJson() { + final map = {}; + map['couponDiscountAmount'] = _couponDiscountAmount; + map['couponDiscountRate'] = _couponDiscountRate; + map['couponId'] = _couponId; + map['couponType'] = _couponType; + map['discountAmount'] = _discountAmount; + map['discountRate'] = _discountRate; + map['promotionId'] = _promotionId; + map['promotionType'] = _promotionType; + return map; + } + + set couponDiscountRate(int value) { + _couponDiscountRate = value; + } + + set couponId(int value) { + _couponId = value; + } + + set couponType(int value) { + _couponType = value; + } + + set discountAmount(int value) { + _discountAmount = value; + } + + set discountRate(int value) { + _discountRate = value; + } + + set promotionId(int value) { + _promotionId = value; + } + + set promotionType(int value) { + _promotionType = value; + } +} + +class AdditionalComment { + AdditionalComment({ + int bizType, + String commentImgs, + bool commentImgsFlag, + int commentStar, + String commentText, + int descStar, + bool hideFlag, + int id, + bool isDelete, + int likeNum, + int logisticsStar, + int mid, + int orderProductId, + int parentId, + int productId, + bool sensitiveFlag, + int serviceStar, + int storeId,}){ + _bizType = bizType; + _commentImgs = commentImgs; + _commentImgsFlag = commentImgsFlag; + _commentStar = commentStar; + _commentText = commentText; + _descStar = descStar; + _hideFlag = hideFlag; + _id = id; + _isDelete = isDelete; + _likeNum = likeNum; + _logisticsStar = logisticsStar; + _mid = mid; + _orderProductId = orderProductId; + _parentId = parentId; + _productId = productId; + _sensitiveFlag = sensitiveFlag; + _serviceStar = serviceStar; + _storeId = storeId; + } + + AdditionalComment.fromJson(dynamic json) { + _bizType = json['bizType']; + _commentImgs = json['commentImgs']; + _commentImgsFlag = json['commentImgsFlag']; + _commentStar = json['commentStar']; + _commentText = json['commentText']; + _descStar = json['descStar']; + _hideFlag = json['hideFlag']; + _id = json['id']; + _isDelete = json['isDelete']; + _likeNum = json['likeNum']; + _logisticsStar = json['logisticsStar']; + _mid = json['mid']; + _orderProductId = json['orderProductId']; + _parentId = json['parentId']; + _productId = json['productId']; + _sensitiveFlag = json['sensitiveFlag']; + _serviceStar = json['serviceStar']; + _storeId = json['storeId']; + } + int _bizType; + String _commentImgs; + bool _commentImgsFlag; + int _commentStar; + String _commentText; + int _descStar; + bool _hideFlag; + int _id; + bool _isDelete; + int _likeNum; + int _logisticsStar; + int _mid; + int _orderProductId; + int _parentId; + int _productId; + bool _sensitiveFlag; + int _serviceStar; + int _storeId; + + int get bizType => _bizType; + String get commentImgs => _commentImgs; + bool get commentImgsFlag => _commentImgsFlag; + int get commentStar => _commentStar; + String get commentText => _commentText; + int get descStar => _descStar; + bool get hideFlag => _hideFlag; + int get id => _id; + bool get isDelete => _isDelete; + int get likeNum => _likeNum; + int get logisticsStar => _logisticsStar; + int get mid => _mid; + int get orderProductId => _orderProductId; + int get parentId => _parentId; + int get productId => _productId; + bool get sensitiveFlag => _sensitiveFlag; + int get serviceStar => _serviceStar; + int get storeId => _storeId; + + + set bizType(int value) { + _bizType = value; + } + + Map toJson() { + final map = {}; + map['bizType'] = _bizType; + map['commentImgs'] = _commentImgs; + map['commentImgsFlag'] = _commentImgsFlag; + map['commentStar'] = _commentStar; + map['commentText'] = _commentText; + map['descStar'] = _descStar; + map['hideFlag'] = _hideFlag; + map['id'] = _id; + map['isDelete'] = _isDelete; + map['likeNum'] = _likeNum; + map['logisticsStar'] = _logisticsStar; + map['mid'] = _mid; + map['orderProductId'] = _orderProductId; + map['parentId'] = _parentId; + map['productId'] = _productId; + map['sensitiveFlag'] = _sensitiveFlag; + map['serviceStar'] = _serviceStar; + map['storeId'] = _storeId; + return map; + } + + set commentImgs(String value) { + _commentImgs = value; + } + + set commentImgsFlag(bool value) { + _commentImgsFlag = value; + } + + set commentStar(int value) { + _commentStar = value; + } + + set commentText(String value) { + _commentText = value; + } + + set descStar(int value) { + _descStar = value; + } + + set hideFlag(bool value) { + _hideFlag = value; + } + + set id(int value) { + _id = value; + } + + set isDelete(bool value) { + _isDelete = value; + } + + set likeNum(int value) { + _likeNum = value; + } + + set logisticsStar(int value) { + _logisticsStar = value; + } + + set mid(int value) { + _mid = value; + } + + set orderProductId(int value) { + _orderProductId = value; + } + + set parentId(int value) { + _parentId = value; + } + + set productId(int value) { + _productId = value; + } + + set sensitiveFlag(bool value) { + _sensitiveFlag = value; + } + + set serviceStar(int value) { + _serviceStar = value; + } + + set storeId(int value) { + _storeId = value; + } +} + +class Comment { + Comment({ + int bizType, + String commentImgs, + bool commentImgsFlag, + int commentStar, + String commentText, + int descStar, + bool hideFlag, + int id, + bool isDelete, + int likeNum, + int logisticsStar, + int mid, + int orderProductId, + int parentId, + int productId, + bool sensitiveFlag, + int serviceStar, + int storeId,}){ + _bizType = bizType; + _commentImgs = commentImgs; + _commentImgsFlag = commentImgsFlag; + _commentStar = commentStar; + _commentText = commentText; + _descStar = descStar; + _hideFlag = hideFlag; + _id = id; + _isDelete = isDelete; + _likeNum = likeNum; + _logisticsStar = logisticsStar; + _mid = mid; + _orderProductId = orderProductId; + _parentId = parentId; + _productId = productId; + _sensitiveFlag = sensitiveFlag; + _serviceStar = serviceStar; + _storeId = storeId; + } + + Comment.fromJson(dynamic json) { + _bizType = json['bizType']; + _commentImgs = json['commentImgs']; + _commentImgsFlag = json['commentImgsFlag']; + _commentStar = json['commentStar']; + _commentText = json['commentText']; + _descStar = json['descStar']; + _hideFlag = json['hideFlag']; + _id = json['id']; + _isDelete = json['isDelete']; + _likeNum = json['likeNum']; + _logisticsStar = json['logisticsStar']; + _mid = json['mid']; + _orderProductId = json['orderProductId']; + _parentId = json['parentId']; + _productId = json['productId']; + _sensitiveFlag = json['sensitiveFlag']; + _serviceStar = json['serviceStar']; + _storeId = json['storeId']; + } + int _bizType; + String _commentImgs; + bool _commentImgsFlag; + int _commentStar; + String _commentText; + int _descStar; + bool _hideFlag; + int _id; + bool _isDelete; + int _likeNum; + int _logisticsStar; + int _mid; + int _orderProductId; + int _parentId; + int _productId; + bool _sensitiveFlag; + int _serviceStar; + int _storeId; + + int get bizType => _bizType; + String get commentImgs => _commentImgs; + bool get commentImgsFlag => _commentImgsFlag; + int get commentStar => _commentStar; + String get commentText => _commentText; + int get descStar => _descStar; + bool get hideFlag => _hideFlag; + int get id => _id; + bool get isDelete => _isDelete; + int get likeNum => _likeNum; + int get logisticsStar => _logisticsStar; + int get mid => _mid; + int get orderProductId => _orderProductId; + int get parentId => _parentId; + int get productId => _productId; + bool get sensitiveFlag => _sensitiveFlag; + int get serviceStar => _serviceStar; + int get storeId => _storeId; + + + set bizType(int value) { + _bizType = value; + } + + Map toJson() { + final map = {}; + map['bizType'] = _bizType; + map['commentImgs'] = _commentImgs; + map['commentImgsFlag'] = _commentImgsFlag; + map['commentStar'] = _commentStar; + map['commentText'] = _commentText; + map['descStar'] = _descStar; + map['hideFlag'] = _hideFlag; + map['id'] = _id; + map['isDelete'] = _isDelete; + map['likeNum'] = _likeNum; + map['logisticsStar'] = _logisticsStar; + map['mid'] = _mid; + map['orderProductId'] = _orderProductId; + map['parentId'] = _parentId; + map['productId'] = _productId; + map['sensitiveFlag'] = _sensitiveFlag; + map['serviceStar'] = _serviceStar; + map['storeId'] = _storeId; + return map; + } + + set commentImgs(String value) { + _commentImgs = value; + } + + set commentImgsFlag(bool value) { + _commentImgsFlag = value; + } + + set commentStar(int value) { + _commentStar = value; + } + + set commentText(String value) { + _commentText = value; + } + + set descStar(int value) { + _descStar = value; + } + + set hideFlag(bool value) { + _hideFlag = value; + } + + set id(int value) { + _id = value; + } + + set isDelete(bool value) { + _isDelete = value; + } + + set likeNum(int value) { + _likeNum = value; + } + + set logisticsStar(int value) { + _logisticsStar = value; + } + + set mid(int value) { + _mid = value; + } + + set orderProductId(int value) { + _orderProductId = value; + } + + set parentId(int value) { + _parentId = value; + } + + set productId(int value) { + _productId = value; + } + + set sensitiveFlag(bool value) { + _sensitiveFlag = value; + } + + set serviceStar(int value) { + _serviceStar = value; + } + + set storeId(int value) { + _storeId = value; + } +} diff --git a/lib/retrofit/data/placeOrderFirst.dart b/lib/retrofit/data/placeOrderFirst.dart index d93ab4a6..da05b643 100644 --- a/lib/retrofit/data/placeOrderFirst.dart +++ b/lib/retrofit/data/placeOrderFirst.dart @@ -1,491 +1,135 @@ +import 'package:huixiang/retrofit/data/down_order.dart'; +import 'package:huixiang/retrofit/data/order_product_vo.dart'; import 'package:huixiang/retrofit/data/shoppingCart.dart'; -/// addressId : 0 -/// isSubscribe : true -/// isTakeOut : 0 -/// notes : "" -/// numberOfPeople : 0 -/// orderSource : 0 -/// orderType : 0 -/// orderTypeId : 0 -/// parentCode : "" -/// parentId : 0 -/// payChannel : 0 -/// promotionInfoDTO : {"couponId":0,"promotionId":0} -/// recMobile : "" -/// shoppingCartSkuItemList : [] -/// skuItemDTOList : [{"buyNum":0,"couponId":0,"couponName":"","discountPercent":0,"orderId":0,"orderProductId":0,"platterList":[{"deleted":true,"id":0,"productId":0,"required":true,"skuId":0}],"promotionId":0,"promotionName":"","refundNum":0,"skuId":0}] -/// source : 0 -/// storeId : 0 -/// subcribeTime : "" -/// tableId : 0 - class PlaceOrderFirst { - PlaceOrderFirst({ - String addressId, - bool isSubscribe, - int isTakeOut, - String notes, - String numberOfPeople, - int orderSource, - int orderType, - int orderTypeId, - String parentCode, - int parentId, - int payChannel, - PlaceOrderFirstPromotionInfoDTO promotionInfoDTO, - String recMobile, - List shoppingCartSkuItemList, - List skuItemDTOList, - int source, - String storeId, - String subcribeTime, - int tableId,}){ - _addressId = addressId; - _isSubscribe = isSubscribe; - _isTakeOut = isTakeOut; - _notes = notes; - _numberOfPeople = numberOfPeople; - _orderSource = orderSource; - _orderType = orderType; - _orderTypeId = orderTypeId; - _parentCode = parentCode; - _parentId = parentId; - _payChannel = payChannel; - _promotionInfoDTO = promotionInfoDTO; - _recMobile = recMobile; - _skuItemDTOList = skuItemDTOList; - _shoppingCartSkuItemList = shoppingCartSkuItemList; - _source = source; - _storeId = storeId; - _subcribeTime = subcribeTime; - _tableId = tableId; + int cartNum; + String cartSum; + String addressId; + bool isSubscribe; + num isTakeOut; + String notes; + String id; + String numberOfPeople; + num orderSource; + String orderType; + num orderTypeId; + String parentCode; + String parentId; + num payChannel; + PromotionInfoDTOBean promotionInfoDTO; + String recMobile; + List orderProductVOList; + List shoppingCartSkuItemList; + List skuItemDTOList; + num source; + String storeId; + String subcribeTime; + String tableId; + + PlaceOrderFirst( + { + this.cartNum, + this.cartSum, + this.addressId, + this.isSubscribe, + this.isTakeOut, + this.notes, + this.id, + this.numberOfPeople, + this.orderSource, + this.orderType, + this.orderTypeId, + this.parentCode, + this.parentId, + this.payChannel, + this.promotionInfoDTO, + this.recMobile, + this.orderProductVOList, + this.shoppingCartSkuItemList, + this.skuItemDTOList, + this.source, + this.storeId, + this.subcribeTime, + this.tableId}); + + static PlaceOrderFirst fromJson(Map json) { + if (json == null) return null; + PlaceOrderFirst placeOrderFirst = PlaceOrderFirst(); + placeOrderFirst.cartNum = json['cartNum']; + placeOrderFirst.cartSum = json['cartSum']; + placeOrderFirst.addressId = json['addressId']; + placeOrderFirst.isSubscribe = json['isSubscribe']; + placeOrderFirst.isTakeOut = json['isTakeOut']; + placeOrderFirst.notes = json['notes']; + placeOrderFirst.id = json['id']; + placeOrderFirst.numberOfPeople = json['numberOfPeople']; + placeOrderFirst.orderSource = json['orderSource']; + placeOrderFirst.orderType = json['orderType']; + placeOrderFirst.orderTypeId = json['orderTypeId']; + placeOrderFirst.parentCode = json['parentCode']; + placeOrderFirst.parentId = json['parentId']; + placeOrderFirst.payChannel = json['payChannel']; + placeOrderFirst.promotionInfoDTO = + PromotionInfoDTOBean.fromJson(json['promotionInfoDTO']); + placeOrderFirst.recMobile = json['recMobile']; + placeOrderFirst.shoppingCartSkuItemList = []..addAll( + (json['shoppingCartSkuItemList'] as List ?? []) + .map((o) => ShoppingCartSkuItemListBean.fromJson(o))); + placeOrderFirst.orderProductVOList = []..addAll( + (json['orderProductVOList'] as List ?? []) + .map((o) => OrderProductVOList.fromJson(o))); + placeOrderFirst.skuItemDTOList = json['skuItemDTOList']; + placeOrderFirst.source = json['source']; + placeOrderFirst.storeId = json['storeId']; + placeOrderFirst.subcribeTime = json['subcribeTime']; + placeOrderFirst.tableId = json['tableId']; + return placeOrderFirst; + } + + Map toJson() => { + "cartNum": cartNum, + "cartSum": cartSum, + "addressId": addressId, + "isSubscribe": isSubscribe, + "isTakeOut": isTakeOut, + "notes": notes, + "id": id, + "numberOfPeople": numberOfPeople, + "orderSource": orderSource, + "orderType": orderType, + "orderTypeId": orderTypeId, + "parentCode": parentCode, + "parentId": parentId, + "payChannel": payChannel, + "promotionInfoDTO": promotionInfoDTO == null ? null : promotionInfoDTO.toJson(), + "recMobile": recMobile, + "shoppingCartSkuItemList": shoppingCartSkuItemList == null ? null : shoppingCartSkuItemList.map((e) => e.toJson()).toList(), + "orderProductVOList": orderProductVOList == null ? null : orderProductVOList.map((e) => e.toJson()).toList(), + "skuItemDTOList": skuItemDTOList, + "source": source, + "storeId": storeId, + "subcribeTime": subcribeTime, + "tableId": tableId, + }; } - PlaceOrderFirst.fromJson(dynamic json) { - _addressId = json['addressId']; - _isSubscribe = json['isSubscribe']; - _isTakeOut = json['isTakeOut']; - _notes = json['notes']; - _numberOfPeople = json['numberOfPeople']; - _orderSource = json['orderSource']; - _orderType = json['orderType']; - _orderTypeId = json['orderTypeId']; - _parentCode = json['parentCode']; - _parentId = json['parentId']; - _payChannel = json['payChannel']; - _promotionInfoDTO = json['promotionInfoDTO'] != null ? PlaceOrderFirstPromotionInfoDTO.fromJson(json['promotionInfoDTO']) : null; - _recMobile = json['recMobile']; - if (json['skuItemDTOList'] != null) { - _skuItemDTOList = []; - json['skuItemDTOList'].forEach((v) { - _skuItemDTOList.add(SkuItemDTOList.fromJson(v)); - }); - } - if (json['shoppingCartSkuItemList'] != null) { - _shoppingCartSkuItemList = []; - json['shoppingCartSkuItemList'].forEach((v) { - _shoppingCartSkuItemList.add(ShoppingCartSkuItemListBean.fromJson(v)); - }); - } - _source = json['source']; - _storeId = json['storeId']; - _subcribeTime = json['subcribeTime']; - _tableId = json['tableId']; - } - String _addressId; - bool _isSubscribe; - int _isTakeOut; - String _notes; - String _numberOfPeople; - int _orderSource; - int _orderType; - int _orderTypeId; - String _parentCode; - int _parentId; - int _payChannel; - PlaceOrderFirstPromotionInfoDTO _promotionInfoDTO; - String _recMobile; - List _skuItemDTOList; - List _shoppingCartSkuItemList; - int _source; - String _storeId; - String _subcribeTime; - int _tableId; - - set addressId(String value) { - _addressId = value; - } - - String get addressId => _addressId; - bool get isSubscribe => _isSubscribe; - int get isTakeOut => _isTakeOut; - String get notes => _notes; - String get numberOfPeople => _numberOfPeople; - int get orderSource => _orderSource; - int get orderType => _orderType; - int get orderTypeId => _orderTypeId; - String get parentCode => _parentCode; - int get parentId => _parentId; - int get payChannel => _payChannel; - PlaceOrderFirstPromotionInfoDTO get promotionInfoDTO => _promotionInfoDTO; - String get recMobile => _recMobile; - List get skuItemDTOList => _skuItemDTOList; - List get shoppingCartSkuItemList => _shoppingCartSkuItemList; - int get source => _source; - String get storeId => _storeId; - String get subcribeTime => _subcribeTime; - int get tableId => _tableId; - - Map toJson() { - final map = {}; - map['addressId'] = _addressId; - map['isSubscribe'] = _isSubscribe; - map['isTakeOut'] = _isTakeOut; - map['notes'] = _notes; - map['numberOfPeople'] = _numberOfPeople; - map['orderSource'] = _orderSource; - map['orderType'] = _orderType; - map['orderTypeId'] = _orderTypeId; - map['parentCode'] = _parentCode; - map['parentId'] = _parentId; - map['payChannel'] = _payChannel; - if (_promotionInfoDTO != null) { - map['promotionInfoDTO'] = _promotionInfoDTO.toJson(); - } - map['recMobile'] = _recMobile; - if (_skuItemDTOList != null) { - map['skuItemDTOList'] = _skuItemDTOList.map((v) => v.toJson()).toList(); - } - if (_shoppingCartSkuItemList != null) { - map['shoppingCartSkuItemList'] = _shoppingCartSkuItemList.map((v) => v.toJson()).toList(); - } - map['source'] = _source; - map['storeId'] = _storeId; - map['subcribeTime'] = _subcribeTime; - map['tableId'] = _tableId; - return map; - } - - set isSubscribe(bool value) { - _isSubscribe = value; - } - - set isTakeOut(int value) { - _isTakeOut = value; - } - - set notes(String value) { - _notes = value; - } - - set numberOfPeople(String value) { - _numberOfPeople = value; - } - - set orderSource(int value) { - _orderSource = value; - } +class PromotionInfoDTOBean { + String couponId; + String promotionId; - set orderType(int value) { - _orderType = value; - } - - set orderTypeId(int value) { - _orderTypeId = value; - } - - set parentCode(String value) { - _parentCode = value; - } - - set parentId(int value) { - _parentId = value; - } - - set payChannel(int value) { - _payChannel = value; - } + PromotionInfoDTOBean({this.couponId, this.promotionId}); - set promotionInfoDTO(PlaceOrderFirstPromotionInfoDTO value) { - _promotionInfoDTO = value; + static PromotionInfoDTOBean fromJson(Map json) { + if (json == null) return null; + PromotionInfoDTOBean promotionInfoDTOBean = PromotionInfoDTOBean(); + promotionInfoDTOBean.couponId = json['couponId']; + promotionInfoDTOBean.promotionId = json['promotionId']; + return promotionInfoDTOBean; } - set recMobile(String value) { - _recMobile = value; - } - - set skuItemDTOList(List value) { - _skuItemDTOList = value; - } - - set shoppingCartSkuItemList(List value) { - _shoppingCartSkuItemList = value; - } - - set source(int value) { - _source = value; - } - - set storeId(String value) { - _storeId = value; - } - - set subcribeTime(String value) { - _subcribeTime = value; - } - - set tableId(int value) { - _tableId = value; - } + Map toJson() => { + "couponId": couponId, + "promotionId": promotionId, + }; } - -/// buyNum : 0 -/// couponId : 0 -/// couponName : "" -/// discountPercent : 0 -/// orderId : 0 -/// orderProductId : 0 -/// platterList : [{"deleted":true,"id":0,"productId":0,"required":true,"skuId":0}] -/// promotionId : 0 -/// promotionName : "" -/// refundNum : 0 -/// skuId : 0 - -class SkuItemDTOList { - SkuItemDTOList({ - int buyNum, - int couponId, - String couponName, - int discountPercent, - int orderId, - int orderProductId, - List platterList, - int promotionId, - String promotionName, - int refundNum, - String skuId,}){ - _buyNum = buyNum; - _couponId = couponId; - _couponName = couponName; - _discountPercent = discountPercent; - _orderId = orderId; - _orderProductId = orderProductId; - _platterList = platterList; - _promotionId = promotionId; - _promotionName = promotionName; - _refundNum = refundNum; - _skuId = skuId; -} - - SkuItemDTOList.fromJson(dynamic json) { - _buyNum = json['buyNum']; - _couponId = json['couponId']; - _couponName = json['couponName']; - _discountPercent = json['discountPercent']; - _orderId = json['orderId']; - _orderProductId = json['orderProductId']; - if (json['platterList'] != null) { - _platterList = []; - json['platterList'].forEach((v) { - _platterList.add(PlatterList.fromJson(v)); - }); - } - _promotionId = json['promotionId']; - _promotionName = json['promotionName']; - _refundNum = json['refundNum']; - _skuId = json['skuId']; - } - int _buyNum; - int _couponId; - String _couponName; - int _discountPercent; - int _orderId; - int _orderProductId; - List _platterList; - int _promotionId; - String _promotionName; - int _refundNum; - String _skuId; - - int get buyNum => _buyNum; - int get couponId => _couponId; - String get couponName => _couponName; - int get discountPercent => _discountPercent; - int get orderId => _orderId; - int get orderProductId => _orderProductId; - List get platterList => _platterList; - int get promotionId => _promotionId; - String get promotionName => _promotionName; - int get refundNum => _refundNum; - String get skuId => _skuId; - - set buyNum(int value) { - _buyNum = value; - } - - Map toJson() { - final map = {}; - map['buyNum'] = _buyNum; - map['couponId'] = _couponId; - map['couponName'] = _couponName; - map['discountPercent'] = _discountPercent; - map['orderId'] = _orderId; - map['orderProductId'] = _orderProductId; - if (_platterList != null) { - map['platterList'] = _platterList.map((v) => v.toJson()).toList(); - } - map['promotionId'] = _promotionId; - map['promotionName'] = _promotionName; - map['refundNum'] = _refundNum; - map['skuId'] = _skuId; - return map; - } - - set couponId(int value) { - _couponId = value; - } - - set couponName(String value) { - _couponName = value; - } - - set discountPercent(int value) { - _discountPercent = value; - } - - set orderId(int value) { - _orderId = value; - } - - set orderProductId(int value) { - _orderProductId = value; - } - - set platterList(List value) { - _platterList = value; - } - - set promotionId(int value) { - _promotionId = value; - } - - set promotionName(String value) { - _promotionName = value; - } - - set refundNum(int value) { - _refundNum = value; - } - - set skuId(String value) { - _skuId = value; - } -} - -/// deleted : true -/// id : 0 -/// productId : 0 -/// required : true -/// skuId : 0 - -class PlatterList { - PlatterList({ - bool deleted, - int id, - String productId, - bool required, - String skuId,}){ - _deleted = deleted; - _id = id; - _productId = productId; - _required = required; - _skuId = skuId; -} - - PlatterList.fromJson(dynamic json) { - _deleted = json['deleted']; - _id = json['id']; - _productId = json['productId']; - _required = json['required']; - _skuId = json['skuId']; - } - bool _deleted; - int _id; - String _productId; - bool _required; - String _skuId; - - bool get deleted => _deleted; - int get id => _id; - String get productId => _productId; - bool get required => _required; - String get skuId => _skuId; - - set deleted(bool value) { - _deleted = value; - } - - Map toJson() { - final map = {}; - map['deleted'] = _deleted; - map['id'] = _id; - map['productId'] = _productId; - map['required'] = _required; - map['skuId'] = _skuId; - return map; - } - - set id(int value) { - _id = value; - } - - set productId(String value) { - _productId = value; - } - - set required(bool value) { - _required = value; - } - - set skuId(String value) { - _skuId = value; - } -} - -/// couponId : 0 -/// promotionId : 0 - -class PlaceOrderFirstPromotionInfoDTO { - PlaceOrderFirstPromotionInfoDTO({ - String couponId, - String promotionId,}){ - _couponId = couponId; - _promotionId = promotionId; -} - - PlaceOrderFirstPromotionInfoDTO.fromJson(dynamic json) { - _couponId = json['couponId']; - _promotionId = json['promotionId']; - } - String _couponId; - String _promotionId; - - set couponId(String value) { - _couponId = value; - } - - String get couponId => _couponId; - String get promotionId => _promotionId; - - Map toJson() { - final map = {}; - map['couponId'] = _couponId; - map['promotionId'] = _promotionId; - return map; - } - - set promotionId(String value) { - _promotionId = value; - } -} \ No newline at end of file diff --git a/lib/retrofit/data/product.dart b/lib/retrofit/data/product.dart new file mode 100644 index 00000000..afd86b87 --- /dev/null +++ b/lib/retrofit/data/product.dart @@ -0,0 +1,182 @@ + +class ProductList { + String _id; + String _createTime; + String _createUser; + String _updateTime; + String _updateUser; + dynamic _tenantCode; + String _storeId; + String _orderId; + String _productId; + String _productName; + String _skuId; + String _skuNameStr; + String _skuImg; + int _buyNum; + int _refundNum; + double _weight; + String _applyPrice; + String _sellPrice; + String _postPay; + int _isDelete; + String _discountAmount; + int _discountPercent; + bool _status; + int _batch; + + String get id => _id; + + String get createTime => _createTime; + + String get createUser => _createUser; + + String get updateTime => _updateTime; + + String get updateUser => _updateUser; + + dynamic get tenantCode => _tenantCode; + + String get storeId => _storeId; + + String get orderId => _orderId; + + String get productId => _productId; + + String get productName => _productName; + + String get skuId => _skuId; + + String get skuNameStr => _skuNameStr; + + String get skuImg => _skuImg; + + int get buyNum => _buyNum; + + int get refundNum => _refundNum; + + double get weight => _weight; + + String get applyPrice => _applyPrice; + + String get sellPrice => _sellPrice; + + String get postPay => _postPay; + + int get isDelete => _isDelete; + + String get discountAmount => _discountAmount; + + int get discountPercent => _discountPercent; + + bool get status => _status; + + int get batch => _batch; + + ProductList( + {String id, + String createTime, + String createUser, + String updateTime, + String updateUser, + dynamic tenantCode, + String storeId, + String orderId, + String productId, + String productName, + String skuId, + String skuNameStr, + String skuImg, + int buyNum, + int refundNum, + double weight, + String applyPrice, + String sellPrice, + String postPay, + int isDelete, + String discountAmount, + int discountPercent, + bool status, + int batch}) { + _id = id; + _createTime = createTime; + _createUser = createUser; + _updateTime = updateTime; + _updateUser = updateUser; + _tenantCode = tenantCode; + _storeId = storeId; + _orderId = orderId; + _productId = productId; + _productName = productName; + _skuId = skuId; + _skuNameStr = skuNameStr; + _skuImg = skuImg; + _buyNum = buyNum; + _refundNum = refundNum; + _weight = weight; + _applyPrice = applyPrice; + _sellPrice = sellPrice; + _postPay = postPay; + _isDelete = isDelete; + _discountAmount = discountAmount; + _discountPercent = discountPercent; + _status = status; + _batch = batch; + } + + ProductList.fromJson(dynamic json) { + _id = json["id"]; + _createTime = json["createTime"]; + _createUser = json["createUser"]; + _updateTime = json["updateTime"]; + _updateUser = json["updateUser"]; + _tenantCode = json["tenantCode"]; + _storeId = json["storeId"]; + _orderId = json["orderId"]; + _productId = json["productId"]; + _productName = json["productName"]; + _skuId = json["skuId"]; + _skuNameStr = json["skuNameStr"]; + _skuImg = json["skuImg"]; + _buyNum = json["buyNum"]; + _refundNum = json["refundNum"]; + _weight = json["weight"]; + _applyPrice = json["applyPrice"]; + _sellPrice = json["sellPrice"]; + _postPay = json["postPay"]; + _isDelete = json["isDelete"]; + _discountAmount = json["discountAmount"]; + _discountPercent = json["discountPercent"]; + _status = json["status"]; + _batch = json["batch"]; + } + + Map toJson() { + var map = {}; + map["id"] = _id; + map["createTime"] = _createTime; + map["createUser"] = _createUser; + map["updateTime"] = _updateTime; + map["updateUser"] = _updateUser; + map["tenantCode"] = _tenantCode; + map["storeId"] = _storeId; + map["orderId"] = _orderId; + map["productId"] = _productId; + map["productName"] = _productName; + map["skuId"] = _skuId; + map["skuNameStr"] = _skuNameStr; + map["skuImg"] = _skuImg; + map["buyNum"] = _buyNum; + map["refundNum"] = _refundNum; + map["weight"] = _weight; + map["applyPrice"] = _applyPrice; + map["sellPrice"] = _sellPrice; + map["postPay"] = _postPay; + map["isDelete"] = _isDelete; + map["discountAmount"] = _discountAmount; + map["discountPercent"] = _discountPercent; + map["status"] = _status; + map["batch"] = _batch; + return map; + } +} diff --git a/lib/retrofit/data/settlement_bean.dart b/lib/retrofit/data/settlement_bean.dart index d612b14d..c932fbe7 100644 --- a/lib/retrofit/data/settlement_bean.dart +++ b/lib/retrofit/data/settlement_bean.dart @@ -1,3 +1,5 @@ +import 'package:huixiang/retrofit/data/order_product_vo.dart'; + /// addressId : 0 /// buyNum : 0 /// id : 0 @@ -139,743 +141,3 @@ class PromotionInfoDTO { } } -/// actInfo : {"couponDiscountAmount":0,"couponDiscountRate":0,"couponId":0,"couponType":0,"discountAmount":0,"discountRate":0,"promotionId":0,"promotionType":0} -/// additionalComment : {"bizType":0,"commentImgs":"","commentImgsFlag":true,"commentStar":0,"commentText":"","descStar":0,"hideFlag":true,"id":0,"isDelete":true,"likeNum":0,"logisticsStar":0,"mid":0,"orderProductId":0,"parentId":0,"productId":0,"sensitiveFlag":true,"serviceStar":0,"storeId":0} -/// buyNum : 0 -/// canApplyIntervention : 0 -/// comment : {"bizType":0,"commentImgs":"","commentImgsFlag":true,"commentStar":0,"commentText":"","descStar":0,"hideFlag":true,"id":0,"isDelete":true,"likeNum":0,"logisticsStar":0,"mid":0,"orderProductId":0,"parentId":0,"productId":0,"sensitiveFlag":true,"serviceStar":0,"storeId":0} -/// commentStatus : 0 -/// discountAmount : 0 -/// id : 0 -/// productId : 0 -/// productName : "" -/// returnCode : "" -/// returnStatus : 0 -/// returnType : 0 -/// sellPrice : 0 -/// skuId : 0 -/// skuImg : "" -/// skuNameStr : "" - -class OrderProductVOList { - OrderProductVOList({ - ActInfo actInfo, - AdditionalComment additionalComment, - int buyNum, - int canApplyIntervention, - Comment comment, - int commentStatus, - int discountAmount, - int id, - int productId, - String productName, - String returnCode, - int returnStatus, - int returnType, - int sellPrice, - String skuId, - String skuImg, - String skuNameStr,}){ - _actInfo = actInfo; - _additionalComment = additionalComment; - _buyNum = buyNum; - _canApplyIntervention = canApplyIntervention; - _comment = comment; - _commentStatus = commentStatus; - _discountAmount = discountAmount; - _id = id; - _productId = productId; - _productName = productName; - _returnCode = returnCode; - _returnStatus = returnStatus; - _returnType = returnType; - _sellPrice = sellPrice; - _skuId = skuId; - _skuImg = skuImg; - _skuNameStr = skuNameStr; -} - - OrderProductVOList.fromJson(dynamic json) { - _actInfo = json['actInfo'] != null ? ActInfo.fromJson(json['actInfo']) : null; - _additionalComment = json['additionalComment'] != null ? AdditionalComment.fromJson(json['additionalComment']) : null; - _buyNum = json['buyNum']; - _canApplyIntervention = json['canApplyIntervention']; - _comment = json['comment'] != null ? Comment.fromJson(json['comment']) : null; - _commentStatus = json['commentStatus']; - _discountAmount = json['discountAmount']; - _id = json['id']; - _productId = json['productId']; - _productName = json['productName']; - _returnCode = json['returnCode']; - _returnStatus = json['returnStatus']; - _returnType = json['returnType']; - _sellPrice = json['sellPrice']; - _skuId = json['skuId']; - _skuImg = json['skuImg']; - _skuNameStr = json['skuNameStr']; - } - ActInfo _actInfo; - AdditionalComment _additionalComment; - int _buyNum; - int _canApplyIntervention; - Comment _comment; - int _commentStatus; - int _discountAmount; - int _id; - int _productId; - String _productName; - String _returnCode; - int _returnStatus; - int _returnType; - int _sellPrice; - String _skuId; - String _skuImg; - String _skuNameStr; - - ActInfo get actInfo => _actInfo; - AdditionalComment get additionalComment => _additionalComment; - int get buyNum => _buyNum; - int get canApplyIntervention => _canApplyIntervention; - Comment get comment => _comment; - int get commentStatus => _commentStatus; - int get discountAmount => _discountAmount; - int get id => _id; - int get productId => _productId; - String get productName => _productName; - String get returnCode => _returnCode; - int get returnStatus => _returnStatus; - int get returnType => _returnType; - int get sellPrice => _sellPrice; - String get skuId => _skuId; - String get skuImg => _skuImg; - String get skuNameStr => _skuNameStr; - - - set actInfo(ActInfo value) { - _actInfo = value; - } - - Map toJson() { - final map = {}; - if (_actInfo != null) { - map['actInfo'] = _actInfo.toJson(); - } - if (_additionalComment != null) { - map['additionalComment'] = _additionalComment.toJson(); - } - map['buyNum'] = _buyNum; - map['canApplyIntervention'] = _canApplyIntervention; - if (_comment != null) { - map['comment'] = _comment.toJson(); - } - map['commentStatus'] = _commentStatus; - map['discountAmount'] = _discountAmount; - map['id'] = _id; - map['productId'] = _productId; - map['productName'] = _productName; - map['returnCode'] = _returnCode; - map['returnStatus'] = _returnStatus; - map['returnType'] = _returnType; - map['sellPrice'] = _sellPrice; - map['skuId'] = _skuId; - map['skuImg'] = _skuImg; - map['skuNameStr'] = _skuNameStr; - return map; - } - - set additionalComment(AdditionalComment value) { - _additionalComment = value; - } - - set buyNum(int value) { - _buyNum = value; - } - - set canApplyIntervention(int value) { - _canApplyIntervention = value; - } - - set comment(Comment value) { - _comment = value; - } - - set commentStatus(int value) { - _commentStatus = value; - } - - set discountAmount(int value) { - _discountAmount = value; - } - - set id(int value) { - _id = value; - } - - set productId(int value) { - _productId = value; - } - - set productName(String value) { - _productName = value; - } - - set returnCode(String value) { - _returnCode = value; - } - - set returnStatus(int value) { - _returnStatus = value; - } - - set returnType(int value) { - _returnType = value; - } - - set sellPrice(int value) { - _sellPrice = value; - } - - set skuId(String value) { - _skuId = value; - } - - set skuImg(String value) { - _skuImg = value; - } - - set skuNameStr(String value) { - _skuNameStr = value; - } -} - -/// bizType : 0 -/// commentImgs : "" -/// commentImgsFlag : true -/// commentStar : 0 -/// commentText : "" -/// descStar : 0 -/// hideFlag : true -/// id : 0 -/// isDelete : true -/// likeNum : 0 -/// logisticsStar : 0 -/// mid : 0 -/// orderProductId : 0 -/// parentId : 0 -/// productId : 0 -/// sensitiveFlag : true -/// serviceStar : 0 -/// storeId : 0 - -class Comment { - Comment({ - int bizType, - String commentImgs, - bool commentImgsFlag, - int commentStar, - String commentText, - int descStar, - bool hideFlag, - int id, - bool isDelete, - int likeNum, - int logisticsStar, - int mid, - int orderProductId, - int parentId, - int productId, - bool sensitiveFlag, - int serviceStar, - int storeId,}){ - _bizType = bizType; - _commentImgs = commentImgs; - _commentImgsFlag = commentImgsFlag; - _commentStar = commentStar; - _commentText = commentText; - _descStar = descStar; - _hideFlag = hideFlag; - _id = id; - _isDelete = isDelete; - _likeNum = likeNum; - _logisticsStar = logisticsStar; - _mid = mid; - _orderProductId = orderProductId; - _parentId = parentId; - _productId = productId; - _sensitiveFlag = sensitiveFlag; - _serviceStar = serviceStar; - _storeId = storeId; -} - - Comment.fromJson(dynamic json) { - _bizType = json['bizType']; - _commentImgs = json['commentImgs']; - _commentImgsFlag = json['commentImgsFlag']; - _commentStar = json['commentStar']; - _commentText = json['commentText']; - _descStar = json['descStar']; - _hideFlag = json['hideFlag']; - _id = json['id']; - _isDelete = json['isDelete']; - _likeNum = json['likeNum']; - _logisticsStar = json['logisticsStar']; - _mid = json['mid']; - _orderProductId = json['orderProductId']; - _parentId = json['parentId']; - _productId = json['productId']; - _sensitiveFlag = json['sensitiveFlag']; - _serviceStar = json['serviceStar']; - _storeId = json['storeId']; - } - int _bizType; - String _commentImgs; - bool _commentImgsFlag; - int _commentStar; - String _commentText; - int _descStar; - bool _hideFlag; - int _id; - bool _isDelete; - int _likeNum; - int _logisticsStar; - int _mid; - int _orderProductId; - int _parentId; - int _productId; - bool _sensitiveFlag; - int _serviceStar; - int _storeId; - - int get bizType => _bizType; - String get commentImgs => _commentImgs; - bool get commentImgsFlag => _commentImgsFlag; - int get commentStar => _commentStar; - String get commentText => _commentText; - int get descStar => _descStar; - bool get hideFlag => _hideFlag; - int get id => _id; - bool get isDelete => _isDelete; - int get likeNum => _likeNum; - int get logisticsStar => _logisticsStar; - int get mid => _mid; - int get orderProductId => _orderProductId; - int get parentId => _parentId; - int get productId => _productId; - bool get sensitiveFlag => _sensitiveFlag; - int get serviceStar => _serviceStar; - int get storeId => _storeId; - - - set bizType(int value) { - _bizType = value; - } - - Map toJson() { - final map = {}; - map['bizType'] = _bizType; - map['commentImgs'] = _commentImgs; - map['commentImgsFlag'] = _commentImgsFlag; - map['commentStar'] = _commentStar; - map['commentText'] = _commentText; - map['descStar'] = _descStar; - map['hideFlag'] = _hideFlag; - map['id'] = _id; - map['isDelete'] = _isDelete; - map['likeNum'] = _likeNum; - map['logisticsStar'] = _logisticsStar; - map['mid'] = _mid; - map['orderProductId'] = _orderProductId; - map['parentId'] = _parentId; - map['productId'] = _productId; - map['sensitiveFlag'] = _sensitiveFlag; - map['serviceStar'] = _serviceStar; - map['storeId'] = _storeId; - return map; - } - - set commentImgs(String value) { - _commentImgs = value; - } - - set commentImgsFlag(bool value) { - _commentImgsFlag = value; - } - - set commentStar(int value) { - _commentStar = value; - } - - set commentText(String value) { - _commentText = value; - } - - set descStar(int value) { - _descStar = value; - } - - set hideFlag(bool value) { - _hideFlag = value; - } - - set id(int value) { - _id = value; - } - - set isDelete(bool value) { - _isDelete = value; - } - - set likeNum(int value) { - _likeNum = value; - } - - set logisticsStar(int value) { - _logisticsStar = value; - } - - set mid(int value) { - _mid = value; - } - - set orderProductId(int value) { - _orderProductId = value; - } - - set parentId(int value) { - _parentId = value; - } - - set productId(int value) { - _productId = value; - } - - set sensitiveFlag(bool value) { - _sensitiveFlag = value; - } - - set serviceStar(int value) { - _serviceStar = value; - } - - set storeId(int value) { - _storeId = value; - } -} - -/// bizType : 0 -/// commentImgs : "" -/// commentImgsFlag : true -/// commentStar : 0 -/// commentText : "" -/// descStar : 0 -/// hideFlag : true -/// id : 0 -/// isDelete : true -/// likeNum : 0 -/// logisticsStar : 0 -/// mid : 0 -/// orderProductId : 0 -/// parentId : 0 -/// productId : 0 -/// sensitiveFlag : true -/// serviceStar : 0 -/// storeId : 0 - -class AdditionalComment { - AdditionalComment({ - int bizType, - String commentImgs, - bool commentImgsFlag, - int commentStar, - String commentText, - int descStar, - bool hideFlag, - int id, - bool isDelete, - int likeNum, - int logisticsStar, - int mid, - int orderProductId, - int parentId, - int productId, - bool sensitiveFlag, - int serviceStar, - int storeId,}){ - _bizType = bizType; - _commentImgs = commentImgs; - _commentImgsFlag = commentImgsFlag; - _commentStar = commentStar; - _commentText = commentText; - _descStar = descStar; - _hideFlag = hideFlag; - _id = id; - _isDelete = isDelete; - _likeNum = likeNum; - _logisticsStar = logisticsStar; - _mid = mid; - _orderProductId = orderProductId; - _parentId = parentId; - _productId = productId; - _sensitiveFlag = sensitiveFlag; - _serviceStar = serviceStar; - _storeId = storeId; -} - - AdditionalComment.fromJson(dynamic json) { - _bizType = json['bizType']; - _commentImgs = json['commentImgs']; - _commentImgsFlag = json['commentImgsFlag']; - _commentStar = json['commentStar']; - _commentText = json['commentText']; - _descStar = json['descStar']; - _hideFlag = json['hideFlag']; - _id = json['id']; - _isDelete = json['isDelete']; - _likeNum = json['likeNum']; - _logisticsStar = json['logisticsStar']; - _mid = json['mid']; - _orderProductId = json['orderProductId']; - _parentId = json['parentId']; - _productId = json['productId']; - _sensitiveFlag = json['sensitiveFlag']; - _serviceStar = json['serviceStar']; - _storeId = json['storeId']; - } - int _bizType; - String _commentImgs; - bool _commentImgsFlag; - int _commentStar; - String _commentText; - int _descStar; - bool _hideFlag; - int _id; - bool _isDelete; - int _likeNum; - int _logisticsStar; - int _mid; - int _orderProductId; - int _parentId; - int _productId; - bool _sensitiveFlag; - int _serviceStar; - int _storeId; - - int get bizType => _bizType; - String get commentImgs => _commentImgs; - bool get commentImgsFlag => _commentImgsFlag; - int get commentStar => _commentStar; - String get commentText => _commentText; - int get descStar => _descStar; - bool get hideFlag => _hideFlag; - int get id => _id; - bool get isDelete => _isDelete; - int get likeNum => _likeNum; - int get logisticsStar => _logisticsStar; - int get mid => _mid; - int get orderProductId => _orderProductId; - int get parentId => _parentId; - int get productId => _productId; - bool get sensitiveFlag => _sensitiveFlag; - int get serviceStar => _serviceStar; - int get storeId => _storeId; - - - set bizType(int value) { - _bizType = value; - } - - Map toJson() { - final map = {}; - map['bizType'] = _bizType; - map['commentImgs'] = _commentImgs; - map['commentImgsFlag'] = _commentImgsFlag; - map['commentStar'] = _commentStar; - map['commentText'] = _commentText; - map['descStar'] = _descStar; - map['hideFlag'] = _hideFlag; - map['id'] = _id; - map['isDelete'] = _isDelete; - map['likeNum'] = _likeNum; - map['logisticsStar'] = _logisticsStar; - map['mid'] = _mid; - map['orderProductId'] = _orderProductId; - map['parentId'] = _parentId; - map['productId'] = _productId; - map['sensitiveFlag'] = _sensitiveFlag; - map['serviceStar'] = _serviceStar; - map['storeId'] = _storeId; - return map; - } - - set commentImgs(String value) { - _commentImgs = value; - } - - set commentImgsFlag(bool value) { - _commentImgsFlag = value; - } - - set commentStar(int value) { - _commentStar = value; - } - - set commentText(String value) { - _commentText = value; - } - - set descStar(int value) { - _descStar = value; - } - - set hideFlag(bool value) { - _hideFlag = value; - } - - set id(int value) { - _id = value; - } - - set isDelete(bool value) { - _isDelete = value; - } - - set likeNum(int value) { - _likeNum = value; - } - - set logisticsStar(int value) { - _logisticsStar = value; - } - - set mid(int value) { - _mid = value; - } - - set orderProductId(int value) { - _orderProductId = value; - } - - set parentId(int value) { - _parentId = value; - } - - set productId(int value) { - _productId = value; - } - - set sensitiveFlag(bool value) { - _sensitiveFlag = value; - } - - set serviceStar(int value) { - _serviceStar = value; - } - - set storeId(int value) { - _storeId = value; - } -} - -/// couponDiscountAmount : 0 -/// couponDiscountRate : 0 -/// couponId : 0 -/// couponType : 0 -/// discountAmount : 0 -/// discountRate : 0 -/// promotionId : 0 -/// promotionType : 0 - -class ActInfo { - ActInfo({ - int couponDiscountAmount, - int couponDiscountRate, - int couponId, - int couponType, - int discountAmount, - int discountRate, - int promotionId, - int promotionType,}){ - _couponDiscountAmount = couponDiscountAmount; - _couponDiscountRate = couponDiscountRate; - _couponId = couponId; - _couponType = couponType; - _discountAmount = discountAmount; - _discountRate = discountRate; - _promotionId = promotionId; - _promotionType = promotionType; -} - - ActInfo.fromJson(dynamic json) { - _couponDiscountAmount = json['couponDiscountAmount']; - _couponDiscountRate = json['couponDiscountRate']; - _couponId = json['couponId']; - _couponType = json['couponType']; - _discountAmount = json['discountAmount']; - _discountRate = json['discountRate']; - _promotionId = json['promotionId']; - _promotionType = json['promotionType']; - } - int _couponDiscountAmount; - int _couponDiscountRate; - int _couponId; - int _couponType; - int _discountAmount; - int _discountRate; - int _promotionId; - int _promotionType; - - int get couponDiscountAmount => _couponDiscountAmount; - int get couponDiscountRate => _couponDiscountRate; - int get couponId => _couponId; - int get couponType => _couponType; - int get discountAmount => _discountAmount; - int get discountRate => _discountRate; - int get promotionId => _promotionId; - int get promotionType => _promotionType; - - - set couponDiscountAmount(int value) { - _couponDiscountAmount = value; - } - - Map toJson() { - final map = {}; - map['couponDiscountAmount'] = _couponDiscountAmount; - map['couponDiscountRate'] = _couponDiscountRate; - map['couponId'] = _couponId; - map['couponType'] = _couponType; - map['discountAmount'] = _discountAmount; - map['discountRate'] = _discountRate; - map['promotionId'] = _promotionId; - map['promotionType'] = _promotionType; - return map; - } - - set couponDiscountRate(int value) { - _couponDiscountRate = value; - } - - set couponId(int value) { - _couponId = value; - } - - set couponType(int value) { - _couponType = value; - } - - set discountAmount(int value) { - _discountAmount = value; - } - - set discountRate(int value) { - _discountRate = value; - } - - set promotionId(int value) { - _promotionId = value; - } - - set promotionType(int value) { - _promotionType = value; - } -} \ No newline at end of file diff --git a/lib/retrofit/min_api.dart b/lib/retrofit/min_api.dart index 59c1a1e8..0bee7037 100644 --- a/lib/retrofit/min_api.dart +++ b/lib/retrofit/min_api.dart @@ -9,8 +9,10 @@ import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:huixiang/generated/l10n.dart'; import 'package:huixiang/retrofit/data/address.dart'; import 'package:huixiang/retrofit/data/base_data.dart'; +import 'package:huixiang/retrofit/data/down_order.dart'; import 'package:huixiang/retrofit/data/placeOrderFirst.dart'; import 'package:huixiang/retrofit/data/settlement_bean.dart'; +import 'package:huixiang/retrofit/data/wx_pay.dart'; import 'package:huixiang/view_widget/login_tips_dialog.dart'; import 'package:retrofit/retrofit.dart'; @@ -45,7 +47,6 @@ abstract class MinApiService { String tenant, String storeId, bool showLoading = true, - bool pay = false, }) { Map headers = (token == null || token == "") ? {} : {'token': "Bearer $token"}; @@ -55,9 +56,7 @@ abstract class MinApiService { if (storeId != null && storeId != "") { headers["store_id"] = storeId; } - if (pay) { - headers["Environment"] = "app"; - } + headers["Environment"] = "app"; dio.options = BaseOptions( connectTimeout: 60000, receiveTimeout: 60000, @@ -173,7 +172,11 @@ abstract class MinApiService { ///小程序下单 @POST("order/placeOrderFirst") - Future placeOrderFirst(@Body() Map param); + Future> placeOrderFirst(@Body() Map param); + + /// 结算 + @POST("order/settlement") + Future> settlementWx(@Body() Map param); /// 结算 @POST("order/settlement") diff --git a/lib/retrofit/min_api.g.dart b/lib/retrofit/min_api.g.dart index 1d33c8eb..f233b182 100644 --- a/lib/retrofit/min_api.g.dart +++ b/lib/retrofit/min_api.g.dart @@ -226,7 +226,7 @@ class _MinApiService implements MinApiService { } @override - Future> placeOrderFirst(param) async { + Future> placeOrderFirst(param) async { ArgumentError.checkNotNull(param, 'param'); const _extra = {}; final queryParameters = {}; @@ -241,9 +241,31 @@ class _MinApiService implements MinApiService { extra: _extra, baseUrl: baseUrl), data: _data); - final value = BaseData.fromJson( + final value = BaseData.fromJson( _result.data, - (json) => json as dynamic, + (json) => DownOrder.fromJson(json), + ); + return value; + } + + @override + Future> settlementWx(param) async { + ArgumentError.checkNotNull(param, 'param'); + const _extra = {}; + final queryParameters = {}; + final _data = {}; + _data.addAll(param ?? {}); + final _result = await _dio.request>('order/settlement', + queryParameters: queryParameters, + options: RequestOptions( + method: 'POST', + headers: {}, + extra: _extra, + baseUrl: baseUrl), + data: _data); + final value = BaseData.fromJson( + _result.data, + (json) => WxPay.fromJson(json), ); return value; } diff --git a/lib/settlement/settlement.dart b/lib/settlement/settlement.dart index fa5be140..efaf677f 100644 --- a/lib/settlement/settlement.dart +++ b/lib/settlement/settlement.dart @@ -4,13 +4,17 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_baidu_mapapi_base/flutter_baidu_mapapi_base.dart'; import 'package:flutter_baidu_mapapi_utils/flutter_baidu_mapapi_utils.dart'; +import 'package:fluwx/fluwx.dart'; import 'package:huixiang/generated/l10n.dart'; import 'package:huixiang/retrofit/data/address.dart'; import 'package:huixiang/retrofit/data/base_data.dart'; +import 'package:huixiang/retrofit/data/down_order.dart'; import 'package:huixiang/retrofit/data/placeOrderFirst.dart'; import 'package:huixiang/retrofit/data/settleOrderInfo.dart'; import 'package:huixiang/retrofit/data/settlement_bean.dart'; +import 'package:huixiang/retrofit/data/shoppingCart.dart'; import 'package:huixiang/retrofit/data/store_info.dart'; +import 'package:huixiang/retrofit/data/wx_pay.dart'; import 'package:huixiang/retrofit/min_api.dart'; import 'package:huixiang/settlement/settlement_view/activity_coupon_remarks.dart'; import 'package:huixiang/settlement/settlement_view/distribution.dart'; @@ -20,6 +24,7 @@ import 'package:huixiang/settlement/settlement_view/settlement_activity.dart'; import 'package:huixiang/settlement/settlement_view/settlement_coupon.dart'; import 'package:huixiang/settlement/settlement_view/settlement_order_commodity.dart'; import 'package:huixiang/utils/font_weight.dart'; +import 'package:huixiang/utils/min.dart'; import 'package:huixiang/view_widget/my_appbar.dart'; import 'package:huixiang/view_widget/round_button.dart'; import 'package:shared_preferences/shared_preferences.dart'; @@ -40,9 +45,14 @@ class _Settlement extends State { MinApiService minService; Function(int type) callback; StoreInfo storeInfo; + ShoppingCart shopCarGoods; SettleOrderInfo settleOrderInfo; int selectedBtn = 0; + String remakers = ""; + int payChannel = 4; + String tableId = "0"; + Address address; CouponListBean couponListBean; PromotionInfoListBean promotion; String mobile; @@ -51,6 +61,7 @@ class _Settlement extends State { void initState() { super.initState(); storeInfo = widget.arguments["storeInfo"]; + shopCarGoods = widget.arguments["shoppingCart"]; SharedPreferences.getInstance().then((value) { String minToken = value.getString("minToken"); @@ -76,7 +87,7 @@ class _Settlement extends State { "memberCouponId": memberCouponId, "orderId": orderId, "promotionId": promotionId - }); + }).catchError((error){}); if (baseData != null && baseData.isSuccess) { setState(() { settleOrderInfo = baseData.data; @@ -84,8 +95,6 @@ class _Settlement extends State { } } - Address address; - queryAddress(int selectedBtn) async { this.selectedBtn = selectedBtn; if (address != null) { @@ -134,53 +143,92 @@ class _Settlement extends State { ///小程序下单 queryPlaceOrderFirst() async { + + for(int i = 0; i < shopCarGoods.shoppingCartSkuItemList.length; i ++) { + settleOrderInfo.orderProductList.forEach((element1) { + if (shopCarGoods.shoppingCartSkuItemList[i].productId == element1.productId) { + shopCarGoods.shoppingCartSkuItemList[i].skuId = element1.skuId; + } + }); + } + PlaceOrderFirst placeOrderFirst = PlaceOrderFirst(); - placeOrderFirst.addressId = null; + placeOrderFirst.cartNum = settleOrderInfo.orderNum; + placeOrderFirst.cartSum = settleOrderInfo.price; + placeOrderFirst.addressId = address == null ? null : address.id; placeOrderFirst.isSubscribe = false; - placeOrderFirst.isTakeOut = 0; - placeOrderFirst.notes = ""; - placeOrderFirst.numberOfPeople = null; - placeOrderFirst.orderSource = 0; - placeOrderFirst.orderType = 0; + placeOrderFirst.isTakeOut = selectedBtn; + placeOrderFirst.notes = remakers; + placeOrderFirst.numberOfPeople = "0"; + placeOrderFirst.orderSource = 2; + placeOrderFirst.orderType = "0"; placeOrderFirst.orderTypeId = 0; - placeOrderFirst.parentCode = ""; - placeOrderFirst.parentId = 0; - placeOrderFirst.payChannel = 1; - placeOrderFirst.promotionInfoDTO = PlaceOrderFirstPromotionInfoDTO(); - // placeOrderFirst.promotionInfoDTO.couponId = selectedCouponIndex == -1 - // ? null - // : settleOrderInfo.couponList[selectedCouponIndex].couponId; - placeOrderFirst.promotionInfoDTO.promotionId = "0"; - placeOrderFirst.recMobile = storeInfo.headMobile; - placeOrderFirst.shoppingCartSkuItemList = []; + placeOrderFirst.parentCode = ""; // 火锅加菜 + placeOrderFirst.parentId = "0"; // 火锅加菜 + placeOrderFirst.payChannel = payChannel; + placeOrderFirst.promotionInfoDTO = PromotionInfoDTOBean(); + placeOrderFirst.promotionInfoDTO.promotionId = promotion != null ? promotion.id : ""; + placeOrderFirst.promotionInfoDTO.couponId = couponListBean != null ? couponListBean.id : ""; + placeOrderFirst.recMobile = (mobile == null || mobile == "") ? mobile : storeInfo.headMobile; + placeOrderFirst.shoppingCartSkuItemList = shopCarGoods.shoppingCartSkuItemList; placeOrderFirst.skuItemDTOList = []; - placeOrderFirst.source = 1; placeOrderFirst.storeId = storeInfo.id; placeOrderFirst.subcribeTime = null; - placeOrderFirst.tableId = 0; - BaseData baseData = await minService.placeOrderFirst(placeOrderFirst.toJson()) + placeOrderFirst.tableId = tableId; + BaseData baseData = await minService.placeOrderFirst(placeOrderFirst.toJson()) .catchError((error) {}); if (baseData != null && baseData.isSuccess) { - querySettlement(); + querySettlement(placeOrderFirst, baseData.data); } } ///结算 - querySettlement() async { - SettlementBean settlementBean = SettlementBean(); - settlementBean.addressId = 0; - settlementBean.buyNum = 0; - settlementBean.id = 0; - settlementBean.isLogistics = true; - settlementBean.orderProductVOList = []; + querySettlement(PlaceOrderFirst placeOrderFirst, DownOrder downOrder) async { + placeOrderFirst.id = downOrder.id; + placeOrderFirst.orderProductVOList = downOrder.orderProductVOList; + if (placeOrderFirst.payChannel == 1) { + if (!(await Min.isInitialize())) { + // 小程序的微信支付和app的充值支付使用同一个WXPayEntryActivity回调, + // 然而充值时小程序未初始化会导致回调内部代码调用getPackage空指针, + // 故而在此初始化一下 + await Min.initialize(); + } + BaseData 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}"); + toOrderDetails(placeOrderFirst.id); + }); + } + } else { + BaseData baseData = await minService.settlementApi(placeOrderFirst.toJson()).catchError((error) {}); + if (baseData != null && baseData.isSuccess) { + toOrderDetails(placeOrderFirst.id); + } + } + } + + toOrderDetails(String orderId) { + //1451130052983914496 + //202110211815390002 + Navigator.of(context).popAndPushNamed('/router/order_details', arguments: { + "id": orderId, + }); - settlementBean.payChannel = 0; - settlementBean.promotionInfoDTO = PromotionInfoDTO(); - settlementBean.promotionInfoDTO.couponId = 0; - settlementBean.promotionInfoDTO.promotionId = 0; - BaseData baseData = await minService.settlementApi({}).catchError((error) {}); - if (baseData != null && baseData.isSuccess) {} } @override @@ -251,7 +299,7 @@ class _Settlement extends State { ), ///支付方式 - PayMethod(), + PayMethod(payChannelCheck), ], ), ), @@ -296,7 +344,9 @@ class _Settlement extends State { padding: EdgeInsets.symmetric( vertical: 5.h, ), - callback: () {}, + callback: () { + queryPlaceOrderFirst(); + }, ), ], ), @@ -314,6 +364,10 @@ class _Settlement extends State { ); } + payChannelCheck(int payChannel) { + this.payChannel = payChannel; + } + mobileChange(String mobile) { this.mobile = mobile; } diff --git a/lib/settlement/settlement_view/pay_method.dart b/lib/settlement/settlement_view/pay_method.dart index d1598eee..5cf2be66 100644 --- a/lib/settlement/settlement_view/pay_method.dart +++ b/lib/settlement/settlement_view/pay_method.dart @@ -6,6 +6,10 @@ import 'package:huixiang/utils/font_weight.dart'; class PayMethod extends StatefulWidget { + final Function(int payChannel) payChannelCheck; + + PayMethod(this.payChannelCheck); + @override State createState() { return _PayMethod(); @@ -61,6 +65,7 @@ class _PayMethod extends State { setState(() { checkIndex = 1; }); + widget.payChannelCheck(4); }, child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, @@ -85,6 +90,7 @@ class _PayMethod extends State { setState(() { checkIndex = 2; }); + widget.payChannelCheck(3); }, child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, @@ -109,6 +115,7 @@ class _PayMethod extends State { onTap: () { setState(() { checkIndex = 3; + widget.payChannelCheck(1); }); }, child: Row( diff --git a/lib/store/store_order.dart b/lib/store/store_order.dart index bc340880..c058f887 100644 --- a/lib/store/store_order.dart +++ b/lib/store/store_order.dart @@ -68,17 +68,6 @@ class _StoreOrderPage extends State queryStoreInfo(); } - _fc(int count, String productId, int allCount, double allPrice) { - // if (count == 0) { - // int index = shopCarGoods.indexWhere((element) => element.id == productId); - // shopCarGoods.removeAt(index); - // } - // setState(() { - // this.allCount = allCount; - // this.allPrice = allPrice; - // }); - } - /// 小程序登录 minLogin() async { final SharedPreferences value = await SharedPreferences.getInstance(); @@ -316,7 +305,6 @@ class _StoreOrderPage extends State shopCarGoods, controller, _queryMiNiDetail, - _fc, ), ///星店活动, @@ -449,7 +437,7 @@ class _StoreOrderPage extends State } ///去下单结算页面 - toDownOrder() { + toDownOrder() async { int num = count(); if (num == 0) { @@ -457,12 +445,17 @@ class _StoreOrderPage extends State return; } - Navigator.of(context).pushNamed( + await Navigator.of(context).pushNamed( '/router/settlement', arguments: { "storeInfo": storeInfo, + "shoppingCart": shopCarGoods, }, ); + queryShopCar().then((value) { + this.shopCarGoods = value; + setState(() {}); + }); } Widget buildSwiper() { diff --git a/lib/store/store_view/store_order_list.dart b/lib/store/store_view/store_order_list.dart index aacfef32..83817f88 100644 --- a/lib/store/store_view/store_order_list.dart +++ b/lib/store/store_view/store_order_list.dart @@ -19,9 +19,7 @@ class StoreOrderListPage extends StatefulWidget { final List activitys; final StoreInfo storeInfo; final ScrollController controller; - final Function(int count, String productId, int allCount, double allPrice) fc; final Function(String id) queryMiNiDetail; - // final Function(List appletProducts) productListResult; ShoppingCart shopCarGoods; StoreOrderListPage( @@ -30,9 +28,7 @@ class StoreOrderListPage extends StatefulWidget { this.storeInfo, this.shopCarGoods, this.controller, - this.queryMiNiDetail, - // this.productListResult, - this.fc); + this.queryMiNiDetail,); @override State createState() { From b5839dd08a9aae62c969957cc85c65355b7afa84 Mon Sep 17 00:00:00 2001 From: fmk Date: Fri, 22 Oct 2021 19:04:15 +0800 Subject: [PATCH 06/20] safety --- lib/mine/mine_page.dart | 26 +- lib/order/order_detail_page.dart | 62 +- lib/order/order_history_page.dart | 83 +- lib/order/order_utils.dart | 84 + lib/order/order_view/order_address.dart | 2 +- lib/order/order_view/order_pay_selected.dart | 147 ++ lib/qr/qr_code_scan.dart | 125 +- lib/retrofit/data/order_info.dart | 1431 +++++++----------- lib/retrofit/data/order_product_vo.dart | 855 ++++------- lib/retrofit/data/store_info.dart | 49 + lib/retrofit/min_api.dart | 8 + lib/retrofit/min_api.g.dart | 44 + lib/retrofit/retrofit_api.dart | 8 +- lib/retrofit/retrofit_api.g.dart | 2 +- lib/settlement/settlement.dart | 73 +- lib/store/store_order.dart | 453 +++--- lib/store/store_view/people_num.dart | 139 ++ lib/store/store_view/store_activity.dart | 21 +- lib/store/store_view/store_order_list.dart | 108 +- lib/union/union_page.dart | 80 +- lib/view_widget/no_data_view.dart | 23 +- pubspec.lock | 6 +- pubspec.yaml | 4 +- 23 files changed, 1888 insertions(+), 1945 deletions(-) create mode 100644 lib/order/order_utils.dart create mode 100644 lib/order/order_view/order_pay_selected.dart create mode 100644 lib/store/store_view/people_num.dart diff --git a/lib/mine/mine_page.dart b/lib/mine/mine_page.dart index 6fb622f8..58c79909 100644 --- a/lib/mine/mine_page.dart +++ b/lib/mine/mine_page.dart @@ -51,8 +51,7 @@ class _MinePage extends State with AutomaticKeepAliveClientMixin { @override void dispose() { super.dispose(); - if (_refreshController != null) - _refreshController.dispose(); + if (_refreshController != null) _refreshController.dispose(); } @override @@ -62,12 +61,10 @@ class _MinePage extends State with AutomaticKeepAliveClientMixin { eventBus.on().listen((event) { print("EventType: ${event.type}"); if (event.type < 3) { - if (mounted) - setState(() {}); + if (mounted) setState(() {}); } if (event.type == 3) { - if (mounted) - setState(() {}); + if (mounted) setState(() {}); } }); } @@ -81,8 +78,12 @@ class _MinePage extends State with AutomaticKeepAliveClientMixin { value.getString('user') != "") { userInfo = UserInfo.fromJson(jsonDecode(value.getString('user'))); } - apiService = ApiService(Dio(), - context: context, token: value.getString('token'), showLoading: false); + apiService = ApiService( + Dio(), + context: context, + token: value.getString('token'), + showLoading: false, + ); BaseData> rankData = await apiService.rankList().catchError((onError) { @@ -208,7 +209,6 @@ class _MinePage extends State with AutomaticKeepAliveClientMixin { ); } - ///横向的提示 Widget buildNotice() { return Container( @@ -283,11 +283,11 @@ class _MinePage extends State with AutomaticKeepAliveClientMixin { } ///关注度/粉丝/发布 - Widget attention(){ + Widget attention() { return Container( - margin: EdgeInsets.only(left: 16,right: 17,top: 10), - child:GestureDetector( - onTap:(){ + margin: EdgeInsets.only(left: 16, right: 17, top: 10), + child: GestureDetector( + onTap: () { Navigator.of(context).pushNamed( '/router/communityFollow', arguments: {}, diff --git a/lib/order/order_detail_page.dart b/lib/order/order_detail_page.dart index 9a2acd07..403d40f6 100644 --- a/lib/order/order_detail_page.dart +++ b/lib/order/order_detail_page.dart @@ -1,21 +1,28 @@ import 'package:dio/dio.dart'; import 'package:flutter/material.dart'; import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; +import 'package:fluwx/fluwx.dart'; import 'package:huixiang/generated/l10n.dart'; import 'package:huixiang/order/order_view/order_address.dart'; import 'package:huixiang/order/order_view/order_commodity.dart'; import 'package:huixiang/order/order_view/order_info.dart'; +import 'package:huixiang/order/order_view/order_pay_selected.dart'; import 'package:huixiang/order/order_view/order_status.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/retrofit/retrofit_api.dart'; +import 'package:huixiang/settlement/settlement_view/pay_method.dart'; +import 'package:huixiang/utils/min.dart'; import 'package:huixiang/view_widget/icon_text.dart'; import 'package:huixiang/view_widget/my_appbar.dart'; import 'package:shared_preferences/shared_preferences.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'order_utils.dart'; + class OrderDetailPage extends StatefulWidget { final arguments; @@ -41,22 +48,20 @@ class _OrderDetailPage extends State { context: context, token: value.getString("token"), ); - minLogin(); queryDetails(); }); } /// 小程序登录 minLogin() async { - apiService - .minLogin(widget.arguments["id"]) - .catchError((onError) {}) + apiService.minLogin(orderInfo.storeId) + .catchError((onError) {debugPrint(onError);}) .then((baseData) { if (baseData != null && baseData.isSuccess) { Map minStoreInfo = baseData.data; String minToken = minStoreInfo["token"]; - String tenant = widget.arguments["tenant"]; - String storeId = widget.arguments["id"]; + String tenant = orderInfo.tenantCode; + String storeId = orderInfo.storeId; SharedPreferences.getInstance().then( (value) => { value.setString('minToken', minToken), @@ -82,8 +87,6 @@ class _OrderDetailPage extends State { int isTakeOut = 0; int refundStatus = 0; - // String storeType = "NORMALSTORE"; //NORMALSTORE FASTSTORE RETAILSTORE - queryDetails() async { BaseData baseData = await apiService .orderDetail(widget.arguments["id"]) @@ -101,6 +104,8 @@ class _OrderDetailPage extends State { print("order orderStatus: $orderStatus"); print("order sendStatus: $sendStatus"); print("order isTakeOut: $isTakeOut"); + + minLogin(); if (mounted) setState(() { statusTitle(); @@ -162,7 +167,7 @@ class _OrderDetailPage extends State { refundStatus, title, center, - carryOnPay, + paySelected, _orderCancel, orderInfo, ), @@ -194,34 +199,17 @@ class _OrderDetailPage extends State { String title = ""; String center = ""; - carryOnPay() { - 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 = orderInfo.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; - - - + paySelected() async { + var payChannel = await showModalBottomSheet( + context: context, + backgroundColor: Colors.transparent, + builder: (context) { + return OrderPaySelected(); + }, + ); + if (payChannel != null && payChannel > 0) { + OrderUtils.carryOnPay(payChannel, minService, orderInfo, queryDetails); + } } statusTitle() { diff --git a/lib/order/order_history_page.dart b/lib/order/order_history_page.dart index a57f32aa..3c221b8a 100644 --- a/lib/order/order_history_page.dart +++ b/lib/order/order_history_page.dart @@ -2,11 +2,14 @@ import 'package:dio/dio.dart'; import 'package:flutter/material.dart'; import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:huixiang/generated/l10n.dart'; +import 'package:huixiang/order/order_utils.dart'; +import 'package:huixiang/order/order_view/order_pay_selected.dart'; import 'package:huixiang/retrofit/data/base_data.dart'; import 'package:huixiang/retrofit/data/order_info.dart'; import 'package:huixiang/retrofit/data/order_product_vo.dart'; import 'package:huixiang/retrofit/data/page.dart'; import 'package:huixiang/retrofit/data/product.dart'; +import 'package:huixiang/retrofit/min_api.dart'; import 'package:huixiang/retrofit/retrofit_api.dart'; import 'package:huixiang/utils/status_utils.dart'; import 'package:huixiang/view_widget/classic_header.dart'; @@ -21,7 +24,6 @@ import 'package:shared_preferences/shared_preferences.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; class OrderHistoryPage extends StatefulWidget { - final Map arguments; OrderHistoryPage({this.arguments}); @@ -41,7 +43,8 @@ class _OrderHistoryPage extends State void didChangeDependencies() { super.didChangeDependencies(); if (tabController == null) - tabController = TabController(initialIndex: widget.arguments["status"], length: 4, vsync: this); + tabController = TabController( + initialIndex: widget.arguments["status"], length: 4, vsync: this); _pages = [ OrderHistoryList(0), @@ -226,7 +229,7 @@ class _OrderHistoryList extends State offset: Offset(0, 1), blurRadius: 12, spreadRadius: 0, - ) + ), ], ), child: Column( @@ -455,26 +458,7 @@ class _OrderHistoryList extends State } else if (type == 2) { orderCancel(orderInfo.id); } else if (type == 3) { - SmartDialog.show( - widget: Tips( - () { - SmartDialog.dismiss(); - }, - text: "暂不支持此功能", - )); - orderInfo.tenantCode; - orderInfo.id; - ///去支付 - // Map param = { - // "id": orderInfo.id, - // "orderProductVOList": orderInfo - // .orderDetail.orderProductList - // .map((e) => e.toJson()) - // .toList(), - // "payChannel": 1, - // "orderType": 0 - // }; - // toPay(param); + minLogin(orderInfo); } else if (type == 4) { Navigator.of(context).pushNamed( '/router/logistics_information_page', @@ -500,12 +484,53 @@ class _OrderHistoryList extends State ); } - toPay(Map param) async { - apiService.settlement(param).catchError((error) { - + minLogin(OrderInfo orderInfo) { + apiService.minLogin(orderInfo.storeId).catchError((onError) { + debugPrint(onError); + }).then((baseData) { + if (baseData != null && baseData.isSuccess) { + Map minStoreInfo = baseData.data; + String minToken = minStoreInfo["token"]; + String tenant = orderInfo.tenantCode; + String storeId = orderInfo.storeId; + SharedPreferences.getInstance().then( + (value) => { + value.setString('minToken', minToken), + value.setString('tenant', tenant), + value.setString('storeId', storeId), + }, + ); + paySelected( + orderInfo, + MinApiService( + Dio(), + context: context, + token: minToken, + tenant: tenant, + storeId: storeId, + )); + } }); } + paySelected(OrderInfo orderInfo, MinApiService minService) async { + var payChannel = await showModalBottomSheet( + context: context, + backgroundColor: Colors.transparent, + builder: (context) { + return OrderPaySelected(); + }, + ); + if (payChannel != null && payChannel > 0) { + OrderUtils.carryOnPay(payChannel, minService, orderInfo, () { + SmartDialog.showToast("订单支付成功"); + Future.delayed(Duration(seconds: 1), () { + _onRefresh(); + }); + }); + } + } + orderCancel(String orderId) async { BaseData baseData = await apiService.orderCancel(orderId); if (baseData != null && baseData.isSuccess) { @@ -515,8 +540,10 @@ class _OrderHistoryList extends State } aginOrder(storeId) { - Navigator.of(context) - .pushNamed('/router/union_detail_page', arguments: {"id": storeId}); + Navigator.of(context).pushNamed( + '/router/union_detail_page', + arguments: {"id": storeId}, + ); } String totalPrice(orderInfo) { diff --git a/lib/order/order_utils.dart b/lib/order/order_utils.dart new file mode 100644 index 00000000..1b9a73e4 --- /dev/null +++ b/lib/order/order_utils.dart @@ -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 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(); + } + } + } + + + +} \ No newline at end of file diff --git a/lib/order/order_view/order_address.dart b/lib/order/order_view/order_address.dart index ac601059..f1928911 100644 --- a/lib/order/order_view/order_address.dart +++ b/lib/order/order_view/order_address.dart @@ -19,7 +19,7 @@ class OrderAddress extends StatefulWidget { final String title; final String center; final Function orderCancel; - final Function carryOnPay; + final Function() carryOnPay; final OrderInfo orderInfo; OrderAddress( diff --git a/lib/order/order_view/order_pay_selected.dart b/lib/order/order_view/order_pay_selected.dart new file mode 100644 index 00000000..adaa02e5 --- /dev/null +++ b/lib/order/order_view/order_pay_selected.dart @@ -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 createState() { + return _OrderPaySelected(); + } + +} + +class _OrderPaySelected extends State { + @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, + ), + ); + } + + +} \ No newline at end of file diff --git a/lib/qr/qr_code_scan.dart b/lib/qr/qr_code_scan.dart index 529d84e0..8561242d 100644 --- a/lib/qr/qr_code_scan.dart +++ b/lib/qr/qr_code_scan.dart @@ -1,10 +1,10 @@ +import 'dart:ui'; + import 'package:flutter/material.dart'; -import 'package:flutter_qr_reader/flutter_qr_reader.dart'; -import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; +import 'package:flutter_scankit/scan_kit_widget.dart'; import 'package:huixiang/generated/l10n.dart'; import 'package:huixiang/view_widget/my_appbar.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; -import 'package:huixiang/view_widget/tips_dialog.dart'; import 'package:image_pickers/image_pickers.dart'; import 'package:permission_handler/permission_handler.dart'; @@ -16,18 +16,14 @@ class QrCodeScanPage extends StatefulWidget { } class _QrCodeScanPage extends State { - GlobalKey<_QrCodeScanPage> qrViewKey = GlobalKey(); - QrReaderViewController viewController; + ScanKitController _controller; + final screenWidth = window.physicalSize.width; + final screenHeight = window.physicalSize.height; @override void initState() { super.initState(); - - readerHeight = 812; - Future.delayed(Duration(seconds: 1), () { - buildReaderView(); - }); } @override @@ -37,20 +33,24 @@ class _QrCodeScanPage extends State { child: Stack( children: [ Positioned( - child: qrReaderView != null - ? Column( - children: [ - Expanded( - child: qrReaderView, - flex: readerHeight.toInt(), - ), - // Expanded(child: qrReaderView, flex: readerHeight,), - ], - ) - : Container( - width: MediaQuery.of(context).size.width, - height: MediaQuery.of(context).size.height, + child: Column( + children: [ + Expanded( + child: ScanKitWidget( + callback: (controller) { + _controller = controller; + controller.onResult.listen((result) { + debugPrint("scanning result:$result"); + Navigator.of(context).pop(result); + }); + }, + continuouslyScan: false, + boundingBox: Rect.fromLTRB(0, 0, screenWidth, screenHeight), ), + flex: 1, + ), + ], + ), top: 0, bottom: 0, left: 0, @@ -68,12 +68,12 @@ class _QrCodeScanPage extends State { margin: EdgeInsets.only(right: 16.w), child: GestureDetector( onTap: () { - openStorage(); + _controller.pickPhoto(); }, child: Text( S.of(context).xiangce, style: TextStyle( - color: Colors.white, + color: Colors.black, fontSize: 18.sp, fontWeight: FontWeight.bold, ), @@ -91,80 +91,11 @@ class _QrCodeScanPage extends State { ); } - QrReaderView qrReaderView; - double readerHeight; - - buildReaderView() async { - double screenWidth = MediaQuery.of(context).size.width; - - readerHeight = 1920.0 / 1080.0 * screenWidth; - print("object: $readerHeight"); - qrReaderView = await QrReaderView( - key: qrViewKey, - callback: onScan, - width: MediaQuery.of(context).size.width, - height: readerHeight, - ); - setState(() {}); - } - - ///打开相册 - openStorage() async { - if (await Permission.storage.isGranted) { - List medias = await ImagePickers.pickerPaths( - galleryMode: GalleryMode.image, - selectCount: 1, - showGif: true, - showCamera: false, - compressSize: 500, - uiConfig: UIConfig( - uiThemeColor: Color(0xFFFFFFFF), - ), - cropConfig: CropConfig( - enableCrop: true, - width: 200, - height: 200, - ), - ); - if (medias == null || medias.length == 0) return; - String filePath = medias[0].path; - final String data = await FlutterQrReader.imgScan(filePath); - showData(data); - } else { - await Permission.storage.request(); - openStorage(); - } - } - - void _startCameraResult(String data, List offset) { - showData(data); - this.viewController.stopCamera(); - } - - Future onScan(QrReaderViewController viewController) async { - this.viewController = viewController; - await this.viewController.startCamera(_startCameraResult); - } - - showData(String data) { - SmartDialog.show( - widget: Tips( - () {}, - text: "$data", - ), - onDismiss: () { - Future.delayed(Duration(seconds: 1), () { - this.viewController.startCamera(_startCameraResult); - }); - }, - ); - } - @override void dispose() { - if (this.viewController != null) { - this.viewController.stopCamera(); - } + // if (this._controller != null) { + // this._controller.dispose(); + // } super.dispose(); } } diff --git a/lib/retrofit/data/order_info.dart b/lib/retrofit/data/order_info.dart index 12628ffe..6b7eff3c 100644 --- a/lib/retrofit/data/order_info.dart +++ b/lib/retrofit/data/order_info.dart @@ -64,185 +64,66 @@ import 'package:huixiang/retrofit/data/shoppingCart.dart'; /// productList : [{"id":"1408358257390518272","createTime":"2021-06-25 17:35:49","createUser":"1404743858104827904","updateTime":"2021-06-25 17:35:49","updateUser":"1404743858104827904","tenantCode":null,"storeId":"1344490596986781696","orderId":"1408358257373741056","productId":"1404742074535772160","productName":"商品1","skuId":"1404744485652398080","skuNameStr":"中","skuImg":"","buyNum":2,"refundNum":0,"weight":0,"applyPrice":"0.00","sellPrice":"10.00","postPay":"0.00","isDelete":0,"discountAmount":"2.20","discountPercent":11,"status":true,"batch":1}] class OrderInfo { - String _id; - String _createTime; - String _createUser; - String _updateTime; - String _updateUser; - String _tenantCode; - String _storeId; - String _storeName; - String _tableId; - String _mid; - String _parentId; - String _parentCode; - String _orderCode; - String _orderType; - String _dayFlowCode; - int _orderStatus; - int _sendStatus; - int _payStatus; - String _memberAccount; - String _logisticsId; - String _shipperCode; - String _logisticsName; - String _logisticsNum; - dynamic _logisticsCase; - int _refundStatus; - AddressExt _addressExt; - String _postFee; - String _orderSum; - String _paySum; - String _paySumSub; - String _accountPay; - String _couponSubPrice; - String _customPrice; - String _removeDecimal; - bool _isSubscribe; - dynamic _subcribeTime; - dynamic _sendTime; - dynamic _confirmTime; - dynamic _returnMoneyTime; - String _notes; - dynamic _prepayId; - String _payTime; - int _payChannel; - String _payNum; - String _promotionId; - String _couponId; - int _isDelete; - int _isTakeOut; - int _batch; - String _orderDiscountPrice; - String _dishesDiscountPrice; - String _orderPercentPrice; - String _finalPayPrice; - String _activityNoPrice; - String _activityDiscountPrice; - String _totalDiscountPrice; - int _orderSource; - StoreVO _storeVO; - OrderDetail _orderDetail; - List _productList; - - String get id => _id; - - String get createTime => _createTime; - - String get createUser => _createUser; - - String get updateTime => _updateTime; - - String get updateUser => _updateUser; - - String get tenantCode => _tenantCode; - - String get storeId => _storeId; - - String get storeName => _storeName; - - String get tableId => _tableId; - - String get mid => _mid; - - String get parentId => _parentId; - - String get parentCode => _parentCode; - - String get orderCode => _orderCode; - String get orderType => _orderType; - - String get dayFlowCode => _dayFlowCode; - - int get orderStatus => _orderStatus; - - int get sendStatus => _sendStatus; - - int get payStatus => _payStatus; - - String get memberAccount => _memberAccount; - - String get logisticsId => _logisticsId; - - String get shipperCode => _shipperCode; - - String get logisticsName => _logisticsName; - - String get logisticsNum => _logisticsNum; - - dynamic get logisticsCase => _logisticsCase; - - int get refundStatus => _refundStatus; - - AddressExt get addressExt => _addressExt; - - String get postFee => _postFee; - - String get orderSum => _orderSum; - - String get paySum => _paySum; - - String get paySumSub => _paySumSub; - - String get accountPay => _accountPay; - - String get couponSubPrice => _couponSubPrice; - - String get customPrice => _customPrice; - - String get removeDecimal => _removeDecimal; - - bool get isSubscribe => _isSubscribe; - - dynamic get subcribeTime => _subcribeTime; - - dynamic get sendTime => _sendTime; - - dynamic get confirmTime => _confirmTime; - - dynamic get returnMoneyTime => _returnMoneyTime; - - String get notes => _notes; - - dynamic get prepayId => _prepayId; - - String get payTime => _payTime; - - int get payChannel => _payChannel; - - String get payNum => _payNum; - - String get promotionId => _promotionId; - - String get couponId => _couponId; - - int get isDelete => _isDelete; - - int get isTakeOut => _isTakeOut; - - int get batch => _batch; - - String get orderDiscountPrice => _orderDiscountPrice; - - String get dishesDiscountPrice => _dishesDiscountPrice; - - String get orderPercentPrice => _orderPercentPrice; - - String get finalPayPrice => _finalPayPrice; - - String get activityNoPrice => _activityNoPrice; - - String get activityDiscountPrice => _activityDiscountPrice; - - String get totalDiscountPrice => _totalDiscountPrice; - - int get orderSource => _orderSource; - - StoreVO get storeVO => _storeVO; - - OrderDetail get orderDetail => _orderDetail; - - List get productList => _productList; + String id; + String createTime; + String createUser; + String updateTime; + String updateUser; + String tenantCode; + String storeId; + String storeName; + String tableId; + String mid; + String parentId; + String parentCode; + String orderCode; + int orderType; + String dayFlowCode; + int orderStatus; + int sendStatus; + int payStatus; + String memberAccount; + String logisticsId; + String shipperCode; + String logisticsName; + String logisticsNum; + dynamic logisticsCase; + int refundStatus; + AddressExt addressExt; + String postFee; + String orderSum; + String paySum; + String paySumSub; + String accountPay; + String couponSubPrice; + String customPrice; + String removeDecimal; + bool isSubscribe; + dynamic subcribeTime; + dynamic sendTime; + dynamic confirmTime; + dynamic returnMoneyTime; + String notes; + dynamic prepayId; + String payTime; + int payChannel; + String payNum; + String promotionId; + String couponId; + int isDelete; + int isTakeOut; + int batch; + String orderDiscountPrice; + String dishesDiscountPrice; + String orderPercentPrice; + String finalPayPrice; + String activityNoPrice; + String activityDiscountPrice; + String totalDiscountPrice; + int orderSource; + StoreVO storeVO; + OrderDetail orderDetail; + List productList; OrderInfo( {String id, @@ -258,6 +139,7 @@ class OrderInfo { String parentId, String parentCode, String orderCode, + int orderType, String dayFlowCode, int orderStatus, int sendStatus, @@ -304,345 +186,242 @@ class OrderInfo { StoreVO storeVO, OrderDetail orderDetail, List< OrderProductVOList> productList}) { - _id = id; - _createTime = createTime; - _createUser = createUser; - _updateTime = updateTime; - _updateUser = updateUser; - _tenantCode = tenantCode; - _storeId = storeId; - _storeName = storeName; - _tableId = tableId; - _mid = mid; - _parentId = parentId; - _parentCode = parentCode; - _orderCode = orderCode; - _orderType = orderType; - _dayFlowCode = dayFlowCode; - _orderStatus = orderStatus; - _sendStatus = sendStatus; - _payStatus = payStatus; - _memberAccount = memberAccount; - _logisticsId = logisticsId; - _shipperCode = shipperCode; - _logisticsName = logisticsName; - _logisticsNum = logisticsNum; - _logisticsCase = logisticsCase; - _refundStatus = refundStatus; - _addressExt = addressExt; - _postFee = postFee; - _orderSum = orderSum; - _paySum = paySum; - _paySumSub = paySumSub; - _accountPay = accountPay; - _couponSubPrice = couponSubPrice; - _customPrice = customPrice; - _removeDecimal = removeDecimal; - _isSubscribe = isSubscribe; - _subcribeTime = subcribeTime; - _sendTime = sendTime; - _confirmTime = confirmTime; - _returnMoneyTime = returnMoneyTime; - _notes = notes; - _prepayId = prepayId; - _payTime = payTime; - _payChannel = payChannel; - _payNum = payNum; - _promotionId = promotionId; - _couponId = couponId; - _isDelete = isDelete; - _isTakeOut = isTakeOut; - _batch = batch; - _orderDiscountPrice = orderDiscountPrice; - _dishesDiscountPrice = dishesDiscountPrice; - _orderPercentPrice = orderPercentPrice; - _finalPayPrice = finalPayPrice; - _activityNoPrice = activityNoPrice; - _activityDiscountPrice = activityDiscountPrice; - _totalDiscountPrice = totalDiscountPrice; - _orderSource = orderSource; - _storeVO = storeVO; - _orderDetail = orderDetail; - _productList = productList; + this.id = id; + this.createTime = createTime; + this.createUser = createUser; + this.updateTime = updateTime; + this.updateUser = updateUser; + this.tenantCode = tenantCode; + this.storeId = storeId; + this.storeName = storeName; + this.tableId = tableId; + this.mid = mid; + this.parentId = parentId; + this.parentCode = parentCode; + this.orderCode = orderCode; + this.orderType = orderType; + this.dayFlowCode = dayFlowCode; + this.orderStatus = orderStatus; + this.sendStatus = sendStatus; + this.payStatus = payStatus; + this.memberAccount = memberAccount; + this.logisticsId = logisticsId; + this.shipperCode = shipperCode; + this.logisticsName = logisticsName; + this.logisticsNum = logisticsNum; + this.logisticsCase = logisticsCase; + this.refundStatus = refundStatus; + this.addressExt = addressExt; + this.postFee = postFee; + this.orderSum = orderSum; + this.paySum = paySum; + this.paySumSub = paySumSub; + this.accountPay = accountPay; + this.couponSubPrice = couponSubPrice; + this.customPrice = customPrice; + this.removeDecimal = removeDecimal; + this.isSubscribe = isSubscribe; + this.subcribeTime = subcribeTime; + this.sendTime = sendTime; + this.confirmTime = confirmTime; + this.returnMoneyTime = returnMoneyTime; + this.notes = notes; + this.prepayId = prepayId; + this.payTime = payTime; + this.payChannel = payChannel; + this.payNum = payNum; + this.promotionId = promotionId; + this.couponId = couponId; + this.isDelete = isDelete; + this.isTakeOut = isTakeOut; + this.batch = batch; + this.orderDiscountPrice = orderDiscountPrice; + this.dishesDiscountPrice = dishesDiscountPrice; + this.orderPercentPrice = orderPercentPrice; + this.finalPayPrice = finalPayPrice; + this.activityNoPrice = activityNoPrice; + this.activityDiscountPrice = activityDiscountPrice; + this.totalDiscountPrice = totalDiscountPrice; + this.orderSource = orderSource; + this.storeVO = storeVO; + this.orderDetail = orderDetail; + this.productList = productList; } OrderInfo.fromJson(dynamic json) { - _id = json["id"]; - _createTime = json["createTime"]; - _createUser = json["createUser"]; - _updateTime = json["updateTime"]; - _updateUser = json["updateUser"]; - _tenantCode = json["tenantCode"]; - _storeId = json["storeId"]; - _storeName = json["storeName"]; - _tableId = json["tableId"]; - _mid = json["mid"]; - _parentId = json["parentId"]; - _parentCode = json["parentCode"]; - _orderCode = json["orderCode"]; - _orderType = json["orderType"]; - _dayFlowCode = json["dayFlowCode"]; - _orderStatus = json["orderStatus"]; - _sendStatus = json["sendStatus"]; - _payStatus = json["payStatus"]; - _memberAccount = json["memberAccount"]; - _logisticsId = json["logisticsId"]; - _shipperCode = json["shipperCode"]; - _logisticsName = json["logisticsName"]; - _logisticsNum = json["logisticsNum"]; - _logisticsCase = json["logisticsCase"]; - _refundStatus = json["refundStatus"]; - _addressExt = json["addressExt"] != null + this.id = json["id"]; + this.createTime = json["createTime"]; + this.createUser = json["createUser"]; + this.updateTime = json["updateTime"]; + this.updateUser = json["updateUser"]; + this.tenantCode = json["tenantCode"]; + this.storeId = json["storeId"]; + this.storeName = json["storeName"]; + this.tableId = json["tableId"]; + this.mid = json["mid"]; + this.parentId = json["parentId"]; + this.parentCode = json["parentCode"]; + this.orderCode = json["orderCode"]; + this.orderType = json["orderType"]; + this.dayFlowCode = json["dayFlowCode"]; + this.orderStatus = json["orderStatus"]; + this.sendStatus = json["sendStatus"]; + this.payStatus = json["payStatus"]; + this.memberAccount = json["memberAccount"]; + this.logisticsId = json["logisticsId"]; + this.shipperCode = json["shipperCode"]; + this.logisticsName = json["logisticsName"]; + this.logisticsNum = json["logisticsNum"]; + this.logisticsCase = json["logisticsCase"]; + this.refundStatus = json["refundStatus"]; + this.addressExt = json["addressExt"] != null ? AddressExt.fromJson(json["addressExt"]) : null; - _postFee = json["postFee"]; - _orderSum = json["orderSum"]; - _paySum = json["paySum"]; - _paySumSub = json["paySumSub"]; - _accountPay = json["accountPay"]; - _couponSubPrice = json["couponSubPrice"]; - _customPrice = json["customPrice"]; - _removeDecimal = json["removeDecimal"]; - _isSubscribe = json["isSubscribe"]; - _subcribeTime = json["subcribeTime"]; - _sendTime = json["sendTime"]; - _confirmTime = json["confirmTime"]; - _returnMoneyTime = json["returnMoneyTime"]; - _notes = json["notes"]; - _prepayId = json["prepayId"]; - _payTime = json["payTime"]; - _payChannel = json["payChannel"]; - _payNum = json["payNum"]; - _promotionId = json["promotionId"]; - _couponId = json["couponId"]; - _isDelete = json["isDelete"]; - _isTakeOut = json["isTakeOut"]; - _batch = json["batch"]; - _orderDiscountPrice = json["orderDiscountPrice"]; - _dishesDiscountPrice = json["dishesDiscountPrice"]; - _orderPercentPrice = json["orderPercentPrice"]; - _finalPayPrice = json["finalPayPrice"]; - _activityNoPrice = json["activityNoPrice"]; - _activityDiscountPrice = json["activityDiscountPrice"]; - _totalDiscountPrice = json["totalDiscountPrice"]; - _orderSource = json["orderSource"]; - _storeVO = + this.postFee = json["postFee"]; + this.orderSum = json["orderSum"]; + this.paySum = json["paySum"]; + this.paySumSub = json["paySumSub"]; + this.accountPay = json["accountPay"]; + this.couponSubPrice = json["couponSubPrice"]; + this.customPrice = json["customPrice"]; + this.removeDecimal = json["removeDecimal"]; + this.isSubscribe = json["isSubscribe"]; + this.subcribeTime = json["subcribeTime"]; + this.sendTime = json["sendTime"]; + this.confirmTime = json["confirmTime"]; + this.returnMoneyTime = json["returnMoneyTime"]; + this.notes = json["notes"]; + this.prepayId = json["prepayId"]; + this.payTime = json["payTime"]; + this.payChannel = json["payChannel"]; + this.payNum = json["payNum"]; + this.promotionId = json["promotionId"]; + this.couponId = json["couponId"]; + this.isDelete = json["isDelete"]; + this.isTakeOut = json["isTakeOut"]; + this.batch = json["batch"]; + this.orderDiscountPrice = json["orderDiscountPrice"]; + this.dishesDiscountPrice = json["dishesDiscountPrice"]; + this.orderPercentPrice = json["orderPercentPrice"]; + this.finalPayPrice = json["finalPayPrice"]; + this.activityNoPrice = json["activityNoPrice"]; + this.activityDiscountPrice = json["activityDiscountPrice"]; + this.totalDiscountPrice = json["totalDiscountPrice"]; + this.orderSource = json["orderSource"]; + this.storeVO = json["storeVO"] != null ? StoreVO.fromJson(json["storeVO"]) : null; - _orderDetail = json["orderDetail"] != null + this.orderDetail = json["orderDetail"] != null ? OrderDetail.fromJson(json["orderDetail"]) : null; if (json["productList"] != null) { - _productList = []; + this.productList = []; json["productList"].forEach((v) { - _productList.add( OrderProductVOList.fromJson(v)); + this.productList.add( OrderProductVOList.fromJson(v)); }); } } Map toJson() { var map = {}; - map["id"] = _id; - map["createTime"] = _createTime; - map["createUser"] = _createUser; - map["updateTime"] = _updateTime; - map["updateUser"] = _updateUser; - map["tenantCode"] = _tenantCode; - map["storeId"] = _storeId; - map["storeName"] = _storeName; - map["tableId"] = _tableId; - map["mid"] = _mid; - map["parentId"] = _parentId; - map["parentCode"] = _parentCode; - map["orderCode"] = _orderCode; - map["orderType"] = _orderType; - map["dayFlowCode"] = _dayFlowCode; - map["orderStatus"] = _orderStatus; - map["sendStatus"] = _sendStatus; - map["payStatus"] = _payStatus; - map["memberAccount"] = _memberAccount; - map["logisticsId"] = _logisticsId; - map["shipperCode"] = _shipperCode; - map["logisticsName"] = _logisticsName; - map["logisticsNum"] = _logisticsNum; - map["logisticsCase"] = _logisticsCase; - map["refundStatus"] = _refundStatus; - if (_addressExt != null) { - map["addressExt"] = _addressExt.toJson(); + map["id"] = this.id; + map["createTime"] = this.createTime; + map["createUser"] = this.createUser; + map["updateTime"] = this.updateTime; + map["updateUser"] = this.updateUser; + map["tenantCode"] = this.tenantCode; + map["storeId"] = this.storeId; + map["storeName"] = this.storeName; + map["tableId"] = this.tableId; + map["mid"] = this.mid; + map["parentId"] = this.parentId; + map["parentCode"] = this.parentCode; + map["orderCode"] = this.orderCode; + map["orderType"] = this.orderType; + map["dayFlowCode"] = this.dayFlowCode; + map["orderStatus"] = this.orderStatus; + map["sendStatus"] = this.sendStatus; + map["payStatus"] = this.payStatus; + map["memberAccount"] = this.memberAccount; + map["logisticsId"] = this.logisticsId; + map["shipperCode"] = this.shipperCode; + map["logisticsName"] = this.logisticsName; + map["logisticsNum"] = this.logisticsNum; + map["logisticsCase"] = this.logisticsCase; + map["refundStatus"] = this.refundStatus; + if (this.addressExt != null) { + map["addressExt"] = this.addressExt.toJson(); } - map["postFee"] = _postFee; - map["orderSum"] = _orderSum; - map["paySum"] = _paySum; - map["paySumSub"] = _paySumSub; - map["accountPay"] = _accountPay; - map["couponSubPrice"] = _couponSubPrice; - map["customPrice"] = _customPrice; - map["removeDecimal"] = _removeDecimal; - map["isSubscribe"] = _isSubscribe; - map["subcribeTime"] = _subcribeTime; - map["sendTime"] = _sendTime; - map["confirmTime"] = _confirmTime; - map["returnMoneyTime"] = _returnMoneyTime; - map["notes"] = _notes; - map["prepayId"] = _prepayId; - map["payTime"] = _payTime; - map["payChannel"] = _payChannel; - map["payNum"] = _payNum; - map["promotionId"] = _promotionId; - map["couponId"] = _couponId; - map["isDelete"] = _isDelete; - map["isTakeOut"] = _isTakeOut; - map["batch"] = _batch; - map["orderDiscountPrice"] = _orderDiscountPrice; - map["dishesDiscountPrice"] = _dishesDiscountPrice; - map["orderPercentPrice"] = _orderPercentPrice; - map["finalPayPrice"] = _finalPayPrice; - map["activityNoPrice"] = _activityNoPrice; - map["activityDiscountPrice"] = _activityDiscountPrice; - map["totalDiscountPrice"] = _totalDiscountPrice; - map["orderSource"] = _orderSource; - if (_storeVO != null) { - map["storeVO"] = _storeVO.toJson(); + map["postFee"] = this.postFee; + map["orderSum"] = this.orderSum; + map["paySum"] = this.paySum; + map["paySumSub"] = this.paySumSub; + map["accountPay"] = this.accountPay; + map["couponSubPrice"] = this.couponSubPrice; + map["customPrice"] = this.customPrice; + map["removeDecimal"] = this.removeDecimal; + map["isSubscribe"] = this.isSubscribe; + map["subcribeTime"] = this.subcribeTime; + map["sendTime"] = this.sendTime; + map["confirmTime"] = this.confirmTime; + map["returnMoneyTime"] = this.returnMoneyTime; + map["notes"] = this.notes; + map["prepayId"] = this.prepayId; + map["payTime"] = this.payTime; + map["payChannel"] = this.payChannel; + map["payNum"] = this.payNum; + map["promotionId"] = this.promotionId; + map["couponId"] = this.couponId; + map["isDelete"] = this.isDelete; + map["isTakeOut"] = this.isTakeOut; + map["batch"] = this.batch; + map["orderDiscountPrice"] = this.orderDiscountPrice; + map["dishesDiscountPrice"] = this.dishesDiscountPrice; + map["orderPercentPrice"] = this.orderPercentPrice; + map["finalPayPrice"] = this.finalPayPrice; + map["activityNoPrice"] = this.activityNoPrice; + map["activityDiscountPrice"] = this.activityDiscountPrice; + map["totalDiscountPrice"] = this.totalDiscountPrice; + map["orderSource"] = this.orderSource; + if (this.storeVO != null) { + map["storeVO"] = this.storeVO.toJson(); } - if (_orderDetail != null) { - map["orderDetail"] = _orderDetail.toJson(); + if (this.orderDetail != null) { + map["orderDetail"] = this.orderDetail.toJson(); } - if (_productList != null) { - map["productList"] = _productList.map((v) => v.toJson()).toList(); + if (this.productList != null) { + map["productList"] = this.productList.map((v) => v.toJson()).toList(); } return map; } } -/// id : "1408358257390518272" -/// createTime : "2021-06-25 17:35:49" -/// createUser : "1404743858104827904" -/// updateTime : "2021-06-25 17:35:49" -/// updateUser : "1404743858104827904" -/// tenantCode : null -/// storeId : "1344490596986781696" -/// orderId : "1408358257373741056" -/// productId : "1404742074535772160" -/// productName : "商品1" -/// skuId : "1404744485652398080" -/// skuNameStr : "中" -/// skuImg : "" -/// buyNum : 2 -/// refundNum : 0 -/// weight : 0 -/// applyPrice : "0.00" -/// sellPrice : "10.00" -/// postPay : "0.00" -/// isDelete : 0 -/// discountAmount : "2.20" -/// discountPercent : 11 -/// status : true -/// batch : 1 - - -/// orderProductList : [{"id":"1408358257390518272","platterList":null,"tenantCode":"1177","storeId":"1344490596986781696","orderId":"1408358257373741056","productId":"1404742074535772160","productName":"商品1","skuId":"1404744485652398080","skuNameStr":"中","skuImg":"","buyNum":2,"refundNum":0,"weight":0,"applyPrice":"0.00","sellPrice":"10.00","postPay":"0.00","isDelete":0,"discountAmount":"2.20","discountPercent":100}] -/// discountName : null -/// discountMoney : null -/// discountNumber : null -/// activityName : null -/// couponDTO : null -/// orderSumPrice : "20.00" -/// paySumPrice : "17.80" -/// activityNoPrice : "0.00" -/// activityPrice : "0.00" -/// dishesList : [] -/// customPrice : "0.00" -/// nextPerson : "占永辉" -/// isTakeOut : 0 -/// memberRec : null -/// isSubscribe : null -/// subcribeTime : null -/// postFee : "0.00" -/// shipperCode : "" -/// logisticsName : "" -/// logisticsNum : "" -/// orderNum : 0 -/// productNum : 0 -/// mins : 1 -/// predictTime : null - class OrderDetail { - List< OrderProductVOList> _orderProductList; - dynamic _discountName; - dynamic _discountMoney; - dynamic _discountNumber; - dynamic _activityName; - CouponDTO _couponDTO; - String _orderSumPrice; - String _paySumPrice; - String _activityNoPrice; - String _activityPrice; - String _promotionName; - List _dishesList; - String _customPrice; - String _nextPerson; - int _isTakeOut; - dynamic _memberRec; - dynamic _isSubscribe; - dynamic _subcribeTime; - String _postFee; - String _shipperCode; - String _logisticsName; - String _logisticsNum; - int _orderNum; - int _productNum; - int _mins; - dynamic _predictTime; - - List< OrderProductVOList> get orderProductList => _orderProductList; - - dynamic get discountName => _discountName; - - dynamic get discountMoney => _discountMoney; - - dynamic get discountNumber => _discountNumber; - - dynamic get activityName => _activityName; - - CouponDTO get couponDTO => _couponDTO; - - String get orderSumPrice => _orderSumPrice; - - String get paySumPrice => _paySumPrice; - - String get activityNoPrice => _activityNoPrice; - - String get activityPrice => _activityPrice; - String get promotionName => _promotionName; - - List get dishesList => _dishesList; - - String get customPrice => _customPrice; - - String get nextPerson => _nextPerson; - - int get isTakeOut => _isTakeOut; - - dynamic get memberRec => _memberRec; - - dynamic get isSubscribe => _isSubscribe; - - dynamic get subcribeTime => _subcribeTime; - - String get postFee => _postFee; - - String get shipperCode => _shipperCode; - - String get logisticsName => _logisticsName; - - String get logisticsNum => _logisticsNum; - - int get orderNum => _orderNum; - - int get productNum => _productNum; - - int get mins => _mins; - - dynamic get predictTime => _predictTime; + List< OrderProductVOList> orderProductList; + dynamic discountName; + dynamic discountMoney; + dynamic discountNumber; + dynamic activityName; + CouponDTO couponDTO; + String orderSumPrice; + String paySumPrice; + String activityNoPrice; + String activityPrice; + String promotionName; + List dishesList; + String customPrice; + String nextPerson; + int isTakeOut; + dynamic memberRec; + dynamic isSubscribe; + dynamic subcribeTime; + String postFee; + String shipperCode; + String logisticsName; + String logisticsNum; + int orderNum; + int productNum; + int mins; + dynamic predictTime; OrderDetail( {List< OrderProductVOList> orderProductList, @@ -671,235 +450,141 @@ class OrderDetail { int productNum, int mins, dynamic predictTime}) { - _orderProductList = orderProductList; - _discountName = discountName; - _discountMoney = discountMoney; - _discountNumber = discountNumber; - _activityName = activityName; - _couponDTO = couponDTO; - _orderSumPrice = orderSumPrice; - _paySumPrice = paySumPrice; - _activityNoPrice = activityNoPrice; - _activityPrice = activityPrice; - _promotionName = promotionName; - _dishesList = dishesList; - _customPrice = customPrice; - _nextPerson = nextPerson; - _isTakeOut = isTakeOut; - _memberRec = memberRec; - _isSubscribe = isSubscribe; - _subcribeTime = subcribeTime; - _postFee = postFee; - _shipperCode = shipperCode; - _logisticsName = logisticsName; - _logisticsNum = logisticsNum; - _orderNum = orderNum; - _productNum = productNum; - _mins = mins; - _predictTime = predictTime; + this.orderProductList = orderProductList; + this.discountName = discountName; + this.discountMoney = discountMoney; + this.discountNumber = discountNumber; + this.activityName = activityName; + this.couponDTO = couponDTO; + this.orderSumPrice = orderSumPrice; + this.paySumPrice = paySumPrice; + this.activityNoPrice = activityNoPrice; + this.activityPrice = activityPrice; + this.promotionName = promotionName; + this.dishesList = dishesList; + this.customPrice = customPrice; + this.nextPerson = nextPerson; + this.isTakeOut = isTakeOut; + this.memberRec = memberRec; + this.isSubscribe = isSubscribe; + this.subcribeTime = subcribeTime; + this.postFee = postFee; + this.shipperCode = shipperCode; + this.logisticsName = logisticsName; + this.logisticsNum = logisticsNum; + this.orderNum = orderNum; + this.productNum = productNum; + this.mins = mins; + this.predictTime = predictTime; } OrderDetail.fromJson(dynamic json) { if (json["orderProductList"] != null) { - _orderProductList = []; + this.orderProductList = []; json["orderProductList"].forEach((v) { - _orderProductList.add( OrderProductVOList.fromJson(v)); + this.orderProductList.add( OrderProductVOList.fromJson(v)); }); } - _discountName = json["discountName"]; - _discountMoney = json["discountMoney"]; - _discountNumber = json["discountNumber"]; - _activityName = json["activityName"]; - _couponDTO = json["couponDTO"] != null ? CouponDTO.fromJson(json["couponDTO"]) : null; - _orderSumPrice = json["orderSumPrice"]; - _paySumPrice = json["paySumPrice"]; - _activityNoPrice = json["activityNoPrice"]; - _activityPrice = json["activityPrice"]; - _promotionName = json["promotionName"]; + this.discountName = json["discountName"]; + this.discountMoney = json["discountMoney"]; + this.discountNumber = json["discountNumber"]; + this.activityName = json["activityName"]; + this.couponDTO = json["couponDTO"] != null ? CouponDTO.fromJson(json["couponDTO"]) : null; + this.orderSumPrice = json["orderSumPrice"]; + this.paySumPrice = json["paySumPrice"]; + this.activityNoPrice = json["activityNoPrice"]; + this.activityPrice = json["activityPrice"]; + this.promotionName = json["promotionName"]; if (json["dishesList"] != null) { - _dishesList = []; + this.dishesList = []; json["dishesList"].forEach((v) { - _dishesList.add(v); + this.dishesList.add(v); }); } - _customPrice = json["customPrice"]; - _nextPerson = json["nextPerson"]; - _isTakeOut = json["isTakeOut"]; - _memberRec = json["memberRec"]; - _isSubscribe = json["isSubscribe"]; - _subcribeTime = json["subcribeTime"]; - _postFee = json["postFee"]; - _shipperCode = json["shipperCode"]; - _logisticsName = json["logisticsName"]; - _logisticsNum = json["logisticsNum"]; - _orderNum = json["orderNum"]; - _productNum = json["productNum"]; - _mins = json["mins"]; - _predictTime = json["predictTime"]; + this.customPrice = json["customPrice"]; + this.nextPerson = json["nextPerson"]; + this.isTakeOut = json["isTakeOut"]; + this.memberRec = json["memberRec"]; + this.isSubscribe = json["isSubscribe"]; + this.subcribeTime = json["subcribeTime"]; + this.postFee = json["postFee"]; + this.shipperCode = json["shipperCode"]; + this.logisticsName = json["logisticsName"]; + this.logisticsNum = json["logisticsNum"]; + this.orderNum = json["orderNum"]; + this.productNum = json["productNum"]; + this.mins = json["mins"]; + this.predictTime = json["predictTime"]; } Map toJson() { var map = {}; - if (_orderProductList != null) { + if (this.orderProductList != null) { map["orderProductList"] = - _orderProductList.map((v) => v.toJson()).toList(); + this.orderProductList.map((v) => v.toJson()).toList(); } - map["discountName"] = _discountName; - map["discountMoney"] = _discountMoney; - map["discountNumber"] = _discountNumber; - map["activityName"] = _activityName; - map["couponDTO"] = _couponDTO; - map["orderSumPrice"] = _orderSumPrice; - map["paySumPrice"] = _paySumPrice; - map["activityNoPrice"] = _activityNoPrice; - map["activityPrice"] = _activityPrice; - if (_dishesList != null) { - map["dishesList"] = _dishesList.map((v) => v.toJson()).toList(); + map["discountName"] = this.discountName; + map["discountMoney"] = this.discountMoney; + map["discountNumber"] = this.discountNumber; + map["activityName"] = this.activityName; + map["couponDTO"] = this.couponDTO; + map["orderSumPrice"] = this.orderSumPrice; + map["paySumPrice"] = this.paySumPrice; + map["activityNoPrice"] = this.activityNoPrice; + map["activityPrice"] = this.activityPrice; + if (this.dishesList != null) { + map["dishesList"] = this.dishesList.map((v) => v.toJson()).toList(); } - map["customPrice"] = _customPrice; - map["nextPerson"] = _nextPerson; - map["isTakeOut"] = _isTakeOut; - map["memberRec"] = _memberRec; - map["isSubscribe"] = _isSubscribe; - map["subcribeTime"] = _subcribeTime; - map["postFee"] = _postFee; - map["shipperCode"] = _shipperCode; - map["logisticsName"] = _logisticsName; - map["logisticsNum"] = _logisticsNum; - map["orderNum"] = _orderNum; - map["productNum"] = _productNum; - map["mins"] = _mins; - map["predictTime"] = _predictTime; + map["customPrice"] = this.customPrice; + map["nextPerson"] = this.nextPerson; + map["isTakeOut"] = this.isTakeOut; + map["memberRec"] = this.memberRec; + map["isSubscribe"] = this.isSubscribe; + map["subcribeTime"] = this.subcribeTime; + map["postFee"] = this.postFee; + map["shipperCode"] = this.shipperCode; + map["logisticsName"] = this.logisticsName; + map["logisticsNum"] = this.logisticsNum; + map["orderNum"] = this.orderNum; + map["productNum"] = this.productNum; + map["mins"] = this.mins; + map["predictTime"] = this.predictTime; return map; } } -/// id : "1344490596986781696" -/// storeName : "小小店" -/// nickName : "" -/// businessService : "WIFI,免费停车" -/// businessType : "测试" -/// logo : "" -/// openStartTime : "08:25:43" -/// openEndTime : "23:25:43" -/// shipAddress : "汉街总部国际" -/// remark : null -/// mobile : "13554204268" -/// refundAddress : null -/// refundTel : null -/// refundContact : null -/// isAutoSendRefundAddress : 1 -/// soldNum : null -/// storeTemplateConfig : null -/// storeTable : null -/// threshold : null -/// freePostAge : null -/// logisticsThreshold : null -/// logisticsFreePostAge : null -/// longitude : "114.3442250000" -/// latitude : "30.5541770000" -/// deliveryDistance : null -/// couponVO : null -/// posType : {"desc":"零售商店","code":"RETAILSTORE"} -/// banners : null -/// tips : null -/// storeBrandImg : null -/// defaultPostAge : null - class StoreVO { - String _id; - String _storeName; - String _nickName; - String _businessService; - String _businessType; - String _logo; - String _openStartTime; - String _openEndTime; - String _shipAddress; - dynamic _remark; - String _mobile; - dynamic _refundAddress; - dynamic _refundTel; - dynamic _refundContact; - int _isAutoSendRefundAddress; - dynamic _soldNum; - dynamic _storeTemplateConfig; - dynamic _storeTable; - dynamic _threshold; - dynamic _freePostAge; - dynamic _logisticsThreshold; - dynamic _logisticsFreePostAge; - String _longitude; - String _latitude; - dynamic _deliveryDistance; - dynamic _couponVO; - PosType _posType; - dynamic _banners; - dynamic _tips; - dynamic _storeBrandImg; - dynamic _defaultPostAge; - - String get id => _id; - - String get storeName => _storeName; - - String get nickName => _nickName; - - String get businessService => _businessService; - - String get businessType => _businessType; - - String get logo => _logo; - - String get openStartTime => _openStartTime; - - String get openEndTime => _openEndTime; - - String get shipAddress => _shipAddress; - - dynamic get remark => _remark; - - String get mobile => _mobile; - - dynamic get refundAddress => _refundAddress; - - dynamic get refundTel => _refundTel; - - dynamic get refundContact => _refundContact; - - int get isAutoSendRefundAddress => _isAutoSendRefundAddress; - - dynamic get soldNum => _soldNum; - - dynamic get storeTemplateConfig => _storeTemplateConfig; - - dynamic get storeTable => _storeTable; - - dynamic get threshold => _threshold; - - dynamic get freePostAge => _freePostAge; - - dynamic get logisticsThreshold => _logisticsThreshold; - - dynamic get logisticsFreePostAge => _logisticsFreePostAge; - - String get longitude => _longitude; - - String get latitude => _latitude; - - dynamic get deliveryDistance => _deliveryDistance; - - dynamic get couponVO => _couponVO; - - PosType get posType => _posType; - - dynamic get banners => _banners; - - dynamic get tips => _tips; - - dynamic get storeBrandImg => _storeBrandImg; - - dynamic get defaultPostAge => _defaultPostAge; + String id; + String storeName; + String nickName; + String businessService; + String businessType; + String logo; + String openStartTime; + String openEndTime; + String shipAddress; + dynamic remark; + String mobile; + dynamic refundAddress; + dynamic refundTel; + dynamic refundContact; + int isAutoSendRefundAddress; + dynamic soldNum; + dynamic storeTemplateConfig; + dynamic storeTable; + dynamic threshold; + dynamic freePostAge; + dynamic logisticsThreshold; + dynamic logisticsFreePostAge; + String longitude; + String latitude; + dynamic deliveryDistance; + dynamic couponVO; + PosType posType; + dynamic banners; + dynamic tips; + dynamic storeBrandImg; + dynamic defaultPostAge; StoreVO( {String id, @@ -933,109 +618,109 @@ class StoreVO { dynamic tips, dynamic storeBrandImg, dynamic defaultPostAge}) { - _id = id; - _storeName = storeName; - _nickName = nickName; - _businessService = businessService; - _businessType = businessType; - _logo = logo; - _openStartTime = openStartTime; - _openEndTime = openEndTime; - _shipAddress = shipAddress; - _remark = remark; - _mobile = mobile; - _refundAddress = refundAddress; - _refundTel = refundTel; - _refundContact = refundContact; - _isAutoSendRefundAddress = isAutoSendRefundAddress; - _soldNum = soldNum; - _storeTemplateConfig = storeTemplateConfig; - _storeTable = storeTable; - _threshold = threshold; - _freePostAge = freePostAge; - _logisticsThreshold = logisticsThreshold; - _logisticsFreePostAge = logisticsFreePostAge; - _longitude = longitude; - _latitude = latitude; - _deliveryDistance = deliveryDistance; - _couponVO = couponVO; - _posType = posType; - _banners = banners; - _tips = tips; - _storeBrandImg = storeBrandImg; - _defaultPostAge = defaultPostAge; + this.id = id; + this.storeName = storeName; + this.nickName = nickName; + this.businessService = businessService; + this.businessType = businessType; + this.logo = logo; + this.openStartTime = openStartTime; + this.openEndTime = openEndTime; + this.shipAddress = shipAddress; + this.remark = remark; + this.mobile = mobile; + this.refundAddress = refundAddress; + this.refundTel = refundTel; + this.refundContact = refundContact; + this.isAutoSendRefundAddress = isAutoSendRefundAddress; + this.soldNum = soldNum; + this.storeTemplateConfig = storeTemplateConfig; + this.storeTable = storeTable; + this.threshold = threshold; + this.freePostAge = freePostAge; + this.logisticsThreshold = logisticsThreshold; + this.logisticsFreePostAge = logisticsFreePostAge; + this.longitude = longitude; + this.latitude = latitude; + this.deliveryDistance = deliveryDistance; + this.couponVO = couponVO; + this.posType = posType; + this.banners = banners; + this.tips = tips; + this.storeBrandImg = storeBrandImg; + this.defaultPostAge = defaultPostAge; } StoreVO.fromJson(dynamic json) { - _id = json["id"]; - _storeName = json["storeName"]; - _nickName = json["nickName"]; - _businessService = json["businessService"]; - _businessType = json["businessType"]; - _logo = json["logo"]; - _openStartTime = json["openStartTime"]; - _openEndTime = json["openEndTime"]; - _shipAddress = json["shipAddress"]; - _remark = json["remark"]; - _mobile = json["mobile"]; - _refundAddress = json["refundAddress"]; - _refundTel = json["refundTel"]; - _refundContact = json["refundContact"]; - _isAutoSendRefundAddress = json["isAutoSendRefundAddress"]; - _soldNum = json["soldNum"]; - _storeTemplateConfig = json["storeTemplateConfig"]; - _storeTable = json["storeTable"]; - _threshold = json["threshold"]; - _freePostAge = json["freePostAge"]; - _logisticsThreshold = json["logisticsThreshold"]; - _logisticsFreePostAge = json["logisticsFreePostAge"]; - _longitude = json["longitude"]; - _latitude = json["latitude"]; - _deliveryDistance = json["deliveryDistance"]; - _couponVO = json["couponVO"]; - _posType = + this.id = json["id"]; + this.storeName = json["storeName"]; + this.nickName = json["nickName"]; + this.businessService = json["businessService"]; + this.businessType = json["businessType"]; + this.logo = json["logo"]; + this.openStartTime = json["openStartTime"]; + this.openEndTime = json["openEndTime"]; + this.shipAddress = json["shipAddress"]; + this.remark = json["remark"]; + this.mobile = json["mobile"]; + this.refundAddress = json["refundAddress"]; + this.refundTel = json["refundTel"]; + this.refundContact = json["refundContact"]; + this.isAutoSendRefundAddress = json["isAutoSendRefundAddress"]; + this.soldNum = json["soldNum"]; + this.storeTemplateConfig = json["storeTemplateConfig"]; + this.storeTable = json["storeTable"]; + this.threshold = json["threshold"]; + this.freePostAge = json["freePostAge"]; + this.logisticsThreshold = json["logisticsThreshold"]; + this.logisticsFreePostAge = json["logisticsFreePostAge"]; + this.longitude = json["longitude"]; + this.latitude = json["latitude"]; + this.deliveryDistance = json["deliveryDistance"]; + this.couponVO = json["couponVO"]; + this.posType = json["posType"] != null ? PosType.fromJson(json["posType"]) : null; - _banners = json["banners"]; - _tips = json["tips"]; - _storeBrandImg = json["storeBrandImg"]; - _defaultPostAge = json["defaultPostAge"]; + this.banners = json["banners"]; + this.tips = json["tips"]; + this.storeBrandImg = json["storeBrandImg"]; + this.defaultPostAge = json["defaultPostAge"]; } Map toJson() { var map = {}; - map["id"] = _id; - map["storeName"] = _storeName; - map["nickName"] = _nickName; - map["businessService"] = _businessService; - map["businessType"] = _businessType; - map["logo"] = _logo; - map["openStartTime"] = _openStartTime; - map["openEndTime"] = _openEndTime; - map["shipAddress"] = _shipAddress; - map["remark"] = _remark; - map["mobile"] = _mobile; - map["refundAddress"] = _refundAddress; - map["refundTel"] = _refundTel; - map["refundContact"] = _refundContact; - map["isAutoSendRefundAddress"] = _isAutoSendRefundAddress; - map["soldNum"] = _soldNum; - map["storeTemplateConfig"] = _storeTemplateConfig; - map["storeTable"] = _storeTable; - map["threshold"] = _threshold; - map["freePostAge"] = _freePostAge; - map["logisticsThreshold"] = _logisticsThreshold; - map["logisticsFreePostAge"] = _logisticsFreePostAge; - map["longitude"] = _longitude; - map["latitude"] = _latitude; - map["deliveryDistance"] = _deliveryDistance; - map["couponVO"] = _couponVO; - if (_posType != null) { - map["posType"] = _posType.toJson(); + map["id"] = this.id; + map["storeName"] = this.storeName; + map["nickName"] = this.nickName; + map["businessService"] = this.businessService; + map["businessType"] = this.businessType; + map["logo"] = this.logo; + map["openStartTime"] = this.openStartTime; + map["openEndTime"] = this.openEndTime; + map["shipAddress"] = this.shipAddress; + map["remark"] = this.remark; + map["mobile"] = this.mobile; + map["refundAddress"] = this.refundAddress; + map["refundTel"] = this.refundTel; + map["refundContact"] = this.refundContact; + map["isAutoSendRefundAddress"] = this.isAutoSendRefundAddress; + map["soldNum"] = this.soldNum; + map["storeTemplateConfig"] = this.storeTemplateConfig; + map["storeTable"] = this.storeTable; + map["threshold"] = this.threshold; + map["freePostAge"] = this.freePostAge; + map["logisticsThreshold"] = this.logisticsThreshold; + map["logisticsFreePostAge"] = this.logisticsFreePostAge; + map["longitude"] = this.longitude; + map["latitude"] = this.latitude; + map["deliveryDistance"] = this.deliveryDistance; + map["couponVO"] = this.couponVO; + if (this.posType != null) { + map["posType"] = this.posType.toJson(); } - map["banners"] = _banners; - map["tips"] = _tips; - map["storeBrandImg"] = _storeBrandImg; - map["defaultPostAge"] = _defaultPostAge; + map["banners"] = this.banners; + map["tips"] = this.tips; + map["storeBrandImg"] = this.storeBrandImg; + map["defaultPostAge"] = this.defaultPostAge; return map; } } @@ -1044,27 +729,23 @@ class StoreVO { /// code : "RETAILSTORE" class PosType { - String _desc; - String _code; - - String get desc => _desc; - - String get code => _code; + String desc; + String code; PosType({String desc, String code}) { - _desc = desc; - _code = code; + this.desc = desc; + this.code = code; } PosType.fromJson(dynamic json) { - _desc = json["desc"]; - _code = json["code"]; + this.desc = json["desc"]; + this.code = json["code"]; } Map toJson() { var map = {}; - map["desc"] = _desc; - map["code"] = _code; + map["desc"] = this.desc; + map["code"] = this.code; return map; } } @@ -1085,48 +766,20 @@ class PosType { /// latitude : "30.554177" class AddressExt { - dynamic _addressId; - dynamic _country; - dynamic _countryId; - String _province; - dynamic _provinceId; - String _city; - dynamic _cityId; - String _district; - dynamic _districtId; - String _address; - dynamic _recName; - dynamic _recMobile; - String _longitude; - String _latitude; - - dynamic get addressId => _addressId; - - dynamic get country => _country; - - dynamic get countryId => _countryId; - - String get province => _province; - - dynamic get provinceId => _provinceId; - - String get city => _city; - - dynamic get cityId => _cityId; - - String get district => _district; - - dynamic get districtId => _districtId; - - String get address => _address; - - dynamic get recName => _recName; - - dynamic get recMobile => _recMobile; - - String get longitude => _longitude; - - String get latitude => _latitude; + dynamic addressId; + dynamic country; + dynamic countryId; + String province; + dynamic provinceId; + String city; + dynamic cityId; + String district; + dynamic districtId; + String address; + dynamic recName; + dynamic recMobile; + String longitude; + String latitude; AddressExt( {dynamic addressId, @@ -1143,55 +796,55 @@ class AddressExt { dynamic recMobile, String longitude, String latitude}) { - _addressId = addressId; - _country = country; - _countryId = countryId; - _province = province; - _provinceId = provinceId; - _city = city; - _cityId = cityId; - _district = district; - _districtId = districtId; - _address = address; - _recName = recName; - _recMobile = recMobile; - _longitude = longitude; - _latitude = latitude; + this.addressId = addressId; + this.country = country; + this.countryId = countryId; + this.province = province; + this.provinceId = provinceId; + this.city = city; + this.cityId = cityId; + this.district = district; + this.districtId = districtId; + this.address = address; + this.recName = recName; + this.recMobile = recMobile; + this.longitude = longitude; + this.latitude = latitude; } AddressExt.fromJson(dynamic json) { - _addressId = json["addressId"]; - _country = json["country"]; - _countryId = json["countryId"]; - _province = json["province"]; - _provinceId = json["provinceId"]; - _city = json["city"]; - _cityId = json["cityId"]; - _district = json["district"]; - _districtId = json["districtId"]; - _address = json["address"]; - _recName = json["recName"]; - _recMobile = json["recMobile"]; - _longitude = json["longitude"]; - _latitude = json["latitude"]; + this.addressId = json["addressId"]; + this.country = json["country"]; + this.countryId = json["countryId"]; + this.province = json["province"]; + this.provinceId = json["provinceId"]; + this.city = json["city"]; + this.cityId = json["cityId"]; + this.district = json["district"]; + this.districtId = json["districtId"]; + this.address = json["address"]; + this.recName = json["recName"]; + this.recMobile = json["recMobile"]; + this.longitude = json["longitude"]; + this.latitude = json["latitude"]; } Map toJson() { var map = {}; - map["addressId"] = _addressId; - map["country"] = _country; - map["countryId"] = _countryId; - map["province"] = _province; - map["provinceId"] = _provinceId; - map["city"] = _city; - map["cityId"] = _cityId; - map["district"] = _district; - map["districtId"] = _districtId; - map["address"] = _address; - map["recName"] = _recName; - map["recMobile"] = _recMobile; - map["longitude"] = _longitude; - map["latitude"] = _latitude; + map["addressId"] = this.addressId; + map["country"] = this.country; + map["countryId"] = this.countryId; + map["province"] = this.province; + map["provinceId"] = this.provinceId; + map["city"] = this.city; + map["cityId"] = this.cityId; + map["district"] = this.district; + map["districtId"] = this.districtId; + map["address"] = this.address; + map["recName"] = this.recName; + map["recMobile"] = this.recMobile; + map["longitude"] = this.longitude; + map["latitude"] = this.latitude; return map; } } diff --git a/lib/retrofit/data/order_product_vo.dart b/lib/retrofit/data/order_product_vo.dart index 5b150446..b3e62d5b 100644 --- a/lib/retrofit/data/order_product_vo.dart +++ b/lib/retrofit/data/order_product_vo.dart @@ -1,193 +1,113 @@ - class OrderProductVOList { OrderProductVOList({ ActInfo actInfo, AdditionalComment additionalComment, int buyNum, - int canApplyIntervention, + String canApplyIntervention, Comment comment, - int commentStatus, - int discountAmount, - int id, - int productId, + String commentStatus, + String discountAmount, + String id, + String productId, String productName, String returnCode, - int returnStatus, - int returnType, - int sellPrice, + String returnStatus, + String returnType, + String sellPrice, String skuId, String skuImg, - String skuNameStr,}){ - _actInfo = actInfo; - _additionalComment = additionalComment; - _buyNum = buyNum; - _canApplyIntervention = canApplyIntervention; - _comment = comment; - _commentStatus = commentStatus; - _discountAmount = discountAmount; - _id = id; - _productId = productId; - _productName = productName; - _returnCode = returnCode; - _returnStatus = returnStatus; - _returnType = returnType; - _sellPrice = sellPrice; - _skuId = skuId; - _skuImg = skuImg; - _skuNameStr = skuNameStr; + String skuNameStr, + }) { + this.actInfo = actInfo; + this.additionalComment = additionalComment; + this.buyNum = buyNum; + this.canApplyIntervention = canApplyIntervention; + this.comment = comment; + this.commentStatus = commentStatus; + this.discountAmount = discountAmount; + this.id = id; + this.productId = productId; + this.productName = productName; + this.returnCode = returnCode; + this.returnStatus = returnStatus; + this.returnType = returnType; + this.sellPrice = sellPrice; + this.skuId = skuId; + this.skuImg = skuImg; + this.skuNameStr = skuNameStr; } OrderProductVOList.fromJson(dynamic json) { - _actInfo = json['actInfo'] != null ? ActInfo.fromJson(json['actInfo']) : null; - _additionalComment = json['additionalComment'] != null ? AdditionalComment.fromJson(json['additionalComment']) : null; - _buyNum = json['buyNum']; - _canApplyIntervention = json['canApplyIntervention']; - _comment = json['comment'] != null ? Comment.fromJson(json['comment']) : null; - _commentStatus = json['commentStatus']; - _discountAmount = json['discountAmount']; - _id = json['id']; - _productId = json['productId']; - _productName = json['productName']; - _returnCode = json['returnCode']; - _returnStatus = json['returnStatus']; - _returnType = json['returnType']; - _sellPrice = json['sellPrice']; - _skuId = json['skuId']; - _skuImg = json['skuImg']; - _skuNameStr = json['skuNameStr']; - } - ActInfo _actInfo; - AdditionalComment _additionalComment; - int _buyNum; - int _canApplyIntervention; - Comment _comment; - int _commentStatus; - int _discountAmount; - int _id; - int _productId; - String _productName; - String _returnCode; - int _returnStatus; - int _returnType; - int _sellPrice; - String _skuId; - String _skuImg; - String _skuNameStr; - - ActInfo get actInfo => _actInfo; - AdditionalComment get additionalComment => _additionalComment; - int get buyNum => _buyNum; - int get canApplyIntervention => _canApplyIntervention; - Comment get comment => _comment; - int get commentStatus => _commentStatus; - int get discountAmount => _discountAmount; - int get id => _id; - int get productId => _productId; - String get productName => _productName; - String get returnCode => _returnCode; - int get returnStatus => _returnStatus; - int get returnType => _returnType; - int get sellPrice => _sellPrice; - String get skuId => _skuId; - String get skuImg => _skuImg; - String get skuNameStr => _skuNameStr; + this.actInfo = + json['actInfo'] != null ? ActInfo.fromJson(json['actInfo']) : null; + this.additionalComment = json['additionalComment'] != null + ? AdditionalComment.fromJson(json['additionalComment']) + : null; + this.buyNum = json['buyNum']; + this.canApplyIntervention = json['canApplyIntervention']; + this.comment = + json['comment'] != null ? Comment.fromJson(json['comment']) : null; + this.commentStatus = json['commentStatus']; + this.discountAmount = json['discountAmount']; + this.id = json['id']; + this.productId = json['productId']; + this.productName = json['productName']; + this.returnCode = json['returnCode']; + this.returnStatus = json['returnStatus']; + this.returnType = json['returnType']; + this.sellPrice = json['sellPrice']; + this.skuId = json['skuId']; + this.skuImg = json['skuImg']; + this.skuNameStr = json['skuNameStr']; + } + + ActInfo actInfo; + AdditionalComment additionalComment; + int buyNum; + String canApplyIntervention; + Comment comment; + String commentStatus; + String discountAmount; + String id; + String productId; + String productName; + String returnCode; + String returnStatus; + String returnType; + String sellPrice; + String skuId; + String skuImg; + String skuNameStr; - set actInfo(ActInfo value) { - _actInfo = value; - } - Map toJson() { final map = {}; - if (_actInfo != null) { - map['actInfo'] = _actInfo.toJson(); + if (this.actInfo != null) { + map['actInfo'] = this.actInfo.toJson(); } - if (_additionalComment != null) { - map['additionalComment'] = _additionalComment.toJson(); + if (this.additionalComment != null) { + map['additionalComment'] = this.additionalComment.toJson(); } - map['buyNum'] = _buyNum; - map['canApplyIntervention'] = _canApplyIntervention; - if (_comment != null) { - map['comment'] = _comment.toJson(); + map['buyNum'] = this.buyNum; + map['canApplyIntervention'] = this.canApplyIntervention; + if (this.comment != null) { + map['comment'] = this.comment.toJson(); } - map['commentStatus'] = _commentStatus; - map['discountAmount'] = _discountAmount; - map['id'] = _id; - map['productId'] = _productId; - map['productName'] = _productName; - map['returnCode'] = _returnCode; - map['returnStatus'] = _returnStatus; - map['returnType'] = _returnType; - map['sellPrice'] = _sellPrice; - map['skuId'] = _skuId; - map['skuImg'] = _skuImg; - map['skuNameStr'] = _skuNameStr; + map['commentStatus'] = this.commentStatus; + map['discountAmount'] = this.discountAmount; + map['id'] = this.id; + map['productId'] = this.productId; + map['productName'] = this.productName; + map['returnCode'] = this.returnCode; + map['returnStatus'] = this.returnStatus; + map['returnType'] = this.returnType; + map['sellPrice'] = this.sellPrice; + map['skuId'] = this.skuId; + map['skuImg'] = this.skuImg; + map['skuNameStr'] = this.skuNameStr; return map; } - set additionalComment(AdditionalComment value) { - _additionalComment = value; - } - - set buyNum(int value) { - _buyNum = value; - } - - set canApplyIntervention(int value) { - _canApplyIntervention = value; - } - - set comment(Comment value) { - _comment = value; - } - - set commentStatus(int value) { - _commentStatus = value; - } - - set discountAmount(int value) { - _discountAmount = value; - } - - set id(int value) { - _id = value; - } - - set productId(int value) { - _productId = value; - } - - set productName(String value) { - _productName = value; - } - - set returnCode(String value) { - _returnCode = value; - } - - set returnStatus(int value) { - _returnStatus = value; - } - - set returnType(int value) { - _returnType = value; - } - - set sellPrice(int value) { - _sellPrice = value; - } - - set skuId(String value) { - _skuId = value; - } - - set skuImg(String value) { - _skuImg = value; - } - - set skuNameStr(String value) { - _skuNameStr = value; - } } /// couponDiscountAmount : 0 @@ -201,97 +121,58 @@ class OrderProductVOList { class ActInfo { ActInfo({ - int couponDiscountAmount, + String couponDiscountAmount, int couponDiscountRate, - int couponId, + String couponId, int couponType, - int discountAmount, + String discountAmount, int discountRate, - int promotionId, - int promotionType,}){ - _couponDiscountAmount = couponDiscountAmount; - _couponDiscountRate = couponDiscountRate; - _couponId = couponId; - _couponType = couponType; - _discountAmount = discountAmount; - _discountRate = discountRate; - _promotionId = promotionId; - _promotionType = promotionType; + String promotionId, + int promotionType, + }) { + this.couponDiscountAmount = couponDiscountAmount; + this.couponDiscountRate = couponDiscountRate; + this.couponId = couponId; + this.couponType = couponType; + this.discountAmount = discountAmount; + this.discountRate = discountRate; + this.promotionId = promotionId; + this.promotionType = promotionType; } ActInfo.fromJson(dynamic json) { - _couponDiscountAmount = json['couponDiscountAmount']; - _couponDiscountRate = json['couponDiscountRate']; - _couponId = json['couponId']; - _couponType = json['couponType']; - _discountAmount = json['discountAmount']; - _discountRate = json['discountRate']; - _promotionId = json['promotionId']; - _promotionType = json['promotionType']; - } - int _couponDiscountAmount; - int _couponDiscountRate; - int _couponId; - int _couponType; - int _discountAmount; - int _discountRate; - int _promotionId; - int _promotionType; - - int get couponDiscountAmount => _couponDiscountAmount; - int get couponDiscountRate => _couponDiscountRate; - int get couponId => _couponId; - int get couponType => _couponType; - int get discountAmount => _discountAmount; - int get discountRate => _discountRate; - int get promotionId => _promotionId; - int get promotionType => _promotionType; - - - set couponDiscountAmount(int value) { - _couponDiscountAmount = value; - } + this.couponDiscountAmount = json['couponDiscountAmount']; + this.couponDiscountRate = json['couponDiscountRate']; + this.couponId = json['couponId']; + this.couponType = json['couponType']; + this.discountAmount = json['discountAmount']; + this.discountRate = json['discountRate']; + this.promotionId = json['promotionId']; + this.promotionType = json['promotionType']; + } + + String couponDiscountAmount; + int couponDiscountRate; + String couponId; + int couponType; + String discountAmount; + int discountRate; + String promotionId; + int promotionType; Map toJson() { final map = {}; - map['couponDiscountAmount'] = _couponDiscountAmount; - map['couponDiscountRate'] = _couponDiscountRate; - map['couponId'] = _couponId; - map['couponType'] = _couponType; - map['discountAmount'] = _discountAmount; - map['discountRate'] = _discountRate; - map['promotionId'] = _promotionId; - map['promotionType'] = _promotionType; + map['couponDiscountAmount'] = this.couponDiscountAmount; + map['couponDiscountRate'] = this.couponDiscountRate; + map['couponId'] = this.couponId; + map['couponType'] = this.couponType; + map['discountAmount'] = this.discountAmount; + map['discountRate'] = this.discountRate; + map['promotionId'] = this.promotionId; + map['promotionType'] = this.promotionType; return map; } - set couponDiscountRate(int value) { - _couponDiscountRate = value; - } - - set couponId(int value) { - _couponId = value; - } - - set couponType(int value) { - _couponType = value; - } - - set discountAmount(int value) { - _discountAmount = value; - } - - set discountRate(int value) { - _discountRate = value; - } - - set promotionId(int value) { - _promotionId = value; - } - - set promotionType(int value) { - _promotionType = value; - } } class AdditionalComment { @@ -313,180 +194,91 @@ class AdditionalComment { int productId, bool sensitiveFlag, int serviceStar, - int storeId,}){ - _bizType = bizType; - _commentImgs = commentImgs; - _commentImgsFlag = commentImgsFlag; - _commentStar = commentStar; - _commentText = commentText; - _descStar = descStar; - _hideFlag = hideFlag; - _id = id; - _isDelete = isDelete; - _likeNum = likeNum; - _logisticsStar = logisticsStar; - _mid = mid; - _orderProductId = orderProductId; - _parentId = parentId; - _productId = productId; - _sensitiveFlag = sensitiveFlag; - _serviceStar = serviceStar; - _storeId = storeId; + int storeId, + }) { + this.bizType = bizType; + this.commentImgs = commentImgs; + this.commentImgsFlag = commentImgsFlag; + this.commentStar = commentStar; + this.commentText = commentText; + this.descStar = descStar; + this.hideFlag = hideFlag; + this.id = id; + this.isDelete = isDelete; + this.likeNum = likeNum; + this.logisticsStar = logisticsStar; + this.mid = mid; + this.orderProductId = orderProductId; + this.parentId = parentId; + this.productId = productId; + this.sensitiveFlag = sensitiveFlag; + this.serviceStar = serviceStar; + this.storeId = storeId; } AdditionalComment.fromJson(dynamic json) { - _bizType = json['bizType']; - _commentImgs = json['commentImgs']; - _commentImgsFlag = json['commentImgsFlag']; - _commentStar = json['commentStar']; - _commentText = json['commentText']; - _descStar = json['descStar']; - _hideFlag = json['hideFlag']; - _id = json['id']; - _isDelete = json['isDelete']; - _likeNum = json['likeNum']; - _logisticsStar = json['logisticsStar']; - _mid = json['mid']; - _orderProductId = json['orderProductId']; - _parentId = json['parentId']; - _productId = json['productId']; - _sensitiveFlag = json['sensitiveFlag']; - _serviceStar = json['serviceStar']; - _storeId = json['storeId']; - } - int _bizType; - String _commentImgs; - bool _commentImgsFlag; - int _commentStar; - String _commentText; - int _descStar; - bool _hideFlag; - int _id; - bool _isDelete; - int _likeNum; - int _logisticsStar; - int _mid; - int _orderProductId; - int _parentId; - int _productId; - bool _sensitiveFlag; - int _serviceStar; - int _storeId; - - int get bizType => _bizType; - String get commentImgs => _commentImgs; - bool get commentImgsFlag => _commentImgsFlag; - int get commentStar => _commentStar; - String get commentText => _commentText; - int get descStar => _descStar; - bool get hideFlag => _hideFlag; - int get id => _id; - bool get isDelete => _isDelete; - int get likeNum => _likeNum; - int get logisticsStar => _logisticsStar; - int get mid => _mid; - int get orderProductId => _orderProductId; - int get parentId => _parentId; - int get productId => _productId; - bool get sensitiveFlag => _sensitiveFlag; - int get serviceStar => _serviceStar; - int get storeId => _storeId; - - - set bizType(int value) { - _bizType = value; - } + this.bizType = json['bizType']; + this.commentImgs = json['commentImgs']; + this.commentImgsFlag = json['commentImgsFlag']; + this.commentStar = json['commentStar']; + this.commentText = json['commentText']; + this.descStar = json['descStar']; + this.hideFlag = json['hideFlag']; + this.id = json['id']; + this.isDelete = json['isDelete']; + this.likeNum = json['likeNum']; + this.logisticsStar = json['logisticsStar']; + this.mid = json['mid']; + this.orderProductId = json['orderProductId']; + this.parentId = json['parentId']; + this.productId = json['productId']; + this.sensitiveFlag = json['sensitiveFlag']; + this.serviceStar = json['serviceStar']; + this.storeId = json['storeId']; + } + + int bizType; + String commentImgs; + bool commentImgsFlag; + int commentStar; + String commentText; + int descStar; + bool hideFlag; + int id; + bool isDelete; + int likeNum; + int logisticsStar; + int mid; + int orderProductId; + int parentId; + int productId; + bool sensitiveFlag; + int serviceStar; + int storeId; Map toJson() { final map = {}; - map['bizType'] = _bizType; - map['commentImgs'] = _commentImgs; - map['commentImgsFlag'] = _commentImgsFlag; - map['commentStar'] = _commentStar; - map['commentText'] = _commentText; - map['descStar'] = _descStar; - map['hideFlag'] = _hideFlag; - map['id'] = _id; - map['isDelete'] = _isDelete; - map['likeNum'] = _likeNum; - map['logisticsStar'] = _logisticsStar; - map['mid'] = _mid; - map['orderProductId'] = _orderProductId; - map['parentId'] = _parentId; - map['productId'] = _productId; - map['sensitiveFlag'] = _sensitiveFlag; - map['serviceStar'] = _serviceStar; - map['storeId'] = _storeId; + map['bizType'] = this.bizType; + map['commentImgs'] = this.commentImgs; + map['commentImgsFlag'] = this.commentImgsFlag; + map['commentStar'] = this.commentStar; + map['commentText'] = this.commentText; + map['descStar'] = this.descStar; + map['hideFlag'] = this.hideFlag; + map['id'] = this.id; + map['isDelete'] = this.isDelete; + map['likeNum'] = this.likeNum; + map['logisticsStar'] = this.logisticsStar; + map['mid'] = this.mid; + map['orderProductId'] = this.orderProductId; + map['parentId'] = this.parentId; + map['productId'] = this.productId; + map['sensitiveFlag'] = this.sensitiveFlag; + map['serviceStar'] = this.serviceStar; + map['storeId'] = this.storeId; return map; } - set commentImgs(String value) { - _commentImgs = value; - } - - set commentImgsFlag(bool value) { - _commentImgsFlag = value; - } - - set commentStar(int value) { - _commentStar = value; - } - - set commentText(String value) { - _commentText = value; - } - - set descStar(int value) { - _descStar = value; - } - - set hideFlag(bool value) { - _hideFlag = value; - } - - set id(int value) { - _id = value; - } - - set isDelete(bool value) { - _isDelete = value; - } - - set likeNum(int value) { - _likeNum = value; - } - - set logisticsStar(int value) { - _logisticsStar = value; - } - - set mid(int value) { - _mid = value; - } - - set orderProductId(int value) { - _orderProductId = value; - } - - set parentId(int value) { - _parentId = value; - } - - set productId(int value) { - _productId = value; - } - - set sensitiveFlag(bool value) { - _sensitiveFlag = value; - } - - set serviceStar(int value) { - _serviceStar = value; - } - - set storeId(int value) { - _storeId = value; - } } class Comment { @@ -508,178 +300,89 @@ class Comment { int productId, bool sensitiveFlag, int serviceStar, - int storeId,}){ - _bizType = bizType; - _commentImgs = commentImgs; - _commentImgsFlag = commentImgsFlag; - _commentStar = commentStar; - _commentText = commentText; - _descStar = descStar; - _hideFlag = hideFlag; - _id = id; - _isDelete = isDelete; - _likeNum = likeNum; - _logisticsStar = logisticsStar; - _mid = mid; - _orderProductId = orderProductId; - _parentId = parentId; - _productId = productId; - _sensitiveFlag = sensitiveFlag; - _serviceStar = serviceStar; - _storeId = storeId; + int storeId, + }) { + this.bizType = bizType; + this.commentImgs = commentImgs; + this.commentImgsFlag = commentImgsFlag; + this.commentStar = commentStar; + this.commentText = commentText; + this.descStar = descStar; + this.hideFlag = hideFlag; + this.id = id; + this.isDelete = isDelete; + this.likeNum = likeNum; + this.logisticsStar = logisticsStar; + this.mid = mid; + this.orderProductId = orderProductId; + this.parentId = parentId; + this.productId = productId; + this.sensitiveFlag = sensitiveFlag; + this.serviceStar = serviceStar; + this.storeId = storeId; } Comment.fromJson(dynamic json) { - _bizType = json['bizType']; - _commentImgs = json['commentImgs']; - _commentImgsFlag = json['commentImgsFlag']; - _commentStar = json['commentStar']; - _commentText = json['commentText']; - _descStar = json['descStar']; - _hideFlag = json['hideFlag']; - _id = json['id']; - _isDelete = json['isDelete']; - _likeNum = json['likeNum']; - _logisticsStar = json['logisticsStar']; - _mid = json['mid']; - _orderProductId = json['orderProductId']; - _parentId = json['parentId']; - _productId = json['productId']; - _sensitiveFlag = json['sensitiveFlag']; - _serviceStar = json['serviceStar']; - _storeId = json['storeId']; - } - int _bizType; - String _commentImgs; - bool _commentImgsFlag; - int _commentStar; - String _commentText; - int _descStar; - bool _hideFlag; - int _id; - bool _isDelete; - int _likeNum; - int _logisticsStar; - int _mid; - int _orderProductId; - int _parentId; - int _productId; - bool _sensitiveFlag; - int _serviceStar; - int _storeId; - - int get bizType => _bizType; - String get commentImgs => _commentImgs; - bool get commentImgsFlag => _commentImgsFlag; - int get commentStar => _commentStar; - String get commentText => _commentText; - int get descStar => _descStar; - bool get hideFlag => _hideFlag; - int get id => _id; - bool get isDelete => _isDelete; - int get likeNum => _likeNum; - int get logisticsStar => _logisticsStar; - int get mid => _mid; - int get orderProductId => _orderProductId; - int get parentId => _parentId; - int get productId => _productId; - bool get sensitiveFlag => _sensitiveFlag; - int get serviceStar => _serviceStar; - int get storeId => _storeId; - - - set bizType(int value) { - _bizType = value; - } + this.bizType = json['bizType']; + this.commentImgs = json['commentImgs']; + this.commentImgsFlag = json['commentImgsFlag']; + this.commentStar = json['commentStar']; + this.commentText = json['commentText']; + this.descStar = json['descStar']; + this.hideFlag = json['hideFlag']; + this.id = json['id']; + this.isDelete = json['isDelete']; + this.likeNum = json['likeNum']; + this.logisticsStar = json['logisticsStar']; + this.mid = json['mid']; + this.orderProductId = json['orderProductId']; + this.parentId = json['parentId']; + this.productId = json['productId']; + this.sensitiveFlag = json['sensitiveFlag']; + this.serviceStar = json['serviceStar']; + this.storeId = json['storeId']; + } + + int bizType; + String commentImgs; + bool commentImgsFlag; + int commentStar; + String commentText; + int descStar; + bool hideFlag; + int id; + bool isDelete; + int likeNum; + int logisticsStar; + int mid; + int orderProductId; + int parentId; + int productId; + bool sensitiveFlag; + int serviceStar; + int storeId; Map toJson() { final map = {}; - map['bizType'] = _bizType; - map['commentImgs'] = _commentImgs; - map['commentImgsFlag'] = _commentImgsFlag; - map['commentStar'] = _commentStar; - map['commentText'] = _commentText; - map['descStar'] = _descStar; - map['hideFlag'] = _hideFlag; - map['id'] = _id; - map['isDelete'] = _isDelete; - map['likeNum'] = _likeNum; - map['logisticsStar'] = _logisticsStar; - map['mid'] = _mid; - map['orderProductId'] = _orderProductId; - map['parentId'] = _parentId; - map['productId'] = _productId; - map['sensitiveFlag'] = _sensitiveFlag; - map['serviceStar'] = _serviceStar; - map['storeId'] = _storeId; + map['bizType'] = this.bizType; + map['commentImgs'] = this.commentImgs; + map['commentImgsFlag'] = this.commentImgsFlag; + map['commentStar'] = this.commentStar; + map['commentText'] = this.commentText; + map['descStar'] = this.descStar; + map['hideFlag'] = this.hideFlag; + map['id'] = this.id; + map['isDelete'] = this.isDelete; + map['likeNum'] = this.likeNum; + map['logisticsStar'] = this.logisticsStar; + map['mid'] = this.mid; + map['orderProductId'] = this.orderProductId; + map['parentId'] = this.parentId; + map['productId'] = this.productId; + map['sensitiveFlag'] = this.sensitiveFlag; + map['serviceStar'] = this.serviceStar; + map['storeId'] = this.storeId; return map; } - set commentImgs(String value) { - _commentImgs = value; - } - - set commentImgsFlag(bool value) { - _commentImgsFlag = value; - } - - set commentStar(int value) { - _commentStar = value; - } - - set commentText(String value) { - _commentText = value; - } - - set descStar(int value) { - _descStar = value; - } - - set hideFlag(bool value) { - _hideFlag = value; - } - - set id(int value) { - _id = value; - } - - set isDelete(bool value) { - _isDelete = value; - } - - set likeNum(int value) { - _likeNum = value; - } - - set logisticsStar(int value) { - _logisticsStar = value; - } - - set mid(int value) { - _mid = value; - } - - set orderProductId(int value) { - _orderProductId = value; - } - - set parentId(int value) { - _parentId = value; - } - - set productId(int value) { - _productId = value; - } - - set sensitiveFlag(bool value) { - _sensitiveFlag = value; - } - - set serviceStar(int value) { - _serviceStar = value; - } - - set storeId(int value) { - _storeId = value; - } } diff --git a/lib/retrofit/data/store_info.dart b/lib/retrofit/data/store_info.dart index 67a8fc96..2f6010a3 100644 --- a/lib/retrofit/data/store_info.dart +++ b/lib/retrofit/data/store_info.dart @@ -38,6 +38,7 @@ class StoreInfo { String remark; String shipAddress; String storeName; + StoreTable storeTable; String tenantCode; String updateTime; String updateUser; @@ -94,6 +95,7 @@ class StoreInfo { ..remark = json['remark'] as String ..shipAddress = json['shipAddress'] as String ..storeName = json['storeName'] as String + ..storeTable = json['storeTable'] != null ? StoreTable.fromJson(json['storeTable']) : null ..tenantCode = json['tenantCode'] as String ..updateTime = json['updateTime'] as String ..updateUser = json['updateUser'] as String @@ -138,6 +140,7 @@ class StoreInfo { 'remark': this.remark, 'shipAddress': this.shipAddress, 'storeName': this.storeName, + 'storeTable': this.storeTable.toJson(), 'tenantCode': this.tenantCode, 'updateTime': this.updateTime, 'updateUser': this.updateUser, @@ -151,3 +154,49 @@ class StoreInfo { }; } + +class StoreTable { + + StoreTable(); + + String areaId; + String id; + int isDelete; + int numberOfPeople; + String remark; + String storeId; + int tableCapacity; + String tableName; + int tableSort; + int tableType; + String tenantCode; + + factory StoreTable.fromJson(Map json) => StoreTable() + ..areaId = json["areaId"] + ..id = json["id"] + ..isDelete = json["isDelete"] + ..numberOfPeople = json["numberOfPeople"] + ..remark = json["remark"] + ..storeId = json["storeId"] + ..tableCapacity = json["tableCapacity"] + ..tableName = json["tableName"] + ..tableSort = json["tableSort"] + ..tableType = json["tableType"] + ..tenantCode = json["tenantCode"]; + + Map toJson() => { + "areaId": this.areaId, + "id": this.id, + "isDelete": this.isDelete, + "numberOfPeople": this.numberOfPeople, + "remark": this.remark, + "storeId": this.storeId, + "tableCapacity": this.tableCapacity, + "tableName": this.tableName, + "tableSort": this.tableSort, + "tableType": this.tableType, + "tenantCode": this.tenantCode, + }; + +} + diff --git a/lib/retrofit/min_api.dart b/lib/retrofit/min_api.dart index 0bee7037..015efc27 100644 --- a/lib/retrofit/min_api.dart +++ b/lib/retrofit/min_api.dart @@ -182,4 +182,12 @@ abstract class MinApiService { @POST("order/settlement") Future settlementApi(@Body() Map param); + ///查询店铺商家详情 + @POST("store/getStore") + Future queryStoreInfo1(@Body() Map param); + + // 父订单信息 + @GET("order/getParentInfo?tableId={tableId}") + Future getParentInfo(@Path("tableId") String tableId); + } diff --git a/lib/retrofit/min_api.g.dart b/lib/retrofit/min_api.g.dart index f233b182..b98fa96b 100644 --- a/lib/retrofit/min_api.g.dart +++ b/lib/retrofit/min_api.g.dart @@ -291,4 +291,48 @@ class _MinApiService implements MinApiService { ); return value; } + + @override + Future> queryStoreInfo1(param) async { + ArgumentError.checkNotNull(param, 'param'); + const _extra = {}; + final queryParameters = {}; + final _data = {}; + _data.addAll(param ?? {}); + final _result = await _dio.request>('/store/getStore', + queryParameters: queryParameters, + options: RequestOptions( + method: 'POST', + headers: {}, + extra: _extra, + baseUrl: baseUrl), + data: _data); + final value = BaseData.fromJson( + _result.data, + (json) => json as dynamic, + ); + return value; + } + + @override + Future> getParentInfo(id) async { + ArgumentError.checkNotNull(id, 'id'); + const _extra = {}; + final queryParameters = {}; + final _data = {}; + final _result = await _dio.request>( + '/order/getParentInfo/$id', + queryParameters: queryParameters, + options: RequestOptions( + method: 'GET', + headers: {}, + extra: _extra, + baseUrl: baseUrl), + data: _data); + final value = BaseData.fromJson( + _result.data, + (json) => json as dynamic, + ); + return value; + } } diff --git a/lib/retrofit/retrofit_api.dart b/lib/retrofit/retrofit_api.dart index 73e259b0..60f94b5a 100644 --- a/lib/retrofit/retrofit_api.dart +++ b/lib/retrofit/retrofit_api.dart @@ -266,13 +266,11 @@ abstract class ApiService { ///分页查看资讯列表 @POST("/information/list") - Future>> queryArticle( - @Body() Map param); + Future>> queryArticle(@Body() Map param); ///banner查询 @POST("/banner/page") - Future>> queryBanner( - @Body() Map param); + Future>> queryBanner(@Body() Map param); ///品牌信息 @GET("/home/brand") @@ -357,7 +355,7 @@ abstract class ApiService { Future> report(@Body() Map map); ///取消订单 - @GET("/order/orderCancel?id={id}") + @GET("/order/cancel/{id}") Future> orderCancel(@Path("id") String id); ///继续付款? diff --git a/lib/retrofit/retrofit_api.g.dart b/lib/retrofit/retrofit_api.g.dart index 9fc29cfd..cd2ce872 100644 --- a/lib/retrofit/retrofit_api.g.dart +++ b/lib/retrofit/retrofit_api.g.dart @@ -1168,7 +1168,7 @@ class _ApiService implements ApiService { final queryParameters = {}; final _data = {}; final _result = await _dio.request>( - '/order/orderCancel?id=$id', + '/order/cancel/$id', queryParameters: queryParameters, options: RequestOptions( method: 'GET', diff --git a/lib/settlement/settlement.dart b/lib/settlement/settlement.dart index efaf677f..fb460c2e 100644 --- a/lib/settlement/settlement.dart +++ b/lib/settlement/settlement.dart @@ -87,7 +87,7 @@ class _Settlement extends State { "memberCouponId": memberCouponId, "orderId": orderId, "promotionId": promotionId - }).catchError((error){}); + }).catchError((error) {}); if (baseData != null && baseData.isSuccess) { setState(() { settleOrderInfo = baseData.data; @@ -143,10 +143,10 @@ class _Settlement extends State { ///小程序下单 queryPlaceOrderFirst() async { - - for(int i = 0; i < shopCarGoods.shoppingCartSkuItemList.length; i ++) { + for (int i = 0; i < shopCarGoods.shoppingCartSkuItemList.length; i++) { settleOrderInfo.orderProductList.forEach((element1) { - if (shopCarGoods.shoppingCartSkuItemList[i].productId == element1.productId) { + if (shopCarGoods.shoppingCartSkuItemList[i].productId == + element1.productId) { shopCarGoods.shoppingCartSkuItemList[i].skuId = element1.skuId; } }); @@ -164,20 +164,27 @@ class _Settlement extends State { placeOrderFirst.orderType = "0"; placeOrderFirst.orderTypeId = 0; placeOrderFirst.parentCode = ""; // 火锅加菜 - placeOrderFirst.parentId = "0"; // 火锅加菜 + placeOrderFirst.parentId = "0"; // 火锅加菜 placeOrderFirst.payChannel = payChannel; placeOrderFirst.promotionInfoDTO = PromotionInfoDTOBean(); - placeOrderFirst.promotionInfoDTO.promotionId = promotion != null ? promotion.id : ""; - placeOrderFirst.promotionInfoDTO.couponId = couponListBean != null ? couponListBean.id : ""; - placeOrderFirst.recMobile = (mobile == null || mobile == "") ? mobile : storeInfo.headMobile; - placeOrderFirst.shoppingCartSkuItemList = shopCarGoods.shoppingCartSkuItemList; + placeOrderFirst.promotionInfoDTO.promotionId = + promotion != null ? promotion.id : ""; + placeOrderFirst.promotionInfoDTO.couponId = + couponListBean != null ? couponListBean.id : ""; + placeOrderFirst.recMobile = + (mobile == null || mobile == "") ? mobile : storeInfo.headMobile; + placeOrderFirst.shoppingCartSkuItemList = + shopCarGoods.shoppingCartSkuItemList; placeOrderFirst.skuItemDTOList = []; placeOrderFirst.source = 1; placeOrderFirst.storeId = storeInfo.id; placeOrderFirst.subcribeTime = null; placeOrderFirst.tableId = tableId; - BaseData baseData = await minService.placeOrderFirst(placeOrderFirst.toJson()) - .catchError((error) {}); + BaseData baseData = await minService + .placeOrderFirst(placeOrderFirst.toJson()) + .catchError((error) { + print("error: $error"); + }); if (baseData != null && baseData.isSuccess) { querySettlement(placeOrderFirst, baseData.data); } @@ -194,28 +201,34 @@ class _Settlement extends State { // 故而在此初始化一下 await Min.initialize(); } - BaseData baseData = await minService.settlementWx(placeOrderFirst.toJson()).catchError((error) {}); + BaseData 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/"); + 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); + 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}"); toOrderDetails(placeOrderFirst.id); }); } } else { - BaseData baseData = await minService.settlementApi(placeOrderFirst.toJson()).catchError((error) {}); + BaseData baseData = await minService + .settlementApi(placeOrderFirst.toJson()) + .catchError((error) {}); if (baseData != null && baseData.isSuccess) { toOrderDetails(placeOrderFirst.id); } @@ -223,12 +236,9 @@ class _Settlement extends State { } toOrderDetails(String orderId) { - //1451130052983914496 - //202110211815390002 Navigator.of(context).popAndPushNamed('/router/order_details', arguments: { "id": orderId, }); - } @override @@ -421,11 +431,12 @@ class _Settlement extends State { this.promotion = pro; this.couponListBean = null; queryOrderInfo( - address != null ? address.id : null, - selectedBtn, - couponListBean != null ? couponListBean.id : null, - 0, - promotion != null ? promotion.id : null); + address != null ? address.id : null, + selectedBtn, + couponListBean != null ? couponListBean.id : null, + 0, + promotion != null ? promotion.id : null, + ); } } } diff --git a/lib/store/store_order.dart b/lib/store/store_order.dart index c058f887..45348499 100644 --- a/lib/store/store_order.dart +++ b/lib/store/store_order.dart @@ -14,6 +14,7 @@ import 'package:huixiang/retrofit/data/shoppingCart.dart'; import 'package:huixiang/retrofit/data/store_info.dart'; import 'package:huixiang/retrofit/min_api.dart'; import 'package:huixiang/retrofit/retrofit_api.dart'; +import 'package:huixiang/store/store_view/people_num.dart'; import 'package:huixiang/store/store_view/product_sku.dart'; import 'package:huixiang/store/store_view/shop_car.dart'; import 'package:huixiang/store/store_view/store_activity.dart'; @@ -48,43 +49,51 @@ class _StoreOrderPage extends State MinApiService minService; StoreInfo storeInfo; List activitys; - RefreshController refreshController; StoreOrderListPage storeOrderListPage; ScrollController controller = ScrollController(); ShoppingCart shopCarGoods; + int tableId = 0; + String tenant = ""; + String storeId = ""; + int numberOfPeople = 0; @override void initState() { super.initState(); + tableId = widget.arguments["tableId"]; + tenant = widget.arguments["tenant"]; + storeId = widget.arguments["id"]; + + debugPrint( + "store_param tableId:$tableId tenant:$tenant storeId:$storeId"); + if (tabcontroller == null) tabcontroller = TabController( length: 2, vsync: this, ); - minLogin(); - queryStoreInfo(); + SharedPreferences.getInstance().then((value) { + minLogin(value); + }); } /// 小程序登录 - minLogin() async { - final SharedPreferences value = await SharedPreferences.getInstance(); + minLogin(SharedPreferences shared) async { apiService = ApiService( Dio(), context: context, - token: value.getString('token'), + token: shared.getString('token'), ); - apiService - .minLogin(widget.arguments["id"]) - .catchError((onError) {}) - .then((baseData) { + queryStoreInfo(); + apiService.minLogin(storeId).catchError((onError) { + debugPrint(onError); + }).then((baseData) { if (baseData != null && baseData.isSuccess) { Map minStoreInfo = baseData.data; String minToken = minStoreInfo["token"]; - String tenant = widget.arguments["tenant"]; - String storeId = widget.arguments["id"]; SharedPreferences.getInstance().then( (value) => { value.setString('minToken', minToken), @@ -103,25 +112,48 @@ class _StoreOrderPage extends State this.shopCarGoods = value; setState(() {}); }); + if (tableId > 0) { + queryStoreInfo1(); + } } }); } + ///获取父订单(火锅订单加菜前调用) + getParentInfo() async { + BaseData baseData = + await minService.getParentInfo("$tableId").catchError((error) { + debugPrint(error); + }); + if (baseData != null && baseData.isSuccess) { + + } + } + + ///获取桌子信息 + queryStoreInfo1() async { + BaseData baseData = await minService.queryStoreInfo1({ + "getCoupon": true, + "storeId": storeId, + "tableId": tableId, + }).catchError((error) { + debugPrint(error); + }); + if (baseData != null && baseData.isSuccess) { + StoreInfo storeInfo = StoreInfo.fromJson(baseData.data); + if (storeInfo.storeTable != null) { + showPeopleNum(storeInfo.storeTable.tableName); + } + } + } + /// 查询店铺信息 queryStoreInfo() async { - final SharedPreferences value = await SharedPreferences.getInstance(); - apiService = ApiService( - Dio(), - context: context, - token: value.getString('token'), - ); - BaseData baseData = await apiService - .queryStoreInfo(widget.arguments["id"]) - .catchError((error) { - // refreshController.refreshFailed(); + BaseData baseData = + await apiService.queryStoreInfo(storeId).catchError((error) { + debugPrint(error); }); if (baseData != null && baseData.isSuccess) { - // refreshController.refreshCompleted(); storeInfo = StoreInfo.fromJson(baseData.data); activitys = storeInfo.informationVOPageVO.list .map((e) => Activity.fromJson(e)) @@ -143,178 +175,168 @@ class _StoreOrderPage extends State bottom: 54.h, child: DefaultTabController( length: 2, - child: SmartRefresher( - controller: refreshController = - RefreshController(initialRefresh: false), - enablePullDown: true, - enablePullUp: false, - header: MyHeader(), + child: NestedScrollView( + controller: controller, + dragStartBehavior: DragStartBehavior.start, physics: BouncingScrollPhysics(), - onRefresh: () { - queryStoreInfo(); - }, - child: NestedScrollView( - controller: controller, - dragStartBehavior: DragStartBehavior.start, - headerSliverBuilder: - (BuildContext context, bool innerBoxIsScrolled) { - return [ - SliverOverlapAbsorber( - handle: NestedScrollView.sliverOverlapAbsorberHandleFor( - context), - sliver: SliverAppBar( - expandedHeight: (storeInfo != null && - storeInfo.couponVOList != null) - ? 470.h - : 365.h, - floating: false, - snap: false, - pinned: true, - stretch: false, - brightness: Brightness.light, - leading: GestureDetector( - onTap: () { - Navigator.of(context).pop(); - }, - child: Container( - alignment: Alignment.centerRight, - margin: EdgeInsets.only(left: 10), - padding: EdgeInsets.all(6), - child: Icon( - Icons.arrow_back_ios, - color: Colors.black, - size: 24, - ), + headerSliverBuilder: + (BuildContext context, bool innerBoxIsScrolled) { + return [ + SliverOverlapAbsorber( + handle: NestedScrollView.sliverOverlapAbsorberHandleFor( + context), + sliver: SliverAppBar( + expandedHeight: + (storeInfo != null && storeInfo.couponVOList != null) + ? 470.h + : 365.h, + floating: false, + snap: false, + pinned: true, + stretch: false, + brightness: Brightness.light, + leading: GestureDetector( + onTap: () { + Navigator.of(context).pop(); + }, + child: Container( + alignment: Alignment.centerRight, + margin: EdgeInsets.only(left: 10), + padding: EdgeInsets.all(6), + child: Icon( + Icons.arrow_back_ios, + color: Colors.black, + size: 24, ), ), - flexibleSpace: FlexibleSpaceBar( - title: Title( - controller, - storeInfo != null ? storeInfo.storeName : '', - ), - collapseMode: CollapseMode.pin, - stretchModes: [ - StretchMode.zoomBackground, - StretchMode.fadeTitle, - StretchMode.blurBackground, - ], - background: Stack( - children: [ - Positioned( + ), + flexibleSpace: FlexibleSpaceBar( + title: Title( + controller, + storeInfo != null ? storeInfo.storeName : '', + ), + collapseMode: CollapseMode.pin, + stretchModes: [ + StretchMode.zoomBackground, + StretchMode.fadeTitle, + StretchMode.blurBackground, + ], + background: Stack( + children: [ + Positioned( + child: Column( + children: [ + buildSwiper(), + Expanded( + child: Container( + color: Colors.transparent, + ), + flex: 1, + ), + ], + ), + top: 0, + bottom: 0, + left: 0, + right: 0, + ), + Positioned( + child: Container( child: Column( children: [ - buildSwiper(), - Expanded( - child: Container( - color: Colors.transparent, + ///门店信息 + StoreInfoView(storeInfo), + + ///门店对应优惠券 + if (storeInfo != null && + storeInfo.couponVOList != null) + UnionCoupon( + storeInfo, + _receiveCoupon, + coupon: true, ), - flex: 1, - ), + + if (storeInfo == null || + storeInfo.couponVOList == null) + SizedBox( + height: 8, + ), + + ///门店对应VIP信息 + Vip(storeInfo, () {}, false), ], ), - top: 0, - bottom: 0, - left: 0, - right: 0, ), - Positioned( - child: Container( - child: Column( - children: [ - ///门店信息 - StoreInfoView(storeInfo), - - ///门店对应优惠券 - if (storeInfo != null && - storeInfo.couponVOList != null) - UnionCoupon( - storeInfo, - _receiveCoupon, - coupon: true, - ), - - if (storeInfo == null || - storeInfo.couponVOList == null) - SizedBox( - height: 8, - ), - - ///门店对应VIP信息 - Vip(storeInfo, () {}, false), - ], - ), - ), - top: 110.h, - bottom: 0, - left: 0, - right: 0, - ), - ], - ), + top: 110.h, + bottom: 0, + left: 0, + right: 0, + ), + ], ), - backgroundColor: Color(0x33FAFAFA), - centerTitle: false, - elevation: 0, - bottom: PreferredSize( - preferredSize: Size( - MediaQuery.of(context).size.width, - 38, - ), - child: Container( - padding: EdgeInsets.symmetric(horizontal: 10.w), - width: MediaQuery.of(context).size.width, - child: TabBar( - controller: tabcontroller, - automaticIndicatorColorAdjustment: true, - isScrollable: true, - indicatorWeight: 1, - indicatorColor: Color(0xFFFAFAFA), - labelPadding: EdgeInsets.only( - left: 8.w, - right: 8.w, - ), - indicatorSize: TabBarIndicatorSize.label, - unselectedLabelStyle: TextStyle( - fontSize: 15.sp, - fontWeight: FontWeight.w400, - ), - labelStyle: TextStyle( - color: Colors.black, - fontSize: 18.sp, - fontWeight: FontWeight.bold, - ), - labelColor: Colors.black, - tabs: [ - MyTab(text: S.of(context).diancan), - MyTab(text: S.of(context).xindianhuodong), - ], + ), + backgroundColor: Color(0x33FAFAFA), + centerTitle: false, + elevation: 0, + bottom: PreferredSize( + preferredSize: Size( + MediaQuery.of(context).size.width, + 38, + ), + child: Container( + padding: EdgeInsets.symmetric(horizontal: 10.w), + width: MediaQuery.of(context).size.width, + child: TabBar( + controller: tabcontroller, + automaticIndicatorColorAdjustment: true, + isScrollable: true, + indicatorWeight: 1, + indicatorColor: Color(0xFFFAFAFA), + labelPadding: EdgeInsets.only( + left: 8.w, + right: 8.w, + ), + indicatorSize: TabBarIndicatorSize.label, + unselectedLabelStyle: TextStyle( + fontSize: 15.sp, + fontWeight: FontWeight.w400, + ), + labelStyle: TextStyle( + color: Colors.black, + fontSize: 18.sp, + fontWeight: FontWeight.bold, ), + labelColor: Colors.black, + tabs: [ + MyTab(text: S.of(context).diancan), + MyTab(text: S.of(context).xindianhuodong), + ], ), ), ), ), - ]; - }, - body: TabBarView( - physics: BouncingScrollPhysics(), - children: [ - StoreOrderListPage( - widget.arguments, - activitys, - storeInfo, - shopCarGoods, - controller, - _queryMiNiDetail, - ), + ), + ]; + }, + body: TabBarView( + physics: BouncingScrollPhysics(), + children: [ + StoreOrderListPage( + widget.arguments, + activitys, + storeInfo, + shopCarGoods, + controller, + _queryMiNiDetail, + ), - ///星店活动, - StoreActivity( - widget.arguments, - activitys, - ), - ], - controller: tabcontroller, - ), + ///星店活动, + StoreActivity( + widget.arguments, + activitys, + ), + ], + controller: tabcontroller, ), ), ), @@ -424,6 +446,21 @@ class _StoreOrderPage extends State ); } + showPeopleNum(String tableName) async { + var people = await showDialog( + context: context, + builder: (context) { + return PeopleNumView(tableName); + }, + ); + + if (people != null && people > 0) { + setState(() { + this.numberOfPeople = people; + }); + } + } + ///计算个数 int count() { if (shopCarGoods == null || @@ -555,7 +592,8 @@ class _StoreOrderPage extends State ///添加购物车 Future _addShopCar(MiNiDetail miNiDetail, selectSkus, int count) async { - ProductSkuVOListBean productSku = miNiDetail.productSkuVOList.firstWhere((element) { + ProductSkuVOListBean productSku = + miNiDetail.productSkuVOList.firstWhere((element) { bool gg = true; selectSkus.forEach((element1) { if (element.skuNameStr.indexOf(element1) < 0) { @@ -567,13 +605,18 @@ class _StoreOrderPage extends State }); if (productSku == null) return; String skuId = productSku.id; - String skuValue = selectSkus.toString().replaceAll("[", "").replaceAll("]", "").replaceAll(",", ""); + String skuValue = selectSkus + .toString() + .replaceAll("[", "") + .replaceAll("]", "") + .replaceAll(",", ""); if (miNiDetail != null) { BaseData> baseDate = await minService.addShoppingCart({ "storeId": storeInfo.id, "storeName": storeInfo.storeName ?? "", - "tableId": 0, + "numberOfPeople": numberOfPeople, + "tableId": tableId, "shoppingCartSkuItemList": [ { "buyNum": count, @@ -584,7 +627,7 @@ class _StoreOrderPage extends State "storeId": storeInfo.id, "skuPrice": productSku.applyPrice, "skuStock": productSku.skuStock, - "tableId": 0, + "tableId": tableId, }, ], }); @@ -599,7 +642,8 @@ class _StoreOrderPage extends State ///查询购物车 Future queryShopCar() async { - BaseData> baseDate = await minService.getShoppingCart(0); + BaseData> baseDate = + await minService.getShoppingCart(tableId); if (baseDate != null && baseDate.isSuccess && baseDate.data != null && @@ -615,7 +659,8 @@ class _StoreOrderPage extends State Map shopCarTemp = shopCarGoods.toJson(); cartSkuItem.buyNum += 1; shopCarTemp["shoppingCartSkuItemList"] = [cartSkuItem.toJson()]; - BaseData> baseDate = await minService.shoppingCartSingle(shopCarTemp); + BaseData> baseDate = + await minService.shoppingCartSingle(shopCarTemp); if (baseDate.isSuccess) { queryShopCar().then((value) { this.shopCarGoods = value; @@ -632,7 +677,8 @@ class _StoreOrderPage extends State Map shopCarTemp = shopCarGoods.toJson(); cartSkuItem.buyNum -= 1; shopCarTemp["shoppingCartSkuItemList"] = [cartSkuItem.toJson()]; - BaseData> baseDate = await minService.shoppingCartSingle(shopCarTemp); + BaseData> baseDate = + await minService.shoppingCartSingle(shopCarTemp); if (baseDate.isSuccess) { queryShopCar().then((value) { this.shopCarGoods = value; @@ -646,7 +692,8 @@ class _StoreOrderPage extends State ///商品➕1 add(MiNiDetail miNiDetail, selectSkus) async { - ProductSkuVOListBean productSku = miNiDetail.productSkuVOList.firstWhere((element) { + ProductSkuVOListBean productSku = + miNiDetail.productSkuVOList.firstWhere((element) { return skuY(element, selectSkus); }); @@ -656,20 +703,24 @@ class _StoreOrderPage extends State await _addShopCar(miNiDetail, selectSkus, 2); return; } - int shopSkuIndex = shopCarGoods.shoppingCartSkuItemList.indexWhere((element) => skuId == element.id); + int shopSkuIndex = shopCarGoods.shoppingCartSkuItemList + .indexWhere((element) => skuId == element.id); Map shopCarTemp = shopCarGoods.toJson(); - shopCarGoods.tableId = "0"; + shopCarGoods.tableId = "$tableId"; if (shopSkuIndex >= 0) { shopCarGoods.shoppingCartSkuItemList[shopSkuIndex].buyNum += 1; - ShoppingCartSkuItemListBean cartSkuItem = shopCarGoods.shoppingCartSkuItemList.firstWhere((element) => skuId == element.id); + ShoppingCartSkuItemListBean cartSkuItem = shopCarGoods + .shoppingCartSkuItemList + .firstWhere((element) => skuId == element.id); shopCarTemp["shoppingCartSkuItemList"] = [cartSkuItem.toJson()]; } else { await _addShopCar(miNiDetail, selectSkus, 2); return; } - BaseData> baseDate = await minService.shoppingCartSingle(shopCarTemp); + BaseData> baseDate = + await minService.shoppingCartSingle(shopCarTemp); if (baseDate.isSuccess) { queryShopCar().then((value) { this.shopCarGoods = value; @@ -680,7 +731,8 @@ class _StoreOrderPage extends State ///商品➖1 reduce(MiNiDetail miNiDetail, selectSkus) async { - ProductSkuVOListBean productSku = miNiDetail.productSkuVOList.firstWhere((element) { + ProductSkuVOListBean productSku = + miNiDetail.productSkuVOList.firstWhere((element) { return skuY(element, selectSkus); }); @@ -690,8 +742,11 @@ class _StoreOrderPage extends State await _addShopCar(miNiDetail, selectSkus, 2); return; } - ShoppingCartSkuItemListBean shopSkuItem = shopCarGoods.shoppingCartSkuItemList.firstWhere((element) => skuId == element.skuId); - int shopSkuIndex = shopCarGoods.shoppingCartSkuItemList.indexWhere((element) => skuId == element.skuId); + ShoppingCartSkuItemListBean shopSkuItem = shopCarGoods + .shoppingCartSkuItemList + .firstWhere((element) => skuId == element.skuId); + int shopSkuIndex = shopCarGoods.shoppingCartSkuItemList + .indexWhere((element) => skuId == element.skuId); if (shopSkuItem != null) { if (shopSkuItem.buyNum > 1) { @@ -701,13 +756,16 @@ class _StoreOrderPage extends State await _addShopCar(miNiDetail, selectSkus, 2); return; } - shopCarGoods.tableId = "0"; + shopCarGoods.tableId = "$tableId"; Map shopCarTemp = shopCarGoods.toJson(); - ShoppingCartSkuItemListBean cartSkuItem = shopCarGoods.shoppingCartSkuItemList.firstWhere((element) => skuId == element.id); + ShoppingCartSkuItemListBean cartSkuItem = shopCarGoods + .shoppingCartSkuItemList + .firstWhere((element) => skuId == element.id); shopCarTemp["shoppingCartSkuItemList"] = [cartSkuItem.toJson()]; - BaseData> baseDate = await minService.shoppingCartSingle(shopCarTemp); + BaseData> baseDate = + await minService.shoppingCartSingle(shopCarTemp); if (baseDate.isSuccess) { queryShopCar().then((value) { this.shopCarGoods = value; @@ -726,7 +784,6 @@ class _StoreOrderPage extends State }); return gg; } - } class Title extends StatefulWidget { diff --git a/lib/store/store_view/people_num.dart b/lib/store/store_view/people_num.dart new file mode 100644 index 00000000..cc59b318 --- /dev/null +++ b/lib/store/store_view/people_num.dart @@ -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 createState() { + return _PeopleNumView(); + } +} + +class _PeopleNumView extends State { + 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); + }, + ), + ], + ), + ), + ], + ), + ], + ); + } +} diff --git a/lib/store/store_view/store_activity.dart b/lib/store/store_view/store_activity.dart index 1c2d26e5..7c385d3e 100644 --- a/lib/store/store_view/store_activity.dart +++ b/lib/store/store_view/store_activity.dart @@ -22,11 +22,20 @@ class _StoreActivity extends State { @override Widget build(BuildContext context) { return (widget.activitys == null || widget.activitys.length == 0) - ? NoDataView( - isShowBtn: false, - text: "还没有活动~", - fontSize: 16.sp, - margin: EdgeInsets.only(top: 180.h), + ? Container( + width: MediaQuery.of(context).size.width, + height: MediaQuery.of(context).size.height - (kToolbarHeight + 38 + 54.h), + margin: EdgeInsets.only( + top: (MediaQuery.of(context).padding.top + 38 + kToolbarHeight), + ), + color: Colors.white, + child: NoDataView( + isShowBtn: false, + text: "还没有活动~", + iconWidth: 220, + iconHeight: 140, + fontSize: 16.sp, + ), ) : Container( width: MediaQuery.of(context).size.width, @@ -51,7 +60,7 @@ class _StoreActivity extends State { '/router/web_page', arguments: { "activityId": widget.activitys[position].id, - "source": widget.arguments["id"] + "source": widget.arguments["id"], }, ); } diff --git a/lib/store/store_view/store_order_list.dart b/lib/store/store_view/store_order_list.dart index 83817f88..99dc71ff 100644 --- a/lib/store/store_view/store_order_list.dart +++ b/lib/store/store_view/store_order_list.dart @@ -11,7 +11,9 @@ import 'package:huixiang/retrofit/retrofit_api.dart'; import 'package:huixiang/store/store_view/shop_goods.dart'; import 'package:huixiang/utils/font_weight.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:huixiang/view_widget/classic_header.dart'; import 'package:huixiang/view_widget/round_button.dart'; +import 'package:pull_to_refresh/pull_to_refresh.dart'; import 'package:shared_preferences/shared_preferences.dart'; class StoreOrderListPage extends StatefulWidget { @@ -23,12 +25,13 @@ class StoreOrderListPage extends StatefulWidget { ShoppingCart shopCarGoods; StoreOrderListPage( - this.arguments, - this.activitys, - this.storeInfo, - this.shopCarGoods, - this.controller, - this.queryMiNiDetail,); + this.arguments, + this.activitys, + this.storeInfo, + this.shopCarGoods, + this.controller, + this.queryMiNiDetail, + ); @override State createState() { @@ -64,22 +67,26 @@ class _StoreOrderListPage extends State { ); BaseData> baseData = - await minService.findMiNiGroupList( - { - "id": widget.arguments["id"], - }, - ); + await minService.findMiNiGroupList({ + "id": widget.arguments["id"], + }).catchError((error) { + refreshController.refreshFailed(); + }); if (baseData != null && baseData.isSuccess) { + refreshController.refreshCompleted(); setState(() { appletProducts = baseData.data; - // widget.productListResult(appletProducts); productListBeans.clear(); if (appletProducts.length > 0) - productListBeans.addAll(appletProducts[0].productList); + productListBeans.addAll(appletProducts[isSelected].productList); }); + } else { + refreshController.refreshFailed(); } } + RefreshController refreshController; + @override Widget build(BuildContext context) { return Container( @@ -88,34 +95,51 @@ class _StoreOrderListPage extends State { margin: EdgeInsets.only( top: (MediaQuery.of(context).padding.top + 38 + kToolbarHeight), ), - child: Row( - mainAxisAlignment: MainAxisAlignment.start, - mainAxisSize: MainAxisSize.max, - children: [ - Container( - width: 100.w, - child: ListView.builder( - itemCount: appletProducts == null ? 0 : appletProducts.length, - controller: controller1, - physics: BouncingScrollPhysics(), - padding: EdgeInsets.only(top: 0, bottom: 25), - itemBuilder: (context, position) { - return orderItem(appletProducts[position], position); - }, - ), - ), - Container( - width: MediaQuery.of(context).size.width - 100.w, - child: ListView.builder( - itemCount: productListBeans == null ? 0 : productListBeans.length, - physics: BouncingScrollPhysics(), - padding: EdgeInsets.zero, - itemBuilder: (context, position) { - return goodsItem(position); - }, - ), + child: SmartRefresher( + controller: refreshController = + RefreshController(initialRefresh: false), + enablePullDown: true, + enablePullUp: false, + header: MyHeader(), + physics: BouncingScrollPhysics(), + onRefresh: () { + appletGoods(); + }, + child: SingleChildScrollView( + child: Row( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.max, + children: [ + Container( + width: 100.w, + child: ListView.builder( + itemCount: appletProducts == null ? 0 : appletProducts.length, + controller: controller1, + physics: BouncingScrollPhysics(), + shrinkWrap: true, + padding: EdgeInsets.only(top: 0, bottom: 25), + itemBuilder: (context, position) { + return orderItem(appletProducts[position], position); + }, + ), + ), + Container( + width: MediaQuery.of(context).size.width - 100.w, + child: ListView.builder( + itemCount: + productListBeans == null ? 0 : productListBeans.length, + physics: BouncingScrollPhysics(), + shrinkWrap: true, + padding: EdgeInsets.zero, + itemBuilder: (context, position) { + return goodsItem(position); + }, + ), + ), + ], ), - ], + ), ), ); } @@ -228,8 +252,8 @@ class _StoreOrderListPage extends State { (ShoppingCartSkuItemListBean shoppingCartSkuItemListBean) { widget.queryMiNiDetail(productListBeans[position].id); }, - (ShoppingCartSkuItemListBean shoppingCartSkuItemListBean) { - widget.queryMiNiDetail(productListBeans[position].id); + (ShoppingCartSkuItemListBean shoppingCartSkuItemListBean) { + widget.queryMiNiDetail(productListBeans[position].id); }, productListBean: productListBeans[position], count: count, diff --git a/lib/union/union_page.dart b/lib/union/union_page.dart index 66e40ad3..7762ab6e 100644 --- a/lib/union/union_page.dart +++ b/lib/union/union_page.dart @@ -12,6 +12,7 @@ import 'package:huixiang/generated/l10n.dart'; import 'package:huixiang/main.dart'; import 'package:huixiang/retrofit/data/base_data.dart'; import 'package:huixiang/retrofit/data/store.dart'; +import 'package:huixiang/retrofit/data/store_type.dart'; import 'package:huixiang/retrofit/retrofit_api.dart'; import 'package:huixiang/utils/event_type.dart'; import 'package:huixiang/utils/location.dart'; @@ -20,6 +21,8 @@ import 'package:huixiang/view_widget/custom_image.dart'; import 'package:huixiang/view_widget/icon_text.dart'; import 'package:huixiang/view_widget/item_title.dart'; import 'package:huixiang/view_widget/my_appbar.dart'; +import 'package:huixiang/view_widget/request_permission.dart'; +import 'package:permission_handler/permission_handler.dart'; import 'package:pull_to_refresh/pull_to_refresh.dart'; import 'package:shared_preferences/shared_preferences.dart'; import 'package:flutter/rendering.dart'; @@ -263,21 +266,26 @@ class _UnionPage extends State }, child: ListView.builder( itemCount: storeList == null ? 0 : storeList.length, - // padding: EdgeInsets.only(top: 8.h, bottom: 84.h + (375.h - 88.h) + 4.h), padding: EdgeInsets.only( - top: 8.h, bottom: 84.h /* + (375.h - 88.h) + 4.h*/), + top: 8.h, + bottom: 84.h, /* + (375.h - 88.h) + 4.h*/ + ), physics: NeverScrollableScrollPhysics(), itemBuilder: (context, position) { return GestureDetector( onTap: () { - Navigator.of(context).pushNamed( - '/router/store_order', - arguments: { - "id": storeList[position].id, - "tenant": storeList[position].tenantCode, - "storeName": storeList[position].storeName - }, - ); + if(storeList[position].posType.code == "NORMALSTORE") { + toScan(storeList[position]); + } else { + Navigator.of(context).pushNamed( + '/router/store_order', + arguments: { + "id": storeList[position].id, + "tenant": storeList[position].tenantCode, + "storeName": storeList[position].storeName + }, + ); + } }, child: buildStoreItem(storeList[position], position), ); @@ -293,6 +301,58 @@ class _UnionPage extends State _mapController = controller; } + toScan(Store store) async { + Navigator.of(context).pushNamed( + '/router/store_order', + arguments: { + "id": store.id, + "tenant": store.tenantCode, + "storeName": store.storeName, + "tableId": 1315903669597634560, + }, + ); + + // if (await Permission.camera.isPermanentlyDenied) { + // showCupertinoDialog( + // context: context, + // builder: (context) { + // return RequestPermission( + // "assets/image/icon_camera_permission_tips.png", + // S.of(context).ninxiangjiquanxianweikaiqi, + // S.of(context).weilekaipaizhaoxuanzhetouxiang, + // S.of(context).kaiqiquanxian, + // (result) async { + // if (result) { + // await openAppSettings(); + // } + // }, + // heightRatioWithWidth: 0.82, + // ); + // }); + // } else if (await Permission.camera.isGranted) { + // var result = await Navigator.of(context).pushNamed('/router/qr_scan'); + // + // if (result != null && result != "") { + // Uri uri = Uri.parse(result); + // String table = uri.queryParameters["tableId"]; + // if (table != null && table != "") { + // int tableId = int.tryParse(table); + // Navigator.of(context).pushNamed( + // '/router/store_order', + // arguments: { + // "id": store.id, + // "tenant": store.tenantCode, + // "storeName": store.storeName, + // "tableId": tableId, + // }, + // ); + // } + // } + // } else { + // await Permission.camera.request(); + // } + } + Widget buildSearchItem() { return Container( height: 36.h, diff --git a/lib/view_widget/no_data_view.dart b/lib/view_widget/no_data_view.dart index 03a40908..28a5ddce 100644 --- a/lib/view_widget/no_data_view.dart +++ b/lib/view_widget/no_data_view.dart @@ -6,13 +6,18 @@ class NoDataView extends StatelessWidget { final bool isShowBtn; final String text; final double fontSize; + final double iconWidth; + final double iconHeight; final EdgeInsets margin; - NoDataView( - {this.isShowBtn = true, - this.text, - this.fontSize, - this.margin = const EdgeInsets.only(top: 30)}); + NoDataView({ + this.isShowBtn = true, + this.text, + this.fontSize, + this.iconWidth = 270, + this.iconHeight = 180, + this.margin = const EdgeInsets.only(top: 30), + }); @override Widget build(BuildContext context) { @@ -21,7 +26,11 @@ class NoDataView extends StatelessWidget { alignment: Alignment.center, child: Column( children: [ - Image(image: AssetImage("assets/image/icon_empty.png")), + Image( + image: AssetImage("assets/image/icon_empty.png"), + width: iconWidth, + height: iconHeight, + ), SizedBox( height: 35.h, ), @@ -46,7 +55,7 @@ class NoDataView extends StatelessWidget { backgroup: Color(0xFF32A060), radius: 4, ), - ) + ), ], ), ); diff --git a/pubspec.lock b/pubspec.lock index aee75a6d..0f090c29 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -375,13 +375,13 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "1.0.11" - flutter_qr_reader: + flutter_scankit: dependency: "direct main" description: - name: flutter_qr_reader + name: flutter_scankit url: "https://pub.flutter-io.cn" source: hosted - version: "1.0.5" + version: "1.2.0" flutter_screenutil: dependency: "direct main" description: diff --git a/pubspec.yaml b/pubspec.yaml index cb37c7c2..e657ae81 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -54,7 +54,7 @@ dependencies: flutter_smart_dialog: ^2.1.6 barcode_widget: ^2.0.1 - flutter_qr_reader: ^1.0.5 +# flutter_qr_reader: ^1.0.5 qr_flutter: ^4.0.0 url_launcher: ^5.0.0 @@ -64,6 +64,8 @@ dependencies: #多图, 裁剪 image_pickers: ^2.0.0 + flutter_scankit: ^1.2.0 + # 数量,视频时长 # images_picker: ^1.2.4 From 8d1f3e08beca3575c575bfa0610df07f293b48ea Mon Sep 17 00:00:00 2001 From: fmk Date: Fri, 22 Oct 2021 19:21:43 +0800 Subject: [PATCH 07/20] safety --- lib/store/store_order.dart | 322 +++++++++++---------- lib/store/store_view/store_order_list.dart | 83 +++--- 2 files changed, 202 insertions(+), 203 deletions(-) diff --git a/lib/store/store_order.dart b/lib/store/store_order.dart index 45348499..24ec32c6 100644 --- a/lib/store/store_order.dart +++ b/lib/store/store_order.dart @@ -43,7 +43,7 @@ class StoreOrderPage extends StatefulWidget { } class _StoreOrderPage extends State - with TickerProviderStateMixin /*, AutomaticKeepAliveClientMixin*/ { + with TickerProviderStateMixin { TabController tabcontroller; ApiService apiService; MinApiService minService; @@ -125,9 +125,7 @@ class _StoreOrderPage extends State await minService.getParentInfo("$tableId").catchError((error) { debugPrint(error); }); - if (baseData != null && baseData.isSuccess) { - - } + if (baseData != null && baseData.isSuccess) {} } ///获取桌子信息 @@ -164,6 +162,8 @@ class _StoreOrderPage extends State } } + RefreshController refreshController; + @override Widget build(BuildContext context) { return Stack( @@ -173,173 +173,181 @@ class _StoreOrderPage extends State right: 0, top: 0, bottom: 54.h, - child: DefaultTabController( - length: 2, - child: NestedScrollView( - controller: controller, - dragStartBehavior: DragStartBehavior.start, - physics: BouncingScrollPhysics(), - headerSliverBuilder: - (BuildContext context, bool innerBoxIsScrolled) { - return [ - SliverOverlapAbsorber( - handle: NestedScrollView.sliverOverlapAbsorberHandleFor( - context), - sliver: SliverAppBar( - expandedHeight: - (storeInfo != null && storeInfo.couponVOList != null) - ? 470.h - : 365.h, - floating: false, - snap: false, - pinned: true, - stretch: false, - brightness: Brightness.light, - leading: GestureDetector( - onTap: () { - Navigator.of(context).pop(); - }, - child: Container( - alignment: Alignment.centerRight, - margin: EdgeInsets.only(left: 10), - padding: EdgeInsets.all(6), - child: Icon( - Icons.arrow_back_ios, - color: Colors.black, - size: 24, - ), + child: NestedScrollView( + controller: controller, + dragStartBehavior: DragStartBehavior.start, + physics: BouncingScrollPhysics(), + headerSliverBuilder: (BuildContext context, bool innerScrolled) { + return [ + SliverOverlapAbsorber( + handle: NestedScrollView.sliverOverlapAbsorberHandleFor( + context), + sliver: SliverAppBar( + expandedHeight: + (storeInfo != null && storeInfo.couponVOList != null) + ? 470.h + : 365.h, + floating: false, + snap: false, + pinned: true, + stretch: false, + brightness: Brightness.light, + leading: GestureDetector( + onTap: () { + Navigator.of(context).pop(); + }, + child: Container( + alignment: Alignment.centerRight, + margin: EdgeInsets.only(left: 10), + padding: EdgeInsets.all(6), + child: Icon( + Icons.arrow_back_ios, + color: Colors.black, + size: 24, ), ), - flexibleSpace: FlexibleSpaceBar( - title: Title( - controller, - storeInfo != null ? storeInfo.storeName : '', - ), - collapseMode: CollapseMode.pin, - stretchModes: [ - StretchMode.zoomBackground, - StretchMode.fadeTitle, - StretchMode.blurBackground, - ], - background: Stack( - children: [ - Positioned( + ), + flexibleSpace: FlexibleSpaceBar( + title: Title( + controller, + storeInfo != null ? storeInfo.storeName : '', + ), + collapseMode: CollapseMode.pin, + stretchModes: [ + StretchMode.zoomBackground, + StretchMode.fadeTitle, + StretchMode.blurBackground, + ], + background: Stack( + children: [ + Positioned( + child: Column( + children: [ + buildSwiper(), + Expanded( + child: Container( + color: Colors.transparent, + ), + flex: 1, + ), + ], + ), + top: 0, + bottom: 0, + left: 0, + right: 0, + ), + Positioned( + child: Container( child: Column( children: [ - buildSwiper(), - Expanded( - child: Container( - color: Colors.transparent, + ///门店信息 + StoreInfoView(storeInfo), + + ///门店对应优惠券 + if (storeInfo != null && + storeInfo.couponVOList != null) + UnionCoupon( + storeInfo, + _receiveCoupon, + coupon: true, ), - flex: 1, - ), + + if (storeInfo == null || + storeInfo.couponVOList == null) + SizedBox( + height: 8, + ), + + ///门店对应VIP信息 + Vip(storeInfo, () {}, false), ], ), - top: 0, - bottom: 0, - left: 0, - right: 0, - ), - Positioned( - child: Container( - child: Column( - children: [ - ///门店信息 - StoreInfoView(storeInfo), - - ///门店对应优惠券 - if (storeInfo != null && - storeInfo.couponVOList != null) - UnionCoupon( - storeInfo, - _receiveCoupon, - coupon: true, - ), - - if (storeInfo == null || - storeInfo.couponVOList == null) - SizedBox( - height: 8, - ), - - ///门店对应VIP信息 - Vip(storeInfo, () {}, false), - ], - ), - ), - top: 110.h, - bottom: 0, - left: 0, - right: 0, ), - ], - ), + top: 110.h, + bottom: 0, + left: 0, + right: 0, + ), + ], ), - backgroundColor: Color(0x33FAFAFA), - centerTitle: false, - elevation: 0, - bottom: PreferredSize( - preferredSize: Size( - MediaQuery.of(context).size.width, - 38, - ), - child: Container( - padding: EdgeInsets.symmetric(horizontal: 10.w), - width: MediaQuery.of(context).size.width, - child: TabBar( - controller: tabcontroller, - automaticIndicatorColorAdjustment: true, - isScrollable: true, - indicatorWeight: 1, - indicatorColor: Color(0xFFFAFAFA), - labelPadding: EdgeInsets.only( - left: 8.w, - right: 8.w, - ), - indicatorSize: TabBarIndicatorSize.label, - unselectedLabelStyle: TextStyle( - fontSize: 15.sp, - fontWeight: FontWeight.w400, - ), - labelStyle: TextStyle( - color: Colors.black, - fontSize: 18.sp, - fontWeight: FontWeight.bold, - ), - labelColor: Colors.black, - tabs: [ - MyTab(text: S.of(context).diancan), - MyTab(text: S.of(context).xindianhuodong), - ], + ), + backgroundColor: Color(0x33FAFAFA), + centerTitle: false, + elevation: 0, + bottom: PreferredSize( + preferredSize: Size( + MediaQuery.of(context).size.width, + 38, + ), + child: Container( + padding: EdgeInsets.symmetric(horizontal: 10.w), + width: MediaQuery.of(context).size.width, + child: TabBar( + controller: tabcontroller, + automaticIndicatorColorAdjustment: true, + isScrollable: true, + indicatorWeight: 1, + indicatorColor: Color(0xFFFAFAFA), + labelPadding: EdgeInsets.only( + left: 8.w, + right: 8.w, + ), + indicatorSize: TabBarIndicatorSize.label, + unselectedLabelStyle: TextStyle( + fontSize: 15.sp, + fontWeight: FontWeight.w400, + ), + labelStyle: TextStyle( + color: Colors.black, + fontSize: 18.sp, + fontWeight: FontWeight.bold, ), + labelColor: Colors.black, + tabs: [ + MyTab(text: S.of(context).diancan), + MyTab(text: S.of(context).xindianhuodong), + ], ), ), ), ), - ]; - }, - body: TabBarView( - physics: BouncingScrollPhysics(), - children: [ - StoreOrderListPage( - widget.arguments, - activitys, - storeInfo, - shopCarGoods, - controller, - _queryMiNiDetail, - ), + ), + ]; + }, + body: TabBarView( + physics: NeverScrollableScrollPhysics(), + children: [ + ///点餐 + StoreOrderListPage( + widget.arguments, + activitys, + storeInfo, + shopCarGoods, + controller, + _queryMiNiDetail, + ), - ///星店活动, - StoreActivity( - widget.arguments, - activitys, - ), - ], - controller: tabcontroller, - ), + ///星店活动, + StoreActivity( + widget.arguments, + activitys, + ), + ], + controller: tabcontroller, ), - ), + ),/*SmartRefresher( + controller: refreshController = + RefreshController(initialRefresh: false), + enablePullDown: true, + enablePullUp: false, + header: MyHeader(), + physics: BouncingScrollPhysics(), + onRefresh: () { + queryStoreInfo(); + }, + child: + ),*/ ), Positioned( bottom: 0, @@ -446,9 +454,11 @@ class _StoreOrderPage extends State ); } + ///显示选择人数的弹窗 showPeopleNum(String tableName) async { var people = await showDialog( context: context, + barrierDismissible: false, builder: (context) { return PeopleNumView(tableName); }, @@ -458,6 +468,8 @@ class _StoreOrderPage extends State setState(() { this.numberOfPeople = people; }); + } else { + Navigator.of(context).pop(); } } diff --git a/lib/store/store_view/store_order_list.dart b/lib/store/store_view/store_order_list.dart index 99dc71ff..07f8fa29 100644 --- a/lib/store/store_view/store_order_list.dart +++ b/lib/store/store_view/store_order_list.dart @@ -70,10 +70,10 @@ class _StoreOrderListPage extends State { await minService.findMiNiGroupList({ "id": widget.arguments["id"], }).catchError((error) { - refreshController.refreshFailed(); + // refreshController.refreshFailed(); }); if (baseData != null && baseData.isSuccess) { - refreshController.refreshCompleted(); + // refreshController.refreshCompleted(); setState(() { appletProducts = baseData.data; productListBeans.clear(); @@ -81,11 +81,11 @@ class _StoreOrderListPage extends State { productListBeans.addAll(appletProducts[isSelected].productList); }); } else { - refreshController.refreshFailed(); + // refreshController.refreshFailed(); } } - RefreshController refreshController; + // RefreshController refreshController; @override Widget build(BuildContext context) { @@ -95,51 +95,38 @@ class _StoreOrderListPage extends State { margin: EdgeInsets.only( top: (MediaQuery.of(context).padding.top + 38 + kToolbarHeight), ), - child: SmartRefresher( - controller: refreshController = - RefreshController(initialRefresh: false), - enablePullDown: true, - enablePullUp: false, - header: MyHeader(), - physics: BouncingScrollPhysics(), - onRefresh: () { - appletGoods(); - }, - child: SingleChildScrollView( - child: Row( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisSize: MainAxisSize.max, - children: [ - Container( - width: 100.w, - child: ListView.builder( - itemCount: appletProducts == null ? 0 : appletProducts.length, - controller: controller1, - physics: BouncingScrollPhysics(), - shrinkWrap: true, - padding: EdgeInsets.only(top: 0, bottom: 25), - itemBuilder: (context, position) { - return orderItem(appletProducts[position], position); - }, - ), - ), - Container( - width: MediaQuery.of(context).size.width - 100.w, - child: ListView.builder( - itemCount: - productListBeans == null ? 0 : productListBeans.length, - physics: BouncingScrollPhysics(), - shrinkWrap: true, - padding: EdgeInsets.zero, - itemBuilder: (context, position) { - return goodsItem(position); - }, - ), - ), - ], + child: Row( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.max, + children: [ + Container( + width: 100.w, + child: ListView.builder( + itemCount: appletProducts == null ? 0 : appletProducts.length, + controller: controller1, + physics: BouncingScrollPhysics(), + shrinkWrap: true, + padding: EdgeInsets.only(top: 0, bottom: 25), + itemBuilder: (context, position) { + return orderItem(appletProducts[position], position); + }, + ), ), - ), + Container( + width: MediaQuery.of(context).size.width - 100.w, + child: ListView.builder( + itemCount: + productListBeans == null ? 0 : productListBeans.length, + physics: BouncingScrollPhysics(), + shrinkWrap: true, + padding: EdgeInsets.zero, + itemBuilder: (context, position) { + return goodsItem(position); + }, + ), + ), + ], ), ); } From b25139adcb926e7a08dd2898c5f5e51b1af64342 Mon Sep 17 00:00:00 2001 From: fmk Date: Sat, 23 Oct 2021 18:29:55 +0800 Subject: [PATCH 08/20] safety --- ios/Podfile.lock | 70 +- ios/Runner.xcodeproj/project.pbxproj | 45 +- lib/retrofit/data/base_data.g.dart | 37 - lib/retrofit/data/min_order_info.dart | 713 +++++++++ lib/retrofit/data/page.g.dart | 41 - lib/retrofit/data/placeOrderFirst.dart | 5 +- lib/retrofit/min_api.dart | 9 + lib/retrofit/min_api.g.dart | 338 ----- lib/retrofit/retrofit_api.g.dart | 1349 ----------------- lib/settlement/settlement.dart | 133 +- .../settlement_order_commodity.dart | 39 +- lib/store/store_order.dart | 2 +- lib/union/union_page.dart | 96 +- pubspec.yaml | 18 +- 14 files changed, 989 insertions(+), 1906 deletions(-) delete mode 100644 lib/retrofit/data/base_data.g.dart create mode 100644 lib/retrofit/data/min_order_info.dart delete mode 100644 lib/retrofit/data/page.g.dart delete mode 100644 lib/retrofit/min_api.g.dart delete mode 100644 lib/retrofit/retrofit_api.g.dart diff --git a/ios/Podfile.lock b/ios/Podfile.lock index e30b0e1c..aaf89031 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -1,4 +1,19 @@ PODS: + - AFNetworking (4.0.1): + - AFNetworking/NSURLSession (= 4.0.1) + - AFNetworking/Reachability (= 4.0.1) + - AFNetworking/Security (= 4.0.1) + - AFNetworking/Serialization (= 4.0.1) + - AFNetworking/UIKit (= 4.0.1) + - AFNetworking/NSURLSession (4.0.1): + - AFNetworking/Reachability + - AFNetworking/Security + - AFNetworking/Serialization + - AFNetworking/Reachability (4.0.1) + - AFNetworking/Security (4.0.1) + - AFNetworking/Serialization (4.0.1) + - AFNetworking/UIKit (4.0.1): + - AFNetworking/NSURLSession - BaiduMapKit/Base (6.2.0) - BaiduMapKit/Map (6.2.0): - BaiduMapKit/Base @@ -26,18 +41,19 @@ PODS: - flutter_bmflocation (1.0.3): - BMKLocationKit - Flutter - - flutter_qr_reader (0.0.1): + - flutter_scankit (0.0.1): - Flutter + - ScanKitFrameWork (~> 1.0.2.300) - fluwx (0.0.1): - Flutter + - WechatOpenSDK_Fuck (~> 1.9.2) - FMDB (2.7.5): - FMDB/standard (= 2.7.5) - FMDB/standard (2.7.5) - - image_cropper (0.0.4): - - Flutter - - TOCropViewController (~> 2.6.0) - - image_picker (0.0.1): + - image_pickers (0.0.1): + - AFNetworking - Flutter + - ZLPhotoBrowser-objc (= 1.0.4) - mob_sharesdk (4.4.0): - mob_sharesdk/ShareSDK (= 4.4.0) - MOBFoundation (>= 3.2.9) @@ -68,6 +84,10 @@ PODS: - Flutter - "permission_handler (5.1.0+2)": - Flutter + - ScanKitFrameWork (1.0.2.300) + - SDWebImage (5.12.1): + - SDWebImage/Core (= 5.12.1) + - SDWebImage/Core (5.12.1) - shared_preferences (0.0.1): - Flutter - sharesdk_plugin (1.1.2): @@ -83,7 +103,6 @@ PODS: - Flutter - FMDB (>= 2.7.5) - SSZipArchive (2.4.2) - - TOCropViewController (2.6.0) - TPNS-iOS (1.3.3.0) - tpns_flutter_plugin (1.1.2): - Flutter @@ -96,6 +115,9 @@ PODS: - Flutter - webview_flutter (0.0.1): - Flutter + - WechatOpenSDK_Fuck (1.9.2) + - ZLPhotoBrowser-objc (1.0.4): + - SDWebImage DEPENDENCIES: - Flutter (from `Flutter`) @@ -104,10 +126,9 @@ DEPENDENCIES: - flutter_baidu_mapapi_search (from `.symlinks/plugins/flutter_baidu_mapapi_search/ios`) - flutter_baidu_mapapi_utils (from `.symlinks/plugins/flutter_baidu_mapapi_utils/ios`) - flutter_bmflocation (from `.symlinks/plugins/flutter_bmflocation/ios`) - - flutter_qr_reader (from `.symlinks/plugins/flutter_qr_reader/ios`) + - flutter_scankit (from `.symlinks/plugins/flutter_scankit/ios`) - fluwx (from `.symlinks/plugins/fluwx/ios`) - - image_cropper (from `.symlinks/plugins/image_cropper/ios`) - - image_picker (from `.symlinks/plugins/image_picker/ios`) + - image_pickers (from `.symlinks/plugins/image_pickers/ios`) - package_info (from `.symlinks/plugins/package_info/ios`) - path_provider (from `.symlinks/plugins/path_provider/ios`) - permission_handler (from `.symlinks/plugins/permission_handler/ios`) @@ -123,14 +144,18 @@ DEPENDENCIES: SPEC REPOS: trunk: + - AFNetworking - BaiduMapKit - BMKLocationKit - FMDB - mob_sharesdk - MOBFoundation + - ScanKitFrameWork + - SDWebImage - SSZipArchive - - TOCropViewController - TPNS-iOS + - WechatOpenSDK_Fuck + - ZLPhotoBrowser-objc EXTERNAL SOURCES: Flutter: @@ -145,14 +170,12 @@ EXTERNAL SOURCES: :path: ".symlinks/plugins/flutter_baidu_mapapi_utils/ios" flutter_bmflocation: :path: ".symlinks/plugins/flutter_bmflocation/ios" - flutter_qr_reader: - :path: ".symlinks/plugins/flutter_qr_reader/ios" + flutter_scankit: + :path: ".symlinks/plugins/flutter_scankit/ios" fluwx: :path: ".symlinks/plugins/fluwx/ios" - image_cropper: - :path: ".symlinks/plugins/image_cropper/ios" - image_picker: - :path: ".symlinks/plugins/image_picker/ios" + image_pickers: + :path: ".symlinks/plugins/image_pickers/ios" package_info: :path: ".symlinks/plugins/package_info/ios" path_provider: @@ -177,6 +200,7 @@ EXTERNAL SOURCES: :path: ".symlinks/plugins/webview_flutter/ios" SPEC CHECKSUMS: + AFNetworking: 7864c38297c79aaca1500c33288e429c3451fdce BaiduMapKit: 907c6d9b74f66c3ff4741fc4b568ae0b339917f8 BMKLocationKit: 097814ef672b1e57e86e6c1968d7892fb78002bf Flutter: 434fef37c0980e73bb6479ef766c45957d4b510c @@ -185,28 +209,30 @@ SPEC CHECKSUMS: flutter_baidu_mapapi_search: 4cffaa74e739a4114595c4f82f790e1783bb612d flutter_baidu_mapapi_utils: a5bd582b91ecd35be1bc45558b38f49d5684f70a flutter_bmflocation: 12f1ba91bae4b16d78d4f475023e0254ed351f1c - flutter_qr_reader: d930dde3b2cfe2b3d0bb7d66e5ff3e514300a5e5 - fluwx: c64c2b84b965279aaa251a80b5b6a1cd0ef7bd45 + flutter_scankit: 16936d86b3de3f83c122e763f4c24c5da214c78f + fluwx: c192ef1ea3617badb813fa1a761ffc5c9c12208a FMDB: 2ce00b547f966261cd18927a3ddb07cb6f3db82a - image_cropper: f1668dd8d2cad2d357955caad15a40547856edcb - image_picker: 9c3312491f862b28d21ecd8fdf0ee14e601b3f09 + image_pickers: 25c8916d358bc9d2707cb470ba3d57497f105773 mob_sharesdk: c771f001e00739d24301a9fa250247601efe7a3c MOBFoundation: 2abd23c80c33d1337d30dc4b0018ed914cef8f8e package_info: 873975fc26034f0b863a300ad47e7f1ac6c7ec62 path_provider: f96fff6166a8867510d2c25fdcc346327cc4b259 permission_handler: ccb20a9fad0ee9b1314a52b70b76b473c5f8dab0 + ScanKitFrameWork: 0ad578f3db0ef9b64dd0f533d10d10a52ce93c80 + SDWebImage: 4dc3e42d9ec0c1028b960a33ac6b637bb432207b shared_preferences: af6bfa751691cdc24be3045c43ec037377ada40d sharesdk_plugin: 6d6634bb480174b607030f19fc9d84d68cfbf326 sqflite: 6d358c025f5b867b29ed92fc697fd34924e11904 SSZipArchive: e7b4f3d9e780c2acc1764cd88fbf2de28f26e5b2 - TOCropViewController: 3105367e808b7d3d886a74ff59bf4804e7d3ab38 TPNS-iOS: 57a146496858ba2fb5d43e5f240feb19243b69cb tpns_flutter_plugin: a366649c8ad71f19dfb864d3c994ed0480b69daa url_launcher: 6fef411d543ceb26efce54b05a0a40bfd74cbbef video_player: 9cc823b1d9da7e8427ee591e8438bfbcde500e6e wakelock: bfc7955c418d0db797614075aabbc58a39ab5107 webview_flutter: d2b4d6c66968ad042ad94cbb791f5b72b4678a96 + WechatOpenSDK_Fuck: aa8f4b0af902837e887a1d40c62f06c060c1dc98 + ZLPhotoBrowser-objc: c7657d3bc85ae231884e058d0e3638f619164736 PODFILE CHECKSUM: 7092aa3092b9508e0ccea9e76cd5fa33505dbb46 -COCOAPODS: 1.10.1 +COCOAPODS: 1.11.2 diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index 656c85d9..1d593ab0 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -657,6 +657,7 @@ 9705A1C41CF9048500538489 /* Embed Frameworks */, 3B06AD1E1E4923F5004D2608 /* Thin Binary */, 120EAF7195D9AB3BB1E8FA2B /* [CP] Copy Pods Resources */, + 8ADBB1E9F51ACB25060865A4 /* [CP] Embed Pods Frameworks */, ); buildRules = ( ); @@ -763,6 +764,23 @@ shellPath = /bin/sh; shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin"; }; + 8ADBB1E9F51ACB25060865A4 /* [CP] Embed Pods Frameworks */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-input-files.xcfilelist", + ); + name = "[CP] Embed Pods Frameworks"; + outputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-output-files.xcfilelist", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n"; + showEnvVarsInLog = 0; + }; 9740EEB61CF901F6004384FC /* Run Script */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; @@ -892,7 +910,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 9.0; + IPHONEOS_DEPLOYMENT_TARGET = 10.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SUPPORTED_PLATFORMS = iphoneos; @@ -935,8 +953,7 @@ "\"${PODS_ROOT}/Headers/Public/flutter_baidu_mapapi_search\"", "\"${PODS_ROOT}/Headers/Public/flutter_baidu_mapapi_map\"", "\"${PODS_ROOT}/Headers/Public/flutter_baidu_mapapi_base\"", - "\"${PODS_ROOT}/Headers/Public/image_cropper\"", - "\"${PODS_ROOT}/Headers/Public/image_picker\"", + "\"${PODS_ROOT}/Headers/Public/image_pickers\"", "\"${PODS_ROOT}/Headers/Public/path_provider\"", "\"${PODS_ROOT}/Headers/Public/permission_handler\"", "\"${PODS_ROOT}/Headers/Public/shared_preferences\"", @@ -949,6 +966,7 @@ "\"${PODS_ROOT}/Headers/Private/fluwx\"", ); INFOPLIST_FILE = Runner/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 10.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -966,8 +984,7 @@ "$(inherited)", "-ObjC", "-l\"c++\"", - "-l\"image_cropper\"", - "-l\"image_picker\"", + "-l\"image_pickers\"", "-l\"path_provider\"", "-l\"flutter_bmflocation\"", "-l\"flutter_baidu_mapapi_utils\"", @@ -1078,7 +1095,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 9.0; + IPHONEOS_DEPLOYMENT_TARGET = 10.0; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; @@ -1128,7 +1145,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 9.0; + IPHONEOS_DEPLOYMENT_TARGET = 10.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SUPPORTED_PLATFORMS = iphoneos; @@ -1171,8 +1188,7 @@ "\"${PODS_ROOT}/Headers/Public/flutter_baidu_mapapi_search\"", "\"${PODS_ROOT}/Headers/Public/flutter_baidu_mapapi_map\"", "\"${PODS_ROOT}/Headers/Public/flutter_baidu_mapapi_base\"", - "\"${PODS_ROOT}/Headers/Public/image_cropper\"", - "\"${PODS_ROOT}/Headers/Public/image_picker\"", + "\"${PODS_ROOT}/Headers/Public/image_pickers\"", "\"${PODS_ROOT}/Headers/Public/path_provider\"", "\"${PODS_ROOT}/Headers/Public/permission_handler\"", "\"${PODS_ROOT}/Headers/Public/shared_preferences\"", @@ -1185,6 +1201,7 @@ "\"${PODS_ROOT}/Headers/Private/fluwx\"", ); INFOPLIST_FILE = Runner/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 10.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -1202,8 +1219,7 @@ "$(inherited)", "-ObjC", "-l\"c++\"", - "-l\"image_cropper\"", - "-l\"image_picker\"", + "-l\"image_pickers\"", "-l\"path_provider\"", "-l\"flutter_bmflocation\"", "-l\"flutter_baidu_mapapi_utils\"", @@ -1300,8 +1316,7 @@ "\"${PODS_ROOT}/Headers/Public/flutter_baidu_mapapi_search\"", "\"${PODS_ROOT}/Headers/Public/flutter_baidu_mapapi_map\"", "\"${PODS_ROOT}/Headers/Public/flutter_baidu_mapapi_base\"", - "\"${PODS_ROOT}/Headers/Public/image_cropper\"", - "\"${PODS_ROOT}/Headers/Public/image_picker\"", + "\"${PODS_ROOT}/Headers/Public/image_pickers\"", "\"${PODS_ROOT}/Headers/Public/path_provider\"", "\"${PODS_ROOT}/Headers/Public/permission_handler\"", "\"${PODS_ROOT}/Headers/Public/shared_preferences\"", @@ -1314,6 +1329,7 @@ "\"${PODS_ROOT}/Headers/Private/fluwx\"", ); INFOPLIST_FILE = Runner/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 10.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -1331,8 +1347,7 @@ "$(inherited)", "-ObjC", "-l\"c++\"", - "-l\"image_cropper\"", - "-l\"image_picker\"", + "-l\"image_pickers\"", "-l\"path_provider\"", "-l\"flutter_bmflocation\"", "-l\"flutter_baidu_mapapi_utils\"", diff --git a/lib/retrofit/data/base_data.g.dart b/lib/retrofit/data/base_data.g.dart deleted file mode 100644 index 3a4ba372..00000000 --- a/lib/retrofit/data/base_data.g.dart +++ /dev/null @@ -1,37 +0,0 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND - -part of 'base_data.dart'; - -// ************************************************************************** -// JsonSerializableGenerator -// ************************************************************************** - -BaseData _$BaseDataFromJson( - Map json, - T Function(Object json) fromJsonT, -) { - return BaseData() - ..code = json['code'] as int - ..data = fromJsonT(json['data']) - ..extra = json['extra'] - ..isError = json['isError'] as bool - ..isSuccess = json['isSuccess'] as bool - ..msg = json['msg'] as String - ..path = json['path'] as String - ..timestamp = json['timestamp'] as String; -} - -Map _$BaseDataToJson( - BaseData instance, - Object Function(T value) toJsonT, -) => - { - 'code': instance.code, - 'data': toJsonT(instance.data), - 'extra': instance.extra, - 'isError': instance.isError, - 'isSuccess': instance.isSuccess, - 'msg': instance.msg, - 'path': instance.path, - 'timestamp': instance.timestamp, - }; diff --git a/lib/retrofit/data/min_order_info.dart b/lib/retrofit/data/min_order_info.dart new file mode 100644 index 00000000..917d4842 --- /dev/null +++ b/lib/retrofit/data/min_order_info.dart @@ -0,0 +1,713 @@ +import 'package:huixiang/retrofit/data/order_product_vo.dart'; +import 'package:huixiang/retrofit/data/settleOrderInfo.dart'; + +class MinOrderInfo { + MinOrderInfo({ + String id, + String createTime, + String createUser, + String updateTime, + String updateUser, + String tenantCode, + String storeId, + String storeName, + String tableId, + int orderType, + bool clearTable, + String mid, + String parentId, + String parentCode, + String orderCode, + String dayFlowCode, + int orderStatus, + int sendStatus, + int payStatus, + String memberAccount, + String logisticsId, + String shipperCode, + String logisticsName, + String logisticsNum, + dynamic logisticsCase, + int refundStatus, + dynamic addressExt, + String postFee, + String orderSum, + String paySum, + String paySumSub, + String accountPay, + String couponSubPrice, + String customPrice, + String removeDecimal, + bool isSubscribe, + dynamic subcribeTime, + dynamic sendTime, + dynamic confirmTime, + dynamic returnMoneyTime, + String notes, + dynamic prepayId, + dynamic payTime, + int payChannel, + dynamic payNum, + String promotionId, + String couponId, + int isDelete, + int isTakeOut, + int batch, + String orderDiscountPrice, + String dishesDiscountPrice, + String orderPercentPrice, + String finalPayPrice, + String activityNoPrice, + String activityDiscountPrice, + String totalDiscountPrice, + int orderSource, + dynamic address, + dynamic discountPercent, + dynamic discountAmount, + dynamic discountType, + dynamic discountMoney, + dynamic overTime, + List orderProductVOList, + dynamic moneyReturnList, + dynamic goodsReturnList, + dynamic moneyReturnVOList, + dynamic goodsReturnVOList, + dynamic moneyReturnActionHistoryList, + dynamic goodsReturnActionHistoryList, + String currentTime, + dynamic tablePrice, + String tableName, + String balance, + String money, + dynamic prodNum, + bool onCredit, + OrderInfoVo orderInfoVo, + String endPayTime, + String orderSumPrice,}){ + this.id = id; + this.createTime = createTime; + this.createUser = createUser; + this.updateTime = updateTime; + this.updateUser = updateUser; + this.tenantCode = tenantCode; + this.storeId = storeId; + this.storeName = storeName; + this.tableId = tableId; + this.orderType = orderType; + this.clearTable = clearTable; + this.mid = mid; + this.parentId = parentId; + this.parentCode = parentCode; + this.orderCode = orderCode; + this.dayFlowCode = dayFlowCode; + this.orderStatus = orderStatus; + this.sendStatus = sendStatus; + this.payStatus = payStatus; + this.memberAccount = memberAccount; + this.logisticsId = logisticsId; + this.shipperCode = shipperCode; + this.logisticsName = logisticsName; + this.logisticsNum = logisticsNum; + this.logisticsCase = logisticsCase; + this.refundStatus = refundStatus; + this.addressExt = addressExt; + this.postFee = postFee; + this.orderSum = orderSum; + this.paySum = paySum; + this.paySumSub = paySumSub; + this.accountPay = accountPay; + this.couponSubPrice = couponSubPrice; + this.customPrice = customPrice; + this.removeDecimal = removeDecimal; + this.isSubscribe = isSubscribe; + this.subcribeTime = subcribeTime; + this.sendTime = sendTime; + this.confirmTime = confirmTime; + this.returnMoneyTime = returnMoneyTime; + this.notes = notes; + this.prepayId = prepayId; + this.payTime = payTime; + this.payChannel = payChannel; + this.payNum = payNum; + this.promotionId = promotionId; + this.couponId = couponId; + this.isDelete = isDelete; + this.isTakeOut = isTakeOut; + this.batch = batch; + this.orderDiscountPrice = orderDiscountPrice; + this.dishesDiscountPrice = dishesDiscountPrice; + this.orderPercentPrice = orderPercentPrice; + this.finalPayPrice = finalPayPrice; + this.activityNoPrice = activityNoPrice; + this.activityDiscountPrice = activityDiscountPrice; + this.totalDiscountPrice = totalDiscountPrice; + this.orderSource = orderSource; + this.address = address; + this.discountPercent = discountPercent; + this.discountAmount = discountAmount; + this.discountType = discountType; + this.discountMoney = discountMoney; + this.overTime = overTime; + this.orderProductVOList = orderProductVOList; + this.moneyReturnList = moneyReturnList; + this.goodsReturnList = goodsReturnList; + this.moneyReturnVOList = moneyReturnVOList; + this.goodsReturnVOList = goodsReturnVOList; + this.moneyReturnActionHistoryList = moneyReturnActionHistoryList; + this.goodsReturnActionHistoryList = goodsReturnActionHistoryList; + this.currentTime = currentTime; + this.tablePrice = tablePrice; + this.tableName = tableName; + this.balance = balance; + this.money = money; + this.prodNum = prodNum; + this.onCredit = onCredit; + this.orderInfoVo = orderInfoVo; + this.endPayTime = endPayTime; + this.orderSumPrice = orderSumPrice; +} + + MinOrderInfo.fromJson(dynamic json) { + this.id = json['id']; + this.createTime = json['createTime']; + this.createUser = json['createUser']; + this.updateTime = json['updateTime']; + this.updateUser = json['updateUser']; + this.tenantCode = json['tenantCode']; + this.storeId = json['storeId']; + this.storeName = json['storeName']; + this.tableId = json['tableId']; + this.orderType = json['orderType']; + this.clearTable = json['clearTable']; + this.mid = json['mid']; + this.parentId = json['parentId']; + this.parentCode = json['parentCode']; + this.orderCode = json['orderCode']; + this.dayFlowCode = json['dayFlowCode']; + this.orderStatus = json['orderStatus']; + this.sendStatus = json['sendStatus']; + this.payStatus = json['payStatus']; + this.memberAccount = json['memberAccount']; + this.logisticsId = json['logisticsId']; + this.shipperCode = json['shipperCode']; + this.logisticsName = json['logisticsName']; + this.logisticsNum = json['logisticsNum']; + this.logisticsCase = json['logisticsCase']; + this.refundStatus = json['refundStatus']; + this.addressExt = json['addressExt']; + this.postFee = json['postFee']; + this.orderSum = json['orderSum']; + this.paySum = json['paySum']; + this.paySumSub = json['paySumSub']; + this.accountPay = json['accountPay']; + this.couponSubPrice = json['couponSubPrice']; + this.customPrice = json['customPrice']; + this.removeDecimal = json['removeDecimal']; + this.isSubscribe = json['isSubscribe']; + this.subcribeTime = json['subcribeTime']; + this.sendTime = json['sendTime']; + this.confirmTime = json['confirmTime']; + this.returnMoneyTime = json['returnMoneyTime']; + this.notes = json['notes']; + this.prepayId = json['prepayId']; + this.payTime = json['payTime']; + this.payChannel = json['payChannel']; + this.payNum = json['payNum']; + this.promotionId = json['promotionId']; + this.couponId = json['couponId']; + this.isDelete = json['isDelete']; + this.isTakeOut = json['isTakeOut']; + this.batch = json['batch']; + this.orderDiscountPrice = json['orderDiscountPrice']; + this.dishesDiscountPrice = json['dishesDiscountPrice']; + this.orderPercentPrice = json['orderPercentPrice']; + this.finalPayPrice = json['finalPayPrice']; + this.activityNoPrice = json['activityNoPrice']; + this.activityDiscountPrice = json['activityDiscountPrice']; + this.totalDiscountPrice = json['totalDiscountPrice']; + this.orderSource = json['orderSource']; + this.address = json['address']; + this.discountPercent = json['discountPercent']; + this.discountAmount = json['discountAmount']; + this.discountType = json['discountType']; + this.discountMoney = json['discountMoney']; + this.overTime = json['overTime']; + if (json['orderProductVOList'] != null) { + this.orderProductVOList = []; + json['orderProductVOList'].forEach((v) { + this.orderProductVOList.add(OrderProductListBean.fromJson(v)); + }); + } + this.moneyReturnList = json['moneyReturnList']; + this.goodsReturnList = json['goodsReturnList']; + this.moneyReturnVOList = json['moneyReturnVOList']; + this.goodsReturnVOList = json['goodsReturnVOList']; + this.moneyReturnActionHistoryList = json['moneyReturnActionHistoryList']; + this.goodsReturnActionHistoryList = json['goodsReturnActionHistoryList']; + this.currentTime = json['currentTime']; + this.tablePrice = json['tablePrice']; + this.tableName = json['tableName']; + this.balance = json['balance']; + this.money = json['money']; + this.prodNum = json['prodNum']; + this.onCredit = json['onCredit']; + this.orderInfoVo = json['orderInfoVo'] != null ? OrderInfoVo.fromJson(json['orderInfoVo']) : null; + this.endPayTime = json['endPayTime']; + this.orderSumPrice = json['orderSumPrice']; + } + String id; + String createTime; + String createUser; + String updateTime; + String updateUser; + String tenantCode; + String storeId; + String storeName; + String tableId; + int orderType; + bool clearTable; + String mid; + String parentId; + String parentCode; + String orderCode; + String dayFlowCode; + int orderStatus; + int sendStatus; + int payStatus; + String memberAccount; + String logisticsId; + String shipperCode; + String logisticsName; + String logisticsNum; + dynamic logisticsCase; + int refundStatus; + dynamic addressExt; + String postFee; + String orderSum; + String paySum; + String paySumSub; + String accountPay; + String couponSubPrice; + String customPrice; + String removeDecimal; + bool isSubscribe; + dynamic subcribeTime; + dynamic sendTime; + dynamic confirmTime; + dynamic returnMoneyTime; + String notes; + dynamic prepayId; + dynamic payTime; + int payChannel; + dynamic payNum; + String promotionId; + String couponId; + int isDelete; + int isTakeOut; + int batch; + String orderDiscountPrice; + String dishesDiscountPrice; + String orderPercentPrice; + String finalPayPrice; + String activityNoPrice; + String activityDiscountPrice; + String totalDiscountPrice; + int orderSource; + dynamic address; + dynamic discountPercent; + dynamic discountAmount; + dynamic discountType; + dynamic discountMoney; + dynamic overTime; + List orderProductVOList; + dynamic moneyReturnList; + dynamic goodsReturnList; + dynamic moneyReturnVOList; + dynamic goodsReturnVOList; + dynamic moneyReturnActionHistoryList; + dynamic goodsReturnActionHistoryList; + String currentTime; + dynamic tablePrice; + String tableName; + String balance; + String money; + dynamic prodNum; + bool onCredit; + OrderInfoVo orderInfoVo; + String endPayTime; + String orderSumPrice; + + Map toJson() { + final map = {}; + map['id'] = this.id; + map['createTime'] = this.createTime; + map['createUser'] = this.createUser; + map['updateTime'] = this.updateTime; + map['updateUser'] = this.updateUser; + map['tenantCode'] = this.tenantCode; + map['storeId'] = this.storeId; + map['storeName'] = this.storeName; + map['tableId'] = this.tableId; + map['orderType'] = this.orderType; + map['clearTable'] = this.clearTable; + map['mid'] = this.mid; + map['parentId'] = this.parentId; + map['parentCode'] = this.parentCode; + map['orderCode'] = this.orderCode; + map['dayFlowCode'] = this.dayFlowCode; + map['orderStatus'] = this.orderStatus; + map['sendStatus'] = this.sendStatus; + map['payStatus'] = this.payStatus; + map['memberAccount'] = this.memberAccount; + map['logisticsId'] = this.logisticsId; + map['shipperCode'] = this.shipperCode; + map['logisticsName'] = this.logisticsName; + map['logisticsNum'] = this.logisticsNum; + map['logisticsCase'] = this.logisticsCase; + map['refundStatus'] = this.refundStatus; + map['addressExt'] = this.addressExt; + map['postFee'] = this.postFee; + map['orderSum'] = this.orderSum; + map['paySum'] = this.paySum; + map['paySumSub'] = this.paySumSub; + map['accountPay'] = this.accountPay; + map['couponSubPrice'] = this.couponSubPrice; + map['customPrice'] = this.customPrice; + map['removeDecimal'] = this.removeDecimal; + map['isSubscribe'] = this.isSubscribe; + map['subcribeTime'] = this.subcribeTime; + map['sendTime'] = this.sendTime; + map['confirmTime'] = this.confirmTime; + map['returnMoneyTime'] = this.returnMoneyTime; + map['notes'] = this.notes; + map['prepayId'] = this.prepayId; + map['payTime'] = this.payTime; + map['payChannel'] = this.payChannel; + map['payNum'] = this.payNum; + map['promotionId'] = this.promotionId; + map['couponId'] = this.couponId; + map['isDelete'] = this.isDelete; + map['isTakeOut'] = this.isTakeOut; + map['batch'] = this.batch; + map['orderDiscountPrice'] = this.orderDiscountPrice; + map['dishesDiscountPrice'] = this.dishesDiscountPrice; + map['orderPercentPrice'] = this.orderPercentPrice; + map['finalPayPrice'] = this.finalPayPrice; + map['activityNoPrice'] = this.activityNoPrice; + map['activityDiscountPrice'] = this.activityDiscountPrice; + map['totalDiscountPrice'] = this.totalDiscountPrice; + map['orderSource'] = this.orderSource; + map['address'] = this.address; + map['discountPercent'] = this.discountPercent; + map['discountAmount'] = this.discountAmount; + map['discountType'] = this.discountType; + map['discountMoney'] = this.discountMoney; + map['overTime'] = this.overTime; + if (this.orderProductVOList != null) { + map['orderProductVOList'] = this.orderProductVOList.map((v) => v.toJson()).toList(); + } + map['moneyReturnList'] = this.moneyReturnList; + map['goodsReturnList'] = this.goodsReturnList; + map['moneyReturnVOList'] = this.moneyReturnVOList; + map['goodsReturnVOList'] = this.goodsReturnVOList; + map['moneyReturnActionHistoryList'] = this.moneyReturnActionHistoryList; + map['goodsReturnActionHistoryList'] = this.goodsReturnActionHistoryList; + map['currentTime'] = this.currentTime; + map['tablePrice'] = this.tablePrice; + map['tableName'] = this.tableName; + map['balance'] = this.balance; + map['money'] = this.money; + map['prodNum'] = this.prodNum; + map['onCredit'] = this.onCredit; + if (this.orderInfoVo != null) { + map['orderInfoVo'] = this.orderInfoVo.toJson(); + } + map['endPayTime'] = this.endPayTime; + map['orderSumPrice'] = this.orderSumPrice; + return map; + } + +} + +/// orderNum : 0 +/// productNum : 0 +/// mins : 1 +/// memberVO : {"vipNo":"1406879717390286848","nickname":"","headimg":"","userType":true,"sex":"0","level":1,"addressId":null,"remark":null,"phone":"15827991714","createTime":"2021-07-10 15:44:23","birth":"1993-02-19","balance":"0.00","money":"9999608.09","points":"1147","isBind":true,"memberRankVo":{"id":"1402947503522840576","rankName":"黄金会员","rankOrigin":8888,"rankContent":"","rankImg":"","status":true,"nextId":"1402947503522840577","nextName":"钻石会员","nextOrigin":null},"age":28} +/// postAge : "0.00" +/// price : "208.00" +/// orderSum : "208.00" +/// discountAmount : null +/// promotionInfoList : null +/// couponList : null +/// threshold : "0" +/// freePostAge : "0" +/// orderProductList : null + +class OrderInfoVo { + OrderInfoVo({ + int orderNum, + int productNum, + int mins, + MemberVO memberVO, + String postAge, + String price, + String orderSum, + dynamic discountAmount, + dynamic promotionInfoList, + dynamic couponList, + String threshold, + String freePostAge, + dynamic orderProductList,}){ + this.orderNum = orderNum; + this.productNum = productNum; + this.mins = mins; + this.memberVO = memberVO; + this.postAge = postAge; + this.price = price; + this.orderSum = orderSum; + this.discountAmount = discountAmount; + this.promotionInfoList = promotionInfoList; + this.couponList = couponList; + this.threshold = threshold; + this.freePostAge = freePostAge; + this.orderProductList = orderProductList; +} + + OrderInfoVo.fromJson(dynamic json) { + this.orderNum = json['orderNum']; + this.productNum = json['productNum']; + this.mins = json['mins']; + this.memberVO = json['memberVO'] != null ? MemberVO.fromJson(json['memberVO']) : null; + this.postAge = json['postAge']; + this.price = json['price']; + this.orderSum = json['orderSum']; + this.discountAmount = json['discountAmount']; + this.promotionInfoList = json['promotionInfoList']; + this.couponList = json['couponList']; + this.threshold = json['threshold']; + this.freePostAge = json['freePostAge']; + this.orderProductList = json['orderProductList']; + } + int orderNum; + int productNum; + int mins; + MemberVO memberVO; + String postAge; + String price; + String orderSum; + dynamic discountAmount; + dynamic promotionInfoList; + dynamic couponList; + String threshold; + String freePostAge; + dynamic orderProductList; + + Map toJson() { + final map = {}; + map['orderNum'] = this.orderNum; + map['productNum'] = this.productNum; + map['mins'] = this.mins; + if (this.memberVO != null) { + map['memberVO'] = this.memberVO.toJson(); + } + map['postAge'] = this.postAge; + map['price'] = this.price; + map['orderSum'] = this.orderSum; + map['discountAmount'] = this.discountAmount; + map['promotionInfoList'] = this.promotionInfoList; + map['couponList'] = this.couponList; + map['threshold'] = this.threshold; + map['freePostAge'] = this.freePostAge; + map['orderProductList'] = this.orderProductList; + return map; + } + +} + +/// vipNo : "1406879717390286848" +/// nickname : "" +/// headimg : "" +/// userType : true +/// sex : "0" +/// level : 1 +/// addressId : null +/// remark : null +/// phone : "15827991714" +/// createTime : "2021-07-10 15:44:23" +/// birth : "1993-02-19" +/// balance : "0.00" +/// money : "9999608.09" +/// points : "1147" +/// isBind : true +/// memberRankVo : {"id":"1402947503522840576","rankName":"黄金会员","rankOrigin":8888,"rankContent":"","rankImg":"","status":true,"nextId":"1402947503522840577","nextName":"钻石会员","nextOrigin":null} +/// age : 28 + +class MemberVO { + MemberVO({ + String vipNo, + String nickname, + String headimg, + bool userType, + String sex, + int level, + dynamic addressId, + dynamic remark, + String phone, + String createTime, + String birth, + String balance, + String money, + String points, + bool isBind, + MemberRankVo memberRankVo, + int age,}){ + this.vipNo = vipNo; + this.nickname = nickname; + this.headimg = headimg; + this.userType = userType; + this.sex = sex; + this.level = level; + this.addressId = addressId; + this.remark = remark; + this.phone = phone; + this.createTime = createTime; + this.birth = birth; + this.balance = balance; + this.money = money; + this.points = points; + this.isBind = isBind; + this.memberRankVo = memberRankVo; + this.age = age; +} + + MemberVO.fromJson(dynamic json) { + this.vipNo = json['vipNo']; + this.nickname = json['nickname']; + this.headimg = json['headimg']; + this.userType = json['userType']; + this.sex = json['sex']; + this.level = json['level']; + this.addressId = json['addressId']; + this.remark = json['remark']; + this.phone = json['phone']; + this.createTime = json['createTime']; + this.birth = json['birth']; + this.balance = json['balance']; + this.money = json['money']; + this.points = json['points']; + this.isBind = json['isBind']; + this.memberRankVo = json['memberRankVo'] != null ? MemberRankVo.fromJson(json['memberRankVo']) : null; + this.age = json['age']; + } + String vipNo; + String nickname; + String headimg; + bool userType; + String sex; + int level; + dynamic addressId; + dynamic remark; + String phone; + String createTime; + String birth; + String balance; + String money; + String points; + bool isBind; + MemberRankVo memberRankVo; + int age; + + Map toJson() { + final map = {}; + map['vipNo'] = this.vipNo; + map['nickname'] = this.nickname; + map['headimg'] = this.headimg; + map['userType'] = this.userType; + map['sex'] = this.sex; + map['level'] = this.level; + map['addressId'] = this.addressId; + map['remark'] = this.remark; + map['phone'] = this.phone; + map['createTime'] = this.createTime; + map['birth'] = this.birth; + map['balance'] = this.balance; + map['money'] = this.money; + map['points'] = this.points; + map['isBind'] = this.isBind; + if (this.memberRankVo != null) { + map['memberRankVo'] = this.memberRankVo.toJson(); + } + map['age'] = this.age; + return map; + } + +} + +/// id : "1402947503522840576" +/// rankName : "黄金会员" +/// rankOrigin : 8888 +/// rankContent : "" +/// rankImg : "" +/// status : true +/// nextId : "1402947503522840577" +/// nextName : "钻石会员" +/// nextOrigin : null + +class MemberRankVo { + MemberRankVo({ + String id, + String rankName, + int rankOrigin, + String rankContent, + String rankImg, + bool status, + String nextId, + String nextName, + dynamic nextOrigin,}){ + this.id = id; + this.rankName = rankName; + this.rankOrigin = rankOrigin; + this.rankContent = rankContent; + this.rankImg = rankImg; + this.status = status; + this.nextId = nextId; + this.nextName = nextName; + this.nextOrigin = nextOrigin; +} + + MemberRankVo.fromJson(dynamic json) { + this.id = json['id']; + this.rankName = json['rankName']; + this.rankOrigin = json['rankOrigin']; + this.rankContent = json['rankContent']; + this.rankImg = json['rankImg']; + this.status = json['status']; + this.nextId = json['nextId']; + this.nextName = json['nextName']; + this.nextOrigin = json['nextOrigin']; + } + String id; + String rankName; + int rankOrigin; + String rankContent; + String rankImg; + bool status; + String nextId; + String nextName; + dynamic nextOrigin; + + Map toJson() { + final map = {}; + map['id'] = this.id; + map['rankName'] = this.rankName; + map['rankOrigin'] = this.rankOrigin; + map['rankContent'] = this.rankContent; + map['rankImg'] = this.rankImg; + map['status'] = this.status; + map['nextId'] = this.nextId; + map['nextName'] = this.nextName; + map['nextOrigin'] = this.nextOrigin; + return map; + } + +} diff --git a/lib/retrofit/data/page.g.dart b/lib/retrofit/data/page.g.dart deleted file mode 100644 index e40a14ae..00000000 --- a/lib/retrofit/data/page.g.dart +++ /dev/null @@ -1,41 +0,0 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND - -part of 'page.dart'; - -// ************************************************************************** -// JsonSerializableGenerator -// ************************************************************************** - -PageInfo _$PageInfoFromJson( - Map json, - D Function(Object json) fromJsonD, -) { - return PageInfo() - ..pageNum = json['pageNum'] as int - ..current = json['current'] - ..pageSize = json['pageSize'] as int - ..size = json['size'] - ..pages = json['pages'] - ..hasPreviousPage = json['hasPreviousPage'] as bool - ..hasNextPage = json['hasNextPage'] as bool - ..total = json['total'] as String - ..list = (json['list'] as List)?.map(fromJsonD)?.toList() - ..records = (json['records'] as List)?.map(fromJsonD)?.toList(); -} - -Map _$PageInfoToJson( - PageInfo instance, - Object Function(D value) toJsonD, -) => - { - 'pageNum': instance.pageNum, - 'current': instance.current, - 'pageSize': instance.pageSize, - 'size': instance.size, - 'pages': instance.pages, - 'hasPreviousPage': instance.hasPreviousPage, - 'hasNextPage': instance.hasNextPage, - 'total': instance.total, - 'list': instance.list?.map(toJsonD)?.toList(), - 'records': instance.records?.map(toJsonD)?.toList(), - }; diff --git a/lib/retrofit/data/placeOrderFirst.dart b/lib/retrofit/data/placeOrderFirst.dart index da05b643..8ae1e446 100644 --- a/lib/retrofit/data/placeOrderFirst.dart +++ b/lib/retrofit/data/placeOrderFirst.dart @@ -1,5 +1,6 @@ import 'package:huixiang/retrofit/data/down_order.dart'; import 'package:huixiang/retrofit/data/order_product_vo.dart'; +import 'package:huixiang/retrofit/data/settleOrderInfo.dart'; import 'package:huixiang/retrofit/data/shoppingCart.dart'; class PlaceOrderFirst { @@ -20,7 +21,7 @@ class PlaceOrderFirst { PromotionInfoDTOBean promotionInfoDTO; String recMobile; List orderProductVOList; - List shoppingCartSkuItemList; + List shoppingCartSkuItemList; List skuItemDTOList; num source; String storeId; @@ -75,7 +76,7 @@ class PlaceOrderFirst { placeOrderFirst.recMobile = json['recMobile']; placeOrderFirst.shoppingCartSkuItemList = []..addAll( (json['shoppingCartSkuItemList'] as List ?? []) - .map((o) => ShoppingCartSkuItemListBean.fromJson(o))); + .map((o) => OrderProductListBean.fromJson(o))); placeOrderFirst.orderProductVOList = []..addAll( (json['orderProductVOList'] as List ?? []) .map((o) => OrderProductVOList.fromJson(o))); diff --git a/lib/retrofit/min_api.dart b/lib/retrofit/min_api.dart index 015efc27..1cb07f09 100644 --- a/lib/retrofit/min_api.dart +++ b/lib/retrofit/min_api.dart @@ -10,6 +10,7 @@ import 'package:huixiang/generated/l10n.dart'; import 'package:huixiang/retrofit/data/address.dart'; import 'package:huixiang/retrofit/data/base_data.dart'; import 'package:huixiang/retrofit/data/down_order.dart'; +import 'package:huixiang/retrofit/data/min_order_info.dart'; import 'package:huixiang/retrofit/data/placeOrderFirst.dart'; import 'package:huixiang/retrofit/data/settlement_bean.dart'; import 'package:huixiang/retrofit/data/wx_pay.dart'; @@ -166,6 +167,10 @@ abstract class MinApiService { @POST("order/getOrderInfo") Future> getOrderInfo(@Body() Map param); + ///查看订单详情 + @POST("order/getOrderDetail") + Future> getOrderDetails(@Body() Map param); + ///查询用户所有收货地址 @GET("address/queryMemberAddress") Future>> queryAddress(); @@ -174,6 +179,10 @@ abstract class MinApiService { @POST("order/placeOrderFirst") Future> placeOrderFirst(@Body() Map param); + ///小程序下单加菜 + @POST("order/addOrder") + Future> addOrder(@Body() Map param); + /// 结算 @POST("order/settlement") Future> settlementWx(@Body() Map param); diff --git a/lib/retrofit/min_api.g.dart b/lib/retrofit/min_api.g.dart deleted file mode 100644 index b98fa96b..00000000 --- a/lib/retrofit/min_api.g.dart +++ /dev/null @@ -1,338 +0,0 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND - -part of 'min_api.dart'; - -// ************************************************************************** -// RetrofitGenerator -// ************************************************************************** - -class _MinApiService implements MinApiService { - _MinApiService(this._dio, {this.baseUrl}) { - ArgumentError.checkNotNull(_dio, '_dio'); - baseUrl ??= 'http://192.168.10.236:8765/app/'; - } - - final Dio _dio; - - String baseUrl; - - @override - Future>> findMiNiGroupList(param) async { - ArgumentError.checkNotNull(param, 'param'); - const _extra = {}; - final queryParameters = {}; - final _data = {}; - _data.addAll(param ?? {}); - final _result = await _dio.request>( - 'product/findMiNiGroupList', - queryParameters: queryParameters, - options: RequestOptions( - method: 'POST', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData>.fromJson( - _result.data, - (json) => (json as List) - .map( - (i) => FindMiNiGroupList.fromJson(i as Map)) - .toList()); - return value; - } - - @override - Future> miNiDetail(id) async { - ArgumentError.checkNotNull(id, 'id'); - const _extra = {}; - final queryParameters = {}; - final _data = {}; - final _result = await _dio.request>( - '/product/queryMiNiProductDetail?id=$id', - queryParameters: queryParameters, - options: RequestOptions( - method: 'GET', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData.fromJson( - _result.data, - (json) => MiNiDetail.fromJson(json), - ); - return value; - } - - @override - Future>> addShoppingCart(param) async { - ArgumentError.checkNotNull(param, 'param'); - const _extra = {}; - final queryParameters = {}; - final _data = {}; - _data.addAll(param ?? {}); - final _result = await _dio.request>('shoppingcart', - queryParameters: queryParameters, - options: RequestOptions( - method: 'POST', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData>.fromJson( - _result.data, - (json) => (json as List) - .map( - (i) => ShoppingCart.fromJson(i as Map)) - .toList()); - return value; - } - - @override - Future>> getShoppingCart(tableId) async { - ArgumentError.checkNotNull(tableId, 'tableId'); - const _extra = {}; - final queryParameters = {r'tableId': tableId}; - final _data = {}; - final _result = await _dio.request>('shoppingcart', - queryParameters: queryParameters, - options: RequestOptions( - method: 'GET', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData>.fromJson( - _result.data, - (json) => (json as List) - .map( - (i) => ShoppingCart.fromJson(i as Map)) - .toList()); - return value; - } - - @override - Future> clearShoppingCart() async { - const _extra = {}; - final queryParameters = {}; - final _data = {}; - final _result = await _dio.request>( - 'shoppingcart/delCart', - queryParameters: queryParameters, - options: RequestOptions( - method: 'GET', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData.fromJson( - _result.data, - (json) => json as bool, - ); - return value; - } - - @override - Future>> shoppingCart1(param) async { - ArgumentError.checkNotNull(param, 'param'); - const _extra = {}; - final queryParameters = {}; - final _data = {}; - _data.addAll(param ?? {}); - final _result = await _dio.request>('shoppingcart', - queryParameters: queryParameters, - options: RequestOptions( - method: 'PUT', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData>.fromJson( - _result.data, - (json) => (json as List) - .map( - (i) => ShoppingCart.fromJson(i as Map)) - .toList()); - return value; - } - - @override - Future>> shoppingCartSingle(param) async { - ArgumentError.checkNotNull(param, 'param'); - const _extra = {}; - final queryParameters = {}; - final _data = {}; - _data.addAll(param ?? {}); - final _result = await _dio.request>( - 'shoppingcart/single', - queryParameters: queryParameters, - options: RequestOptions( - method: 'PUT', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData>.fromJson( - _result.data, - (json) => (json as List) - .map( - (i) => ShoppingCart.fromJson(i as Map)) - .toList()); - return value; - } - - @override - Future> getOrderInfo(param) async { - ArgumentError.checkNotNull(param, 'param'); - const _extra = {}; - final queryParameters = {}; - final _data = {}; - _data.addAll(param ?? {}); - final _result = await _dio.request>( - 'order/getOrderInfo', - queryParameters: queryParameters, - options: RequestOptions( - method: 'POST', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData.fromJson( - _result.data, - (json) => SettleOrderInfo.fromJson(json), - ); - return value; - } - - @override - Future>> queryAddress() async { - const _extra = {}; - final queryParameters = {}; - final _data = {}; - final _result = await _dio.request>( - 'address/queryMemberAddress', - queryParameters: queryParameters, - options: RequestOptions( - method: 'GET', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData>.fromJson( - _result.data, - (json) => (json as List) - .map
((i) => Address.fromJson(i as Map)) - .toList()); - return value; - } - - @override - Future> placeOrderFirst(param) async { - ArgumentError.checkNotNull(param, 'param'); - const _extra = {}; - final queryParameters = {}; - final _data = {}; - _data.addAll(param ?? {}); - final _result = await _dio.request>( - 'order/placeOrderFirst', - queryParameters: queryParameters, - options: RequestOptions( - method: 'POST', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData.fromJson( - _result.data, - (json) => DownOrder.fromJson(json), - ); - return value; - } - - @override - Future> settlementWx(param) async { - ArgumentError.checkNotNull(param, 'param'); - const _extra = {}; - final queryParameters = {}; - final _data = {}; - _data.addAll(param ?? {}); - final _result = await _dio.request>('order/settlement', - queryParameters: queryParameters, - options: RequestOptions( - method: 'POST', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData.fromJson( - _result.data, - (json) => WxPay.fromJson(json), - ); - return value; - } - - @override - Future> settlementApi(param) async { - ArgumentError.checkNotNull(param, 'param'); - const _extra = {}; - final queryParameters = {}; - final _data = {}; - _data.addAll(param ?? {}); - final _result = await _dio.request>('order/settlement', - queryParameters: queryParameters, - options: RequestOptions( - method: 'POST', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData.fromJson( - _result.data, - (json) => json as dynamic, - ); - return value; - } - - @override - Future> queryStoreInfo1(param) async { - ArgumentError.checkNotNull(param, 'param'); - const _extra = {}; - final queryParameters = {}; - final _data = {}; - _data.addAll(param ?? {}); - final _result = await _dio.request>('/store/getStore', - queryParameters: queryParameters, - options: RequestOptions( - method: 'POST', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData.fromJson( - _result.data, - (json) => json as dynamic, - ); - return value; - } - - @override - Future> getParentInfo(id) async { - ArgumentError.checkNotNull(id, 'id'); - const _extra = {}; - final queryParameters = {}; - final _data = {}; - final _result = await _dio.request>( - '/order/getParentInfo/$id', - queryParameters: queryParameters, - options: RequestOptions( - method: 'GET', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData.fromJson( - _result.data, - (json) => json as dynamic, - ); - return value; - } -} diff --git a/lib/retrofit/retrofit_api.g.dart b/lib/retrofit/retrofit_api.g.dart deleted file mode 100644 index 4eb8a7c9..00000000 --- a/lib/retrofit/retrofit_api.g.dart +++ /dev/null @@ -1,1349 +0,0 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND - -part of 'retrofit_api.dart'; - -// ************************************************************************** -// RetrofitGenerator -// ************************************************************************** - -class _ApiService implements ApiService { - _ApiService(this._dio, {this.baseUrl}) { - ArgumentError.checkNotNull(_dio, '_dio'); - baseUrl ??= 'http://192.168.10.236:8766/app/'; - } - - final Dio _dio; - - String baseUrl; - - @override - Future> upload(data, folderId) async { - ArgumentError.checkNotNull(data, 'data'); - ArgumentError.checkNotNull(folderId, 'folderId'); - const _extra = {}; - final queryParameters = {}; - final _data = FormData(); - _data.files.add(MapEntry( - 'file', - MultipartFile.fromFileSync(data.path, - filename: data.path.split(Platform.pathSeparator).last))); - if (folderId != null) { - _data.fields.add(MapEntry('folderId', folderId.toString())); - } - final _result = await _dio.request>('/file/upload', - queryParameters: queryParameters, - options: RequestOptions( - method: 'POST', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData.fromJson( - _result.data, - (json) => UploadResult.fromJson(json), - ); - return value; - } - - @override - Future searchPoi(lat, lng, keywords, size, page) async { - ArgumentError.checkNotNull(lat, 'lat'); - ArgumentError.checkNotNull(lng, 'lng'); - ArgumentError.checkNotNull(keywords, 'keywords'); - ArgumentError.checkNotNull(size, 'size'); - ArgumentError.checkNotNull(page, 'page'); - const _extra = {}; - final queryParameters = {}; - final _data = {}; - final _result = await _dio.request( - 'https://restapi.amap.com/v3/place/around?key=542b46afa8e4b88fe1eb3c4d0ba0872f&location=$lat,$lng&keywords=$keywords&offset={size}&page={page}&extensions=all', - queryParameters: queryParameters, - options: RequestOptions( - method: 'GET', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = _result.data; - return value; - } - - @override - Future> memberLogin(param) async { - ArgumentError.checkNotNull(param, 'param'); - const _extra = {}; - final queryParameters = {}; - final _data = {}; - _data.addAll(param ?? {}); - final _result = await _dio.request>( - '/auth/platform/memberLogin', - queryParameters: queryParameters, - options: RequestOptions( - method: 'POST', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData.fromJson( - _result.data, - (json) => json as dynamic, - ); - return value; - } - - @override - Future> sendVerify(mobile) async { - ArgumentError.checkNotNull(mobile, 'mobile'); - const _extra = {}; - final queryParameters = {}; - final _data = {}; - final _result = await _dio.request>( - '/auth/sendVerify/$mobile', - queryParameters: queryParameters, - options: RequestOptions( - method: 'GET', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData.fromJson( - _result.data, - (json) => json as dynamic, - ); - return value; - } - - @override - Future>> creditGoods(param) async { - ArgumentError.checkNotNull(param, 'param'); - const _extra = {}; - final queryParameters = {}; - final _data = {}; - _data.addAll(param ?? {}); - final _result = await _dio.request>( - '/creditGoods/list', - queryParameters: queryParameters, - options: RequestOptions( - method: 'POST', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData>.fromJson( - _result.data, - (json) => PageInfo.fromJson( - json, - (json) => Goods.fromJson(json), - ), - ); - return value; - } - - @override - Future>> goodsCategory(param) async { - ArgumentError.checkNotNull(param, 'param'); - const _extra = {}; - final queryParameters = {}; - final _data = {}; - _data.addAll(param ?? {}); - final _result = await _dio.request>( - '/creditGoodsCategory/page', - queryParameters: queryParameters, - options: RequestOptions( - method: 'POST', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData>.fromJson( - _result.data, - (json) => PageInfo.fromJson( - json, - (json) => GoodsCategory.fromJson(json), - ), - ); - return value; - } - - @override - Future> creditGoodsById(id) async { - ArgumentError.checkNotNull(id, 'id'); - const _extra = {}; - final queryParameters = {}; - final _data = {}; - final _result = await _dio.request>('/creditGoods/$id', - queryParameters: queryParameters, - options: RequestOptions( - method: 'GET', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData.fromJson( - _result.data, - (json) => Goods.fromJson(json), - ); - return value; - } - - @override - Future> queryInfo() async { - const _extra = {}; - final queryParameters = {}; - final _data = {}; - final _result = await _dio.request>('/member/info', - queryParameters: queryParameters, - options: RequestOptions( - method: 'GET', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData.fromJson( - _result.data, - (json) => UserInfo.fromJson(json), - ); - return value; - } - - @override - Future> editInfo(param) async { - ArgumentError.checkNotNull(param, 'param'); - const _extra = {}; - final queryParameters = {}; - final _data = {}; - _data.addAll(param ?? {}); - final _result = await _dio.request>( - '/member/editMemberInfo', - queryParameters: queryParameters, - options: RequestOptions( - method: 'POST', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData.fromJson( - _result.data, - (json) => json as dynamic, - ); - return value; - } - - @override - Future> signInInfo() async { - const _extra = {}; - final queryParameters = {}; - final _data = {}; - final _result = await _dio.request>( - '/member/signInInfo', - queryParameters: queryParameters, - options: RequestOptions( - method: 'GET', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData.fromJson( - _result.data, - (json) => SignInfo.fromJson(json), - ); - return value; - } - - @override - Future> signIn() async { - const _extra = {}; - final queryParameters = {}; - final _data = {}; - final _result = await _dio.request>('/member/signIn', - queryParameters: queryParameters, - options: RequestOptions( - method: 'GET', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData.fromJson( - _result.data, - (json) => json as dynamic, - ); - return value; - } - - @override - Future> recharge(param) async { - ArgumentError.checkNotNull(param, 'param'); - const _extra = {}; - final queryParameters = {}; - final _data = {}; - _data.addAll(param ?? {}); - final _result = await _dio.request>('/wallet/recharge', - queryParameters: queryParameters, - options: RequestOptions( - method: 'POST', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData.fromJson( - _result.data, - (json) => WxPay.fromJson(json), - ); - return value; - } - - @override - Future> receiveCoupon(couponId) async { - ArgumentError.checkNotNull(couponId, 'couponId'); - const _extra = {}; - final queryParameters = {}; - final _data = {}; - final _result = await _dio.request>( - '/coupon/receive?couponId=$couponId', - queryParameters: queryParameters, - options: RequestOptions( - method: 'GET', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData.fromJson( - _result.data, - (json) => json as dynamic, - ); - return value; - } - - @override - Future>> creditOrderList(param) async { - ArgumentError.checkNotNull(param, 'param'); - const _extra = {}; - final queryParameters = {}; - final _data = {}; - _data.addAll(param ?? {}); - final _result = await _dio.request>( - '/creditOrder/list', - queryParameters: queryParameters, - options: RequestOptions( - method: 'POST', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData>.fromJson( - _result.data, - (json) => PageInfo.fromJson( - json, - (json) => ExchangeOrder.fromJson(json), - ), - ); - return value; - } - - @override - Future> creditOrder(param) async { - ArgumentError.checkNotNull(param, 'param'); - const _extra = {}; - final queryParameters = {}; - final _data = {}; - _data.addAll(param ?? {}); - final _result = await _dio.request>( - '/creditOrder/create', - queryParameters: queryParameters, - options: RequestOptions( - method: 'POST', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData.fromJson( - _result.data, - (json) => json as dynamic, - ); - return value; - } - - @override - Future> addAddress(param) async { - ArgumentError.checkNotNull(param, 'param'); - const _extra = {}; - final queryParameters = {}; - final _data = {}; - _data.addAll(param ?? {}); - final _result = await _dio.request>('/address/add', - queryParameters: queryParameters, - options: RequestOptions( - method: 'POST', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData.fromJson( - _result.data, - (json) => json as dynamic, - ); - return value; - } - - @override - Future> deleteAddress(param) async { - ArgumentError.checkNotNull(param, 'param'); - const _extra = {}; - final queryParameters = {}; - final _data = {}; - _data.addAll(param ?? {}); - final _result = await _dio.request>('/address/delete', - queryParameters: queryParameters, - options: RequestOptions( - method: 'POST', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData.fromJson( - _result.data, - (json) => json as dynamic, - ); - return value; - } - - @override - Future> queryAddress(id) async { - ArgumentError.checkNotNull(id, 'id'); - const _extra = {}; - final queryParameters = {}; - final _data = {}; - final _result = await _dio.request>( - '/address/detail/$id', - queryParameters: queryParameters, - options: RequestOptions( - method: 'GET', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData.fromJson( - _result.data, - (json) => json as dynamic, - ); - return value; - } - - @override - Future>> queryMemberAddress() async { - const _extra = {}; - final queryParameters = {}; - final _data = {}; - final _result = await _dio.request>( - '/address/queryMemberAddress', - queryParameters: queryParameters, - options: RequestOptions( - method: 'GET', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData>.fromJson( - _result.data, - (json) => (json as List) - .map
((i) => Address.fromJson(i as Map)) - .toList()); - return value; - } - - @override - Future> updateAddress(param) async { - ArgumentError.checkNotNull(param, 'param'); - const _extra = {}; - final queryParameters = {}; - final _data = {}; - _data.addAll(param ?? {}); - final _result = await _dio.request>('/address/update', - queryParameters: queryParameters, - options: RequestOptions( - method: 'POST', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData.fromJson( - _result.data, - (json) => json as dynamic, - ); - return value; - } - - @override - Future>> queryCoupon(param) async { - ArgumentError.checkNotNull(param, 'param'); - const _extra = {}; - final queryParameters = {}; - final _data = {}; - _data.addAll(param ?? {}); - final _result = await _dio.request>( - '/coupon/centreList', - queryParameters: queryParameters, - options: RequestOptions( - method: 'POST', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData>.fromJson( - _result.data, - (json) => PageInfo.fromJson( - json, - (json) => Coupon.fromJson(json), - ), - ); - return value; - } - - @override - Future>> queryCard(param) async { - ArgumentError.checkNotNull(param, 'param'); - const _extra = {}; - final queryParameters = {}; - final _data = {}; - _data.addAll(param ?? {}); - final _result = await _dio.request>( - '/coupon/packageList', - queryParameters: queryParameters, - options: RequestOptions( - method: 'POST', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData>.fromJson( - _result.data, - (json) => PageInfo.fromJson( - json, - (json) => Coupon.fromJson(json), - ), - ); - return value; - } - - @override - Future>> queryStore(param) async { - ArgumentError.checkNotNull(param, 'param'); - const _extra = {}; - final queryParameters = {}; - final _data = {}; - _data.addAll(param ?? {}); - final _result = await _dio.request>('/store/list', - queryParameters: queryParameters, - options: RequestOptions( - method: 'POST', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData>.fromJson( - _result.data, - (json) => (json as List) - .map((i) => Store.fromJson(i as Map)) - .toList()); - return value; - } - - @override - Future>> informationList(param) async { - ArgumentError.checkNotNull(param, 'param'); - const _extra = {}; - final queryParameters = {}; - final _data = {}; - _data.addAll(param ?? {}); - final _result = await _dio.request>( - '/information/list', - queryParameters: queryParameters, - options: RequestOptions( - method: 'POST', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData>.fromJson( - _result.data, - (json) => PageInfo.fromJson( - json, - (json) => Activity.fromJson(json), - ), - ); - return value; - } - - @override - Future> informationInfo(id) async { - ArgumentError.checkNotNull(id, 'id'); - const _extra = {}; - final queryParameters = {}; - final _data = {}; - final _result = await _dio.request>('/information/$id', - queryParameters: queryParameters, - options: RequestOptions( - method: 'GET', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData
.fromJson( - _result.data, - (json) => Article.fromJson(json), - ); - return value; - } - - @override - Future> activityInfo(id) async { - ArgumentError.checkNotNull(id, 'id'); - const _extra = {}; - final queryParameters = {}; - final _data = {}; - final _result = await _dio.request>('/information/$id', - queryParameters: queryParameters, - options: RequestOptions( - method: 'GET', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData.fromJson( - _result.data, - (json) => Activity.fromJson(json), - ); - return value; - } - - @override - Future> creditOrderReceive(id) async { - ArgumentError.checkNotNull(id, 'id'); - const _extra = {}; - final queryParameters = {}; - final _data = {}; - final _result = await _dio.request>( - '/creditOrder/receive/$id', - queryParameters: queryParameters, - options: RequestOptions( - method: 'GET', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData.fromJson( - _result.data, - (json) => json as dynamic, - ); - return value; - } - - @override - Future> queryHome() async { - const _extra = {}; - final queryParameters = {}; - final _data = {}; - final _result = await _dio.request>('/home/home', - queryParameters: queryParameters, - options: RequestOptions( - method: 'GET', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData.fromJson( - _result.data, - (json) => BrandData.fromJson(json), - ); - return value; - } - - @override - Future> queryStoreInfo(id) async { - ArgumentError.checkNotNull(id, 'id'); - const _extra = {}; - final queryParameters = {}; - final _data = {}; - final _result = await _dio.request>('/store/$id', - queryParameters: queryParameters, - options: RequestOptions( - method: 'GET', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData.fromJson( - _result.data, - (json) => json as dynamic, - ); - return value; - } - - @override - Future>> queryArticle(param) async { - ArgumentError.checkNotNull(param, 'param'); - const _extra = {}; - final queryParameters = {}; - final _data = {}; - _data.addAll(param ?? {}); - final _result = await _dio.request>( - '/information/list', - queryParameters: queryParameters, - options: RequestOptions( - method: 'POST', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData>.fromJson( - _result.data, - (json) => PageInfo
.fromJson( - json, - (json) => Article.fromJson(json), - ), - ); - return value; - } - - @override - Future>> queryBanner(param) async { - ArgumentError.checkNotNull(param, 'param'); - const _extra = {}; - final queryParameters = {}; - final _data = {}; - _data.addAll(param ?? {}); - final _result = await _dio.request>('/banner/page', - queryParameters: queryParameters, - options: RequestOptions( - method: 'POST', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData>.fromJson( - _result.data, - (json) => PageInfo.fromJson( - json, - (json) => BannerData.fromJson(json), - ), - ); - return value; - } - - @override - Future> queryHomeBrand() async { - const _extra = {}; - final queryParameters = {}; - final _data = {}; - final _result = await _dio.request>('/home/brand', - queryParameters: queryParameters, - options: RequestOptions( - method: 'GET', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData.fromJson( - _result.data, - (json) => json as dynamic, - ); - return value; - } - - @override - Future> minLogin(storeId) async { - ArgumentError.checkNotNull(storeId, 'storeId'); - const _extra = {}; - final queryParameters = {}; - final _data = {}; - final _result = await _dio.request>( - '/auth/mini/login/$storeId', - queryParameters: queryParameters, - options: RequestOptions( - method: 'GET', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData.fromJson( - _result.data, - (json) => json as dynamic, - ); - return value; - } - - @override - Future>> queryBillInfo(param) async { - ArgumentError.checkNotNull(param, 'param'); - const _extra = {}; - final queryParameters = {}; - final _data = {}; - _data.addAll(param ?? {}); - final _result = await _dio.request>('/member/listBill', - queryParameters: queryParameters, - options: RequestOptions( - method: 'POST', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData>.fromJson( - _result.data, - (json) => PageInfo.fromJson( - json, - (json) => UserBill.fromJson(json), - ), - ); - return value; - } - - @override - Future>> rankList() async { - const _extra = {}; - final queryParameters = {}; - final _data = {}; - final _result = await _dio.request>('/member/rankList', - queryParameters: queryParameters, - options: RequestOptions( - method: 'GET', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData>.fromJson( - _result.data, - (json) => (json as List) - .map((i) => Rank.fromJson(i as Map)) - .toList()); - return value; - } - - @override - Future>> orderList(param) async { - ArgumentError.checkNotNull(param, 'param'); - const _extra = {}; - final queryParameters = {}; - final _data = {}; - _data.addAll(param ?? {}); - final _result = await _dio.request>('/order/list', - queryParameters: queryParameters, - options: RequestOptions( - method: 'POST', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData>.fromJson( - _result.data, - (json) => PageInfo.fromJson( - json, - (json) => OrderInfo.fromJson(json), - ), - ); - return value; - } - - @override - Future> orderDetail(id) async { - ArgumentError.checkNotNull(id, 'id'); - const _extra = {}; - final queryParameters = {}; - final _data = {}; - final _result = await _dio.request>( - '/order/orderDetail?id=$id', - queryParameters: queryParameters, - options: RequestOptions( - method: 'GET', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData.fromJson( - _result.data, - (json) => OrderInfo.fromJson(json), - ); - return value; - } - - @override - Future> continuePay(param) async { - ArgumentError.checkNotNull(param, 'param'); - const _extra = {}; - final queryParameters = {}; - final _data = {}; - _data.addAll(param ?? {}); - final _result = await _dio.request>( - '/order/continuePay', - queryParameters: queryParameters, - options: RequestOptions( - method: 'POST', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData.fromJson( - _result.data, - (json) => json as dynamic, - ); - return value; - } - - @override - Future> receiveToCard(id) async { - ArgumentError.checkNotNull(id, 'id'); - const _extra = {}; - final queryParameters = {}; - final _data = {}; - final _result = await _dio.request>( - '/creditOrder/receive/$id', - queryParameters: queryParameters, - options: RequestOptions( - method: 'GET', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData.fromJson( - _result.data, - (json) => json as dynamic, - ); - return value; - } - - @override - Future>> vipList(param) async { - ArgumentError.checkNotNull(param, 'param'); - const _extra = {}; - final queryParameters = {}; - final _data = {}; - _data.addAll(param ?? {}); - final _result = await _dio.request>('/member/vipList', - queryParameters: queryParameters, - options: RequestOptions( - method: 'POST', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData>.fromJson( - _result.data, - (json) => (json as List) - .map((i) => VipCard.fromJson(i as Map)) - .toList()); - return value; - } - - @override - Future> vipDetail(param) async { - ArgumentError.checkNotNull(param, 'param'); - const _extra = {}; - final queryParameters = {}; - final _data = {}; - _data.addAll(param ?? {}); - final _result = await _dio.request>( - '/member/vipDetail', - queryParameters: queryParameters, - options: RequestOptions( - method: 'POST', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData.fromJson( - _result.data, - (json) => VipCard.fromJson(json), - ); - return value; - } - - @override - Future>> msgList(param) async { - ArgumentError.checkNotNull(param, 'param'); - const _extra = {}; - final queryParameters = {}; - final _data = {}; - _data.addAll(param ?? {}); - final _result = await _dio.request>('/app-msg/list', - queryParameters: queryParameters, - options: RequestOptions( - method: 'POST', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData>.fromJson( - _result.data, - (json) => PageInfo.fromJson( - json, - (json) => Message.fromJson(json), - ), - ); - return value; - } - - @override - Future> queryMsg(id) async { - ArgumentError.checkNotNull(id, 'id'); - const _extra = {}; - final queryParameters = {}; - final _data = {}; - final _result = await _dio.request>('/app-msg/$id', - queryParameters: queryParameters, - options: RequestOptions( - method: 'GET', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData.fromJson( - _result.data, - (json) => json as dynamic, - ); - return value; - } - - @override - Future> informationLikes(id) async { - ArgumentError.checkNotNull(id, 'id'); - const _extra = {}; - final queryParameters = {}; - final _data = {}; - final _result = await _dio.request>( - '/information/likes/$id', - queryParameters: queryParameters, - options: RequestOptions( - method: 'GET', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData.fromJson( - _result.data, - (json) => json as dynamic, - ); - return value; - } - - @override - Future> memberComment(param) async { - ArgumentError.checkNotNull(param, 'param'); - const _extra = {}; - final queryParameters = {}; - final _data = {}; - _data.addAll(param ?? {}); - final _result = await _dio.request>('/memberComment', - queryParameters: queryParameters, - options: RequestOptions( - method: 'POST', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData.fromJson( - _result.data, - (json) => json as dynamic, - ); - return value; - } - - @override - Future>> memberCommentList(param) async { - ArgumentError.checkNotNull(param, 'param'); - const _extra = {}; - final queryParameters = {}; - final _data = {}; - _data.addAll(param ?? {}); - final _result = await _dio.request>( - '/memberComment/list', - queryParameters: queryParameters, - options: RequestOptions( - method: 'POST', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData>.fromJson( - _result.data, - (json) => PageInfo.fromJson( - json, - (json) => MemberCommentList.fromJson(json), - ), - ); - return value; - } - - @override - Future> commentLike(id) async { - ArgumentError.checkNotNull(id, 'id'); - const _extra = {}; - final queryParameters = {}; - final _data = {}; - final _result = await _dio.request>( - '/memberComment/likes/$id', - queryParameters: queryParameters, - options: RequestOptions( - method: 'GET', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData.fromJson( - _result.data, - (json) => json as dynamic, - ); - return value; - } - - @override - Future> delComment(id) async { - ArgumentError.checkNotNull(id, 'id'); - const _extra = {}; - final queryParameters = {}; - final _data = {}; - final _result = await _dio.request>( - '/memberComment/delete/$id', - queryParameters: queryParameters, - options: RequestOptions( - method: 'GET', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData.fromJson( - _result.data, - (json) => json as dynamic, - ); - return value; - } - - @override - Future> shippingTrace(shipperCode, logisticCode) async { - ArgumentError.checkNotNull(shipperCode, 'shipperCode'); - ArgumentError.checkNotNull(logisticCode, 'logisticCode'); - const _extra = {}; - final queryParameters = {}; - final _data = {}; - final _result = await _dio.request>( - '/order/getShippingTrace/$shipperCode/$logisticCode', - queryParameters: queryParameters, - options: RequestOptions( - method: 'GET', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData.fromJson( - _result.data, - (json) => Logistics.fromJson(json), - ); - return value; - } - - @override - Future> report(map) async { - ArgumentError.checkNotNull(map, 'map'); - const _extra = {}; - final queryParameters = {}; - final _data = {}; - _data.addAll(map ?? {}); - final _result = await _dio.request>('/other/report', - queryParameters: queryParameters, - options: RequestOptions( - method: 'POST', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData.fromJson( - _result.data, - (json) => json as bool, - ); - return value; - } - - @override - Future> orderCancel(id) async { - ArgumentError.checkNotNull(id, 'id'); - const _extra = {}; - final queryParameters = {}; - final _data = {}; - final _result = await _dio.request>( - '/order/cancel/$id', - queryParameters: queryParameters, - options: RequestOptions( - method: 'GET', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData.fromJson( - _result.data, - (json) => json as bool, - ); - return value; - } - - @override - Future> settlement(map) async { - ArgumentError.checkNotNull(map, 'map'); - const _extra = {}; - final queryParameters = {}; - final _data = {}; - _data.addAll(map ?? {}); - final _result = await _dio.request>( - '/order/settlement', - queryParameters: queryParameters, - options: RequestOptions( - method: 'POST', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData.fromJson( - _result.data, - (json) => json as String, - ); - return value; - } - - @override - Future> trend(map) async { - ArgumentError.checkNotNull(map, 'map'); - const _extra = {}; - final queryParameters = {}; - final _data = {}; - _data.addAll(map ?? {}); - final _result = await _dio.request>( - '/information/trend', - queryParameters: queryParameters, - options: RequestOptions( - method: 'POST', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData.fromJson( - _result.data, - (json) => json as bool, - ); - return value; - } - - @override - Future>> trendList(map) async { - ArgumentError.checkNotNull(map, 'map'); - const _extra = {}; - final queryParameters = {}; - final _data = {}; - _data.addAll(map ?? {}); - final _result = await _dio.request>( - '/information/trend-list', - queryParameters: queryParameters, - options: RequestOptions( - method: 'POST', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData>.fromJson( - _result.data, - (json) => PageInfo.fromJson( - json, - (json) => ComunityComment.fromJson(json), - ), - ); - return value; - } - - @override - Future>> followList(map) async { - ArgumentError.checkNotNull(map, 'map'); - const _extra = {}; - final queryParameters = {}; - final _data = {}; - _data.addAll(map ?? {}); - final _result = await _dio.request>( - '/member/follow/list', - queryParameters: queryParameters, - options: RequestOptions( - method: 'POST', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData>.fromJson( - _result.data, - (json) => PageInfo.fromJson( - json, - (json) => ListData.fromJson(json), - ), - ); - return value; - } - - - @override - Future> follow(followId) async { - ArgumentError.checkNotNull(followId, 'followId'); - const _extra = {}; - final queryParameters = {}; - final _data = {}; - final _result = await _dio.request>( - '/member/follow/$followId', - queryParameters: queryParameters, - options: RequestOptions( - method: 'PUT', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData.fromJson( - _result.data, - (json) => json as dynamic, - ); - return value; - } - - @override - Future> deleteTrend(id) async { - ArgumentError.checkNotNull(id, 'id'); - const _extra = {}; - final queryParameters = {}; - final _data = {}; - final _result = await _dio.request>( - '/information/trend/$id', - queryParameters: queryParameters, - options: RequestOptions( - method: 'DELETE', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData.fromJson( - _result.data, - (json) => json as dynamic, - ); - return value; - } - - @override - Future> socialInfo() async { - const _extra = {}; - final queryParameters = {}; - final _data = {}; - final _result = await _dio.request>( - '/member/socialInfo', - queryParameters: queryParameters, - options: RequestOptions( - method: 'GET', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData.fromJson( - _result.data, - (json) => SocialInfo.fromJson(json), - ); - return value; - } -} diff --git a/lib/settlement/settlement.dart b/lib/settlement/settlement.dart index fb460c2e..6141d9b5 100644 --- a/lib/settlement/settlement.dart +++ b/lib/settlement/settlement.dart @@ -9,6 +9,7 @@ import 'package:huixiang/generated/l10n.dart'; import 'package:huixiang/retrofit/data/address.dart'; import 'package:huixiang/retrofit/data/base_data.dart'; import 'package:huixiang/retrofit/data/down_order.dart'; +import 'package:huixiang/retrofit/data/min_order_info.dart'; import 'package:huixiang/retrofit/data/placeOrderFirst.dart'; import 'package:huixiang/retrofit/data/settleOrderInfo.dart'; import 'package:huixiang/retrofit/data/settlement_bean.dart'; @@ -45,23 +46,35 @@ class _Settlement extends State { MinApiService minService; Function(int type) callback; StoreInfo storeInfo; - ShoppingCart shopCarGoods; + + // ShoppingCart shopCarGoods; SettleOrderInfo settleOrderInfo; + MinOrderInfo minOrderInfo; int selectedBtn = 0; String remakers = ""; + String parentCode = ""; + String parentId = ""; int payChannel = 4; - String tableId = "0"; + int tableId = 0; Address address; CouponListBean couponListBean; PromotionInfoListBean promotion; String mobile; + bool placeOrder = false; + @override void initState() { super.initState(); + tableId = widget.arguments["tableId"] ?? 0; + parentCode = widget.arguments["parentCode"] ?? ""; + parentId = widget.arguments["parentId"] ?? ""; storeInfo = widget.arguments["storeInfo"]; - shopCarGoods = widget.arguments["shoppingCart"]; + + if (tableId == 0) { + placeOrder = true; + } SharedPreferences.getInstance().then((value) { String minToken = value.getString("minToken"); @@ -80,7 +93,12 @@ class _Settlement extends State { ///订单结算信息 queryOrderInfo( - addressId, isTake, memberCouponId, orderId, promotionId) async { + addressId, + isTake, + memberCouponId, + orderId, + promotionId, + ) async { BaseData baseData = await minService.getOrderInfo({ "addressId": addressId, "isTake": isTake, @@ -95,6 +113,18 @@ class _Settlement extends State { } } + ///查看订单详情 + queryOrderDetails(id) async { + BaseData baseData = await minService.getOrderDetails({ + "id": id, + }).catchError((error) {}); + if (baseData != null && baseData.isSuccess) { + setState(() { + minOrderInfo = baseData.data; + }); + } + } + queryAddress(int selectedBtn) async { this.selectedBtn = selectedBtn; if (address != null) { @@ -141,18 +171,21 @@ class _Settlement extends State { } } + PlaceOrderFirst placeOrderFirst; + DownOrder downOrder; + ///小程序下单 queryPlaceOrderFirst() async { - for (int i = 0; i < shopCarGoods.shoppingCartSkuItemList.length; i++) { + for (int i = 0; i < settleOrderInfo.orderProductList.length; i++) { settleOrderInfo.orderProductList.forEach((element1) { - if (shopCarGoods.shoppingCartSkuItemList[i].productId == + if (settleOrderInfo.orderProductList[i].productId == element1.productId) { - shopCarGoods.shoppingCartSkuItemList[i].skuId = element1.skuId; + settleOrderInfo.orderProductList[i].skuId = element1.skuId; } }); } - PlaceOrderFirst placeOrderFirst = PlaceOrderFirst(); + placeOrderFirst = PlaceOrderFirst(); placeOrderFirst.cartNum = settleOrderInfo.orderNum; placeOrderFirst.cartSum = settleOrderInfo.price; placeOrderFirst.addressId = address == null ? null : address.id; @@ -163,8 +196,8 @@ class _Settlement extends State { placeOrderFirst.orderSource = 2; placeOrderFirst.orderType = "0"; placeOrderFirst.orderTypeId = 0; - placeOrderFirst.parentCode = ""; // 火锅加菜 - placeOrderFirst.parentId = "0"; // 火锅加菜 + placeOrderFirst.parentCode = parentCode; // 火锅加菜 + placeOrderFirst.parentId = parentId; // 火锅加菜 placeOrderFirst.payChannel = payChannel; placeOrderFirst.promotionInfoDTO = PromotionInfoDTOBean(); placeOrderFirst.promotionInfoDTO.promotionId = @@ -173,26 +206,66 @@ class _Settlement extends State { couponListBean != null ? couponListBean.id : ""; placeOrderFirst.recMobile = (mobile == null || mobile == "") ? mobile : storeInfo.headMobile; - placeOrderFirst.shoppingCartSkuItemList = - shopCarGoods.shoppingCartSkuItemList; + placeOrderFirst.shoppingCartSkuItemList = settleOrderInfo.orderProductList; placeOrderFirst.skuItemDTOList = []; placeOrderFirst.source = 1; placeOrderFirst.storeId = storeInfo.id; placeOrderFirst.subcribeTime = null; - placeOrderFirst.tableId = tableId; - BaseData baseData = await minService - .placeOrderFirst(placeOrderFirst.toJson()) - .catchError((error) { - print("error: $error"); - }); - if (baseData != null && baseData.isSuccess) { - querySettlement(placeOrderFirst, baseData.data); + placeOrderFirst.tableId = "$tableId"; + + if (tableId == 0) {///正常的商店下单 + BaseData baseData = await minService + .placeOrderFirst(placeOrderFirst.toJson()) + .catchError((error) { + print("error: $error"); + }); + if (baseData != null && baseData.isSuccess) { + placeOrder = true; + this.downOrder = baseData.data; + querySettlement(); + } + } else { ///火锅店下单, 等待结算 + BaseData baseData; + if (parentId == "") { + baseData = await minService + .placeOrderFirst(placeOrderFirst.toJson()) + .catchError((error) { + print("error: $error"); + }); + } else { + baseData = await minService + .addOrder(placeOrderFirst.toJson()) + .catchError((error) { + print("error: $error"); + }); + } + if (baseData != null && baseData.isSuccess) { + placeOrder = true; + this.downOrder = baseData.data; + queryOrderDetails(parentId); + setState(() {}); + } } } +//Undefined symbols for architecture armv7: +// "_OBJC_CLASS_$_HmsBitMap", referenced from: +// objc-class-ref in libflutter_scankit.a(FLScanKitView.o) +// objc-class-ref in libflutter_scankit.a(FlutterScankitPlugin.o) +// "_OBJC_CLASS_$_HmsDefaultScanViewController", referenced from: +// objc-class-ref in libflutter_scankit.a(FlutterScankitPlugin.o) +// "_OBJC_CLASS_$_HmsCustomScanViewController", referenced from: +// objc-class-ref in libflutter_scankit.a(FLScanKitView.o) +// "_OBJC_CLASS_$_HmsScanOptions", referenced from: +// objc-class-ref in libflutter_scankit.a(FLScanKitView.o) +// objc-class-ref in libflutter_scankit.a(FlutterScankitPlugin.o) +// ld: symbol(s) not found for architecture armv7 +// clang: error: linker command failed with exit code 1 (use -v to see invocation) + + ///结算 - querySettlement(PlaceOrderFirst placeOrderFirst, DownOrder downOrder) async { - placeOrderFirst.id = downOrder.id; + querySettlement() async { + placeOrderFirst.id = parentId != "" ? parentId : downOrder.id; placeOrderFirst.orderProductVOList = downOrder.orderProductVOList; if (placeOrderFirst.payChannel == 1) { if (!(await Min.isInitialize())) { @@ -236,9 +309,12 @@ class _Settlement extends State { } toOrderDetails(String orderId) { - Navigator.of(context).popAndPushNamed('/router/order_details', arguments: { - "id": orderId, - }); + Navigator.of(context).popAndPushNamed( + '/router/order_details', + arguments: { + "id": orderId, + }, + ); } @override @@ -297,6 +373,7 @@ class _Settlement extends State { SettlementOrderCommodity( selectedBtn, settleOrderInfo, + minOrderInfo, ), ///优惠券/备注 @@ -333,7 +410,9 @@ class _Settlement extends State { ), ), Text( - "¥${settleOrderInfo == null ? "" : settleOrderInfo.price}", + minOrderInfo != null ? + "¥${minOrderInfo.orderSumPrice}" : + "¥${settleOrderInfo == null ? "0" : settleOrderInfo.price}", style: TextStyle( fontSize: 20.sp, fontWeight: MyFontWeight.semi_bold, @@ -346,7 +425,7 @@ class _Settlement extends State { RoundButton( width: 103.w, height: 54.h, - text: S.current.jiesuan, + text: placeOrder ? S.current.jiesuan : "下单", textColor: Colors.white, fontWeight: MyFontWeight.regular, backgroup: Color(0xFF32A060), diff --git a/lib/settlement/settlement_view/settlement_order_commodity.dart b/lib/settlement/settlement_view/settlement_order_commodity.dart index f4c18d19..8e351e4a 100644 --- a/lib/settlement/settlement_view/settlement_order_commodity.dart +++ b/lib/settlement/settlement_view/settlement_order_commodity.dart @@ -1,7 +1,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:huixiang/generated/l10n.dart'; -import 'package:huixiang/retrofit/data/findMiNiGroupList.dart'; +import 'package:huixiang/retrofit/data/min_order_info.dart'; import 'package:huixiang/retrofit/data/settleOrderInfo.dart'; import 'package:huixiang/utils/font_weight.dart'; import 'package:huixiang/view_widget/custom_image.dart'; @@ -11,13 +11,16 @@ class SettlementOrderCommodity extends StatefulWidget { final int isTakeOut; final SettleOrderInfo settleOrderInfo; + final MinOrderInfo minOrderInfo; - SettlementOrderCommodity(this.isTakeOut, this.settleOrderInfo); + SettlementOrderCommodity( + this.isTakeOut, this.settleOrderInfo, this.minOrderInfo); @override State createState() { return _SettlementOrderCommodity(); } + } class _SettlementOrderCommodity extends State { @@ -67,7 +70,12 @@ class _SettlementOrderCommodity extends State { List commodityList() { if (widget.settleOrderInfo == null) return []; List widgets = []; - if (widget.settleOrderInfo != null) { + + if (widget.minOrderInfo != null) { + widgets.addAll(widget.minOrderInfo.orderProductVOList + .map((e) => commodityItem(e)) + .toList()); + } else if (widget.settleOrderInfo != null) { widgets.addAll(widget.settleOrderInfo.orderProductList .map((e) => commodityItem(e)) .toList()); @@ -76,13 +84,18 @@ class _SettlementOrderCommodity extends State { if (widget.isTakeOut != 0) { // 配送费 - widgets.add(discountItem( + widgets.add( + discountItem( Color(0xFFFF7A1A), widget.isTakeOut == 1 ? S.of(context).peisongfei : S.of(context).yunfei, "", - "+${widget.settleOrderInfo?.postAge ?? "0"}")); + (widget.minOrderInfo != null) + ? "+${widget.minOrderInfo?.postFee ?? "0"}" + : "+${widget.settleOrderInfo?.postAge ?? "0"}", + ), + ); } widgets.add(Container( @@ -310,9 +323,13 @@ class _SettlementOrderCommodity extends State { children: [ Expanded( child: Text( - S.of(context).gongjijianshangpin((widget.settleOrderInfo != null) - ? widget.settleOrderInfo.orderProductList.length - : "0"), + S.of(context).gongjijianshangpin((widget.minOrderInfo != null) + ? ((widget.minOrderInfo != null) + ? widget.minOrderInfo.orderProductVOList.length + : "0") + : (widget.settleOrderInfo != null) + ? widget.settleOrderInfo.orderProductList.length + : "0"), style: TextStyle( fontSize: 10.sp, color: Color(0xFFA29E9E), @@ -323,7 +340,7 @@ class _SettlementOrderCommodity extends State { ), Container( child: Text( - "已优惠:¥${widget.settleOrderInfo.discountAmount}", + "已优惠:¥${(widget.minOrderInfo != null) ? (widget.minOrderInfo.discountAmount ?? "0") : (widget.settleOrderInfo.discountAmount ?? "0")}", style: TextStyle( fontSize: 12.sp, color: Color(0xFF7B7B7B), @@ -362,6 +379,10 @@ class _SettlementOrderCommodity extends State { } String totalPrice() { + if (widget.minOrderInfo != null && + widget.minOrderInfo.orderProductVOList != null) { + return "${widget.minOrderInfo.orderSumPrice}"; + } if (widget.settleOrderInfo.orderProductList == null) return ""; return "${widget.settleOrderInfo.price}"; } diff --git a/lib/store/store_order.dart b/lib/store/store_order.dart index 24ec32c6..b32bfe60 100644 --- a/lib/store/store_order.dart +++ b/lib/store/store_order.dart @@ -489,7 +489,7 @@ class _StoreOrderPage extends State toDownOrder() async { int num = count(); - if (num == 0) { + if (tableId > 0 && num == 0) { SmartDialog.showToast("请先选择您要购买的商品!~"); return; } diff --git a/lib/union/union_page.dart b/lib/union/union_page.dart index 7762ab6e..8f26aeaa 100644 --- a/lib/union/union_page.dart +++ b/lib/union/union_page.dart @@ -302,55 +302,55 @@ class _UnionPage extends State } toScan(Store store) async { - Navigator.of(context).pushNamed( - '/router/store_order', - arguments: { - "id": store.id, - "tenant": store.tenantCode, - "storeName": store.storeName, - "tableId": 1315903669597634560, - }, - ); + // Navigator.of(context).pushNamed( + // '/router/store_order', + // arguments: { + // "id": store.id, + // "tenant": store.tenantCode, + // "storeName": store.storeName, + // "tableId": 1315903669597634560, + // }, + // ); - // if (await Permission.camera.isPermanentlyDenied) { - // showCupertinoDialog( - // context: context, - // builder: (context) { - // return RequestPermission( - // "assets/image/icon_camera_permission_tips.png", - // S.of(context).ninxiangjiquanxianweikaiqi, - // S.of(context).weilekaipaizhaoxuanzhetouxiang, - // S.of(context).kaiqiquanxian, - // (result) async { - // if (result) { - // await openAppSettings(); - // } - // }, - // heightRatioWithWidth: 0.82, - // ); - // }); - // } else if (await Permission.camera.isGranted) { - // var result = await Navigator.of(context).pushNamed('/router/qr_scan'); - // - // if (result != null && result != "") { - // Uri uri = Uri.parse(result); - // String table = uri.queryParameters["tableId"]; - // if (table != null && table != "") { - // int tableId = int.tryParse(table); - // Navigator.of(context).pushNamed( - // '/router/store_order', - // arguments: { - // "id": store.id, - // "tenant": store.tenantCode, - // "storeName": store.storeName, - // "tableId": tableId, - // }, - // ); - // } - // } - // } else { - // await Permission.camera.request(); - // } + if (await Permission.camera.isPermanentlyDenied) { + showCupertinoDialog( + context: context, + builder: (context) { + return RequestPermission( + "assets/image/icon_camera_permission_tips.png", + S.of(context).ninxiangjiquanxianweikaiqi, + S.of(context).weilekaipaizhaoxuanzhetouxiang, + S.of(context).kaiqiquanxian, + (result) async { + if (result) { + await openAppSettings(); + } + }, + heightRatioWithWidth: 0.82, + ); + }); + } else if (await Permission.camera.isGranted) { + var result = await Navigator.of(context).pushNamed('/router/qr_scan'); + + if (result != null && result != "") { + Uri uri = Uri.parse(result); + String table = uri.queryParameters["tableId"]; + if (table != null && table != "") { + int tableId = int.tryParse(table); + Navigator.of(context).pushNamed( + '/router/store_order', + arguments: { + "id": store.id, + "tenant": store.tenantCode, + "storeName": store.storeName, + "tableId": tableId, + }, + ); + } + } + } else { + await Permission.camera.request(); + } } Widget buildSearchItem() { diff --git a/pubspec.yaml b/pubspec.yaml index e657ae81..f6edf240 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -21,11 +21,9 @@ dependencies: git: url: git://github.com/TencentCloud/TPNS-Flutter-Plugin ref: V1.1.2 - # tpns_flutter_plugin: ^1.1.0 like_button: ^2.0.2 cupertino_icons: ^1.0.2 - # flutter_swiper_null_safety: ^1.0.2 flutter_swiper: ^1.1.6 flutter_staggered_grid_view: ^0.4.0 # Null safety pull_to_refresh: ^2.0.0 # Null safety @@ -54,24 +52,14 @@ dependencies: flutter_smart_dialog: ^2.1.6 barcode_widget: ^2.0.1 -# flutter_qr_reader: ^1.0.5 qr_flutter: ^4.0.0 url_launcher: ^5.0.0 -# image_cropper: ^1.4.1 -# image_picker_gallery_camera: ^0.1.6 - #多图, 裁剪 image_pickers: ^2.0.0 flutter_scankit: ^1.2.0 - # 数量,视频时长 -# images_picker: ^1.2.4 - - # 多图,带UI -# wechat_assets_picker: ^4.2.2 - path_provider: ^1.2.0 cached_network_image: ^2.0.0 @@ -79,7 +67,6 @@ dependencies: webview_flutter: ^1.0.7 chewie_audio: ^1.1.2 -# camera: ^0.5.8+17 photo_view: ^0.11.1 video_player: ^1.0.1 @@ -95,11 +82,8 @@ dependencies: flutter_svg: ^0.20.0-nullsafety.3 font_awesome_flutter: ^9.1.0 -# flutter_bugly: ^0.3.3 -# bitmap: ^0.1.2 -# decimal: ^1.3.0 + ai_decimal_accuracy: ^1.1.0 -# zefyr: ^0.12.0 dev_dependencies: flutter_test: From 3378fbdc1a80e0c0223e184b9042730476b0d7d3 Mon Sep 17 00:00:00 2001 From: fmk Date: Sat, 23 Oct 2021 18:30:03 +0800 Subject: [PATCH 09/20] safety --- lib/retrofit/data/base_data.g.dart | 37 + lib/retrofit/data/page.g.dart | 41 + lib/retrofit/min_api.g.dart | 383 ++++++++ lib/retrofit/retrofit_api.g.dart | 1348 ++++++++++++++++++++++++++++ 4 files changed, 1809 insertions(+) create mode 100644 lib/retrofit/data/base_data.g.dart create mode 100644 lib/retrofit/data/page.g.dart create mode 100644 lib/retrofit/min_api.g.dart create mode 100644 lib/retrofit/retrofit_api.g.dart diff --git a/lib/retrofit/data/base_data.g.dart b/lib/retrofit/data/base_data.g.dart new file mode 100644 index 00000000..3a4ba372 --- /dev/null +++ b/lib/retrofit/data/base_data.g.dart @@ -0,0 +1,37 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'base_data.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +BaseData _$BaseDataFromJson( + Map json, + T Function(Object json) fromJsonT, +) { + return BaseData() + ..code = json['code'] as int + ..data = fromJsonT(json['data']) + ..extra = json['extra'] + ..isError = json['isError'] as bool + ..isSuccess = json['isSuccess'] as bool + ..msg = json['msg'] as String + ..path = json['path'] as String + ..timestamp = json['timestamp'] as String; +} + +Map _$BaseDataToJson( + BaseData instance, + Object Function(T value) toJsonT, +) => + { + 'code': instance.code, + 'data': toJsonT(instance.data), + 'extra': instance.extra, + 'isError': instance.isError, + 'isSuccess': instance.isSuccess, + 'msg': instance.msg, + 'path': instance.path, + 'timestamp': instance.timestamp, + }; diff --git a/lib/retrofit/data/page.g.dart b/lib/retrofit/data/page.g.dart new file mode 100644 index 00000000..e40a14ae --- /dev/null +++ b/lib/retrofit/data/page.g.dart @@ -0,0 +1,41 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'page.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +PageInfo _$PageInfoFromJson( + Map json, + D Function(Object json) fromJsonD, +) { + return PageInfo() + ..pageNum = json['pageNum'] as int + ..current = json['current'] + ..pageSize = json['pageSize'] as int + ..size = json['size'] + ..pages = json['pages'] + ..hasPreviousPage = json['hasPreviousPage'] as bool + ..hasNextPage = json['hasNextPage'] as bool + ..total = json['total'] as String + ..list = (json['list'] as List)?.map(fromJsonD)?.toList() + ..records = (json['records'] as List)?.map(fromJsonD)?.toList(); +} + +Map _$PageInfoToJson( + PageInfo instance, + Object Function(D value) toJsonD, +) => + { + 'pageNum': instance.pageNum, + 'current': instance.current, + 'pageSize': instance.pageSize, + 'size': instance.size, + 'pages': instance.pages, + 'hasPreviousPage': instance.hasPreviousPage, + 'hasNextPage': instance.hasNextPage, + 'total': instance.total, + 'list': instance.list?.map(toJsonD)?.toList(), + 'records': instance.records?.map(toJsonD)?.toList(), + }; diff --git a/lib/retrofit/min_api.g.dart b/lib/retrofit/min_api.g.dart new file mode 100644 index 00000000..18b5a5d8 --- /dev/null +++ b/lib/retrofit/min_api.g.dart @@ -0,0 +1,383 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'min_api.dart'; + +// ************************************************************************** +// RetrofitGenerator +// ************************************************************************** + +class _MinApiService implements MinApiService { + _MinApiService(this._dio, {this.baseUrl}) { + ArgumentError.checkNotNull(_dio, '_dio'); + baseUrl ??= 'http://192.168.10.236:8765/app/'; + } + + final Dio _dio; + + String baseUrl; + + @override + Future>> findMiNiGroupList(param) async { + ArgumentError.checkNotNull(param, 'param'); + const _extra = {}; + final queryParameters = {}; + final _data = {}; + _data.addAll(param ?? {}); + final _result = await _dio.request>( + 'product/findMiNiGroupList', + queryParameters: queryParameters, + options: RequestOptions( + method: 'POST', + headers: {}, + extra: _extra, + baseUrl: baseUrl), + data: _data); + final value = BaseData>.fromJson( + _result.data, + (json) => (json as List) + .map( + (i) => FindMiNiGroupList.fromJson(i as Map)) + .toList()); + return value; + } + + @override + Future> miNiDetail(id) async { + ArgumentError.checkNotNull(id, 'id'); + const _extra = {}; + final queryParameters = {}; + final _data = {}; + final _result = await _dio.request>( + '/product/queryMiNiProductDetail?id=$id', + queryParameters: queryParameters, + options: RequestOptions( + method: 'GET', + headers: {}, + extra: _extra, + baseUrl: baseUrl), + data: _data); + final value = BaseData.fromJson( + _result.data, + (json) => MiNiDetail.fromJson(json), + ); + return value; + } + + @override + Future>> addShoppingCart(param) async { + ArgumentError.checkNotNull(param, 'param'); + const _extra = {}; + final queryParameters = {}; + final _data = {}; + _data.addAll(param ?? {}); + final _result = await _dio.request>('shoppingcart', + queryParameters: queryParameters, + options: RequestOptions( + method: 'POST', + headers: {}, + extra: _extra, + baseUrl: baseUrl), + data: _data); + final value = BaseData>.fromJson( + _result.data, + (json) => (json as List) + .map( + (i) => ShoppingCart.fromJson(i as Map)) + .toList()); + return value; + } + + @override + Future>> getShoppingCart(tableId) async { + ArgumentError.checkNotNull(tableId, 'tableId'); + const _extra = {}; + final queryParameters = {r'tableId': tableId}; + final _data = {}; + final _result = await _dio.request>('shoppingcart', + queryParameters: queryParameters, + options: RequestOptions( + method: 'GET', + headers: {}, + extra: _extra, + baseUrl: baseUrl), + data: _data); + final value = BaseData>.fromJson( + _result.data, + (json) => (json as List) + .map( + (i) => ShoppingCart.fromJson(i as Map)) + .toList()); + return value; + } + + @override + Future> clearShoppingCart() async { + const _extra = {}; + final queryParameters = {}; + final _data = {}; + final _result = await _dio.request>( + 'shoppingcart/delCart', + queryParameters: queryParameters, + options: RequestOptions( + method: 'GET', + headers: {}, + extra: _extra, + baseUrl: baseUrl), + data: _data); + final value = BaseData.fromJson( + _result.data, + (json) => json as bool, + ); + return value; + } + + @override + Future>> shoppingCart1(param) async { + ArgumentError.checkNotNull(param, 'param'); + const _extra = {}; + final queryParameters = {}; + final _data = {}; + _data.addAll(param ?? {}); + final _result = await _dio.request>('shoppingcart', + queryParameters: queryParameters, + options: RequestOptions( + method: 'PUT', + headers: {}, + extra: _extra, + baseUrl: baseUrl), + data: _data); + final value = BaseData>.fromJson( + _result.data, + (json) => (json as List) + .map( + (i) => ShoppingCart.fromJson(i as Map)) + .toList()); + return value; + } + + @override + Future>> shoppingCartSingle(param) async { + ArgumentError.checkNotNull(param, 'param'); + const _extra = {}; + final queryParameters = {}; + final _data = {}; + _data.addAll(param ?? {}); + final _result = await _dio.request>( + 'shoppingcart/single', + queryParameters: queryParameters, + options: RequestOptions( + method: 'PUT', + headers: {}, + extra: _extra, + baseUrl: baseUrl), + data: _data); + final value = BaseData>.fromJson( + _result.data, + (json) => (json as List) + .map( + (i) => ShoppingCart.fromJson(i as Map)) + .toList()); + return value; + } + + @override + Future> getOrderInfo(param) async { + ArgumentError.checkNotNull(param, 'param'); + const _extra = {}; + final queryParameters = {}; + final _data = {}; + _data.addAll(param ?? {}); + final _result = await _dio.request>( + 'order/getOrderInfo', + queryParameters: queryParameters, + options: RequestOptions( + method: 'POST', + headers: {}, + extra: _extra, + baseUrl: baseUrl), + data: _data); + final value = BaseData.fromJson( + _result.data, + (json) => SettleOrderInfo.fromJson(json), + ); + return value; + } + + @override + Future> getOrderDetails(param) async { + ArgumentError.checkNotNull(param, 'param'); + const _extra = {}; + final queryParameters = {}; + final _data = {}; + _data.addAll(param ?? {}); + final _result = await _dio.request>( + 'order/getOrderDetail', + queryParameters: queryParameters, + options: RequestOptions( + method: 'POST', + headers: {}, + extra: _extra, + baseUrl: baseUrl), + data: _data); + final value = BaseData.fromJson( + _result.data, + (json) => MinOrderInfo.fromJson(json), + ); + return value; + } + + @override + Future>> queryAddress() async { + const _extra = {}; + final queryParameters = {}; + final _data = {}; + final _result = await _dio.request>( + 'address/queryMemberAddress', + queryParameters: queryParameters, + options: RequestOptions( + method: 'GET', + headers: {}, + extra: _extra, + baseUrl: baseUrl), + data: _data); + final value = BaseData>.fromJson( + _result.data, + (json) => (json as List) + .map
((i) => Address.fromJson(i as Map)) + .toList()); + return value; + } + + @override + Future> placeOrderFirst(param) async { + ArgumentError.checkNotNull(param, 'param'); + const _extra = {}; + final queryParameters = {}; + final _data = {}; + _data.addAll(param ?? {}); + final _result = await _dio.request>( + 'order/placeOrderFirst', + queryParameters: queryParameters, + options: RequestOptions( + method: 'POST', + headers: {}, + extra: _extra, + baseUrl: baseUrl), + data: _data); + final value = BaseData.fromJson( + _result.data, + (json) => DownOrder.fromJson(json), + ); + return value; + } + + @override + Future> addOrder(param) async { + ArgumentError.checkNotNull(param, 'param'); + const _extra = {}; + final queryParameters = {}; + final _data = {}; + _data.addAll(param ?? {}); + final _result = await _dio.request>('order/addOrder', + queryParameters: queryParameters, + options: RequestOptions( + method: 'POST', + headers: {}, + extra: _extra, + baseUrl: baseUrl), + data: _data); + final value = BaseData.fromJson( + _result.data, + (json) => DownOrder.fromJson(json), + ); + return value; + } + + @override + Future> settlementWx(param) async { + ArgumentError.checkNotNull(param, 'param'); + const _extra = {}; + final queryParameters = {}; + final _data = {}; + _data.addAll(param ?? {}); + final _result = await _dio.request>('order/settlement', + queryParameters: queryParameters, + options: RequestOptions( + method: 'POST', + headers: {}, + extra: _extra, + baseUrl: baseUrl), + data: _data); + final value = BaseData.fromJson( + _result.data, + (json) => WxPay.fromJson(json), + ); + return value; + } + + @override + Future> settlementApi(param) async { + ArgumentError.checkNotNull(param, 'param'); + const _extra = {}; + final queryParameters = {}; + final _data = {}; + _data.addAll(param ?? {}); + final _result = await _dio.request>('order/settlement', + queryParameters: queryParameters, + options: RequestOptions( + method: 'POST', + headers: {}, + extra: _extra, + baseUrl: baseUrl), + data: _data); + final value = BaseData.fromJson( + _result.data, + (json) => json as dynamic, + ); + return value; + } + + @override + Future> queryStoreInfo1(param) async { + ArgumentError.checkNotNull(param, 'param'); + const _extra = {}; + final queryParameters = {}; + final _data = {}; + _data.addAll(param ?? {}); + final _result = await _dio.request>('store/getStore', + queryParameters: queryParameters, + options: RequestOptions( + method: 'POST', + headers: {}, + extra: _extra, + baseUrl: baseUrl), + data: _data); + final value = BaseData.fromJson( + _result.data, + (json) => json as dynamic, + ); + return value; + } + + @override + Future> getParentInfo(tableId) async { + ArgumentError.checkNotNull(tableId, 'tableId'); + const _extra = {}; + final queryParameters = {}; + final _data = {}; + final _result = await _dio.request>( + 'order/getParentInfo?tableId=$tableId', + queryParameters: queryParameters, + options: RequestOptions( + method: 'GET', + headers: {}, + extra: _extra, + baseUrl: baseUrl), + data: _data); + final value = BaseData.fromJson( + _result.data, + (json) => json as dynamic, + ); + return value; + } +} diff --git a/lib/retrofit/retrofit_api.g.dart b/lib/retrofit/retrofit_api.g.dart new file mode 100644 index 00000000..1024cdf2 --- /dev/null +++ b/lib/retrofit/retrofit_api.g.dart @@ -0,0 +1,1348 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'retrofit_api.dart'; + +// ************************************************************************** +// RetrofitGenerator +// ************************************************************************** + +class _ApiService implements ApiService { + _ApiService(this._dio, {this.baseUrl}) { + ArgumentError.checkNotNull(_dio, '_dio'); + baseUrl ??= 'http://192.168.10.236:8766/app/'; + } + + final Dio _dio; + + String baseUrl; + + @override + Future> upload(data, folderId) async { + ArgumentError.checkNotNull(data, 'data'); + ArgumentError.checkNotNull(folderId, 'folderId'); + const _extra = {}; + final queryParameters = {}; + final _data = FormData(); + _data.files.add(MapEntry( + 'file', + MultipartFile.fromFileSync(data.path, + filename: data.path.split(Platform.pathSeparator).last))); + if (folderId != null) { + _data.fields.add(MapEntry('folderId', folderId.toString())); + } + final _result = await _dio.request>('/file/upload', + queryParameters: queryParameters, + options: RequestOptions( + method: 'POST', + headers: {}, + extra: _extra, + baseUrl: baseUrl), + data: _data); + final value = BaseData.fromJson( + _result.data, + (json) => UploadResult.fromJson(json), + ); + return value; + } + + @override + Future searchPoi(lat, lng, keywords, size, page) async { + ArgumentError.checkNotNull(lat, 'lat'); + ArgumentError.checkNotNull(lng, 'lng'); + ArgumentError.checkNotNull(keywords, 'keywords'); + ArgumentError.checkNotNull(size, 'size'); + ArgumentError.checkNotNull(page, 'page'); + const _extra = {}; + final queryParameters = {}; + final _data = {}; + final _result = await _dio.request( + 'https://restapi.amap.com/v3/place/around?key=542b46afa8e4b88fe1eb3c4d0ba0872f&location=$lat,$lng&keywords=$keywords&offset={size}&page={page}&extensions=all', + queryParameters: queryParameters, + options: RequestOptions( + method: 'GET', + headers: {}, + extra: _extra, + baseUrl: baseUrl), + data: _data); + final value = _result.data; + return value; + } + + @override + Future> memberLogin(param) async { + ArgumentError.checkNotNull(param, 'param'); + const _extra = {}; + final queryParameters = {}; + final _data = {}; + _data.addAll(param ?? {}); + final _result = await _dio.request>( + '/auth/platform/memberLogin', + queryParameters: queryParameters, + options: RequestOptions( + method: 'POST', + headers: {}, + extra: _extra, + baseUrl: baseUrl), + data: _data); + final value = BaseData.fromJson( + _result.data, + (json) => json as dynamic, + ); + return value; + } + + @override + Future> sendVerify(mobile) async { + ArgumentError.checkNotNull(mobile, 'mobile'); + const _extra = {}; + final queryParameters = {}; + final _data = {}; + final _result = await _dio.request>( + '/auth/sendVerify/$mobile', + queryParameters: queryParameters, + options: RequestOptions( + method: 'GET', + headers: {}, + extra: _extra, + baseUrl: baseUrl), + data: _data); + final value = BaseData.fromJson( + _result.data, + (json) => json as dynamic, + ); + return value; + } + + @override + Future>> creditGoods(param) async { + ArgumentError.checkNotNull(param, 'param'); + const _extra = {}; + final queryParameters = {}; + final _data = {}; + _data.addAll(param ?? {}); + final _result = await _dio.request>( + '/creditGoods/list', + queryParameters: queryParameters, + options: RequestOptions( + method: 'POST', + headers: {}, + extra: _extra, + baseUrl: baseUrl), + data: _data); + final value = BaseData>.fromJson( + _result.data, + (json) => PageInfo.fromJson( + json, + (json) => Goods.fromJson(json), + ), + ); + return value; + } + + @override + Future>> goodsCategory(param) async { + ArgumentError.checkNotNull(param, 'param'); + const _extra = {}; + final queryParameters = {}; + final _data = {}; + _data.addAll(param ?? {}); + final _result = await _dio.request>( + '/creditGoodsCategory/page', + queryParameters: queryParameters, + options: RequestOptions( + method: 'POST', + headers: {}, + extra: _extra, + baseUrl: baseUrl), + data: _data); + final value = BaseData>.fromJson( + _result.data, + (json) => PageInfo.fromJson( + json, + (json) => GoodsCategory.fromJson(json), + ), + ); + return value; + } + + @override + Future> creditGoodsById(id) async { + ArgumentError.checkNotNull(id, 'id'); + const _extra = {}; + final queryParameters = {}; + final _data = {}; + final _result = await _dio.request>('/creditGoods/$id', + queryParameters: queryParameters, + options: RequestOptions( + method: 'GET', + headers: {}, + extra: _extra, + baseUrl: baseUrl), + data: _data); + final value = BaseData.fromJson( + _result.data, + (json) => Goods.fromJson(json), + ); + return value; + } + + @override + Future> queryInfo() async { + const _extra = {}; + final queryParameters = {}; + final _data = {}; + final _result = await _dio.request>('/member/info', + queryParameters: queryParameters, + options: RequestOptions( + method: 'GET', + headers: {}, + extra: _extra, + baseUrl: baseUrl), + data: _data); + final value = BaseData.fromJson( + _result.data, + (json) => UserInfo.fromJson(json), + ); + return value; + } + + @override + Future> editInfo(param) async { + ArgumentError.checkNotNull(param, 'param'); + const _extra = {}; + final queryParameters = {}; + final _data = {}; + _data.addAll(param ?? {}); + final _result = await _dio.request>( + '/member/editMemberInfo', + queryParameters: queryParameters, + options: RequestOptions( + method: 'POST', + headers: {}, + extra: _extra, + baseUrl: baseUrl), + data: _data); + final value = BaseData.fromJson( + _result.data, + (json) => json as dynamic, + ); + return value; + } + + @override + Future> signInInfo() async { + const _extra = {}; + final queryParameters = {}; + final _data = {}; + final _result = await _dio.request>( + '/member/signInInfo', + queryParameters: queryParameters, + options: RequestOptions( + method: 'GET', + headers: {}, + extra: _extra, + baseUrl: baseUrl), + data: _data); + final value = BaseData.fromJson( + _result.data, + (json) => SignInfo.fromJson(json), + ); + return value; + } + + @override + Future> signIn() async { + const _extra = {}; + final queryParameters = {}; + final _data = {}; + final _result = await _dio.request>('/member/signIn', + queryParameters: queryParameters, + options: RequestOptions( + method: 'GET', + headers: {}, + extra: _extra, + baseUrl: baseUrl), + data: _data); + final value = BaseData.fromJson( + _result.data, + (json) => json as dynamic, + ); + return value; + } + + @override + Future> recharge(param) async { + ArgumentError.checkNotNull(param, 'param'); + const _extra = {}; + final queryParameters = {}; + final _data = {}; + _data.addAll(param ?? {}); + final _result = await _dio.request>('/wallet/recharge', + queryParameters: queryParameters, + options: RequestOptions( + method: 'POST', + headers: {}, + extra: _extra, + baseUrl: baseUrl), + data: _data); + final value = BaseData.fromJson( + _result.data, + (json) => WxPay.fromJson(json), + ); + return value; + } + + @override + Future> receiveCoupon(couponId) async { + ArgumentError.checkNotNull(couponId, 'couponId'); + const _extra = {}; + final queryParameters = {}; + final _data = {}; + final _result = await _dio.request>( + '/coupon/receive?couponId=$couponId', + queryParameters: queryParameters, + options: RequestOptions( + method: 'GET', + headers: {}, + extra: _extra, + baseUrl: baseUrl), + data: _data); + final value = BaseData.fromJson( + _result.data, + (json) => json as dynamic, + ); + return value; + } + + @override + Future>> creditOrderList(param) async { + ArgumentError.checkNotNull(param, 'param'); + const _extra = {}; + final queryParameters = {}; + final _data = {}; + _data.addAll(param ?? {}); + final _result = await _dio.request>( + '/creditOrder/list', + queryParameters: queryParameters, + options: RequestOptions( + method: 'POST', + headers: {}, + extra: _extra, + baseUrl: baseUrl), + data: _data); + final value = BaseData>.fromJson( + _result.data, + (json) => PageInfo.fromJson( + json, + (json) => ExchangeOrder.fromJson(json), + ), + ); + return value; + } + + @override + Future> creditOrder(param) async { + ArgumentError.checkNotNull(param, 'param'); + const _extra = {}; + final queryParameters = {}; + final _data = {}; + _data.addAll(param ?? {}); + final _result = await _dio.request>( + '/creditOrder/create', + queryParameters: queryParameters, + options: RequestOptions( + method: 'POST', + headers: {}, + extra: _extra, + baseUrl: baseUrl), + data: _data); + final value = BaseData.fromJson( + _result.data, + (json) => json as dynamic, + ); + return value; + } + + @override + Future> addAddress(param) async { + ArgumentError.checkNotNull(param, 'param'); + const _extra = {}; + final queryParameters = {}; + final _data = {}; + _data.addAll(param ?? {}); + final _result = await _dio.request>('/address/add', + queryParameters: queryParameters, + options: RequestOptions( + method: 'POST', + headers: {}, + extra: _extra, + baseUrl: baseUrl), + data: _data); + final value = BaseData.fromJson( + _result.data, + (json) => json as dynamic, + ); + return value; + } + + @override + Future> deleteAddress(param) async { + ArgumentError.checkNotNull(param, 'param'); + const _extra = {}; + final queryParameters = {}; + final _data = {}; + _data.addAll(param ?? {}); + final _result = await _dio.request>('/address/delete', + queryParameters: queryParameters, + options: RequestOptions( + method: 'POST', + headers: {}, + extra: _extra, + baseUrl: baseUrl), + data: _data); + final value = BaseData.fromJson( + _result.data, + (json) => json as dynamic, + ); + return value; + } + + @override + Future> queryAddress(id) async { + ArgumentError.checkNotNull(id, 'id'); + const _extra = {}; + final queryParameters = {}; + final _data = {}; + final _result = await _dio.request>( + '/address/detail/$id', + queryParameters: queryParameters, + options: RequestOptions( + method: 'GET', + headers: {}, + extra: _extra, + baseUrl: baseUrl), + data: _data); + final value = BaseData.fromJson( + _result.data, + (json) => json as dynamic, + ); + return value; + } + + @override + Future>> queryMemberAddress() async { + const _extra = {}; + final queryParameters = {}; + final _data = {}; + final _result = await _dio.request>( + '/address/queryMemberAddress', + queryParameters: queryParameters, + options: RequestOptions( + method: 'GET', + headers: {}, + extra: _extra, + baseUrl: baseUrl), + data: _data); + final value = BaseData>.fromJson( + _result.data, + (json) => (json as List) + .map
((i) => Address.fromJson(i as Map)) + .toList()); + return value; + } + + @override + Future> updateAddress(param) async { + ArgumentError.checkNotNull(param, 'param'); + const _extra = {}; + final queryParameters = {}; + final _data = {}; + _data.addAll(param ?? {}); + final _result = await _dio.request>('/address/update', + queryParameters: queryParameters, + options: RequestOptions( + method: 'POST', + headers: {}, + extra: _extra, + baseUrl: baseUrl), + data: _data); + final value = BaseData.fromJson( + _result.data, + (json) => json as dynamic, + ); + return value; + } + + @override + Future>> queryCoupon(param) async { + ArgumentError.checkNotNull(param, 'param'); + const _extra = {}; + final queryParameters = {}; + final _data = {}; + _data.addAll(param ?? {}); + final _result = await _dio.request>( + '/coupon/centreList', + queryParameters: queryParameters, + options: RequestOptions( + method: 'POST', + headers: {}, + extra: _extra, + baseUrl: baseUrl), + data: _data); + final value = BaseData>.fromJson( + _result.data, + (json) => PageInfo.fromJson( + json, + (json) => Coupon.fromJson(json), + ), + ); + return value; + } + + @override + Future>> queryCard(param) async { + ArgumentError.checkNotNull(param, 'param'); + const _extra = {}; + final queryParameters = {}; + final _data = {}; + _data.addAll(param ?? {}); + final _result = await _dio.request>( + '/coupon/packageList', + queryParameters: queryParameters, + options: RequestOptions( + method: 'POST', + headers: {}, + extra: _extra, + baseUrl: baseUrl), + data: _data); + final value = BaseData>.fromJson( + _result.data, + (json) => PageInfo.fromJson( + json, + (json) => Coupon.fromJson(json), + ), + ); + return value; + } + + @override + Future>> queryStore(param) async { + ArgumentError.checkNotNull(param, 'param'); + const _extra = {}; + final queryParameters = {}; + final _data = {}; + _data.addAll(param ?? {}); + final _result = await _dio.request>('/store/list', + queryParameters: queryParameters, + options: RequestOptions( + method: 'POST', + headers: {}, + extra: _extra, + baseUrl: baseUrl), + data: _data); + final value = BaseData>.fromJson( + _result.data, + (json) => (json as List) + .map((i) => Store.fromJson(i as Map)) + .toList()); + return value; + } + + @override + Future>> informationList(param) async { + ArgumentError.checkNotNull(param, 'param'); + const _extra = {}; + final queryParameters = {}; + final _data = {}; + _data.addAll(param ?? {}); + final _result = await _dio.request>( + '/information/list', + queryParameters: queryParameters, + options: RequestOptions( + method: 'POST', + headers: {}, + extra: _extra, + baseUrl: baseUrl), + data: _data); + final value = BaseData>.fromJson( + _result.data, + (json) => PageInfo.fromJson( + json, + (json) => Activity.fromJson(json), + ), + ); + return value; + } + + @override + Future> informationInfo(id) async { + ArgumentError.checkNotNull(id, 'id'); + const _extra = {}; + final queryParameters = {}; + final _data = {}; + final _result = await _dio.request>('/information/$id', + queryParameters: queryParameters, + options: RequestOptions( + method: 'GET', + headers: {}, + extra: _extra, + baseUrl: baseUrl), + data: _data); + final value = BaseData
.fromJson( + _result.data, + (json) => Article.fromJson(json), + ); + return value; + } + + @override + Future> activityInfo(id) async { + ArgumentError.checkNotNull(id, 'id'); + const _extra = {}; + final queryParameters = {}; + final _data = {}; + final _result = await _dio.request>('/information/$id', + queryParameters: queryParameters, + options: RequestOptions( + method: 'GET', + headers: {}, + extra: _extra, + baseUrl: baseUrl), + data: _data); + final value = BaseData.fromJson( + _result.data, + (json) => Activity.fromJson(json), + ); + return value; + } + + @override + Future> creditOrderReceive(id) async { + ArgumentError.checkNotNull(id, 'id'); + const _extra = {}; + final queryParameters = {}; + final _data = {}; + final _result = await _dio.request>( + '/creditOrder/receive/$id', + queryParameters: queryParameters, + options: RequestOptions( + method: 'GET', + headers: {}, + extra: _extra, + baseUrl: baseUrl), + data: _data); + final value = BaseData.fromJson( + _result.data, + (json) => json as dynamic, + ); + return value; + } + + @override + Future> queryHome() async { + const _extra = {}; + final queryParameters = {}; + final _data = {}; + final _result = await _dio.request>('/home/home', + queryParameters: queryParameters, + options: RequestOptions( + method: 'GET', + headers: {}, + extra: _extra, + baseUrl: baseUrl), + data: _data); + final value = BaseData.fromJson( + _result.data, + (json) => BrandData.fromJson(json), + ); + return value; + } + + @override + Future> queryStoreInfo(id) async { + ArgumentError.checkNotNull(id, 'id'); + const _extra = {}; + final queryParameters = {}; + final _data = {}; + final _result = await _dio.request>('/store/$id', + queryParameters: queryParameters, + options: RequestOptions( + method: 'GET', + headers: {}, + extra: _extra, + baseUrl: baseUrl), + data: _data); + final value = BaseData.fromJson( + _result.data, + (json) => json as dynamic, + ); + return value; + } + + @override + Future>> queryArticle(param) async { + ArgumentError.checkNotNull(param, 'param'); + const _extra = {}; + final queryParameters = {}; + final _data = {}; + _data.addAll(param ?? {}); + final _result = await _dio.request>( + '/information/list', + queryParameters: queryParameters, + options: RequestOptions( + method: 'POST', + headers: {}, + extra: _extra, + baseUrl: baseUrl), + data: _data); + final value = BaseData>.fromJson( + _result.data, + (json) => PageInfo
.fromJson( + json, + (json) => Article.fromJson(json), + ), + ); + return value; + } + + @override + Future>> queryBanner(param) async { + ArgumentError.checkNotNull(param, 'param'); + const _extra = {}; + final queryParameters = {}; + final _data = {}; + _data.addAll(param ?? {}); + final _result = await _dio.request>('/banner/page', + queryParameters: queryParameters, + options: RequestOptions( + method: 'POST', + headers: {}, + extra: _extra, + baseUrl: baseUrl), + data: _data); + final value = BaseData>.fromJson( + _result.data, + (json) => PageInfo.fromJson( + json, + (json) => BannerData.fromJson(json), + ), + ); + return value; + } + + @override + Future> queryHomeBrand() async { + const _extra = {}; + final queryParameters = {}; + final _data = {}; + final _result = await _dio.request>('/home/brand', + queryParameters: queryParameters, + options: RequestOptions( + method: 'GET', + headers: {}, + extra: _extra, + baseUrl: baseUrl), + data: _data); + final value = BaseData.fromJson( + _result.data, + (json) => json as dynamic, + ); + return value; + } + + @override + Future> minLogin(storeId) async { + ArgumentError.checkNotNull(storeId, 'storeId'); + const _extra = {}; + final queryParameters = {}; + final _data = {}; + final _result = await _dio.request>( + '/auth/mini/login/$storeId', + queryParameters: queryParameters, + options: RequestOptions( + method: 'GET', + headers: {}, + extra: _extra, + baseUrl: baseUrl), + data: _data); + final value = BaseData.fromJson( + _result.data, + (json) => json as dynamic, + ); + return value; + } + + @override + Future>> queryBillInfo(param) async { + ArgumentError.checkNotNull(param, 'param'); + const _extra = {}; + final queryParameters = {}; + final _data = {}; + _data.addAll(param ?? {}); + final _result = await _dio.request>('/member/listBill', + queryParameters: queryParameters, + options: RequestOptions( + method: 'POST', + headers: {}, + extra: _extra, + baseUrl: baseUrl), + data: _data); + final value = BaseData>.fromJson( + _result.data, + (json) => PageInfo.fromJson( + json, + (json) => UserBill.fromJson(json), + ), + ); + return value; + } + + @override + Future>> rankList() async { + const _extra = {}; + final queryParameters = {}; + final _data = {}; + final _result = await _dio.request>('/member/rankList', + queryParameters: queryParameters, + options: RequestOptions( + method: 'GET', + headers: {}, + extra: _extra, + baseUrl: baseUrl), + data: _data); + final value = BaseData>.fromJson( + _result.data, + (json) => (json as List) + .map((i) => Rank.fromJson(i as Map)) + .toList()); + return value; + } + + @override + Future>> orderList(param) async { + ArgumentError.checkNotNull(param, 'param'); + const _extra = {}; + final queryParameters = {}; + final _data = {}; + _data.addAll(param ?? {}); + final _result = await _dio.request>('/order/list', + queryParameters: queryParameters, + options: RequestOptions( + method: 'POST', + headers: {}, + extra: _extra, + baseUrl: baseUrl), + data: _data); + final value = BaseData>.fromJson( + _result.data, + (json) => PageInfo.fromJson( + json, + (json) => OrderInfo.fromJson(json), + ), + ); + return value; + } + + @override + Future> orderDetail(id) async { + ArgumentError.checkNotNull(id, 'id'); + const _extra = {}; + final queryParameters = {}; + final _data = {}; + final _result = await _dio.request>( + '/order/orderDetail?id=$id', + queryParameters: queryParameters, + options: RequestOptions( + method: 'GET', + headers: {}, + extra: _extra, + baseUrl: baseUrl), + data: _data); + final value = BaseData.fromJson( + _result.data, + (json) => OrderInfo.fromJson(json), + ); + return value; + } + + @override + Future> continuePay(param) async { + ArgumentError.checkNotNull(param, 'param'); + const _extra = {}; + final queryParameters = {}; + final _data = {}; + _data.addAll(param ?? {}); + final _result = await _dio.request>( + '/order/continuePay', + queryParameters: queryParameters, + options: RequestOptions( + method: 'POST', + headers: {}, + extra: _extra, + baseUrl: baseUrl), + data: _data); + final value = BaseData.fromJson( + _result.data, + (json) => json as dynamic, + ); + return value; + } + + @override + Future> receiveToCard(id) async { + ArgumentError.checkNotNull(id, 'id'); + const _extra = {}; + final queryParameters = {}; + final _data = {}; + final _result = await _dio.request>( + '/creditOrder/receive/$id', + queryParameters: queryParameters, + options: RequestOptions( + method: 'GET', + headers: {}, + extra: _extra, + baseUrl: baseUrl), + data: _data); + final value = BaseData.fromJson( + _result.data, + (json) => json as dynamic, + ); + return value; + } + + @override + Future>> vipList(param) async { + ArgumentError.checkNotNull(param, 'param'); + const _extra = {}; + final queryParameters = {}; + final _data = {}; + _data.addAll(param ?? {}); + final _result = await _dio.request>('/member/vipList', + queryParameters: queryParameters, + options: RequestOptions( + method: 'POST', + headers: {}, + extra: _extra, + baseUrl: baseUrl), + data: _data); + final value = BaseData>.fromJson( + _result.data, + (json) => (json as List) + .map((i) => VipCard.fromJson(i as Map)) + .toList()); + return value; + } + + @override + Future> vipDetail(param) async { + ArgumentError.checkNotNull(param, 'param'); + const _extra = {}; + final queryParameters = {}; + final _data = {}; + _data.addAll(param ?? {}); + final _result = await _dio.request>( + '/member/vipDetail', + queryParameters: queryParameters, + options: RequestOptions( + method: 'POST', + headers: {}, + extra: _extra, + baseUrl: baseUrl), + data: _data); + final value = BaseData.fromJson( + _result.data, + (json) => VipCard.fromJson(json), + ); + return value; + } + + @override + Future>> msgList(param) async { + ArgumentError.checkNotNull(param, 'param'); + const _extra = {}; + final queryParameters = {}; + final _data = {}; + _data.addAll(param ?? {}); + final _result = await _dio.request>('/app-msg/list', + queryParameters: queryParameters, + options: RequestOptions( + method: 'POST', + headers: {}, + extra: _extra, + baseUrl: baseUrl), + data: _data); + final value = BaseData>.fromJson( + _result.data, + (json) => PageInfo.fromJson( + json, + (json) => Message.fromJson(json), + ), + ); + return value; + } + + @override + Future> queryMsg(id) async { + ArgumentError.checkNotNull(id, 'id'); + const _extra = {}; + final queryParameters = {}; + final _data = {}; + final _result = await _dio.request>('/app-msg/$id', + queryParameters: queryParameters, + options: RequestOptions( + method: 'GET', + headers: {}, + extra: _extra, + baseUrl: baseUrl), + data: _data); + final value = BaseData.fromJson( + _result.data, + (json) => json as dynamic, + ); + return value; + } + + @override + Future> informationLikes(id) async { + ArgumentError.checkNotNull(id, 'id'); + const _extra = {}; + final queryParameters = {}; + final _data = {}; + final _result = await _dio.request>( + '/information/likes/$id', + queryParameters: queryParameters, + options: RequestOptions( + method: 'GET', + headers: {}, + extra: _extra, + baseUrl: baseUrl), + data: _data); + final value = BaseData.fromJson( + _result.data, + (json) => json as dynamic, + ); + return value; + } + + @override + Future> memberComment(param) async { + ArgumentError.checkNotNull(param, 'param'); + const _extra = {}; + final queryParameters = {}; + final _data = {}; + _data.addAll(param ?? {}); + final _result = await _dio.request>('/memberComment', + queryParameters: queryParameters, + options: RequestOptions( + method: 'POST', + headers: {}, + extra: _extra, + baseUrl: baseUrl), + data: _data); + final value = BaseData.fromJson( + _result.data, + (json) => json as dynamic, + ); + return value; + } + + @override + Future>> memberCommentList(param) async { + ArgumentError.checkNotNull(param, 'param'); + const _extra = {}; + final queryParameters = {}; + final _data = {}; + _data.addAll(param ?? {}); + final _result = await _dio.request>( + '/memberComment/list', + queryParameters: queryParameters, + options: RequestOptions( + method: 'POST', + headers: {}, + extra: _extra, + baseUrl: baseUrl), + data: _data); + final value = BaseData>.fromJson( + _result.data, + (json) => PageInfo.fromJson( + json, + (json) => MemberCommentList.fromJson(json), + ), + ); + return value; + } + + @override + Future> commentLike(id) async { + ArgumentError.checkNotNull(id, 'id'); + const _extra = {}; + final queryParameters = {}; + final _data = {}; + final _result = await _dio.request>( + '/memberComment/likes/$id', + queryParameters: queryParameters, + options: RequestOptions( + method: 'GET', + headers: {}, + extra: _extra, + baseUrl: baseUrl), + data: _data); + final value = BaseData.fromJson( + _result.data, + (json) => json as dynamic, + ); + return value; + } + + @override + Future> delComment(id) async { + ArgumentError.checkNotNull(id, 'id'); + const _extra = {}; + final queryParameters = {}; + final _data = {}; + final _result = await _dio.request>( + '/memberComment/delete/$id', + queryParameters: queryParameters, + options: RequestOptions( + method: 'GET', + headers: {}, + extra: _extra, + baseUrl: baseUrl), + data: _data); + final value = BaseData.fromJson( + _result.data, + (json) => json as dynamic, + ); + return value; + } + + @override + Future> shippingTrace(shipperCode, logisticCode) async { + ArgumentError.checkNotNull(shipperCode, 'shipperCode'); + ArgumentError.checkNotNull(logisticCode, 'logisticCode'); + const _extra = {}; + final queryParameters = {}; + final _data = {}; + final _result = await _dio.request>( + '/order/getShippingTrace/$shipperCode/$logisticCode', + queryParameters: queryParameters, + options: RequestOptions( + method: 'GET', + headers: {}, + extra: _extra, + baseUrl: baseUrl), + data: _data); + final value = BaseData.fromJson( + _result.data, + (json) => Logistics.fromJson(json), + ); + return value; + } + + @override + Future> report(map) async { + ArgumentError.checkNotNull(map, 'map'); + const _extra = {}; + final queryParameters = {}; + final _data = {}; + _data.addAll(map ?? {}); + final _result = await _dio.request>('/other/report', + queryParameters: queryParameters, + options: RequestOptions( + method: 'POST', + headers: {}, + extra: _extra, + baseUrl: baseUrl), + data: _data); + final value = BaseData.fromJson( + _result.data, + (json) => json as bool, + ); + return value; + } + + @override + Future> orderCancel(id) async { + ArgumentError.checkNotNull(id, 'id'); + const _extra = {}; + final queryParameters = {}; + final _data = {}; + final _result = await _dio.request>( + '/order/cancel/$id', + queryParameters: queryParameters, + options: RequestOptions( + method: 'GET', + headers: {}, + extra: _extra, + baseUrl: baseUrl), + data: _data); + final value = BaseData.fromJson( + _result.data, + (json) => json as bool, + ); + return value; + } + + @override + Future> settlement(map) async { + ArgumentError.checkNotNull(map, 'map'); + const _extra = {}; + final queryParameters = {}; + final _data = {}; + _data.addAll(map ?? {}); + final _result = await _dio.request>( + '/order/settlement', + queryParameters: queryParameters, + options: RequestOptions( + method: 'POST', + headers: {}, + extra: _extra, + baseUrl: baseUrl), + data: _data); + final value = BaseData.fromJson( + _result.data, + (json) => json as String, + ); + return value; + } + + @override + Future> trend(map) async { + ArgumentError.checkNotNull(map, 'map'); + const _extra = {}; + final queryParameters = {}; + final _data = {}; + _data.addAll(map ?? {}); + final _result = await _dio.request>( + '/information/trend', + queryParameters: queryParameters, + options: RequestOptions( + method: 'POST', + headers: {}, + extra: _extra, + baseUrl: baseUrl), + data: _data); + final value = BaseData.fromJson( + _result.data, + (json) => json as bool, + ); + return value; + } + + @override + Future>> trendList(map) async { + ArgumentError.checkNotNull(map, 'map'); + const _extra = {}; + final queryParameters = {}; + final _data = {}; + _data.addAll(map ?? {}); + final _result = await _dio.request>( + '/information/trend-list', + queryParameters: queryParameters, + options: RequestOptions( + method: 'POST', + headers: {}, + extra: _extra, + baseUrl: baseUrl), + data: _data); + final value = BaseData>.fromJson( + _result.data, + (json) => PageInfo.fromJson( + json, + (json) => ComunityComment.fromJson(json), + ), + ); + return value; + } + + @override + Future>> followList(map) async { + ArgumentError.checkNotNull(map, 'map'); + const _extra = {}; + final queryParameters = {}; + final _data = {}; + _data.addAll(map ?? {}); + final _result = await _dio.request>( + '/member/follow/list', + queryParameters: queryParameters, + options: RequestOptions( + method: 'POST', + headers: {}, + extra: _extra, + baseUrl: baseUrl), + data: _data); + final value = BaseData>.fromJson( + _result.data, + (json) => PageInfo.fromJson( + json, + (json) => ListData.fromJson(json), + ), + ); + return value; + } + + @override + Future> follow(followId) async { + ArgumentError.checkNotNull(followId, 'followId'); + const _extra = {}; + final queryParameters = {}; + final _data = {}; + final _result = await _dio.request>( + '/member/follow/$followId', + queryParameters: queryParameters, + options: RequestOptions( + method: 'PUT', + headers: {}, + extra: _extra, + baseUrl: baseUrl), + data: _data); + final value = BaseData.fromJson( + _result.data, + (json) => json as dynamic, + ); + return value; + } + + @override + Future> deleteTrend(id) async { + ArgumentError.checkNotNull(id, 'id'); + const _extra = {}; + final queryParameters = {}; + final _data = {}; + final _result = await _dio.request>( + '/information/trend/$id', + queryParameters: queryParameters, + options: RequestOptions( + method: 'DELETE', + headers: {}, + extra: _extra, + baseUrl: baseUrl), + data: _data); + final value = BaseData.fromJson( + _result.data, + (json) => json as dynamic, + ); + return value; + } + + @override + Future> socialInfo() async { + const _extra = {}; + final queryParameters = {}; + final _data = {}; + final _result = await _dio.request>( + '/member/socialInfo', + queryParameters: queryParameters, + options: RequestOptions( + method: 'GET', + headers: {}, + extra: _extra, + baseUrl: baseUrl), + data: _data); + final value = BaseData.fromJson( + _result.data, + (json) => SocialInfo.fromJson(json), + ); + return value; + } +} From 17aa407ef7dd4bd8074ac5b44fe2032a9ad55d63 Mon Sep 17 00:00:00 2001 From: fmk Date: Sat, 23 Oct 2021 18:49:40 +0800 Subject: [PATCH 10/20] safety --- lib/retrofit/data/shoppingCart.dart | 2 +- lib/settlement/settlement.dart | 18 ++--------- lib/store/store_order.dart | 50 +++++++++++++++++++++-------- lib/store/store_view/shop_car.dart | 8 +++-- 4 files changed, 46 insertions(+), 32 deletions(-) diff --git a/lib/retrofit/data/shoppingCart.dart b/lib/retrofit/data/shoppingCart.dart index 9f5b9bc7..01b6ec19 100644 --- a/lib/retrofit/data/shoppingCart.dart +++ b/lib/retrofit/data/shoppingCart.dart @@ -34,7 +34,7 @@ class ShoppingCart { "cartSum": cartSum, "numberOfPeople": numberOfPeople, "selected": selected, - "shoppingCartSkuItemList": shoppingCartSkuItemList, + "shoppingCartSkuItemList": shoppingCartSkuItemList == null ? null : shoppingCartSkuItemList.map((e) => e.toJson()).toList(), "storeId": storeId, "storeName": storeName, "tableId": tableId, diff --git a/lib/settlement/settlement.dart b/lib/settlement/settlement.dart index 6141d9b5..30f52ecf 100644 --- a/lib/settlement/settlement.dart +++ b/lib/settlement/settlement.dart @@ -109,6 +109,9 @@ class _Settlement extends State { if (baseData != null && baseData.isSuccess) { setState(() { settleOrderInfo = baseData.data; + if (settleOrderInfo.orderProductList == null || settleOrderInfo.orderProductList.length == 0) { + queryOrderDetails(parentId); + } }); } } @@ -248,21 +251,6 @@ class _Settlement extends State { } } -//Undefined symbols for architecture armv7: -// "_OBJC_CLASS_$_HmsBitMap", referenced from: -// objc-class-ref in libflutter_scankit.a(FLScanKitView.o) -// objc-class-ref in libflutter_scankit.a(FlutterScankitPlugin.o) -// "_OBJC_CLASS_$_HmsDefaultScanViewController", referenced from: -// objc-class-ref in libflutter_scankit.a(FlutterScankitPlugin.o) -// "_OBJC_CLASS_$_HmsCustomScanViewController", referenced from: -// objc-class-ref in libflutter_scankit.a(FLScanKitView.o) -// "_OBJC_CLASS_$_HmsScanOptions", referenced from: -// objc-class-ref in libflutter_scankit.a(FLScanKitView.o) -// objc-class-ref in libflutter_scankit.a(FlutterScankitPlugin.o) -// ld: symbol(s) not found for architecture armv7 -// clang: error: linker command failed with exit code 1 (use -v to see invocation) - - ///结算 querySettlement() async { placeOrderFirst.id = parentId != "" ? parentId : downOrder.id; diff --git a/lib/store/store_order.dart b/lib/store/store_order.dart index b32bfe60..b821c434 100644 --- a/lib/store/store_order.dart +++ b/lib/store/store_order.dart @@ -3,6 +3,7 @@ import 'package:dio/dio.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_easyloading/flutter_easyloading.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:flutter_swiper/flutter_swiper.dart'; @@ -54,6 +55,8 @@ class _StoreOrderPage extends State ScrollController controller = ScrollController(); ShoppingCart shopCarGoods; int tableId = 0; + String parentId = ""; + String parentCode = ""; String tenant = ""; String storeId = ""; int numberOfPeople = 0; @@ -62,7 +65,7 @@ class _StoreOrderPage extends State void initState() { super.initState(); - tableId = widget.arguments["tableId"]; + tableId = widget.arguments["tableId"] ?? 0; tenant = widget.arguments["tenant"]; storeId = widget.arguments["id"]; @@ -82,10 +85,12 @@ class _StoreOrderPage extends State /// 小程序登录 minLogin(SharedPreferences shared) async { + EasyLoading.show(status: S.of(context).zhengzaijiazai); apiService = ApiService( Dio(), context: context, token: shared.getString('token'), + showLoading: false, ); queryStoreInfo(); apiService.minLogin(storeId).catchError((onError) { @@ -107,25 +112,33 @@ class _StoreOrderPage extends State token: minToken, tenant: tenant, storeId: storeId, + showLoading: false, ); queryShopCar().then((value) { this.shopCarGoods = value; setState(() {}); }); if (tableId > 0) { - queryStoreInfo1(); + getParentInfo(); } + EasyLoading.dismiss(); } }); } ///获取父订单(火锅订单加菜前调用) getParentInfo() async { - BaseData baseData = - await minService.getParentInfo("$tableId").catchError((error) { - debugPrint(error); - }); - if (baseData != null && baseData.isSuccess) {} + BaseData baseData = await minService.getParentInfo("$tableId") + .catchError((error) {debugPrint(error);}); + if (baseData != null && baseData.isSuccess) { + if(baseData.data != null) { + parentId = baseData.data["id"]; + parentCode = baseData.data["parentCode"]; + } else { + ///TODO: 没有父订单, + queryStoreInfo1(); + } + } } ///获取桌子信息 @@ -147,10 +160,8 @@ class _StoreOrderPage extends State /// 查询店铺信息 queryStoreInfo() async { - BaseData baseData = - await apiService.queryStoreInfo(storeId).catchError((error) { - debugPrint(error); - }); + BaseData baseData = await apiService.queryStoreInfo(storeId) + .catchError((error) {debugPrint(error);}); if (baseData != null && baseData.isSuccess) { storeInfo = StoreInfo.fromJson(baseData.data); activitys = storeInfo.informationVOPageVO.list @@ -160,6 +171,7 @@ class _StoreOrderPage extends State setState(() {}); } } + EasyLoading.dismiss(); } RefreshController refreshController; @@ -489,18 +501,24 @@ class _StoreOrderPage extends State toDownOrder() async { int num = count(); - if (tableId > 0 && num == 0) { - SmartDialog.showToast("请先选择您要购买的商品!~"); - return; + if (parentId == null || parentId == "") { + if (num == 0) { + SmartDialog.showToast("请先选择您要购买的商品!~"); + return; + } } await Navigator.of(context).pushNamed( '/router/settlement', arguments: { "storeInfo": storeInfo, + "tableId": tableId, + "parentCode": parentCode, + "parentId": parentId, "shoppingCart": shopCarGoods, }, ); + getParentInfo(); queryShopCar().then((value) { this.shopCarGoods = value; setState(() {}); @@ -629,6 +647,8 @@ class _StoreOrderPage extends State "storeName": storeInfo.storeName ?? "", "numberOfPeople": numberOfPeople, "tableId": tableId, + "parentId": parentId, + "parentCode": parentCode, "shoppingCartSkuItemList": [ { "buyNum": count, @@ -676,6 +696,7 @@ class _StoreOrderPage extends State if (baseDate.isSuccess) { queryShopCar().then((value) { this.shopCarGoods = value; + print("shopingCar111111: ${this.shopCarGoods.toJson()}"); if (shopCartKey != null) { shopCartKey.currentState.setState(() {}); } @@ -694,6 +715,7 @@ class _StoreOrderPage extends State if (baseDate.isSuccess) { queryShopCar().then((value) { this.shopCarGoods = value; + print("shopingCar111111: ${this.shopCarGoods.toJson()}"); if (shopCartKey != null) { shopCartKey.currentState.setState(() {}); } diff --git a/lib/store/store_view/shop_car.dart b/lib/store/store_view/shop_car.dart index 90e7a1da..3dbd5624 100644 --- a/lib/store/store_view/shop_car.dart +++ b/lib/store/store_view/shop_car.dart @@ -105,8 +105,12 @@ class _ShopCar extends State { physics: BouncingScrollPhysics(), itemBuilder: (context, position) { return ShopGoods( - widget.shopCartAdd, - widget.shopCartReduce, + (ShoppingCartSkuItemListBean cart) { + widget.shopCartAdd(cart); + }, + (ShoppingCartSkuItemListBean cart) { + widget.shopCartReduce(cart); + }, count: widget.shopingCar .shoppingCartSkuItemList[position].buyNum, shoppingCartSkuItemListBean: From e61ab8f86b22ce0ea93ca870ab6c76776a8dfea0 Mon Sep 17 00:00:00 2001 From: fmk Date: Mon, 25 Oct 2021 13:38:06 +0800 Subject: [PATCH 11/20] safety --- lib/mine/mine_view/mine_view.dart | 82 +-- lib/mine/vip_detail_page.dart | 22 +- lib/order/order_history_page.dart | 39 +- lib/order/order_view/order_address.dart | 20 + lib/store/scan.dart | 53 ++ lib/store/store_order.dart | 572 +++++++++++---------- lib/store/store_view/product_sku.dart | 369 ++++++------- lib/store/store_view/shop_car.dart | 365 ++++++------- lib/store/store_view/store_order_list.dart | 4 +- lib/union/union_page.dart | 64 +-- lib/view_widget/selector_store_dialog.dart | 26 +- lib/web/web_view/web_header.dart | 27 +- 12 files changed, 906 insertions(+), 737 deletions(-) create mode 100644 lib/store/scan.dart diff --git a/lib/mine/mine_view/mine_view.dart b/lib/mine/mine_view/mine_view.dart index f75b1af5..ac4a545e 100644 --- a/lib/mine/mine_view/mine_view.dart +++ b/lib/mine/mine_view/mine_view.dart @@ -23,7 +23,6 @@ class MineView extends StatefulWidget { } class _MineView extends State { - @override Widget build(BuildContext context) { return Column( @@ -91,7 +90,23 @@ class _MineView extends State { ); }); } else if (await Permission.camera.isGranted) { - Navigator.of(context).pushNamed('/router/qr_scan'); + ///http://pos.app.gznl.top/placeorder/?tableId=1315903669597634560&tenantCode=1166&shopId=1300372027722432512 + var result = await Navigator.of(context).pushNamed('/router/qr_scan'); + Uri uri = Uri.parse(result); + String tableId = uri.queryParameters["tableId"]; + String tenantCode = uri.queryParameters["tenantCode"]; + String shopId = uri.queryParameters["shopId"]; + if (tableId != null && tableId != "" && tenantCode != null && tenantCode != "" && shopId != null && shopId != "") { + Navigator.of(context).pushNamed( + '/router/store_order', + arguments: { + "id": shopId, + "tenant": tenantCode, + "storeName": "", + "tableId": int.tryParse(tableId), + }, + ); + } } else { await Permission.camera.request(); } @@ -107,31 +122,31 @@ class _MineView extends State { crossAxisAlignment: CrossAxisAlignment.start, children: [ InkWell( - onTap: () { - widget.toUserInfo(); - }, - child: Stack( - children: [ - MImage( - widget.userInfo == null ? "" : widget.userInfo.headimg, - isCircle: true, - width: 50, - height: 50, - fit: BoxFit.cover, - errorSrc: "assets/image/default_user.png", - fadeSrc: "assets/image/default_user.png", - ), - Positioned( - bottom: 0, - right: 2.w, - child: Image.asset( - "assets/image/icon_mine_edit.png", - width: 17.w, - height: 17.w, - ), + onTap: () { + widget.toUserInfo(); + }, + child: Stack( + children: [ + MImage( + widget.userInfo == null ? "" : widget.userInfo.headimg, + isCircle: true, + width: 50, + height: 50, + fit: BoxFit.cover, + errorSrc: "assets/image/default_user.png", + fadeSrc: "assets/image/default_user.png", + ), + Positioned( + bottom: 0, + right: 2.w, + child: Image.asset( + "assets/image/icon_mine_edit.png", + width: 17.w, + height: 17.w, ), - ], - ), + ), + ], + ), ), SizedBox( width: 10.w, @@ -145,13 +160,16 @@ class _MineView extends State { crossAxisAlignment: CrossAxisAlignment.stretch, children: [ widget.userInfo == null - ? Text( - S.of(context).denglu, - style: TextStyle( - fontSize: 16.sp, - fontWeight: MyFontWeight.medium, - color: Color(0xFF353535), + ? InkWell( + child: Text( + S.of(context).denglu, + style: TextStyle( + fontSize: 16.sp, + fontWeight: MyFontWeight.medium, + color: Color(0xFF353535), + ), ), + onTap: widget.toUserInfo, ) : Row( children: [ diff --git a/lib/mine/vip_detail_page.dart b/lib/mine/vip_detail_page.dart index d6e0794a..a9dc9c4e 100644 --- a/lib/mine/vip_detail_page.dart +++ b/lib/mine/vip_detail_page.dart @@ -7,6 +7,7 @@ import 'package:huixiang/retrofit/data/base_data.dart'; import 'package:huixiang/retrofit/data/product.dart'; import 'package:huixiang/retrofit/data/vip_card.dart'; import 'package:huixiang/retrofit/retrofit_api.dart'; +import 'package:huixiang/store/scan.dart'; import 'package:huixiang/utils/font_weight.dart'; import 'package:huixiang/utils/location.dart'; import 'package:huixiang/utils/painter_bg.dart'; @@ -432,8 +433,25 @@ class _VipDetailPage extends State { ), GestureDetector( onTap: () { - Navigator.of(context).pushNamed('/router/union_detail_page', - arguments: {"id": store.id}); + // Navigator.of(context).pushNamed('/router/union_detail_page', + // arguments: {"id": store.id}); + if(store.posType.code == "NORMALSTORE") { + Scan.toScan( + context, + store.id, + store.tenantCode, + store.storeName, + ); + } else { + Navigator.of(context).pushNamed( + '/router/store_order', + arguments: { + "id": store.id, + "tenant": store.tenantCode, + "storeName": store.storeName + }, + ); + } }, child: Text( S.of(context).chakan, diff --git a/lib/order/order_history_page.dart b/lib/order/order_history_page.dart index 3c221b8a..3a8477c0 100644 --- a/lib/order/order_history_page.dart +++ b/lib/order/order_history_page.dart @@ -11,6 +11,7 @@ import 'package:huixiang/retrofit/data/page.dart'; import 'package:huixiang/retrofit/data/product.dart'; import 'package:huixiang/retrofit/min_api.dart'; import 'package:huixiang/retrofit/retrofit_api.dart'; +import 'package:huixiang/store/scan.dart'; import 'package:huixiang/utils/status_utils.dart'; import 'package:huixiang/view_widget/classic_header.dart'; import 'package:huixiang/view_widget/custom_image.dart'; @@ -442,11 +443,7 @@ class _OrderHistoryList extends State orderInfo.refundStatus, orderInfo.dayFlowCode, (type) { if (type == 0) { - String storeId = (orderInfo != null && - orderInfo.storeVO != null) - ? (orderInfo.storeVO.id ?? "") - : ""; - aginOrder(storeId); + aginOrder(orderInfo); } else if (type == 1) { SmartDialog.show( widget: Tips( @@ -539,11 +536,33 @@ class _OrderHistoryList extends State } } - aginOrder(storeId) { - Navigator.of(context).pushNamed( - '/router/union_detail_page', - arguments: {"id": storeId}, - ); + aginOrder(OrderInfo orderInfo) { + // Navigator.of(context).pushNamed( + // '/router/union_detail_page', + // arguments: {"id": storeId}, + // ); + // String storeId = (orderInfo != null && + // orderInfo.storeVO != null) + // ? (orderInfo.storeVO.id ?? "") + // : ""; + + if(orderInfo.storeVO.posType.code == "NORMALSTORE") { + Scan.toScan( + context, + orderInfo.storeVO.id, + orderInfo.tenantCode, + orderInfo.storeVO.storeName, + ); + } else { + Navigator.of(context).pushNamed( + '/router/store_order', + arguments: { + "id": orderInfo.storeVO.id, + "tenant": orderInfo.tenantCode, + "storeName": orderInfo.storeVO.storeName + }, + ); + } } String totalPrice(orderInfo) { diff --git a/lib/order/order_view/order_address.dart b/lib/order/order_view/order_address.dart index f1928911..ce4e50f5 100644 --- a/lib/order/order_view/order_address.dart +++ b/lib/order/order_view/order_address.dart @@ -3,6 +3,7 @@ import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:huixiang/generated/l10n.dart'; import 'package:huixiang/retrofit/data/order_info.dart'; +import 'package:huixiang/store/scan.dart'; import 'package:huixiang/utils/font_weight.dart'; import 'package:huixiang/view_widget/border_text.dart'; import 'package:huixiang/view_widget/round_button.dart'; @@ -258,6 +259,25 @@ class _OrderAddress extends State { aginOrder(storeId, storeName) { Navigator.of(context).pushNamed('/router/union_detail_page', arguments: {"id": storeId, "storeName": storeName}); + + if(widget.orderInfo.storeVO.posType.code == "NORMALSTORE") { + Scan.toScan( + context, + widget.orderInfo.storeVO.id, + widget.orderInfo.tenantCode, + widget.orderInfo.storeVO.storeName, + ); + } else { + Navigator.of(context).pushNamed( + '/router/store_order', + arguments: { + "id": widget.orderInfo.storeVO.id, + "tenant": widget.orderInfo.tenantCode, + "storeName": widget.orderInfo.storeVO.storeName + }, + ); + } + } // carryOnPay() async { diff --git a/lib/store/scan.dart b/lib/store/scan.dart new file mode 100644 index 00000000..be947359 --- /dev/null +++ b/lib/store/scan.dart @@ -0,0 +1,53 @@ + + +import 'package:flutter/cupertino.dart'; +import 'package:huixiang/generated/l10n.dart'; +import 'package:huixiang/view_widget/request_permission.dart'; +import 'package:permission_handler/permission_handler.dart'; + +class Scan { + + static toScan(context, id, tenantCode, storeName) async { + if (await Permission.camera.isPermanentlyDenied) { + showCupertinoDialog( + context: context, + builder: (context) { + return RequestPermission( + "assets/image/icon_camera_permission_tips.png", + S.of(context).ninxiangjiquanxianweikaiqi, + S.of(context).weilekaipaizhaoxuanzhetouxiang, + S.of(context).kaiqiquanxian, + (result) async { + if (result) { + await openAppSettings(); + } + }, + heightRatioWithWidth: 0.82, + ); + }); + } else if (await Permission.camera.isGranted) { + var result = await Navigator.of(context).pushNamed('/router/qr_scan'); + + if (result != null && result != "") { + Uri uri = Uri.parse(result); + String table = uri.queryParameters["tableId"]; + if (table != null && table != "") { + int tableId = int.tryParse(table); + Navigator.of(context).pushNamed( + '/router/store_order', + arguments: { + "id": id, + "tenant": tenantCode, + "storeName": storeName, + "tableId": tableId, + }, + ); + } + } + } else { + await Permission.camera.request(); + } + + } + +} \ No newline at end of file diff --git a/lib/store/store_order.dart b/lib/store/store_order.dart index b821c434..2f1987ad 100644 --- a/lib/store/store_order.dart +++ b/lib/store/store_order.dart @@ -24,7 +24,6 @@ import 'package:huixiang/store/store_view/store_order_list.dart'; import 'package:huixiang/union/union_view/union_coupon.dart'; import 'package:huixiang/union/union_view/vip.dart'; import 'package:huixiang/utils/font_weight.dart'; -import 'package:huixiang/view_widget/classic_header.dart'; import 'package:huixiang/view_widget/custom_image.dart'; import 'package:huixiang/view_widget/my_tab.dart'; import 'package:huixiang/view_widget/receive_success.dart'; @@ -128,10 +127,12 @@ class _StoreOrderPage extends State ///获取父订单(火锅订单加菜前调用) getParentInfo() async { - BaseData baseData = await minService.getParentInfo("$tableId") - .catchError((error) {debugPrint(error);}); + BaseData baseData = + await minService.getParentInfo("$tableId").catchError((error) { + debugPrint(error); + }); if (baseData != null && baseData.isSuccess) { - if(baseData.data != null) { + if (baseData.data != null) { parentId = baseData.data["id"]; parentCode = baseData.data["parentCode"]; } else { @@ -160,8 +161,10 @@ class _StoreOrderPage extends State /// 查询店铺信息 queryStoreInfo() async { - BaseData baseData = await apiService.queryStoreInfo(storeId) - .catchError((error) {debugPrint(error);}); + BaseData baseData = + await apiService.queryStoreInfo(storeId).catchError((error) { + debugPrint(error); + }); if (baseData != null && baseData.isSuccess) { storeInfo = StoreInfo.fromJson(baseData.data); activitys = storeInfo.informationVOPageVO.list @@ -175,180 +178,191 @@ class _StoreOrderPage extends State } RefreshController refreshController; + bool dialogShowing = false; @override Widget build(BuildContext context) { - return Stack( - children: [ - Positioned( - left: 0, - right: 0, - top: 0, - bottom: 54.h, - child: NestedScrollView( - controller: controller, - dragStartBehavior: DragStartBehavior.start, - physics: BouncingScrollPhysics(), - headerSliverBuilder: (BuildContext context, bool innerScrolled) { - return [ - SliverOverlapAbsorber( - handle: NestedScrollView.sliverOverlapAbsorberHandleFor( - context), - sliver: SliverAppBar( - expandedHeight: - (storeInfo != null && storeInfo.couponVOList != null) - ? 470.h - : 365.h, - floating: false, - snap: false, - pinned: true, - stretch: false, - brightness: Brightness.light, - leading: GestureDetector( - onTap: () { - Navigator.of(context).pop(); - }, - child: Container( - alignment: Alignment.centerRight, - margin: EdgeInsets.only(left: 10), - padding: EdgeInsets.all(6), - child: Icon( - Icons.arrow_back_ios, - color: Colors.black, - size: 24, + return WillPopScope( + onWillPop: () async { + if (dialogShowing) { + debugPrint("ssssasdadsasdadasd"); + SmartDialog.dismiss(); + return false; + } else { + return true; + } + }, + child: Stack( + children: [ + Positioned( + left: 0, + right: 0, + top: 0, + bottom: 54.h, + child: NestedScrollView( + controller: controller, + dragStartBehavior: DragStartBehavior.start, + physics: BouncingScrollPhysics(), + headerSliverBuilder: (BuildContext context, bool innerScrolled) { + return [ + SliverOverlapAbsorber( + handle: NestedScrollView.sliverOverlapAbsorberHandleFor( + context), + sliver: SliverAppBar( + expandedHeight: + (storeInfo != null && storeInfo.couponVOList != null) + ? 470.h + : 365.h, + floating: false, + snap: false, + pinned: true, + stretch: false, + brightness: Brightness.light, + leading: GestureDetector( + onTap: () { + Navigator.of(context).pop(); + }, + child: Container( + alignment: Alignment.centerRight, + margin: EdgeInsets.only(left: 10), + padding: EdgeInsets.all(6), + child: Icon( + Icons.arrow_back_ios, + color: Colors.black, + size: 24, + ), ), ), - ), - flexibleSpace: FlexibleSpaceBar( - title: Title( - controller, - storeInfo != null ? storeInfo.storeName : '', - ), - collapseMode: CollapseMode.pin, - stretchModes: [ - StretchMode.zoomBackground, - StretchMode.fadeTitle, - StretchMode.blurBackground, - ], - background: Stack( - children: [ - Positioned( - child: Column( - children: [ - buildSwiper(), - Expanded( - child: Container( - color: Colors.transparent, - ), - flex: 1, - ), - ], - ), - top: 0, - bottom: 0, - left: 0, - right: 0, - ), - Positioned( - child: Container( + flexibleSpace: FlexibleSpaceBar( + title: Title( + controller, + storeInfo != null ? storeInfo.storeName : '', + ), + collapseMode: CollapseMode.pin, + stretchModes: [ + StretchMode.zoomBackground, + StretchMode.fadeTitle, + StretchMode.blurBackground, + ], + background: Stack( + children: [ + Positioned( child: Column( children: [ - ///门店信息 - StoreInfoView(storeInfo), - - ///门店对应优惠券 - if (storeInfo != null && - storeInfo.couponVOList != null) - UnionCoupon( - storeInfo, - _receiveCoupon, - coupon: true, - ), - - if (storeInfo == null || - storeInfo.couponVOList == null) - SizedBox( - height: 8, + buildSwiper(), + Expanded( + child: Container( + color: Colors.transparent, ), - - ///门店对应VIP信息 - Vip(storeInfo, () {}, false), + flex: 1, + ), ], ), + top: 0, + bottom: 0, + left: 0, + right: 0, ), - top: 110.h, - bottom: 0, - left: 0, - right: 0, - ), - ], - ), - ), - backgroundColor: Color(0x33FAFAFA), - centerTitle: false, - elevation: 0, - bottom: PreferredSize( - preferredSize: Size( - MediaQuery.of(context).size.width, - 38, + Positioned( + child: Container( + child: Column( + children: [ + ///门店信息 + StoreInfoView(storeInfo), + + ///门店对应优惠券 + if (storeInfo != null && + storeInfo.couponVOList != null) + UnionCoupon( + storeInfo, + _receiveCoupon, + coupon: true, + ), + + if (storeInfo == null || + storeInfo.couponVOList == null) + SizedBox( + height: 8, + ), + + ///门店对应VIP信息 + Vip(storeInfo, () {}, false), + ], + ), + ), + top: 110.h, + bottom: 0, + left: 0, + right: 0, + ), + ], + ), ), - child: Container( - padding: EdgeInsets.symmetric(horizontal: 10.w), - width: MediaQuery.of(context).size.width, - child: TabBar( - controller: tabcontroller, - automaticIndicatorColorAdjustment: true, - isScrollable: true, - indicatorWeight: 1, - indicatorColor: Color(0xFFFAFAFA), - labelPadding: EdgeInsets.only( - left: 8.w, - right: 8.w, - ), - indicatorSize: TabBarIndicatorSize.label, - unselectedLabelStyle: TextStyle( - fontSize: 15.sp, - fontWeight: FontWeight.w400, - ), - labelStyle: TextStyle( - color: Colors.black, - fontSize: 18.sp, - fontWeight: FontWeight.bold, + backgroundColor: Color(0x33FAFAFA), + centerTitle: false, + elevation: 0, + bottom: PreferredSize( + preferredSize: Size( + MediaQuery.of(context).size.width, + 38, + ), + child: Container( + padding: EdgeInsets.symmetric(horizontal: 10.w), + width: MediaQuery.of(context).size.width, + child: TabBar( + controller: tabcontroller, + automaticIndicatorColorAdjustment: true, + isScrollable: true, + indicatorWeight: 1, + indicatorColor: Color(0xFFFAFAFA), + labelPadding: EdgeInsets.only( + left: 8.w, + right: 8.w, + ), + indicatorSize: TabBarIndicatorSize.label, + unselectedLabelStyle: TextStyle( + fontSize: 15.sp, + fontWeight: FontWeight.w400, + ), + labelStyle: TextStyle( + color: Colors.black, + fontSize: 18.sp, + fontWeight: FontWeight.bold, + ), + labelColor: Colors.black, + tabs: [ + MyTab(text: S.of(context).diancan), + MyTab(text: S.of(context).xindianhuodong), + ], ), - labelColor: Colors.black, - tabs: [ - MyTab(text: S.of(context).diancan), - MyTab(text: S.of(context).xindianhuodong), - ], ), ), ), ), - ), - ]; - }, - body: TabBarView( - physics: NeverScrollableScrollPhysics(), - children: [ - ///点餐 - StoreOrderListPage( - widget.arguments, - activitys, - storeInfo, - shopCarGoods, - controller, - _queryMiNiDetail, - ), + ]; + }, + body: TabBarView( + physics: NeverScrollableScrollPhysics(), + children: [ + ///点餐 + StoreOrderListPage( + widget.arguments, + activitys, + storeInfo, + shopCarGoods, + controller, + _queryMiNiDetail, + ), - ///星店活动, - StoreActivity( - widget.arguments, - activitys, - ), - ], - controller: tabcontroller, - ), - ),/*SmartRefresher( + ///星店活动, + StoreActivity( + widget.arguments, + activitys, + ), + ], + controller: tabcontroller, + ), + ), /*SmartRefresher( controller: refreshController = RefreshController(initialRefresh: false), enablePullDown: true, @@ -360,89 +374,90 @@ class _StoreOrderPage extends State }, child: ),*/ - ), - Positioned( - bottom: 0, - left: 0, - right: 0, - child: Stack( - alignment: Alignment.bottomLeft, - children: [ - Container( - height: 54.h, - color: Color(0xFFFAFAFA), - child: Row( - children: [ - Spacer(), - Text( - S.of(context).heji, - style: TextStyle( - fontSize: 12.sp, - fontWeight: MyFontWeight.regular, - color: Colors.black, + ), + Positioned( + bottom: 0, + left: 0, + right: 0, + child: Stack( + alignment: Alignment.bottomLeft, + children: [ + Container( + height: 54.h, + color: Color(0xFFFAFAFA), + child: Row( + children: [ + Spacer(), + Text( + S.of(context).heji, + style: TextStyle( + fontSize: 12.sp, + fontWeight: MyFontWeight.regular, + color: Colors.black, + ), ), - ), - Text( - "¥${shopCarGoods != null ? shopCarGoods.cartSum : "0.0"}", - style: TextStyle( - fontSize: 20.sp, - fontWeight: MyFontWeight.medium, - color: Color(0xFF32A060), + Text( + "¥${shopCarGoods != null ? shopCarGoods.cartSum : "0.0"}", + style: TextStyle( + fontSize: 20.sp, + fontWeight: MyFontWeight.medium, + color: Color(0xFF32A060), + ), ), - ), - Spacer(), - GestureDetector( + Spacer(), + GestureDetector( + onTap: () { + toDownOrder(); + }, + child: RoundButton( + width: 103.w, + height: 54.h, + text: S.current.jiesuan, + textColor: Colors.white, + fontWeight: MyFontWeight.regular, + backgroup: Color(0xFF32A060), + radius: 0, + fontSize: 16.sp, + padding: EdgeInsets.symmetric(vertical: 5.h), + ), + ), + ], + ), + ), + Stack( + children: [ + InkWell( onTap: () { - toDownOrder(); + showShoppingCart(); }, + child: Image.asset( + "assets/image/shopp.png", + width: 88, + height: 88, + fit: BoxFit.fitWidth, + ), + ), + Positioned( + right: 15, + top: 14, child: RoundButton( - width: 103.w, - height: 54.h, - text: S.current.jiesuan, + width: 17, + height: 17, + text: "${count()}", textColor: Colors.white, fontWeight: MyFontWeight.regular, backgroup: Color(0xFF32A060), - radius: 0, - fontSize: 16.sp, - padding: EdgeInsets.symmetric(vertical: 5.h), + fontSize: 12.sp, + radius: 100, ), ), ], ), - ), - Stack( - children: [ - InkWell( - onTap: () { - showShoppingCart(); - }, - child: Image.asset( - "assets/image/shopp.png", - width: 88, - height: 88, - fit: BoxFit.fitWidth, - ), - ), - Positioned( - right: 15, - top: 14, - child: RoundButton( - width: 17, - height: 17, - text: "${count()}", - textColor: Colors.white, - fontWeight: MyFontWeight.regular, - backgroup: Color(0xFF32A060), - fontSize: 12.sp, - radius: 100, - ), - ), - ], - ), - ], + ], + ), ), - ), - ], + ], + ), ); } @@ -568,19 +583,34 @@ class _StoreOrderPage extends State showShoppingCart() { queryShopCar().then((value) { this.shopCarGoods = value; - showModalBottomSheet( - context: context, - backgroundColor: Colors.transparent, - builder: (context) { - return ShopCar( - shopCartKey, - this.shopCarGoods, - clearShopCar, - toDownOrder, - shopCartAdd, - shopCartReduce, - ); + // showModalBottomSheet( + // context: context, + // backgroundColor: Colors.transparent, + // builder: (context) { + // return ShopCar( + // shopCartKey, + // this.shopCarGoods, + // clearShopCar, + // toDownOrder, + // shopCartAdd, + // shopCartReduce, + // ); + // }, + // ); + dialogShowing = true; + SmartDialog.show( + widget: ShopCar( + shopCartKey, + this.shopCarGoods, + clearShopCar, + toDownOrder, + shopCartAdd, + shopCartReduce, + ), + onDismiss: () { + dialogShowing = false; }, + alignmentTemp: Alignment.bottomCenter, ); }); } @@ -604,20 +634,20 @@ class _StoreOrderPage extends State ///选规格弹窗 showStoreSelector(MiNiDetail miNiDetail, String id) async { - showModalBottomSheet( - context: context, - backgroundColor: Colors.transparent, - builder: (context) { - return ProductSku( + dialogShowing = true; + SmartDialog.show( + widget: ProductSku( miNiDetail, shopCarGoods, id, _addShopCar, add, reduce, - ); - }, - ); + ), + onDismiss: () { + dialogShowing = false; + }, + alignmentTemp: Alignment.bottomCenter,); } ///添加购物车 @@ -687,41 +717,43 @@ class _StoreOrderPage extends State } ///购物车➕1 - shopCartAdd(ShoppingCartSkuItemListBean cartSkuItem) async { + Future shopCartAdd( + ShoppingCartSkuItemListBean cartSkuItem) async { Map shopCarTemp = shopCarGoods.toJson(); cartSkuItem.buyNum += 1; shopCarTemp["shoppingCartSkuItemList"] = [cartSkuItem.toJson()]; BaseData> baseDate = await minService.shoppingCartSingle(shopCarTemp); if (baseDate.isSuccess) { - queryShopCar().then((value) { - this.shopCarGoods = value; - print("shopingCar111111: ${this.shopCarGoods.toJson()}"); - if (shopCartKey != null) { - shopCartKey.currentState.setState(() {}); - } - setState(() {}); - }); + this.shopCarGoods = await queryShopCar(); + + print("shopingCar111111: ${this.shopCarGoods.toJson()}"); + if (shopCartKey != null) { + shopCartKey.currentState.setState(() {}); + } + setState(() {}); } + return this.shopCarGoods; } ///购物车➖1 - shopCartReduce(ShoppingCartSkuItemListBean cartSkuItem) async { + Future shopCartReduce( + ShoppingCartSkuItemListBean cartSkuItem) async { Map shopCarTemp = shopCarGoods.toJson(); cartSkuItem.buyNum -= 1; shopCarTemp["shoppingCartSkuItemList"] = [cartSkuItem.toJson()]; BaseData> baseDate = await minService.shoppingCartSingle(shopCarTemp); if (baseDate.isSuccess) { - queryShopCar().then((value) { - this.shopCarGoods = value; - print("shopingCar111111: ${this.shopCarGoods.toJson()}"); - if (shopCartKey != null) { - shopCartKey.currentState.setState(() {}); - } - setState(() {}); - }); + this.shopCarGoods = await queryShopCar(); + + print("shopingCar111111: ${this.shopCarGoods.toJson()}"); + if (shopCartKey != null) { + shopCartKey.currentState.setState(() {}); + } + setState(() {}); } + return this.shopCarGoods; } ///商品➕1 diff --git a/lib/store/store_view/product_sku.dart b/lib/store/store_view/product_sku.dart index 7d8a6a59..829745ae 100644 --- a/lib/store/store_view/product_sku.dart +++ b/lib/store/store_view/product_sku.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:huixiang/generated/l10n.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:huixiang/retrofit/data/miNiDetail.dart'; @@ -59,7 +60,6 @@ class _ProductSku extends State { if (shopSkuIndex >= 0) { count = widget.shopCarGoods.shoppingCartSkuItemList[shopSkuIndex].buyNum; } - } bool skuY(ProductSkuVOListBean productSku, selectSkus) { @@ -76,201 +76,213 @@ class _ProductSku extends State { @override Widget build(BuildContext context) { - return StatefulBuilder(builder: (context1, state) { - return Container( - alignment: Alignment.topCenter, - padding: EdgeInsets.only( - top: 16, - left: 16, - right: 16, - ), - width: double.infinity, - decoration: BoxDecoration( - color: Color(0xFFFAFAFA), - borderRadius: BorderRadius.only( - topLeft: Radius.circular(8), - topRight: Radius.circular(8), + return WillPopScope( + onWillPop: () async { + debugPrint("ssssasdadsasdadasd"); + SmartDialog.dismiss(); + return true; + }, + child: StatefulBuilder(builder: (context1, state) { + return Container( + alignment: Alignment.topCenter, + padding: EdgeInsets.only( + top: 16, + left: 16, + right: 16, ), - ), - child: Column( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - MImage( - widget.miNiDetail.imgs[0], - width: 70, - height: 70, - fit: BoxFit.cover, - errorSrc: "assets/image/default_1.png", - fadeSrc: "assets/image/default_1.png", - ), - SizedBox( - width: 10, - ), - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - widget.miNiDetail.productName, - style: TextStyle( - color: Colors.black, - fontSize: 16.sp, - fontWeight: MyFontWeight.medium, - ), - ), - Padding( - padding: EdgeInsets.only(top: 4, bottom: 7), - child: Text( - "已选: " + - (selectSkus.map((e) => "$e").toList().toString()), + height: MediaQuery.of(context).size.height / 3 * 2, + width: double.infinity, + decoration: BoxDecoration( + color: Color(0xFFFAFAFA), + borderRadius: BorderRadius.only( + topLeft: Radius.circular(8), + topRight: Radius.circular(8), + ), + ), + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + MImage( + widget.miNiDetail.imgs[0], + width: 70, + height: 70, + fit: BoxFit.cover, + errorSrc: "assets/image/default_1.png", + fadeSrc: "assets/image/default_1.png", + ), + SizedBox( + width: 10, + ), + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + widget.miNiDetail.productName, style: TextStyle( - color: Color(0xFF727272), - fontSize: 11.sp, - fontWeight: MyFontWeight.regular, + color: Colors.black, + fontSize: 16.sp, + fontWeight: MyFontWeight.medium, ), ), - ), - Row( - children: [ - Text( - S.of(context).huiyuanjia, + Padding( + padding: EdgeInsets.only(top: 4, bottom: 7), + child: Text( + "已选: " + + (selectSkus.map((e) => "$e").toList().toString()), style: TextStyle( - color: Color(0xFFFF7A1A), - fontSize: 13.sp, - fontWeight: MyFontWeight.medium, + color: Color(0xFF727272), + fontSize: 11.sp, + fontWeight: MyFontWeight.regular, ), ), - Text( - widget.miNiDetail.price, - style: TextStyle( - color: Color(0xFFFF7A1A), - fontSize: 14.sp, - fontWeight: MyFontWeight.medium, + ), + Row( + children: [ + Text( + S.of(context).huiyuanjia, + style: TextStyle( + color: Color(0xFFFF7A1A), + fontSize: 13.sp, + fontWeight: MyFontWeight.medium, + ), ), - ), - ], + Text( + widget.miNiDetail.price, + style: TextStyle( + color: Color(0xFFFF7A1A), + fontSize: 14.sp, + fontWeight: MyFontWeight.medium, + ), + ), + ], + ), + ], + ), + Spacer(), + InkWell( + onTap: () { + // Navigator.of(context).pop(); + SmartDialog.dismiss(); + }, + child: Image.asset( + "assets/image/icon_order_cancel.png", + width: 22, + height: 22, ), - ], - ), - Spacer(), - InkWell( - onTap: () { - Navigator.of(context).pop(); - }, - child: Image.asset( - "assets/image/icon_order_cancel.png", - width: 22, - height: 22, ), + ], + ), + SizedBox( + height: 23, + ), + Expanded( + child: ListView.builder( + itemCount: widget.miNiDetail.attrList.length, + scrollDirection: Axis.vertical, + physics: BouncingScrollPhysics(), + padding: EdgeInsets.zero, + itemBuilder: (context, position) { + return attrItem( + (index) { + state(() { + selectSkus[position] = widget.miNiDetail + .attrList[position].attrValueList[index].attrValue; + buildCount(); + }); + }, + widget.miNiDetail.attrList[position], + position, + ); + }, ), - ], - ), - SizedBox( - height: 23, - ), - Expanded( - child: ListView.builder( - itemCount: widget.miNiDetail.attrList.length, - scrollDirection: Axis.vertical, - physics: BouncingScrollPhysics(), - itemBuilder: (context, position) { - return attrItem( - (index) { - state(() { - selectSkus[position] = widget.miNiDetail - .attrList[position].attrValueList[index].attrValue; - buildCount(); - }); - }, - widget.miNiDetail.attrList[position], - position, - ); - }, ), - ), - SizedBox( - height: 24, - ), - Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Expanded( - child: Text( - "数量", - style: TextStyle( - color: Colors.black, - fontSize: 14.sp, - fontWeight: MyFontWeight.regular, + SizedBox( + height: 24, + ), + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Expanded( + child: Text( + "数量", + style: TextStyle( + color: Colors.black, + fontSize: 14.sp, + fontWeight: MyFontWeight.regular, + ), ), ), - ), - InkWell( - onTap: () { - if (count > 1) - setState(() { - count -= 1; - }); - widget.reduce(widget.miNiDetail, selectSkus); - }, - child: Image.asset( - "assets/image/reduce.png", - width: 22, - height: 22, + InkWell( + onTap: () { + if (count > 1) + setState(() { + count -= 1; + }); + widget.reduce(widget.miNiDetail, selectSkus); + }, + child: Image.asset( + "assets/image/reduce.png", + width: 22, + height: 22, + ), ), - ), - Padding( - padding: EdgeInsets.only(left: 8, right: 8), - child: Text( - "$count", - style: TextStyle( - color: Colors.black, - fontSize: 14.sp, - fontWeight: MyFontWeight.medium, + Padding( + padding: EdgeInsets.only(left: 8, right: 8), + child: Text( + "$count", + style: TextStyle( + color: Colors.black, + fontSize: 14.sp, + fontWeight: MyFontWeight.medium, + ), ), ), - ), - InkWell( - onTap: () { - setState(() { - count += 1; - }); - widget.add(widget.miNiDetail, selectSkus); - }, - child: Image.asset( - "assets/image/add.png", - width: 22, - height: 22, + InkWell( + onTap: () { + setState(() { + count += 1; + }); + widget.add(widget.miNiDetail, selectSkus); + }, + child: Image.asset( + "assets/image/add.png", + width: 22, + height: 22, + ), ), - ), - ], - ), - SizedBox( - height: 24, - ), - RoundButton( - width: double.infinity, - height: 54.h, - text: "加入购物车", - textColor: Colors.white, - fontWeight: MyFontWeight.semi_bold, - radius: 27, - backgroup: Color(0xFF32A060), - fontSize: 16.sp, - callback: () { - widget.addShopCar(widget.miNiDetail, selectSkus, 1); - }, - ), - SizedBox( - height: 21.h, - ), - ], - ), - ); - }); + ], + ), + SizedBox( + height: 24, + ), + RoundButton( + width: double.infinity, + height: 54.h, + text: "加入购物车", + textColor: Colors.white, + fontWeight: MyFontWeight.semi_bold, + radius: 27, + backgroup: Color(0xFF32A060), + fontSize: 16.sp, + callback: () { + // Navigator.of(context).pop(); + SmartDialog.dismiss(); + widget.addShopCar(widget.miNiDetail, selectSkus, 1); + }, + ), + SizedBox( + height: 21.h, + ), + ], + ), + ); + }), + ); } Widget attrItem(Function fc, AttrListBean attrListBean, position) { @@ -297,6 +309,7 @@ class _ProductSku extends State { return GridView.builder( itemCount: arrays.length, shrinkWrap: true, + padding: EdgeInsets.zero, physics: NeverScrollableScrollPhysics(), gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( //一行的Widget数量 diff --git a/lib/store/store_view/shop_car.dart b/lib/store/store_view/shop_car.dart index 3dbd5624..d706f898 100644 --- a/lib/store/store_view/shop_car.dart +++ b/lib/store/store_view/shop_car.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:huixiang/generated/l10n.dart'; import 'package:huixiang/retrofit/data/shoppingCart.dart'; import 'package:huixiang/store/store_view/shop_goods.dart'; @@ -32,207 +33,221 @@ class ShopCar extends StatefulWidget { } class _ShopCar extends State { - @override Widget build(BuildContext context) { - return StatefulBuilder( - builder: (context1, state) { - return Container( - alignment: Alignment.topCenter, - width: double.infinity, - height: MediaQuery.of(context).size.height / 2, - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.only( - topLeft: Radius.circular(8), - topRight: Radius.circular(8), + return WillPopScope( + onWillPop: () async { + debugPrint("ssssasdadsasdadasd"); + SmartDialog.dismiss(); + return true; + }, + child: StatefulBuilder( + builder: (context1, state) { + return Container( + alignment: Alignment.topCenter, + width: double.infinity, + height: MediaQuery.of(context).size.height / 2, + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.only( + topLeft: Radius.circular(8), + topRight: Radius.circular(8), + ), ), - ), - child: Column( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Container( - padding: EdgeInsets.only( - top: 16, - left: 16, - right: 16, - bottom: 8, - ), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - "已选商品", - style: TextStyle( - color: Colors.black, - fontSize: 14.sp, - fontWeight: MyFontWeight.medium, + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + padding: EdgeInsets.only( + top: 16, + left: 16, + right: 16, + bottom: 8, + ), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + "已选商品", + style: TextStyle( + color: Colors.black, + fontSize: 14.sp, + fontWeight: MyFontWeight.medium, + ), ), - ), - InkWell( - onTap: () { - widget.shopingCar.shoppingCartSkuItemList.clear(); - state(() {}); - widget.clearShopCar(); - }, - child: Image.asset( - "assets/image/delete.png", - width: 22, - height: 22, + InkWell( + onTap: () { + widget.shopingCar.shoppingCartSkuItemList.clear(); + state(() {}); + widget.clearShopCar(); + }, + child: Image.asset( + "assets/image/delete.png", + width: 22, + height: 22, + ), ), - ), - ], + ], + ), ), - ), - Expanded( - child: Stack( - children: [ - Positioned( - top: 0, - left: 0, - right: 0, - bottom: 54, - child: Container( - padding: EdgeInsets.only( - top: 8, - left: 16, - right: 16, - ), - child: ListView.builder( - itemCount: itemCount(), - physics: BouncingScrollPhysics(), - itemBuilder: (context, position) { - return ShopGoods( - (ShoppingCartSkuItemListBean cart) { - widget.shopCartAdd(cart); - }, - (ShoppingCartSkuItemListBean cart) { - widget.shopCartReduce(cart); - }, - count: widget.shopingCar - .shoppingCartSkuItemList[position].buyNum, - shoppingCartSkuItemListBean: - widget.shopingCar.shoppingCartSkuItemList[position], - queryMiNiDetail: widget.queryMiNiDetail, - ); - }, + Expanded( + child: Stack( + children: [ + Positioned( + top: 0, + left: 0, + right: 0, + bottom: 54, + child: Container( + padding: EdgeInsets.only( + top: 8, + left: 16, + right: 16, + ), + child: ListView.builder( + itemCount: itemCount(), + physics: BouncingScrollPhysics(), + itemBuilder: (context, position) { + return ShopGoods( + (ShoppingCartSkuItemListBean cart) async { + widget.shopingCar = + await widget.shopCartAdd(cart); + setState(() {}); + }, + (ShoppingCartSkuItemListBean cart) async { + widget.shopingCar = + await widget.shopCartReduce(cart); + setState(() {}); + }, + count: widget.shopingCar + .shoppingCartSkuItemList[position].buyNum, + shoppingCartSkuItemListBean: widget.shopingCar + .shoppingCartSkuItemList[position], + queryMiNiDetail: widget.queryMiNiDetail, + ); + }, + ), ), ), - ), - Positioned( - bottom: 0, - left: 0, - right: 0, - child: Stack( - alignment: Alignment.bottomLeft, - children: [ - Container( - height: 54.h, - decoration: BoxDecoration( - color: Color(0xFFFAFAFA), - boxShadow: [ - BoxShadow( - color: Colors.black.withAlpha(8), - offset: Offset(0, -1), - blurRadius: 3, - spreadRadius: 0, - ), - ], - ), - child: Row( - children: [ - Spacer(), - Text( - S.of(context).heji, - style: TextStyle( - fontSize: 12.sp, - fontWeight: MyFontWeight.regular, - color: Colors.black, + Positioned( + bottom: 0, + left: 0, + right: 0, + child: Stack( + alignment: Alignment.bottomLeft, + children: [ + Container( + height: 54.h, + decoration: BoxDecoration( + color: Color(0xFFFAFAFA), + boxShadow: [ + BoxShadow( + color: Colors.black.withAlpha(8), + offset: Offset(0, -1), + blurRadius: 3, + spreadRadius: 0, ), - ), - Text( - "¥" + - (widget.shopingCar == null - ? "0.0" - : widget.shopingCar.cartSum), - style: TextStyle( - fontSize: 20.sp, - fontWeight: MyFontWeight.medium, - color: Color(0xFF32A060), + ], + ), + child: Row( + children: [ + Spacer(), + Text( + S.of(context).heji, + style: TextStyle( + fontSize: 12.sp, + fontWeight: MyFontWeight.regular, + color: Colors.black, + ), ), - ), - Spacer(), - GestureDetector( + Text( + "¥" + + (widget.shopingCar == null + ? "0.0" + : widget.shopingCar.cartSum), + style: TextStyle( + fontSize: 20.sp, + fontWeight: MyFontWeight.medium, + color: Color(0xFF32A060), + ), + ), + Spacer(), + GestureDetector( + onTap: () { + widget.toDownOrder(); + }, + child: RoundButton( + width: 103.w, + height: 54.h, + text: S.current.jiesuan, + textColor: Colors.white, + fontWeight: MyFontWeight.regular, + backgroup: Color(0xFF32A060), + radius: 0, + fontSize: 16.sp, + padding: + EdgeInsets.symmetric(vertical: 5.h), + ), + ), + ], + ), + ), + Stack( + children: [ + InkWell( onTap: () { - widget.toDownOrder(); + // Navigator.of(context).pop(); + SmartDialog.dismiss(); }, + child: Image.asset( + "assets/image/shopp.png", + width: 88, + height: 88, + ), + ), + Positioned( + right: 15, + top: 14, child: RoundButton( - width: 103.w, - height: 54.h, - text: S.current.jiesuan, + width: 17, + height: 17, + text: "${count()}", textColor: Colors.white, fontWeight: MyFontWeight.regular, backgroup: Color(0xFF32A060), - radius: 0, - fontSize: 16.sp, - padding: - EdgeInsets.symmetric(vertical: 5.h), + fontSize: 12.sp, + radius: 100, + callback: () { + // Navigator.of(context) + // .pushNamed('/router/test_page'); + }, ), ), ], ), - ), - Stack( - children: [ - InkWell( - onTap: () { - Navigator.of(context).pop(); - }, - child: Image.asset( - "assets/image/shopp.png", - width: 88, - height: 88, - ), - ), - Positioned( - right: 15, - top: 14, - child: RoundButton( - width: 17, - height: 17, - text: "${count()}", - textColor: Colors.white, - fontWeight: MyFontWeight.regular, - backgroup: Color(0xFF32A060), - fontSize: 12.sp, - radius: 100, - callback: () { - Navigator.of(context) - .pushNamed('/router/test_page'); - }, - ), - ), - ], - ), - ], + ], + ), ), - ), - ], + ], + ), + flex: 1, ), - flex: 1, - ), - ], - ), - ); - }, + ], + ), + ); + }, + ), ); } int itemCount() { - if (widget.shopingCar == null || widget.shopingCar.shoppingCartSkuItemList == null || widget.shopingCar.shoppingCartSkuItemList.length == 0) return 0; - int index = widget.shopingCar.shoppingCartSkuItemList.indexWhere((element) => element.buyNum == 0); + if (widget.shopingCar == null || + widget.shopingCar.shoppingCartSkuItemList == null || + widget.shopingCar.shoppingCartSkuItemList.length == 0) return 0; + int index = widget.shopingCar.shoppingCartSkuItemList + .indexWhere((element) => element.buyNum == 0); if (index >= 0) { widget.shopingCar.shoppingCartSkuItemList.removeAt(index); } diff --git a/lib/store/store_view/store_order_list.dart b/lib/store/store_view/store_order_list.dart index 07f8fa29..dbbbb617 100644 --- a/lib/store/store_view/store_order_list.dart +++ b/lib/store/store_view/store_order_list.dart @@ -1,4 +1,3 @@ -import 'package:ai_decimal_accuracy/ai_decimal_accuracy.dart'; import 'package:dio/dio.dart'; import 'package:flutter/material.dart'; import 'package:huixiang/retrofit/data/activity.dart'; @@ -11,9 +10,7 @@ import 'package:huixiang/retrofit/retrofit_api.dart'; import 'package:huixiang/store/store_view/shop_goods.dart'; import 'package:huixiang/utils/font_weight.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; -import 'package:huixiang/view_widget/classic_header.dart'; import 'package:huixiang/view_widget/round_button.dart'; -import 'package:pull_to_refresh/pull_to_refresh.dart'; import 'package:shared_preferences/shared_preferences.dart'; class StoreOrderListPage extends StatefulWidget { @@ -64,6 +61,7 @@ class _StoreOrderListPage extends State { context: context, token: minToken, tenant: tenant, + storeId: widget.arguments["id"], ); BaseData> baseData = diff --git a/lib/union/union_page.dart b/lib/union/union_page.dart index 8f26aeaa..b976bd82 100644 --- a/lib/union/union_page.dart +++ b/lib/union/union_page.dart @@ -14,6 +14,7 @@ import 'package:huixiang/retrofit/data/base_data.dart'; import 'package:huixiang/retrofit/data/store.dart'; import 'package:huixiang/retrofit/data/store_type.dart'; import 'package:huixiang/retrofit/retrofit_api.dart'; +import 'package:huixiang/store/scan.dart'; import 'package:huixiang/utils/event_type.dart'; import 'package:huixiang/utils/location.dart'; import 'package:huixiang/view_widget/classic_header.dart'; @@ -272,10 +273,15 @@ class _UnionPage extends State ), physics: NeverScrollableScrollPhysics(), itemBuilder: (context, position) { - return GestureDetector( + return InkWell( onTap: () { - if(storeList[position].posType.code == "NORMALSTORE") { - toScan(storeList[position]); + if (storeList[position].posType.code == "NORMALSTORE") { + Scan.toScan( + context, + storeList[position].id, + storeList[position].tenantCode, + storeList[position].storeName, + ); } else { Navigator.of(context).pushNamed( '/router/store_order', @@ -301,58 +307,6 @@ class _UnionPage extends State _mapController = controller; } - toScan(Store store) async { - // Navigator.of(context).pushNamed( - // '/router/store_order', - // arguments: { - // "id": store.id, - // "tenant": store.tenantCode, - // "storeName": store.storeName, - // "tableId": 1315903669597634560, - // }, - // ); - - if (await Permission.camera.isPermanentlyDenied) { - showCupertinoDialog( - context: context, - builder: (context) { - return RequestPermission( - "assets/image/icon_camera_permission_tips.png", - S.of(context).ninxiangjiquanxianweikaiqi, - S.of(context).weilekaipaizhaoxuanzhetouxiang, - S.of(context).kaiqiquanxian, - (result) async { - if (result) { - await openAppSettings(); - } - }, - heightRatioWithWidth: 0.82, - ); - }); - } else if (await Permission.camera.isGranted) { - var result = await Navigator.of(context).pushNamed('/router/qr_scan'); - - if (result != null && result != "") { - Uri uri = Uri.parse(result); - String table = uri.queryParameters["tableId"]; - if (table != null && table != "") { - int tableId = int.tryParse(table); - Navigator.of(context).pushNamed( - '/router/store_order', - arguments: { - "id": store.id, - "tenant": store.tenantCode, - "storeName": store.storeName, - "tableId": tableId, - }, - ); - } - } - } else { - await Permission.camera.request(); - } - } - Widget buildSearchItem() { return Container( height: 36.h, diff --git a/lib/view_widget/selector_store_dialog.dart b/lib/view_widget/selector_store_dialog.dart index 29eee8e0..ea8582a5 100644 --- a/lib/view_widget/selector_store_dialog.dart +++ b/lib/view_widget/selector_store_dialog.dart @@ -2,6 +2,7 @@ import 'package:flutter/material.dart'; import 'package:huixiang/generated/l10n.dart'; import 'package:huixiang/retrofit/data/store.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:huixiang/store/scan.dart'; import 'package:huixiang/view_widget/border_text.dart'; import 'package:huixiang/view_widget/custom_image.dart'; import 'package:huixiang/view_widget/round_button.dart'; @@ -101,9 +102,24 @@ class _SelectorStoreWidget extends State { ), InkWell( onTap: () { - Navigator.of(context).popAndPushNamed( - '/router/union_detail_page', - arguments: {"id": widget.stores[selectIndex].id}); + if(widget.stores[selectIndex].posType.code == "NORMALSTORE") { + Scan.toScan( + context, + widget.stores[selectIndex].id, + widget.stores[selectIndex].tenantCode, + widget.stores[selectIndex].storeName, + ); + } else { + Navigator.of(context).pushNamed( + '/router/store_order', + arguments: { + "id": widget.stores[selectIndex].id, + "tenant": widget.stores[selectIndex].tenantCode, + "storeName": widget.stores[selectIndex].storeName + }, + ); + } + }, child: RoundButton( text: S.of(context).queding, @@ -117,9 +133,9 @@ class _SelectorStoreWidget extends State { horizontal: 42.w, ), ), - ) + ), ], - ) + ), ], ), ); diff --git a/lib/web/web_view/web_header.dart b/lib/web/web_view/web_header.dart index a4e355de..ae67f404 100644 --- a/lib/web/web_view/web_header.dart +++ b/lib/web/web_view/web_header.dart @@ -61,13 +61,26 @@ class _WebHeader extends State { widget.arguments["source"] == widget.activity.storeId) { Navigator.of(context).pop(); } else { - Navigator.of(context).pushNamed( - '/router/union_detail_page', - arguments: { - "id": widget.activity.storeId, - "source": widget.arguments["activityId"] - }, - ); + // Navigator.of(context).pushNamed( + // '/router/union_detail_page', + // arguments: { + // "id": widget.activity.storeId, + // "source": widget.arguments["activityId"] + // }, + // ); + ///TODO: 进入店铺 + // if(widget.stores[selectIndex].posType.code == "NORMALSTORE") { + // toScan(widget.stores[selectIndex]); + // } else { + // Navigator.of(context).pushNamed( + // '/router/store_order', + // arguments: { + // "id": widget.activity.storeId, + // "tenant": widget.stores[selectIndex].tenantCode, + // "storeName": widget.activity.storeName + // }, + // ); + // } } } }, From db51f2a678cb718cc102a523e51a8254e643ddd2 Mon Sep 17 00:00:00 2001 From: fmk Date: Mon, 25 Oct 2021 15:47:13 +0800 Subject: [PATCH 12/20] safety --- lib/community/community_page.dart | 2 +- lib/main_page.dart | 4 +- lib/settlement/settlement.dart | 42 +++++---- .../activity_coupon_remarks.dart | 48 +++++++++-- lib/store/store_order.dart | 57 ++++++------ lib/store/store_view/product_sku.dart | 82 ++++++++++-------- lib/store/store_view/shop_car.dart | 1 + lib/store/store_view/shop_goods.dart | 86 +++++++++++++------ lib/store/store_view/store_order_list.dart | 18 ++-- 9 files changed, 208 insertions(+), 132 deletions(-) diff --git a/lib/community/community_page.dart b/lib/community/community_page.dart index 1d8a41f0..4c9c9b9e 100644 --- a/lib/community/community_page.dart +++ b/lib/community/community_page.dart @@ -32,7 +32,7 @@ class _CommunityPage extends State super.initState(); if (tabcontroller == null) - tabcontroller = TabController(length: lables.length, vsync: this); + tabcontroller = TabController(length: lables.length, vsync: this, initialIndex: 1); } _toRelease() async { diff --git a/lib/main_page.dart b/lib/main_page.dart index e1239a74..37fddb5b 100644 --- a/lib/main_page.dart +++ b/lib/main_page.dart @@ -229,7 +229,7 @@ class _MainPage extends State with WidgetsBindingObserver { } } - final PageController pageController = PageController(initialPage: 1); + final PageController pageController = PageController(initialPage: 0); @override Widget build(BuildContext context) { @@ -279,7 +279,7 @@ class _MainPage extends State with WidgetsBindingObserver { ); } - var clickIndex = 1; + var clickIndex = 0; Widget bottomNavigationItem(text, index) { var isSelected = index == clickIndex; diff --git a/lib/settlement/settlement.dart b/lib/settlement/settlement.dart index 30f52ecf..ba1c21e0 100644 --- a/lib/settlement/settlement.dart +++ b/lib/settlement/settlement.dart @@ -109,7 +109,8 @@ class _Settlement extends State { if (baseData != null && baseData.isSuccess) { setState(() { settleOrderInfo = baseData.data; - if (settleOrderInfo.orderProductList == null || settleOrderInfo.orderProductList.length == 0) { + if (settleOrderInfo.orderProductList == null || + settleOrderInfo.orderProductList.length == 0) { queryOrderDetails(parentId); } }); @@ -216,7 +217,8 @@ class _Settlement extends State { placeOrderFirst.subcribeTime = null; placeOrderFirst.tableId = "$tableId"; - if (tableId == 0) {///正常的商店下单 + if (tableId == 0) { + ///正常的商店下单 BaseData baseData = await minService .placeOrderFirst(placeOrderFirst.toJson()) .catchError((error) { @@ -227,7 +229,8 @@ class _Settlement extends State { this.downOrder = baseData.data; querySettlement(); } - } else { ///火锅店下单, 等待结算 + } else { + ///火锅店下单, 等待结算 BaseData baseData; if (parentId == "") { baseData = await minService @@ -368,8 +371,9 @@ class _Settlement extends State { ActivityCouponRemarks( couponCart, activityCart, - couponListBean, - promotion, + settleOrderInfo, + coupons, + promotions, couponCount(), ), @@ -398,9 +402,9 @@ class _Settlement extends State { ), ), Text( - minOrderInfo != null ? - "¥${minOrderInfo.orderSumPrice}" : - "¥${settleOrderInfo == null ? "0" : settleOrderInfo.price}", + minOrderInfo != null + ? "¥${minOrderInfo.orderSumPrice}" + : "¥${settleOrderInfo == null ? "0" : settleOrderInfo.price}", style: TextStyle( fontSize: 20.sp, fontWeight: MyFontWeight.semi_bold, @@ -462,6 +466,9 @@ class _Settlement extends State { return count; } + String coupons = ""; + String promotions = ""; + ///优惠券弹窗 couponCart() async { CouponListBean couponBean = await showModalBottomSheet( @@ -474,13 +481,15 @@ class _Settlement extends State { ); if (couponBean != null) { this.couponListBean = couponBean; - this.promotion = null; + coupons = couponListBean.promotionName; + promotions = ""; queryOrderInfo( - address != null ? address.id : null, - selectedBtn, - couponListBean != null ? couponListBean.id : null, - 0, - promotion != null ? promotion.id : null); + address != null ? address.id : null, + selectedBtn, + couponListBean != null ? couponListBean.id : null, + 0, + null, + ); } } @@ -496,11 +505,12 @@ class _Settlement extends State { ); if (pro != null) { this.promotion = pro; - this.couponListBean = null; + promotions = promotion.name; + coupons = ""; queryOrderInfo( address != null ? address.id : null, selectedBtn, - couponListBean != null ? couponListBean.id : null, + null, 0, promotion != null ? promotion.id : null, ); diff --git a/lib/settlement/settlement_view/activity_coupon_remarks.dart b/lib/settlement/settlement_view/activity_coupon_remarks.dart index cf33dcfb..52eedfaf 100644 --- a/lib/settlement/settlement_view/activity_coupon_remarks.dart +++ b/lib/settlement/settlement_view/activity_coupon_remarks.dart @@ -7,15 +7,18 @@ import 'package:flutter_screenutil/flutter_screenutil.dart'; class ActivityCouponRemarks extends StatefulWidget { final Function() couponCart; final Function() activityCart; - final CouponListBean couponListBean; - final PromotionInfoListBean promotion; + + final String coupons; + final String promotions; + final SettleOrderInfo settleOrderInfo; final int couponCount; ActivityCouponRemarks( this.couponCart, this.activityCart, - this.couponListBean, - this.promotion, + this.settleOrderInfo, + this.coupons, + this.promotions, this.couponCount, ); @@ -26,7 +29,6 @@ class ActivityCouponRemarks extends StatefulWidget { } class _ActivityCouponRemarks extends State { - @override Widget build(BuildContext context) { return Container( @@ -78,7 +80,7 @@ class _ActivityCouponRemarks extends State { ), ), Text( - widget.promotion == null ? "*优惠券与活动不可同时选择" : widget.promotion.name, + activityText(), textAlign: TextAlign.end, style: TextStyle( fontSize: 14.sp, @@ -116,9 +118,7 @@ class _ActivityCouponRemarks extends State { ), ), Text( - (widget.couponListBean == null) - ? ("未使用优惠券") - : widget.couponListBean.promotionName, + couponText(), textAlign: TextAlign.end, style: TextStyle( fontSize: 14.sp, @@ -170,4 +170,34 @@ class _ActivityCouponRemarks extends State { ), ); } + + String activityText() { + String promotion = ""; + if (widget.promotions == null || widget.promotions == "") { + promotion = "未选择任何活动"; + if (widget.settleOrderInfo == null || widget.settleOrderInfo.promotionInfoList == null) { + promotion = "暂无可选活动"; + } else if (widget.coupons != null && widget.coupons != "") { + promotion = "活动与优惠券不可同享"; + } + } else { + promotion = widget.promotions; + } + return promotion; + } + + String couponText() { + String coupon = ""; + if (widget.coupons == null || widget.coupons == "") { + coupon = "未选择任何优惠券"; + if (widget.settleOrderInfo == null || widget.settleOrderInfo.couponList == null) { + coupon = "暂无可选优惠券"; + } else if (widget.promotions != null && widget.promotions != "") { + coupon = "优惠券与活动不可同享"; + } + } else { + coupon = widget.coupons; + } + return coupon; + } } diff --git a/lib/store/store_order.dart b/lib/store/store_order.dart index 2f1987ad..835cd311 100644 --- a/lib/store/store_order.dart +++ b/lib/store/store_order.dart @@ -577,26 +577,13 @@ class _StoreOrderPage extends State ); } + /// 购物车的key,用于刷新UI GlobalKey shopCartKey = GlobalKey(); ///购物车弹窗 showShoppingCart() { queryShopCar().then((value) { this.shopCarGoods = value; - // showModalBottomSheet( - // context: context, - // backgroundColor: Colors.transparent, - // builder: (context) { - // return ShopCar( - // shopCartKey, - // this.shopCarGoods, - // clearShopCar, - // toDownOrder, - // shopCartAdd, - // shopCartReduce, - // ); - // }, - // ); dialogShowing = true; SmartDialog.show( widget: ShopCar( @@ -626,6 +613,7 @@ class _StoreOrderPage extends State ///选规格 _queryMiNiDetail(String id) async { + EasyLoading.show(status: S.current.zhengzaijiazai); BaseData baseData = await minService.miNiDetail(id); if (baseData != null && baseData.isSuccess) { showStoreSelector(baseData.data, id); @@ -634,8 +622,12 @@ class _StoreOrderPage extends State ///选规格弹窗 showStoreSelector(MiNiDetail miNiDetail, String id) async { - dialogShowing = true; - SmartDialog.show( + if (miNiDetail.attrList != null && miNiDetail.attrList.length == 1) { + _addShopCar(miNiDetail, [], 1); + } else { + EasyLoading.dismiss(); + dialogShowing = true; + SmartDialog.show( widget: ProductSku( miNiDetail, shopCarGoods, @@ -647,22 +639,28 @@ class _StoreOrderPage extends State onDismiss: () { dialogShowing = false; }, - alignmentTemp: Alignment.bottomCenter,); + alignmentTemp: Alignment.bottomCenter, + ); + } } ///添加购物车 Future _addShopCar(MiNiDetail miNiDetail, selectSkus, int count) async { - ProductSkuVOListBean productSku = - miNiDetail.productSkuVOList.firstWhere((element) { - bool gg = true; - selectSkus.forEach((element1) { - if (element.skuNameStr.indexOf(element1) < 0) { - gg = false; - return gg; - } + ProductSkuVOListBean productSku; + if (selectSkus!= null && selectSkus.length == 0) { + productSku = miNiDetail.productSkuVOList.first; + } else { + productSku = miNiDetail.productSkuVOList.firstWhere((element) { + bool gg = true; + selectSkus.forEach((element1) { + if (element.skuNameStr.indexOf(element1) < 0) { + gg = false; + return gg; + } + }); + return gg; }); - return gg; - }); + } if (productSku == null) return; String skuId = productSku.id; String skuValue = selectSkus @@ -693,6 +691,7 @@ class _StoreOrderPage extends State }, ], }); + EasyLoading.dismiss(); if (baseDate != null && baseDate.isSuccess) { queryShopCar().then((value) { this.shopCarGoods = value; @@ -726,8 +725,6 @@ class _StoreOrderPage extends State await minService.shoppingCartSingle(shopCarTemp); if (baseDate.isSuccess) { this.shopCarGoods = await queryShopCar(); - - print("shopingCar111111: ${this.shopCarGoods.toJson()}"); if (shopCartKey != null) { shopCartKey.currentState.setState(() {}); } @@ -746,8 +743,6 @@ class _StoreOrderPage extends State await minService.shoppingCartSingle(shopCarTemp); if (baseDate.isSuccess) { this.shopCarGoods = await queryShopCar(); - - print("shopingCar111111: ${this.shopCarGoods.toJson()}"); if (shopCartKey != null) { shopCartKey.currentState.setState(() {}); } diff --git a/lib/store/store_view/product_sku.dart b/lib/store/store_view/product_sku.dart index 829745ae..9b292e8f 100644 --- a/lib/store/store_view/product_sku.dart +++ b/lib/store/store_view/product_sku.dart @@ -177,30 +177,32 @@ class _ProductSku extends State { ), ], ), - SizedBox( - height: 23, - ), - Expanded( - child: ListView.builder( - itemCount: widget.miNiDetail.attrList.length, - scrollDirection: Axis.vertical, - physics: BouncingScrollPhysics(), - padding: EdgeInsets.zero, - itemBuilder: (context, position) { - return attrItem( - (index) { - state(() { - selectSkus[position] = widget.miNiDetail - .attrList[position].attrValueList[index].attrValue; - buildCount(); - }); - }, - widget.miNiDetail.attrList[position], - position, - ); - }, + if (widget.miNiDetail.attrList != null && widget.miNiDetail.attrList.length > 0) + SizedBox( + height: 23, + ), + if (widget.miNiDetail.attrList != null && widget.miNiDetail.attrList.length > 0) + Expanded( + child: ListView.builder( + itemCount: widget.miNiDetail.attrList.length, + scrollDirection: Axis.vertical, + physics: BouncingScrollPhysics(), + padding: EdgeInsets.zero, + itemBuilder: (context, position) { + return attrItem( + (index) { + state(() { + selectSkus[position] = widget.miNiDetail + .attrList[position].attrValueList[index].attrValue; + buildCount(); + }); + }, + widget.miNiDetail.attrList[position], + position, + ); + }, + ), ), - ), SizedBox( height: 24, ), @@ -286,23 +288,27 @@ class _ProductSku extends State { } Widget attrItem(Function fc, AttrListBean attrListBean, position) { - return Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Padding( - padding: EdgeInsets.only(top: 24, bottom: 16), - child: Text( - attrListBean.attrName, - style: TextStyle( - color: Colors.black, - fontSize: 14.sp, - fontWeight: MyFontWeight.regular, + if (attrListBean.attrValueList != null && attrListBean.attrValueList.length > 0) + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Padding( + padding: EdgeInsets.only(top: 24, bottom: 16), + child: Text( + attrListBean.attrName, + style: TextStyle( + color: Colors.black, + fontSize: 14.sp, + fontWeight: MyFontWeight.regular, + ), ), ), - ), - sweetnessStore(fc, attrListBean.attrValueList, position), - ], - ); + sweetnessStore(fc, attrListBean.attrValueList, position), + ], + ); + else { + return Container(); + } } Widget sweetnessStore(Function fc, List arrays, position) { diff --git a/lib/store/store_view/shop_car.dart b/lib/store/store_view/shop_car.dart index d706f898..6ef893ca 100644 --- a/lib/store/store_view/shop_car.dart +++ b/lib/store/store_view/shop_car.dart @@ -121,6 +121,7 @@ class _ShopCar extends State { await widget.shopCartReduce(cart); setState(() {}); }, + isShopCart: true, count: widget.shopingCar .shoppingCartSkuItemList[position].buyNum, shoppingCartSkuItemListBean: widget.shopingCar diff --git a/lib/store/store_view/shop_goods.dart b/lib/store/store_view/shop_goods.dart index 806db92c..790c1acd 100644 --- a/lib/store/store_view/shop_goods.dart +++ b/lib/store/store_view/shop_goods.dart @@ -8,19 +8,21 @@ import 'package:huixiang/view_widget/custom_image.dart'; import 'package:huixiang/view_widget/round_button.dart'; class ShopGoods extends StatefulWidget { - final Function(String id) queryMiNiDetail; final Function(ShoppingCartSkuItemListBean shoppingCartSkuItemListBean) add; - final Function(ShoppingCartSkuItemListBean shoppingCartSkuItemListBean) reduce; + final Function(ShoppingCartSkuItemListBean shoppingCartSkuItemListBean) + reduce; final ProductListBean productListBean; final ShoppingCartSkuItemListBean shoppingCartSkuItemListBean; final int count; + final bool isShopCart; ShopGoods( this.add, this.reduce, { - this.productListBean, + this.productListBean, this.count = 0, + this.isShopCart = false, this.queryMiNiDetail, this.shoppingCartSkuItemListBean, }); @@ -48,10 +50,11 @@ class _ShopGoods extends State { children: [ SizedBox(width: 12.w), MImage( - widget.productListBean != null ? widget.productListBean.imgPath : - (widget.shoppingCartSkuItemListBean != null - ? widget.shoppingCartSkuItemListBean.skuImg - : ""), + widget.productListBean != null + ? widget.productListBean.imgPath + : (widget.shoppingCartSkuItemListBean != null + ? widget.shoppingCartSkuItemListBean.skuImg + : ""), width: 70, height: 70, fit: BoxFit.cover, @@ -66,7 +69,9 @@ class _ShopGoods extends State { crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( - widget.productListBean != null ? widget.productListBean.productName : widget.shoppingCartSkuItemListBean.productName, + widget.productListBean != null + ? widget.productListBean.productName + : widget.shoppingCartSkuItemListBean.productName, style: TextStyle( color: Colors.black, fontSize: 13.sp, @@ -76,13 +81,16 @@ class _ShopGoods extends State { SizedBox( height: 2, ), + ///{"id":"1442420413828169728","productId":"1432652566000304128","productName":"桂花乌龙茶","skuName":null,"buyNum":1,"skuStock":1000,"skuImg":"https://pos.upload.gznl.top/1177/2021/08/f855ffb8-d473-4f5f-93c9-5907b539b2fd.jpg", ///"skuPrice":"0.00","selected":1,"storeId":null,"groupId":"1426067376096411648","createTime":"2021-10-20 10:27:46","tableId":null,"platterList":null} Row( children: [ Expanded( child: Text( - (widget.productListBean != null ? widget.productListBean.shortName : widget.shoppingCartSkuItemListBean.skuName ?? ""), + (widget.productListBean != null + ? widget.productListBean.shortName + : widget.shoppingCartSkuItemListBean.skuName ?? ""), overflow: TextOverflow.ellipsis, maxLines: 2, style: TextStyle( @@ -154,22 +162,48 @@ class _ShopGoods extends State { ], ), Spacer(), - if (widget.count == 0) - RoundButton( - width: 49.w, - text: S.of(context).xuanguige, - textColor: Colors.white, - fontWeight: MyFontWeight.medium, - radius: 11, - backgroup: Color(0xFF32A060), - fontSize: 11.sp, - padding: EdgeInsets.symmetric(vertical: 5.h), - callback: () { - widget.queryMiNiDetail( - widget.productListBean != null ? widget.productListBean.id : widget.shoppingCartSkuItemListBean.productId); - }, + if (!widget.isShopCart) + Stack( + children: [ + Container( + margin: EdgeInsets.only(right: 8, top: 4), + child: RoundButton( + width: 49.w, + text: S.of(context).xuanguige, + textColor: Colors.white, + fontWeight: MyFontWeight.medium, + radius: 11, + backgroup: Color(0xFF32A060), + fontSize: 11.sp, + padding: EdgeInsets.symmetric(vertical: 5.h), + callback: () { + widget.queryMiNiDetail( + widget.productListBean != null + ? widget.productListBean.id + : widget.shoppingCartSkuItemListBean + .productId); + }, + ), + ), + Positioned( + right: 0, + child: Visibility( + visible: widget.count > 0, + child: RoundButton( + width: 17, + height: 17, + text: "${widget.count}", + textColor: Color(0xFF32A060), + fontWeight: MyFontWeight.regular, + backgroup: Colors.white, + fontSize: 12.sp, + radius: 100, + ), + ), + ), + ], ), - if (widget.count > 0) + if (widget.isShopCart) InkWell( onTap: () { widget.reduce(widget.shoppingCartSkuItemListBean); @@ -180,7 +214,7 @@ class _ShopGoods extends State { height: 22, ), ), - if (widget.count > 0) + if (widget.isShopCart) Container( width: 30, alignment: Alignment.center, @@ -193,7 +227,7 @@ class _ShopGoods extends State { ), ), ), - if (widget.count > 0) + if (widget.isShopCart) InkWell( onTap: () { widget.add(widget.shoppingCartSkuItemListBean); diff --git a/lib/store/store_view/store_order_list.dart b/lib/store/store_view/store_order_list.dart index dbbbb617..d3dab061 100644 --- a/lib/store/store_view/store_order_list.dart +++ b/lib/store/store_view/store_order_list.dart @@ -3,6 +3,7 @@ import 'package:flutter/material.dart'; import 'package:huixiang/retrofit/data/activity.dart'; import 'package:huixiang/retrofit/data/base_data.dart'; import 'package:huixiang/retrofit/data/findMiNiGroupList.dart'; +import 'package:huixiang/retrofit/data/miNiDetail.dart'; import 'package:huixiang/retrofit/data/shoppingCart.dart'; import 'package:huixiang/retrofit/data/store_info.dart'; import 'package:huixiang/retrofit/min_api.dart'; @@ -19,6 +20,7 @@ class StoreOrderListPage extends StatefulWidget { final StoreInfo storeInfo; final ScrollController controller; final Function(String id) queryMiNiDetail; + ShoppingCart shopCarGoods; StoreOrderListPage( @@ -44,6 +46,9 @@ class _StoreOrderListPage extends State { List appletProducts; List productListBeans = []; + ScrollController controller1 = ScrollController(); + ScrollController controller2 = ScrollController(); + @override void initState() { super.initState(); @@ -83,8 +88,6 @@ class _StoreOrderListPage extends State { } } - // RefreshController refreshController; - @override Widget build(BuildContext context) { return Container( @@ -114,8 +117,7 @@ class _StoreOrderListPage extends State { Container( width: MediaQuery.of(context).size.width - 100.w, child: ListView.builder( - itemCount: - productListBeans == null ? 0 : productListBeans.length, + itemCount: productListBeans == null ? 0 : productListBeans.length, physics: BouncingScrollPhysics(), shrinkWrap: true, padding: EdgeInsets.zero, @@ -129,9 +131,6 @@ class _StoreOrderListPage extends State { ); } - ScrollController controller1 = ScrollController(); - ScrollController controller2 = ScrollController(); - Widget orderItem(FindMiNiGroupList findMiNiGroupList, int index) { int count = calculateItemCount(findMiNiGroupList); return Container( @@ -235,13 +234,14 @@ class _StoreOrderListPage extends State { }, child: ShopGoods( (ShoppingCartSkuItemListBean shoppingCartSkuItemListBean) { - widget.queryMiNiDetail(productListBeans[position].id); + // widget.add(productListBeans[position].id); }, (ShoppingCartSkuItemListBean shoppingCartSkuItemListBean) { - widget.queryMiNiDetail(productListBeans[position].id); + // widget.reduce(productListBeans[position].id); }, productListBean: productListBeans[position], count: count, + isShopCart: false, queryMiNiDetail: widget.queryMiNiDetail, shoppingCartSkuItemListBean: shoppingCartSkuItemListBean, ), From c86fa03ba1209c2aa67b97b6a274330eeb463c73 Mon Sep 17 00:00:00 2001 From: fmk Date: Mon, 25 Oct 2021 18:49:29 +0800 Subject: [PATCH 13/20] safety --- ios/Podfile.lock | 4 +- lib/community/community_child_page.dart | 69 ++-- lib/community/community_details.dart | 314 ++++++++---------- .../community_view/community_dynamic.dart | 136 +++++--- lib/home/huixiang_brand_page.dart | 1 - .../integral_store_details_page.dart | 9 - lib/retrofit/min_api.dart | 3 - lib/store/store_order.dart | 109 +++--- lib/store/store_view/store_order_list.dart | 10 +- lib/web/web_page.dart | 27 +- lib/web/web_view/web_content.dart | 104 +++--- pubspec.lock | 305 +++-------------- pubspec.yaml | 13 +- 13 files changed, 437 insertions(+), 667 deletions(-) diff --git a/ios/Podfile.lock b/ios/Podfile.lock index aaf89031..022bd440 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -228,8 +228,8 @@ SPEC CHECKSUMS: tpns_flutter_plugin: a366649c8ad71f19dfb864d3c994ed0480b69daa url_launcher: 6fef411d543ceb26efce54b05a0a40bfd74cbbef video_player: 9cc823b1d9da7e8427ee591e8438bfbcde500e6e - wakelock: bfc7955c418d0db797614075aabbc58a39ab5107 - webview_flutter: d2b4d6c66968ad042ad94cbb791f5b72b4678a96 + wakelock: d0fc7c864128eac40eba1617cb5264d9c940b46f + webview_flutter: 3603125dfd3bcbc9d8d418c3f80aeecf331c068b WechatOpenSDK_Fuck: aa8f4b0af902837e887a1d40c62f06c060c1dc98 ZLPhotoBrowser-objc: c7657d3bc85ae231884e058d0e3638f619164736 diff --git a/lib/community/community_child_page.dart b/lib/community/community_child_page.dart index 00152673..6b0a075e 100644 --- a/lib/community/community_child_page.dart +++ b/lib/community/community_child_page.dart @@ -51,7 +51,7 @@ class _CommunityChildPage extends State { } pageNum += 1; BaseData> baseData = await apiService.trendList({ - "onlyFollow": widget.typeStr == "关注" ? true:false, + "onlyFollow": widget.typeStr == "关注" ? true : false, "onlyMe": false, "pageNum": pageNum, "pageSize": 10, @@ -82,39 +82,44 @@ class _CommunityChildPage extends State { future: queryCommunity(), builder: (context, position) { return SmartRefresher( - controller: refreshController, - enablePullDown: true, - enablePullUp: true, - physics: BouncingScrollPhysics(), - header: MyHeader(), - footer: CustomFooter( - builder: (context, mode) { - return MyFooter(mode); - }, - ), - onRefresh: _onRefresh, - onLoading: () { - setState(() {}); + controller: refreshController, + enablePullDown: true, + enablePullUp: true, + physics: BouncingScrollPhysics(), + header: MyHeader(), + footer: CustomFooter( + builder: (context, mode) { + return MyFooter(mode); }, - child: ListView.builder( - physics: NeverScrollableScrollPhysics(), - itemBuilder: (context, position) { - return InkWell( - child: CommunityDynamic(comments[position],0,exitFull: (){setState(() { - - });},), - onTap: () { - Navigator.of(context).pushNamed( - '/router/community_details', - arguments: { - "comment": comments[position], - }, - ); + ), + onRefresh: _onRefresh, + onLoading: () { + setState(() {}); + }, + child: ListView.builder( + physics: NeverScrollableScrollPhysics(), + itemBuilder: (context, position) { + return InkWell( + child: CommunityDynamic( + comments[position], + 0, + exitFull: () { + setState(() {}); }, - ); - }, - itemCount: comments.length, - )); + ), + onTap: () { + Navigator.of(context).pushNamed( + '/router/community_details', + arguments: { + "comment": comments[position], + }, + ); + }, + ); + }, + itemCount: comments.length, + ), + ); }, ); } diff --git a/lib/community/community_details.dart b/lib/community/community_details.dart index d657e54b..45830a86 100644 --- a/lib/community/community_details.dart +++ b/lib/community/community_details.dart @@ -15,6 +15,7 @@ import 'package:huixiang/retrofit/retrofit_api.dart'; import 'package:huixiang/utils/font_weight.dart'; import 'package:huixiang/view_widget/comment_menu.dart'; import 'package:huixiang/view_widget/login_tips_dialog.dart'; +import 'package:huixiang/view_widget/my_appbar.dart'; import 'package:huixiang/view_widget/tips_dialog.dart'; import 'package:huixiang/web/web_view/input_comment.dart'; import 'package:shared_preferences/shared_preferences.dart'; @@ -48,7 +49,6 @@ class _CommunityDetails extends State int commentTotal = 0; Article article; - @override void didChangeMetrics() { WidgetsBinding.instance.addPostFrameCallback((_) { @@ -56,15 +56,17 @@ class _CommunityDetails extends State if (MediaQuery.of(context).viewInsets.bottom == 0) { if (isKeyBoardShow) { FocusScope.of(context).requestFocus(FocusNode()); - setState(() { - hintText = S.current.liuxianinjingcaidepinglunba; - isKeyBoardShow = false; - }); + if (mounted) + setState(() { + hintText = S.current.liuxianinjingcaidepinglunba; + isKeyBoardShow = false; + }); } } else { - setState(() { - isKeyBoardShow = true; - }); + if (mounted) + setState(() { + isKeyBoardShow = true; + }); } }); } @@ -83,186 +85,140 @@ class _CommunityDetails extends State queryDetails() async { SharedPreferences value = await SharedPreferences.getInstance(); if (apiService == null) - apiService = - ApiService(Dio(), context: context, token: value.getString("token")); - BaseData
baseData = await apiService - .informationInfo(comunity.id) - .catchError((onError) {}); - if (baseData != null && baseData.isSuccess) { - } + apiService = ApiService( + Dio(), + context: context, + token: value.getString("token"), + ); + BaseData
baseData = + await apiService.informationInfo(comunity.id).catchError((onError) {}); + if (baseData != null && baseData.isSuccess) {} } @override Widget build(BuildContext context) { return Scaffold( - body: Container( - child: Column( - children: [ - Expanded( - child: NestedScrollView( - headerSliverBuilder: (context, position) { - return [ - SliverOverlapAbsorber( - handle: - NestedScrollView.sliverOverlapAbsorberHandleFor(context), - sliver: SliverAppBar( - expandedHeight: (height == 0) ? 614 : height, - pinned: true, - backgroundColor: Colors.white, - title: Text( - "动态详情", - style: TextStyle( - color: Colors.black, - fontSize: 18.sp, - fontWeight: MyFontWeight.semi_bold, - ), - ), - elevation: 0, - leading: GestureDetector( - onTap: () { - Navigator.of(context).pop(); + appBar: MyAppBar( + title: "动态详情", + titleColor: Colors.black, + titleSize: 18.sp, + background: Colors.white, + leading: true, + leadingColor: Colors.black, + ), + body: Container( + child: Column( + children: [ + Expanded( + child: SingleChildScrollView( + child: Column( + children: [ + CommunityDynamic( + comunity, + 0, + exitFull: () { + setState(() {}); + }, + itemCount: 3, + isDetails: true, + heightFun: (height) { + this.height = height + + MediaQuery.of(context).padding.top + + kToolbarHeight + + 24; + if (mounted) setState(() {}); }, - child: Container( - alignment: Alignment.centerRight, - margin: EdgeInsets.only(left: 10), - padding: EdgeInsets.all(6), - child: Icon( - Icons.arrow_back_ios, - color: Colors.black, - size: 24, - ), - ), - ), - flexibleSpace: FlexibleSpaceBar( - //Colors.white, - background: Container( - padding: EdgeInsets.only( - top: MediaQuery.of(context).padding.top + - kToolbarHeight, - ), - color: Colors.white, - child: CommunityDynamic( - comunity,0,exitFull: (){setState(() { - - });}, - itemCount: 3, - isDetails: true, - heightFun: (height) { - this.height = height + - MediaQuery.of(context).padding.top + - kToolbarHeight + - 24; - setState(() {}); - }, - ), - ), - collapseMode: CollapseMode.pin, ), - bottom: PreferredSize( - preferredSize: Size( - MediaQuery.of(context).size.width, - 46, - ), - child: Container( - padding: EdgeInsets.all(16), - margin: EdgeInsets.only(top: 16.h), - color: Colors.white, - child: Row( - children: [ - Text( - S.of(context).pinglun_(commentTotal.toString()), - style: TextStyle( - fontSize: 14, - fontWeight: FontWeight.bold, - color: Color(0xff1A1A1A), - ), - ), - SizedBox( - width: 16.w, + Container( + padding: EdgeInsets.all(16), + color: Colors.white, + child: Row( + children: [ + Text( + S.of(context).pinglun_(commentTotal.toString()), + style: TextStyle( + fontSize: 14, + fontWeight: FontWeight.bold, + color: Color(0xff1A1A1A), ), - Text( - S.of(context).xihuan_( - "${comunity?.likes ?? comunity?.likes ?? "0"}"), - style: TextStyle( - fontSize: 14, - fontWeight: FontWeight.bold, - color: Color(0xff1A1A1A), - ), + ), + SizedBox( + width: 16.w, + ), + Text( + S.of(context).xihuan_( + "${comunity?.likes ?? comunity?.likes ?? "0"}"), + style: TextStyle( + fontSize: 14, + fontWeight: FontWeight.bold, + color: Color(0xff1A1A1A), ), - ], - ), + ), + ], ), ), - ), - ), - ]; - }, - body: Container( - height: MediaQuery.of(context).size.height - - MediaQuery.of(context).padding.top + - kToolbarHeight - 68, - margin: EdgeInsets.only(top: 50 + kToolbarHeight), - child: Column( - children: [ - if (memberList != null && memberList.length > 0) - Expanded(child: ListView.builder( - shrinkWrap: true, - physics: NeverScrollableScrollPhysics(), - itemCount: memberList != null ? memberList.length : 0, - scrollDirection: Axis.vertical, - itemBuilder: (context, position) { - return Material( - color: Colors.white, - child: InkWell( - onTap: () { - showPressMenu(memberList[position].createUser, - memberList[position]); - }, - child: CommunityComment( - memberList[position], - _queryCommentLike, - (memberList.length-1 == position)?1:0 + if (memberList != null && memberList.length > 0) + ListView.builder( + shrinkWrap: true, + physics: NeverScrollableScrollPhysics(), + itemCount: memberList != null ? memberList.length : 0, + scrollDirection: Axis.vertical, + itemBuilder: (context, position) { + return Material( + color: Colors.white, + child: InkWell( + onTap: () { + showPressMenu( + memberList[position].createUser, + memberList[position], + ); + }, + child: CommunityComment( + memberList[position], + _queryCommentLike, + (memberList.length - 1 == position) ? 1 : 0, + ), ), + ); + }, + ), + if (memberList == null || memberList.length == 0) + Container( + width: double.infinity, + alignment: Alignment.topCenter, + margin: EdgeInsets.only(top: 40), + padding: EdgeInsets.all(22.h), + child: Text( + S.of(context).zanwupinglun, + style: TextStyle( + fontSize: 12, + fontWeight: FontWeight.bold, + color: Color(0xFFA0A0A0), ), - ); - }, - )), - if (memberList == null || memberList.length == 0) - Container( - width: double.infinity, - alignment: Alignment.topCenter, - margin: EdgeInsets.only(top:40), - padding: EdgeInsets.all(22.h), - child: Text( - S.of(context).zanwupinglun, - style: TextStyle( - fontSize: 12, - fontWeight: FontWeight.bold, - color: Color(0xFFA0A0A0), ), ), - ), - ], + ], + ), ), + flex: 1, ), - ), - flex: 1, - ), - /// 富文本评论的输入框 - InputComment( - inputKey, - hintText, - isKeyBoardShow, - commentFocus, - commentTextController, - _toComment, - _queryMemberComment, - _queryInformationLikes, - isLike: comunity.selfLike, + /// 富文本评论的输入框 + InputComment( + inputKey, + hintText, + isKeyBoardShow, + commentFocus, + commentTextController, + _toComment, + _queryMemberComment, + _queryInformationLikes, + isLike: comunity.selfLike, + ), + ], ), - ], - ))); + ), + ); } ///给文章/活动点赞 @@ -271,10 +227,11 @@ class _CommunityDetails extends State if (baseData != null && baseData.isSuccess) { // commentKey.currentState.setState(() {}); setState(() { - if(comunity.selfLike??false) + if (comunity.selfLike ?? false) comunity.likes -= 1; - else comunity.likes += 1; - comunity.selfLike = !comunity.selfLike??false; + else + comunity.likes += 1; + comunity.selfLike = !comunity.selfLike ?? false; }); } else { SmartDialog.showToast(baseData.msg, alignment: Alignment.center); @@ -303,11 +260,12 @@ class _CommunityDetails extends State RenderBox firstRenderBox = commentKey.currentContext.findRenderObject(); Offset first = firstRenderBox.localToGlobal(Offset.zero); scrollController.animateTo( - first.dy + - scrollController.offset - - (kToolbarHeight + MediaQuery.of(context).padding.top), - duration: Duration(milliseconds: 300), - curve: Curves.easeIn); + first.dy + + scrollController.offset - + (kToolbarHeight + MediaQuery.of(context).padding.top), + duration: Duration(milliseconds: 300), + curve: Curves.easeIn, + ); } final GlobalKey inputKey = GlobalKey(); @@ -415,7 +373,7 @@ class _CommunityDetails extends State commentTotal = baseData.data.size; memberList = baseData.data.list; contentHeight(); - setState(() {}); + if (mounted) setState(() {}); } } } diff --git a/lib/community/community_view/community_dynamic.dart b/lib/community/community_view/community_dynamic.dart index bfca430e..7b57be89 100644 --- a/lib/community/community_view/community_dynamic.dart +++ b/lib/community/community_view/community_dynamic.dart @@ -1,3 +1,5 @@ +import 'dart:ui'; + import 'package:chewie/chewie.dart'; import 'package:dio/dio.dart'; import 'package:flutter/material.dart'; @@ -32,8 +34,8 @@ class CommunityDynamic extends StatefulWidget { this.itemCount = 9, this.heightFun, this.isDetails = false, - this.removalDynamic, - this.exitFull + this.removalDynamic, + this.exitFull, }) : super(key: key); @override @@ -47,13 +49,50 @@ class _CommunityDynamic extends State { double height = 0; ApiService apiService; + VideoPlayerController videoPlayerController; + ChewieController chewieAudioController; + Chewie chewies; + @override void initState() { super.initState(); - SharedPreferences.getInstance().then((value) => { - apiService = ApiService(Dio(), - context: context, token: value.getString('token')), + SharedPreferences.getInstance().then( + (value) => { + apiService = ApiService( + Dio(), + context: context, + token: value.getString('token'), + ), + }, + ); + + if (widget.comment.subjectInfo.type == "video" && + widget.comment.subjectInfo.video.isNotEmpty) { + videoPlayerController = VideoPlayerController.network( + widget.comment.subjectInfo.video, + )..initialize().then((value) { + chewieAudioController = ChewieController( + videoPlayerController: videoPlayerController, + aspectRatio: videoPlayerController.value.aspectRatio, + //宽高比 + autoPlay: false, + //自动播放 + looping: false, + //循环播放 + allowFullScreen: true, + // 拖动条样式颜色 + materialProgressColors: chewie.ChewieProgressColors( + playedColor: Colors.white, + handleColor: Colors.white, + backgroundColor: Colors.grey, + bufferedColor: Colors.transparent, + ), + autoInitialize: true, + ); + chewieAudioController.addListener(_fullScreenListener); + if (mounted) setState(() {}); }); + } } ///关注/取关会员 @@ -71,7 +110,6 @@ class _CommunityDynamic extends State { BaseData baseData = await apiService.deleteTrend(id); if (baseData != null && baseData.isSuccess) { SmartDialog.showToast("删除成功", alignment: Alignment.center); - } else { SmartDialog.showToast(baseData.msg, alignment: Alignment.center); } @@ -111,7 +149,7 @@ class _CommunityDynamic extends State { child: Row( children: [ MImage( - widget?.comment?.memberInfo?.avatar??"", + widget?.comment?.memberInfo?.avatar ?? "", width: 44, height: 44, isCircle: true, @@ -127,7 +165,7 @@ class _CommunityDynamic extends State { crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( - widget?.comment?.memberInfo?.nickname??"", + widget?.comment?.memberInfo?.nickname ?? "", style: TextStyle( fontSize: 14.sp, fontWeight: MyFontWeight.medium, @@ -135,7 +173,7 @@ class _CommunityDynamic extends State { ), ), Text( - widget?.comment?.createTime??"", + widget?.comment?.createTime ?? "", style: TextStyle( fontSize: 12.sp, fontWeight: MyFontWeight.regular, @@ -244,7 +282,7 @@ class _CommunityDynamic extends State { Container( height: 16, color: Color(0xFFF7F7F7), - ) + ), ], ); } @@ -262,7 +300,7 @@ class _CommunityDynamic extends State { subjectInfo.images[0], fit: BoxFit.cover, width: MediaQuery.of(context).size.width / 2, - height: MediaQuery.of(context).size.width /1, + height: MediaQuery.of(context).size.width / 2, errorSrc: "assets/image/default_2_1.png", fadeSrc: "assets/image/default_2_1.png", ), @@ -295,11 +333,13 @@ class _CommunityDynamic extends State { itemCount: subjectInfo.images.length, ); } - } else if (subjectInfo.type == "video" && - subjectInfo.video.isNotEmpty) { + } else if (subjectInfo.type == "video" && subjectInfo.video.isNotEmpty) { widget = videoWidget( MediaQuery.of(context).size.width - 32, - MediaQuery.of(context).size.width /2, + videoPlayerController != null + ? (MediaQuery.of(context).size.width - 32) / + videoPlayerController.value.aspectRatio + : MediaQuery.of(context).size.width / 2, subjectInfo.video); } @@ -316,58 +356,44 @@ class _CommunityDynamic extends State { ); } - VideoPlayerController videoPlayerController; - ChewieController chewieAudioController; - Chewie chewies; + @override + void dispose() { + super.dispose(); - Widget videoWidget(double width, double height, src) { - print("src : $src"); - chewieAudioController = ChewieController( - videoPlayerController: videoPlayerController = - VideoPlayerController.network( - src, - ), - aspectRatio: width / height, - //宽高比 - autoPlay: false, - //自动播放 - looping: false, - //循环播放 - allowFullScreen: true, - // systemOverlaysAfterFullScreen: [], - // systemOverlaysOnEnterFullScreen: [], - // deviceOrientationsAfterFullScreen: [], - // deviceOrientationsOnEnterFullScreen: [], - // 拖动条样式颜色 - materialProgressColors: chewie.ChewieProgressColors( - playedColor: Colors.white, - handleColor: Colors.white, - backgroundColor: Colors.grey, - bufferedColor: Colors.transparent, - ), - autoInitialize: true, - ); + if (chewieAudioController != null) { + chewieAudioController.pause(); + chewieAudioController.dispose(); + chewieAudioController = null; + } - chewieAudioController.addListener(_fullScreenListener); + if (videoPlayerController != null) { + videoPlayerController.pause(); + videoPlayerController.dispose(); + } + } + Widget videoWidget(double width, double height, src) { + print("src : $src"); return MediaQuery( data: MediaQuery.of(context).copyWith( textScaleFactor: 0.9, ), - child: Container( - width: MediaQuery.of(context).size.width - 17, - height: (MediaQuery.of(context).size.width) / (width / height), - child: chewies = Chewie( - controller: chewieAudioController, - ), - ), + child: chewieAudioController != null + ? Container( + width: width, + height: height, + child: chewies = Chewie( + controller: chewieAudioController, + ), + ) + : Container( + width: width, + height: height, + ), ); } Future _fullScreenListener() async { - print("object: isPlaying: ${videoPlayerController.value.isPlaying}"); - print("object: isFullScreen: ${chewieAudioController.isFullScreen}"); - if (!chewieAudioController.isFullScreen) { Future.delayed(Duration(seconds: 1), () { widget.exitFull(); diff --git a/lib/home/huixiang_brand_page.dart b/lib/home/huixiang_brand_page.dart index f8e7d829..24849ed2 100644 --- a/lib/home/huixiang_brand_page.dart +++ b/lib/home/huixiang_brand_page.dart @@ -182,7 +182,6 @@ class _BrandPage extends State child: Html( data: value.content, customImageRenders: { - base64DataUriMatcher(): base64ImageRender(), assetUriMatcher(): assetImageRender(), networkSourceMatcher(extension: "svg"): svgNetworkImageRender(), networkSourceMatcher(): networkImageRender( diff --git a/lib/integral_store/integral_store_details_page.dart b/lib/integral_store/integral_store_details_page.dart index f0230751..0aace98c 100644 --- a/lib/integral_store/integral_store_details_page.dart +++ b/lib/integral_store/integral_store_details_page.dart @@ -100,19 +100,10 @@ class _IntegralStoreDetailsPage extends State { child: Html( data: goods != null ? goods.detail : "", customImageRenders: { - base64DataUriMatcher(): base64ImageRender(), - assetUriMatcher(): assetImageRender(), - networkSourceMatcher(extension: "svg"): - svgNetworkImageRender(), networkSourceMatcher(): networkImageRender( loadingWidget: () { - // return Image.asset("assets/image/default_1.png",); return Container(); }, - // mapUrl: (url) { - // print("objectUrl: $url"); - // return "$url?imageMogr2/format/webp/blur/1x0/quality/75"; - // } ), }, ), diff --git a/lib/retrofit/min_api.dart b/lib/retrofit/min_api.dart index 1cb07f09..89783777 100644 --- a/lib/retrofit/min_api.dart +++ b/lib/retrofit/min_api.dart @@ -1,7 +1,6 @@ import 'dart:convert'; import 'package:dio/dio.dart'; -import 'package:flare_flutter/flare_testing.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter_easyloading/flutter_easyloading.dart'; @@ -11,8 +10,6 @@ import 'package:huixiang/retrofit/data/address.dart'; import 'package:huixiang/retrofit/data/base_data.dart'; import 'package:huixiang/retrofit/data/down_order.dart'; import 'package:huixiang/retrofit/data/min_order_info.dart'; -import 'package:huixiang/retrofit/data/placeOrderFirst.dart'; -import 'package:huixiang/retrofit/data/settlement_bean.dart'; import 'package:huixiang/retrofit/data/wx_pay.dart'; import 'package:huixiang/view_widget/login_tips_dialog.dart'; import 'package:retrofit/retrofit.dart'; diff --git a/lib/store/store_order.dart b/lib/store/store_order.dart index 835cd311..78dde134 100644 --- a/lib/store/store_order.dart +++ b/lib/store/store_order.dart @@ -59,6 +59,8 @@ class _StoreOrderPage extends State String tenant = ""; String storeId = ""; int numberOfPeople = 0; + ///小程序token + String minToken; @override void initState() { @@ -91,13 +93,13 @@ class _StoreOrderPage extends State token: shared.getString('token'), showLoading: false, ); - queryStoreInfo(); apiService.minLogin(storeId).catchError((onError) { debugPrint(onError); }).then((baseData) { if (baseData != null && baseData.isSuccess) { Map minStoreInfo = baseData.data; - String minToken = minStoreInfo["token"]; + minToken = minStoreInfo["token"]; + queryStoreInfo(); SharedPreferences.getInstance().then( (value) => { value.setString('minToken', minToken), @@ -127,10 +129,8 @@ class _StoreOrderPage extends State ///获取父订单(火锅订单加菜前调用) getParentInfo() async { - BaseData baseData = - await minService.getParentInfo("$tableId").catchError((error) { - debugPrint(error); - }); + BaseData baseData = await minService.getParentInfo("$tableId") + .catchError((error) {debugPrint(error);}); if (baseData != null && baseData.isSuccess) { if (baseData.data != null) { parentId = baseData.data["id"]; @@ -244,58 +244,61 @@ class _StoreOrderPage extends State StretchMode.fadeTitle, StretchMode.blurBackground, ], - background: Stack( - children: [ - Positioned( - child: Column( - children: [ - buildSwiper(), - Expanded( - child: Container( - color: Colors.transparent, - ), - flex: 1, - ), - ], - ), - top: 0, - bottom: 0, - left: 0, - right: 0, - ), - Positioned( - child: Container( + background: Container( + color: Colors.white, + child: Stack( + children: [ + Positioned( child: Column( children: [ - ///门店信息 - StoreInfoView(storeInfo), - - ///门店对应优惠券 - if (storeInfo != null && - storeInfo.couponVOList != null) - UnionCoupon( - storeInfo, - _receiveCoupon, - coupon: true, - ), - - if (storeInfo == null || - storeInfo.couponVOList == null) - SizedBox( - height: 8, + buildSwiper(), + Expanded( + child: Container( + color: Colors.transparent, ), - - ///门店对应VIP信息 - Vip(storeInfo, () {}, false), + flex: 1, + ), ], ), + top: 0, + bottom: 0, + left: 0, + right: 0, ), - top: 110.h, - bottom: 0, - left: 0, - right: 0, - ), - ], + Positioned( + child: Container( + child: Column( + children: [ + ///门店信息 + StoreInfoView(storeInfo), + + ///门店对应优惠券 + if (storeInfo != null && + storeInfo.couponVOList != null) + UnionCoupon( + storeInfo, + _receiveCoupon, + coupon: true, + ), + + if (storeInfo == null || + storeInfo.couponVOList == null) + SizedBox( + height: 8, + ), + + ///门店对应VIP信息 + Vip(storeInfo, () {}, false), + ], + ), + ), + top: 110.h, + bottom: 0, + left: 0, + right: 0, + ), + ], + ), ), ), backgroundColor: Color(0x33FAFAFA), @@ -351,6 +354,8 @@ class _StoreOrderPage extends State storeInfo, shopCarGoods, controller, + minToken, + tenant, _queryMiNiDetail, ), diff --git a/lib/store/store_view/store_order_list.dart b/lib/store/store_view/store_order_list.dart index d3dab061..c879e5f9 100644 --- a/lib/store/store_view/store_order_list.dart +++ b/lib/store/store_view/store_order_list.dart @@ -19,6 +19,8 @@ class StoreOrderListPage extends StatefulWidget { final List activitys; final StoreInfo storeInfo; final ScrollController controller; + final String minToken; + final String tenant; final Function(String id) queryMiNiDetail; ShoppingCart shopCarGoods; @@ -29,6 +31,8 @@ class StoreOrderListPage extends StatefulWidget { this.storeInfo, this.shopCarGoods, this.controller, + this.minToken, + this.tenant, this.queryMiNiDetail, ); @@ -59,13 +63,11 @@ class _StoreOrderListPage extends State { ///小程序查询分组及商品列表 appletGoods() async { SharedPreferences value = await SharedPreferences.getInstance(); - String minToken = value.getString("minToken"); - String tenant = value.getString("tenant"); minService = MinApiService( Dio(), context: context, - token: minToken, - tenant: tenant, + token: widget.minToken, + tenant: widget.tenant, storeId: widget.arguments["id"], ); diff --git a/lib/web/web_page.dart b/lib/web/web_page.dart index e5949299..50808716 100644 --- a/lib/web/web_page.dart +++ b/lib/web/web_page.dart @@ -260,20 +260,25 @@ class _WebPage extends State with WidgetsBindingObserver { WebHeader(widget.arguments, activity, article, 16), /// 富文本的内容 - WebContent(activity, article, () { - setState(() {}); - }), + WebContent( + activity, + article, + () { + setState(() {}); + }, + ), /// 富文本的评论 CommentList( - commentKey, - widget.arguments, - activity, - article, - isKeyBoardShow, - _reply, - _delCommentTips, - 12.sp), + commentKey, + widget.arguments, + activity, + article, + isKeyBoardShow, + _reply, + _delCommentTips, + 12.sp, + ), ], ), ), diff --git a/lib/web/web_view/web_content.dart b/lib/web/web_view/web_content.dart index 2469f0a0..43195e03 100644 --- a/lib/web/web_view/web_content.dart +++ b/lib/web/web_view/web_content.dart @@ -44,7 +44,6 @@ class _WebContent extends State { ) }, customImageRenders: { - base64DataUriMatcher(): base64ImageRender(), assetUriMatcher(): assetImageRender(), networkSourceMatcher(extension: "svg"): svgNetworkImageRender(), @@ -54,57 +53,58 @@ class _WebContent extends State { }, ), }, - customRender: { - "video": - (context, parsedChild, attributes, element) { - var src = attributes['src']; - return videoWidget( - double.tryParse(attributes['width'] ?? ""), - double.tryParse( - element.attributes['height'] ?? ""), - (src != null && - src != "" && - src.endsWith(".mp4")) - ? src - : element - .children.first.attributes["src"], - element.attributes["sandbox"]); - }, - "iframe": - (context, parsedChild, attributes, element) { - var src = attributes['src']; - return videoWidget( - double.tryParse(attributes['width'] ?? ""), - double.tryParse( - element.attributes['height'] ?? ""), - (src != null && - src != "" && - src.endsWith(".mp4")) - ? src - : element - .children.first.attributes["src"], - element.attributes["sandbox"]); - }, - "audio": - (context, parsedChild, attributes, element) { - final sources = [ - if (element.attributes['src'] != null) - element.attributes['src'], - ]; - if (sources == null || - sources.isEmpty || - sources.first == null) { - return EmptyContentElement(); - } - return audioWidget( - attributes['controls'] != null, - attributes['loop'] != null, - attributes['autoplay'] != null, - sources, - context.style.width ?? 300.w, - ); - }, - }, + // customRender: { + // "video": + // (context, parsedChild) { + // var src = attributes['src']; + // parsedChild.toString() + // return videoWidget( + // double.tryParse(attributes['width'] ?? ""), + // double.tryParse( + // element.attributes['height'] ?? ""), + // (src != null && + // src != "" && + // src.endsWith(".mp4")) + // ? src + // : element + // .children.first.attributes["src"], + // element.attributes["sandbox"]); + // }, + // "iframe": + // (context, parsedChild) { + // var src = attributes['src']; + // return videoWidget( + // double.tryParse(attributes['width'] ?? ""), + // double.tryParse( + // element.attributes['height'] ?? ""), + // (src != null && + // src != "" && + // src.endsWith(".mp4")) + // ? src + // : element + // .children.first.attributes["src"], + // element.attributes["sandbox"]); + // }, + // "audio": + // (context, parsedChild) { + // final sources = [ + // if (element.attributes['src'] != null) + // element.attributes['src'], + // ]; + // if (sources == null || + // sources.isEmpty || + // sources.first == null) { + // return EmptyContentElement(); + // } + // return audioWidget( + // attributes['controls'] != null, + // attributes['loop'] != null, + // attributes['autoplay'] != null, + // sources, + // context.style.width ?? 300.w, + // ); + // }, + // }, ); } diff --git a/pubspec.lock b/pubspec.lock index 0f090c29..c39c4206 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -1,13 +1,6 @@ # Generated by pub # See https://dart.dev/tools/pub/glossary#lockfile packages: - _fe_analyzer_shared: - dependency: transitive - description: - name: _fe_analyzer_shared - url: "https://pub.flutter-io.cn" - source: hosted - version: "14.0.0" ai_decimal_accuracy: dependency: "direct main" description: @@ -15,13 +8,6 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "1.1.0" - analyzer: - dependency: transitive - description: - name: analyzer - url: "https://pub.flutter-io.cn" - source: hosted - version: "0.41.2" android_intent_plus: dependency: "direct main" description: @@ -29,13 +15,6 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "1.0.2" - args: - dependency: transitive - description: - name: args - url: "https://pub.flutter-io.cn" - source: hosted - version: "2.3.0" async: dependency: transitive description: @@ -71,62 +50,6 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "0.1.6" - build: - dependency: transitive - description: - name: build - url: "https://pub.flutter-io.cn" - source: hosted - version: "1.6.2" - build_config: - dependency: transitive - description: - name: build_config - url: "https://pub.flutter-io.cn" - source: hosted - version: "0.4.6" - build_daemon: - dependency: transitive - description: - name: build_daemon - url: "https://pub.flutter-io.cn" - source: hosted - version: "2.1.10" - build_resolvers: - dependency: transitive - description: - name: build_resolvers - url: "https://pub.flutter-io.cn" - source: hosted - version: "1.5.3" - build_runner: - dependency: "direct dev" - description: - name: build_runner - url: "https://pub.flutter-io.cn" - source: hosted - version: "1.11.5" - build_runner_core: - dependency: transitive - description: - name: build_runner_core - url: "https://pub.flutter-io.cn" - source: hosted - version: "6.1.10" - built_collection: - dependency: transitive - description: - name: built_collection - url: "https://pub.flutter-io.cn" - source: hosted - version: "4.3.2" - built_value: - dependency: transitive - description: - name: built_value - url: "https://pub.flutter-io.cn" - source: hosted - version: "7.1.0" cached_network_image: dependency: "direct main" description: @@ -148,34 +71,20 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "1.2.0" - checked_yaml: - dependency: transitive - description: - name: checked_yaml - url: "https://pub.flutter-io.cn" - source: hosted - version: "1.0.4" chewie: dependency: transitive description: name: chewie url: "https://pub.flutter-io.cn" source: hosted - version: "0.12.2" + version: "1.2.2" chewie_audio: dependency: "direct main" description: name: chewie_audio url: "https://pub.flutter-io.cn" source: hosted - version: "1.1.2" - cli_util: - dependency: transitive - description: - name: cli_util - url: "https://pub.flutter-io.cn" - source: hosted - version: "0.3.5" + version: "1.2.0" clock: dependency: transitive description: @@ -183,13 +92,6 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "1.1.0" - code_builder: - dependency: transitive - description: - name: code_builder - url: "https://pub.flutter-io.cn" - source: hosted - version: "3.7.0" collection: dependency: transitive description: @@ -211,20 +113,13 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "2.1.5" - css_colors: - dependency: transitive - description: - name: css_colors - url: "https://pub.flutter-io.cn" - source: hosted - version: "1.1.1" csslib: dependency: transitive description: name: csslib url: "https://pub.flutter-io.cn" source: hosted - version: "0.16.2" + version: "0.17.1" cupertino_icons: dependency: "direct main" description: @@ -232,13 +127,6 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "1.0.3" - dart_style: - dependency: transitive - description: - name: dart_style - url: "https://pub.flutter-io.cn" - source: hosted - version: "1.3.12" dio: dependency: "direct main" description: @@ -274,13 +162,6 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "6.1.2" - fixnum: - dependency: transitive - description: - name: fixnum - url: "https://pub.flutter-io.cn" - source: hosted - version: "0.10.11" flare_flutter: dependency: "direct main" description: @@ -348,19 +229,26 @@ packages: name: flutter_html url: "https://pub.flutter-io.cn" source: hosted - version: "1.3.0" + version: "2.1.5" flutter_layout_grid: dependency: transitive description: name: flutter_layout_grid url: "https://pub.flutter-io.cn" source: hosted - version: "0.10.5" + version: "1.0.3" flutter_localizations: dependency: "direct main" description: flutter source: sdk version: "0.0.0" + flutter_math_fork: + dependency: transitive + description: + name: flutter_math_fork + url: "https://pub.flutter-io.cn" + source: hosted + version: "0.3.3+1" flutter_page_indicator: dependency: transitive description: @@ -416,7 +304,7 @@ packages: name: flutter_svg url: "https://pub.flutter-io.cn" source: hosted - version: "0.20.0-nullsafety.3" + version: "0.22.0" flutter_swiper: dependency: "direct main" description: @@ -448,13 +336,6 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "9.1.0" - glob: - dependency: transitive - description: - name: glob - url: "https://pub.flutter-io.cn" - source: hosted - version: "2.0.1" graphs: dependency: transitive description: @@ -468,7 +349,7 @@ packages: name: html url: "https://pub.flutter-io.cn" source: hosted - version: "0.14.0+4" + version: "0.15.0" http: dependency: transitive description: @@ -476,13 +357,6 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "0.12.2" - http_multi_server: - dependency: transitive - description: - name: http_multi_server - url: "https://pub.flutter-io.cn" - source: hosted - version: "2.2.0" http_parser: dependency: transitive description: @@ -497,13 +371,6 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "2.0.0" - import_js_library: - dependency: transitive - description: - name: import_js_library - url: "https://pub.flutter-io.cn" - source: hosted - version: "1.0.2" intl: dependency: "direct main" description: @@ -511,13 +378,6 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "0.17.0" - io: - dependency: transitive - description: - name: io - url: "https://pub.flutter-io.cn" - source: hosted - version: "0.3.5" js: dependency: transitive description: @@ -532,13 +392,6 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "3.1.1" - json_serializable: - dependency: "direct dev" - description: - name: json_serializable - url: "https://pub.flutter-io.cn" - source: hosted - version: "3.5.1" keframe: dependency: "direct main" description: @@ -560,13 +413,6 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "1.1.0" - logging: - dependency: transitive - description: - name: logging - url: "https://pub.flutter-io.cn" - source: hosted - version: "1.0.2" matcher: dependency: transitive description: @@ -581,20 +427,20 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "1.3.0" - mime: + nested: dependency: transitive description: - name: mime + name: nested url: "https://pub.flutter-io.cn" source: hosted - version: "1.0.1" - package_config: + version: "1.0.0" + numerus: dependency: transitive description: - name: package_config + name: numerus url: "https://pub.flutter-io.cn" source: hosted - version: "1.9.3" + version: "1.1.1" package_info: dependency: "direct main" description: @@ -700,13 +546,6 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "1.0.3" - pool: - dependency: transitive - description: - name: pool - url: "https://pub.flutter-io.cn" - source: hosted - version: "1.5.0" process: dependency: transitive description: @@ -714,20 +553,13 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "4.2.3" - pub_semver: + provider: dependency: transitive description: - name: pub_semver + name: provider url: "https://pub.flutter-io.cn" source: hosted - version: "2.1.0" - pubspec_parse: - dependency: transitive - description: - name: pubspec_parse - url: "https://pub.flutter-io.cn" - source: hosted - version: "0.1.8" + version: "5.0.0" pull_to_refresh: dependency: "direct main" description: @@ -755,7 +587,7 @@ packages: name: quiver url: "https://pub.flutter-io.cn" source: hosted - version: "2.1.5" + version: "3.0.1+1" retrofit: dependency: "direct main" description: @@ -763,13 +595,6 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "1.3.4+1" - retrofit_generator: - dependency: "direct dev" - description: - name: retrofit_generator - url: "https://pub.flutter-io.cn" - source: hosted - version: "1.4.1+3" rive: dependency: "direct main" description: @@ -833,32 +658,11 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "1.3.0" - shelf: - dependency: transitive - description: - name: shelf - url: "https://pub.flutter-io.cn" - source: hosted - version: "0.7.9" - shelf_web_socket: - dependency: transitive - description: - name: shelf_web_socket - url: "https://pub.flutter-io.cn" - source: hosted - version: "0.2.4+1" sky_engine: dependency: transitive description: flutter source: sdk version: "0.0.99" - source_gen: - dependency: transitive - description: - name: source_gen - url: "https://pub.flutter-io.cn" - source: hosted - version: "0.9.10+3" source_span: dependency: transitive description: @@ -894,13 +698,6 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "2.1.0" - stream_transform: - dependency: transitive - description: - name: stream_transform - url: "https://pub.flutter-io.cn" - source: hosted - version: "2.0.0" string_scanner: dependency: transitive description: @@ -929,13 +726,6 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "0.3.0" - timing: - dependency: transitive - description: - name: timing - url: "https://pub.flutter-io.cn" - source: hosted - version: "0.1.1+3" tpns_flutter_plugin: dependency: "direct main" description: @@ -958,7 +748,7 @@ packages: name: tuple url: "https://pub.flutter-io.cn" source: hosted - version: "1.0.3" + version: "2.0.0" typed_data: dependency: transitive description: @@ -1028,63 +818,63 @@ packages: name: video_player url: "https://pub.flutter-io.cn" source: hosted - version: "1.0.1" + version: "2.2.3" video_player_platform_interface: dependency: transitive description: name: video_player_platform_interface url: "https://pub.flutter-io.cn" source: hosted - version: "2.2.0" + version: "4.2.0" video_player_web: dependency: transitive description: name: video_player_web url: "https://pub.flutter-io.cn" source: hosted - version: "0.1.4+1" + version: "2.0.4" wakelock: dependency: transitive description: name: wakelock url: "https://pub.flutter-io.cn" source: hosted - version: "0.2.1+1" - wakelock_platform_interface: + version: "0.5.6" + wakelock_macos: dependency: transitive description: - name: wakelock_platform_interface + name: wakelock_macos url: "https://pub.flutter-io.cn" source: hosted - version: "0.1.0+1" - wakelock_web: + version: "0.4.0" + wakelock_platform_interface: dependency: transitive description: - name: wakelock_web + name: wakelock_platform_interface url: "https://pub.flutter-io.cn" source: hosted - version: "0.1.0+3" - watcher: + version: "0.3.0" + wakelock_web: dependency: transitive description: - name: watcher + name: wakelock_web url: "https://pub.flutter-io.cn" source: hosted - version: "1.0.0" - web_socket_channel: + version: "0.4.0" + wakelock_windows: dependency: transitive description: - name: web_socket_channel + name: wakelock_windows url: "https://pub.flutter-io.cn" source: hosted - version: "1.2.0" + version: "0.2.0" webview_flutter: - dependency: "direct main" + dependency: transitive description: name: webview_flutter url: "https://pub.flutter-io.cn" source: hosted - version: "1.0.7" + version: "2.0.13" win32: dependency: transitive description: @@ -1106,13 +896,6 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "5.1.2" - yaml: - dependency: transitive - description: - name: yaml - url: "https://pub.flutter-io.cn" - source: hosted - version: "3.1.0" sdks: dart: ">=2.13.0 <3.0.0" - flutter: ">=2.0.0" + flutter: ">=2.2.0" diff --git a/pubspec.yaml b/pubspec.yaml index f6edf240..9f54aad3 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -63,12 +63,11 @@ dependencies: path_provider: ^1.2.0 cached_network_image: ^2.0.0 - flutter_html: ^1.3.0 #2.1.0 - webview_flutter: ^1.0.7 + flutter_html: ^2.1.5 #2.1.0 chewie_audio: ^1.1.2 photo_view: ^0.11.1 - video_player: ^1.0.1 + video_player: ^2.2.3 package_info: ^2.0.2 @@ -80,7 +79,7 @@ dependencies: rive: ^0.6.8 flare_flutter: ^3.0.2 - flutter_svg: ^0.20.0-nullsafety.3 + flutter_svg: ^0.22.0 font_awesome_flutter: ^9.1.0 ai_decimal_accuracy: ^1.1.0 @@ -88,9 +87,9 @@ dependencies: dev_dependencies: flutter_test: sdk: flutter - retrofit_generator: ^1.4.1+3 - build_runner: ^1.11.5 - json_serializable: ^3.5.1 +# retrofit_generator: ^1.4.1+3 +# build_runner: ^1.11.5 +# json_serializable: ^3.5.1 flutter: From d9965800855fd44c16281647864579740e776943 Mon Sep 17 00:00:00 2001 From: fmk Date: Mon, 25 Oct 2021 18:52:55 +0800 Subject: [PATCH 14/20] safety --- lib/community/community_details.dart | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/community/community_details.dart b/lib/community/community_details.dart index 45830a86..f39399e9 100644 --- a/lib/community/community_details.dart +++ b/lib/community/community_details.dart @@ -17,6 +17,7 @@ import 'package:huixiang/view_widget/comment_menu.dart'; import 'package:huixiang/view_widget/login_tips_dialog.dart'; import 'package:huixiang/view_widget/my_appbar.dart'; import 'package:huixiang/view_widget/tips_dialog.dart'; +import 'package:huixiang/web/web_view/comment_list.dart'; import 'package:huixiang/web/web_view/input_comment.dart'; import 'package:shared_preferences/shared_preferences.dart'; @@ -111,6 +112,7 @@ class _CommunityDetails extends State children: [ Expanded( child: SingleChildScrollView( + physics: BouncingScrollPhysics(), child: Column( children: [ CommunityDynamic( @@ -129,6 +131,16 @@ class _CommunityDetails extends State if (mounted) setState(() {}); }, ), + // CommentList( + // commentKey, + // widget.arguments, + // activity, + // article, + // isKeyBoardShow, + // _reply, + // _delCommentTips, + // 12.sp, + // ) Container( padding: EdgeInsets.all(16), color: Colors.white, From aea6451cec09afe6b4a0f3aceafe981e7d928af2 Mon Sep 17 00:00:00 2001 From: fmk Date: Mon, 25 Oct 2021 19:02:14 +0800 Subject: [PATCH 15/20] safety --- lib/community/community_details.dart | 165 +++++++-------------------- lib/web/web_page.dart | 5 +- lib/web/web_view/comment_list.dart | 15 ++- 3 files changed, 49 insertions(+), 136 deletions(-) diff --git a/lib/community/community_details.dart b/lib/community/community_details.dart index f39399e9..14dfe556 100644 --- a/lib/community/community_details.dart +++ b/lib/community/community_details.dart @@ -32,8 +32,7 @@ class CommunityDetails extends StatefulWidget { } } -class _CommunityDetails extends State - with WidgetsBindingObserver { +class _CommunityDetails extends State with WidgetsBindingObserver { double height = 0; double commentHeight = 60.h; ComunityComment comunity; @@ -54,7 +53,10 @@ class _CommunityDetails extends State void didChangeMetrics() { WidgetsBinding.instance.addPostFrameCallback((_) { if (!mounted) return; - if (MediaQuery.of(context).viewInsets.bottom == 0) { + if (MediaQuery + .of(context) + .viewInsets + .bottom == 0) { if (isKeyBoardShow) { FocusScope.of(context).requestFocus(FocusNode()); if (mounted) @@ -91,8 +93,10 @@ class _CommunityDetails extends State context: context, token: value.getString("token"), ); - BaseData
baseData = - await apiService.informationInfo(comunity.id).catchError((onError) {}); + BaseData
baseData = await apiService.informationInfo(comunity.id) + .catchError((onError) { + debugPrint(onError); + }); if (baseData != null && baseData.isSuccess) {} } @@ -125,75 +129,24 @@ class _CommunityDetails extends State isDetails: true, heightFun: (height) { this.height = height + - MediaQuery.of(context).padding.top + + MediaQuery + .of(context) + .padding + .top + kToolbarHeight + 24; if (mounted) setState(() {}); }, ), - // CommentList( - // commentKey, - // widget.arguments, - // activity, - // article, - // isKeyBoardShow, - // _reply, - // _delCommentTips, - // 12.sp, - // ) - Container( - padding: EdgeInsets.all(16), - color: Colors.white, - child: Row( - children: [ - Text( - S.of(context).pinglun_(commentTotal.toString()), - style: TextStyle( - fontSize: 14, - fontWeight: FontWeight.bold, - color: Color(0xff1A1A1A), - ), - ), - SizedBox( - width: 16.w, - ), - Text( - S.of(context).xihuan_( - "${comunity?.likes ?? comunity?.likes ?? "0"}"), - style: TextStyle( - fontSize: 14, - fontWeight: FontWeight.bold, - color: Color(0xff1A1A1A), - ), - ), - ], - ), + CommentList( + commentKey, + "${comunity?.likes ?? comunity?.likes ?? "0"}", + comunity.id, + isKeyBoardShow, + _reply, + _delCommentTips, + 12.sp, ), - if (memberList != null && memberList.length > 0) - ListView.builder( - shrinkWrap: true, - physics: NeverScrollableScrollPhysics(), - itemCount: memberList != null ? memberList.length : 0, - scrollDirection: Axis.vertical, - itemBuilder: (context, position) { - return Material( - color: Colors.white, - child: InkWell( - onTap: () { - showPressMenu( - memberList[position].createUser, - memberList[position], - ); - }, - child: CommunityComment( - memberList[position], - _queryCommentLike, - (memberList.length - 1 == position) ? 1 : 0, - ), - ), - ); - }, - ), if (memberList == null || memberList.length == 0) Container( width: double.infinity, @@ -201,7 +154,9 @@ class _CommunityDetails extends State margin: EdgeInsets.only(top: 40), padding: EdgeInsets.all(22.h), child: Text( - S.of(context).zanwupinglun, + S + .of(context) + .zanwupinglun, style: TextStyle( fontSize: 12, fontWeight: FontWeight.bold, @@ -237,7 +192,7 @@ class _CommunityDetails extends State _queryInformationLikes() async { BaseData baseData = await apiService.informationLikes(comunity.id); if (baseData != null && baseData.isSuccess) { - // commentKey.currentState.setState(() {}); + commentKey.currentState.setState(() {}); setState(() { if (comunity.selfLike ?? false) comunity.likes -= 1; @@ -259,7 +214,7 @@ class _CommunityDetails extends State "relationalType": 1 }).catchError((error) {}); if (baseData != null && baseData.isSuccess) { - // commentKey.currentState.initState(); + commentKey.currentState.initState(); commentTextController.text = ""; FocusScope.of(context).unfocus(); _queryMemberCommentList(); @@ -274,7 +229,10 @@ class _CommunityDetails extends State scrollController.animateTo( first.dy + scrollController.offset - - (kToolbarHeight + MediaQuery.of(context).padding.top), + (kToolbarHeight + MediaQuery + .of(context) + .padding + .top), duration: Duration(milliseconds: 300), curve: Curves.easeIn, ); @@ -284,40 +242,21 @@ class _CommunityDetails extends State final TextEditingController commentTextController = TextEditingController(); contentHeight() { - double contentHeight = MediaQuery.of(context).size.height - + double contentHeight = MediaQuery + .of(context) + .size + .height - kToolbarHeight - - MediaQuery.of(context).padding.top - + MediaQuery + .of(context) + .padding + .top - 160.h; if ((contentHeight - 60.h) > (128.h * memberList.length)) { commentHeight = contentHeight - (128.h * memberList.length); } } - showPressMenu(String userId, memberComment) { - if (isKeyBoardShow) { - FocusScope.of(context).requestFocus(FocusNode()); - return; - } - SharedPreferences.getInstance().then((value) { - SmartDialog.show( - widget: CommentMenu( - (type) { - SmartDialog.dismiss(); - if (type == "huifu") { - _reply(memberComment); - } else if (type == "shanchu") { - _delCommentTips(); - } - }, - isSelf: userId == value.getString("userId"), - ), - alignmentTemp: Alignment.bottomCenter, - isUseAnimationTemp: true, - animationDurationTemp: Duration(milliseconds: 300), - ); - }); - } - ///删除评论的提示 _delCommentTips() { SmartDialog.show(widget: Tips(() { @@ -329,7 +268,7 @@ class _CommunityDetails extends State delComment() async { BaseData baseData = await apiService.delComment(""); if (baseData != null && baseData.isSuccess) { - // commentKey.currentState.initState(); + commentKey.currentState.initState(); } } @@ -340,30 +279,6 @@ class _CommunityDetails extends State hintText = S.of(context).huifu_("${memberComment.username}"); } - ///评论点赞 - _queryCommentLike(String id) async { - SharedPreferences sharedPreferences = await SharedPreferences.getInstance(); - String token = sharedPreferences.getString("token"); - if (token == null || token == "") { - LoginTipsDialog().show(context); - return; - } - BaseData baseData = await apiService.commentLike(id).catchError((error) {}); - if (baseData != null && baseData.isSuccess) { - memberList.forEach((element) { - if (element.id == id) { - if (element.liked) { - element.likes -= 1; - element.liked = false; - } else { - element.likes += 1; - element.liked = true; - } - } - }); - } - } - ///评论列表 _queryMemberCommentList() async { SharedPreferences sharedPreferences = await SharedPreferences.getInstance(); @@ -375,7 +290,7 @@ class _CommunityDetails extends State showLoading: false, ); BaseData> baseData = - await apiService.memberCommentList({ + await apiService.memberCommentList({ "pageNum": 1, "pageSize": 100, "relationalId": comunity.id, diff --git a/lib/web/web_page.dart b/lib/web/web_page.dart index 50808716..c5fc53be 100644 --- a/lib/web/web_page.dart +++ b/lib/web/web_page.dart @@ -271,9 +271,8 @@ class _WebPage extends State with WidgetsBindingObserver { /// 富文本的评论 CommentList( commentKey, - widget.arguments, - activity, - article, + article?.likes ?? activity?.likes ?? "0", + article?.id ?? activity?.id, isKeyBoardShow, _reply, _delCommentTips, diff --git a/lib/web/web_view/comment_list.dart b/lib/web/web_view/comment_list.dart index 69a27904..db3c4c80 100644 --- a/lib/web/web_view/comment_list.dart +++ b/lib/web/web_view/comment_list.dart @@ -16,15 +16,15 @@ import 'package:like_button/like_button.dart'; import 'package:shared_preferences/shared_preferences.dart'; class CommentList extends StatefulWidget { - final Map arguments; - final Activity activity; - final Article article; + final bool isKeyBoardShow; final Function reply; final Function delCommentTips; final double fontSize; + final String relationalId; + final String like; - CommentList(Key key, this.arguments, this.activity, this.article, + CommentList(Key key, this.like, this.relationalId, this.isKeyBoardShow, this.reply, this.delCommentTips, this.fontSize) : super(key: key); @@ -57,6 +57,7 @@ class CommentListState extends State { } else { element.likes += 1; element.liked = true; + } } }); @@ -105,8 +106,7 @@ class CommentListState extends State { width: 16.w, ), Text( - S.of(context).xihuan_( - "${widget.article?.likes ?? widget.activity?.likes ?? "0"}"), + S.of(context).xihuan_("${widget.like ?? "0"}"), style: TextStyle( fontSize: widget.fontSize + 4, fontWeight: FontWeight.bold, @@ -209,8 +209,7 @@ class CommentListState extends State { await apiService.memberCommentList({ "pageNum": 1, "pageSize": 100, - "relationalId": - widget.arguments["activityId"] ?? widget.arguments["articleId"], + "relationalId": widget.relationalId, "relationalType": 1, }).catchError((error) {}); if (baseData != null && baseData.isSuccess) { From 27e99c3be018f23204400bb9f596aa033f6567a1 Mon Sep 17 00:00:00 2001 From: fmk Date: Mon, 25 Oct 2021 19:07:53 +0800 Subject: [PATCH 16/20] safety --- lib/view_widget/custom_image.dart | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/view_widget/custom_image.dart b/lib/view_widget/custom_image.dart index 6fdcff22..efbd7416 100644 --- a/lib/view_widget/custom_image.dart +++ b/lib/view_widget/custom_image.dart @@ -37,6 +37,9 @@ class MImage extends StatelessWidget { "x${constraints.constrainHeight() * scaleIndex}/format/webp/quality/100"; } + print("constrainWidth: ${constraints.constrainWidth()}"); + print("constrainHeight: ${constraints.constrainHeight()}"); + if (imageUrl == null || imageUrl == "") { return Image.asset( "assets/image/default_2_1.png", From 45b1b6ea7422813aaec39d40b3971b924fc10494 Mon Sep 17 00:00:00 2001 From: fmk Date: Tue, 26 Oct 2021 11:57:23 +0800 Subject: [PATCH 17/20] safety --- lib/community/community_child_page.dart | 1 + lib/community/community_details.dart | 2 +- .../community_view/community_dynamic.dart | 131 ++++++++++++------ lib/community/release_dynamic.dart | 29 +++- lib/retrofit/data/comunity_comment.dart | 10 +- lib/view_widget/custom_image.dart | 90 +++++++----- pubspec.lock | 13 +- pubspec.yaml | 3 + 8 files changed, 190 insertions(+), 89 deletions(-) diff --git a/lib/community/community_child_page.dart b/lib/community/community_child_page.dart index 6b0a075e..92e89009 100644 --- a/lib/community/community_child_page.dart +++ b/lib/community/community_child_page.dart @@ -103,6 +103,7 @@ class _CommunityChildPage extends State { child: CommunityDynamic( comments[position], 0, + isList: true, exitFull: () { setState(() {}); }, diff --git a/lib/community/community_details.dart b/lib/community/community_details.dart index 14dfe556..90f541c6 100644 --- a/lib/community/community_details.dart +++ b/lib/community/community_details.dart @@ -95,7 +95,7 @@ class _CommunityDetails extends State with WidgetsBindingObser ); BaseData
baseData = await apiService.informationInfo(comunity.id) .catchError((onError) { - debugPrint(onError); + debugPrint(onError.toString()); }); if (baseData != null && baseData.isSuccess) {} } diff --git a/lib/community/community_view/community_dynamic.dart b/lib/community/community_view/community_dynamic.dart index 7b57be89..eb6276fa 100644 --- a/lib/community/community_view/community_dynamic.dart +++ b/lib/community/community_view/community_dynamic.dart @@ -1,3 +1,4 @@ +import 'dart:io'; import 'dart:ui'; import 'package:chewie/chewie.dart'; @@ -14,8 +15,10 @@ import 'package:huixiang/view_widget/custom_image.dart'; import 'package:huixiang/view_widget/icon_text.dart'; import 'package:huixiang/view_widget/round_button.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:path_provider/path_provider.dart'; import 'package:shared_preferences/shared_preferences.dart'; import 'package:video_player/video_player.dart'; +import 'package:thumbnails/thumbnails.dart'; class CommunityDynamic extends StatefulWidget { final int itemCount; @@ -24,7 +27,7 @@ class CommunityDynamic extends StatefulWidget { final int commentType; final Function removalDynamic; final Function exitFull; - + final bool isList; final ComunityComment comment; CommunityDynamic( @@ -36,6 +39,7 @@ class CommunityDynamic extends StatefulWidget { this.isDetails = false, this.removalDynamic, this.exitFull, + this.isList = false, }) : super(key: key); @override @@ -65,33 +69,44 @@ class _CommunityDynamic extends State { ), }, ); + initVideo(); + } + + String filePath; + initVideo() async { if (widget.comment.subjectInfo.type == "video" && widget.comment.subjectInfo.video.isNotEmpty) { - videoPlayerController = VideoPlayerController.network( - widget.comment.subjectInfo.video, - )..initialize().then((value) { - chewieAudioController = ChewieController( - videoPlayerController: videoPlayerController, - aspectRatio: videoPlayerController.value.aspectRatio, - //宽高比 - autoPlay: false, - //自动播放 - looping: false, - //循环播放 - allowFullScreen: true, - // 拖动条样式颜色 - materialProgressColors: chewie.ChewieProgressColors( - playedColor: Colors.white, - handleColor: Colors.white, - backgroundColor: Colors.grey, - bufferedColor: Colors.transparent, - ), - autoInitialize: true, - ); - chewieAudioController.addListener(_fullScreenListener); - if (mounted) setState(() {}); - }); + if (widget.isList) { + videoPlayerController = VideoPlayerController.network( + widget.comment.subjectInfo.video, + )..initialize().then((value) {}); + } else { + videoPlayerController = VideoPlayerController.network( + widget.comment.subjectInfo.video, + )..initialize().then((value) { + chewieAudioController = ChewieController( + videoPlayerController: videoPlayerController, + aspectRatio: videoPlayerController.value.aspectRatio, + //宽高比 + autoPlay: false, + //自动播放 + looping: false, + //循环播放 + allowFullScreen: true, + // 拖动条样式颜色 + materialProgressColors: chewie.ChewieProgressColors( + playedColor: Colors.white, + handleColor: Colors.white, + backgroundColor: Colors.grey, + bufferedColor: Colors.transparent, + ), + autoInitialize: true, + ); + chewieAudioController.addListener(_fullScreenListener); + if (mounted) setState(() {}); + }); + } } } @@ -292,10 +307,10 @@ class _CommunityDynamic extends State { if (subjectInfo == null) { return Container(); } - Widget widget = Container(); + Widget itemWidget = Container(); if (subjectInfo.type == "image" && subjectInfo.images.length > 0) { if (subjectInfo.images.length == 1) { - widget = Container( + itemWidget = Container( child: MImage( subjectInfo.images[0], fit: BoxFit.cover, @@ -306,7 +321,7 @@ class _CommunityDynamic extends State { ), ); } else { - widget = GridView.builder( + itemWidget = GridView.builder( gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( crossAxisCount: (subjectInfo.images.length == 2 || subjectInfo.images.length == 4) @@ -334,15 +349,15 @@ class _CommunityDynamic extends State { ); } } else if (subjectInfo.type == "video" && subjectInfo.video.isNotEmpty) { - widget = videoWidget( - MediaQuery.of(context).size.width - 32, - videoPlayerController != null - ? (MediaQuery.of(context).size.width - 32) / - videoPlayerController.value.aspectRatio - : MediaQuery.of(context).size.width / 2, - subjectInfo.video); + itemWidget = videoWidget( + MediaQuery.of(context).size.width - 32, + videoPlayerController != null + ? (MediaQuery.of(context).size.width - 32) / + videoPlayerController.value.aspectRatio + : MediaQuery.of(context).size.width / 2, + !widget.isList ? subjectInfo.video : widget.comment.coverImg, + ); } - return Column( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.start, @@ -351,7 +366,7 @@ class _CommunityDynamic extends State { SizedBox( height: 16.h, ), - widget, + itemWidget, ], ); } @@ -378,17 +393,41 @@ class _CommunityDynamic extends State { data: MediaQuery.of(context).copyWith( textScaleFactor: 0.9, ), - child: chewieAudioController != null - ? Container( - width: width, - height: height, - child: chewies = Chewie( - controller: chewieAudioController, - ), - ) + child: !widget.isList + ? (chewieAudioController != null + ? Container( + width: width, + height: height, + child: chewies = Chewie( + controller: chewieAudioController, + ), + ) + : Container( + width: width, + height: height, + )) : Container( width: width, - height: height, + height: width / 3 * 2, + child: Stack( + children: [ + MImage( + src, + width: width, + height: width / 3 * 2, + fit: BoxFit.cover, + errorSrc: "assets/image/default_2_1.png", + fadeSrc: "assets/image/default_2_1.png", + ), + Center( + child: Icon( + Icons.play_circle_outline, + color: Colors.white, + size: 60, + ), + ), + ], + ), ), ); } diff --git a/lib/community/release_dynamic.dart b/lib/community/release_dynamic.dart index 144a6ac6..4156d9ae 100644 --- a/lib/community/release_dynamic.dart +++ b/lib/community/release_dynamic.dart @@ -14,6 +14,7 @@ import 'package:huixiang/view_widget/my_appbar.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:image_pickers/image_pickers.dart'; import 'package:shared_preferences/shared_preferences.dart'; +import 'package:thumbnails/thumbnails.dart'; class ReleaseDynamic extends StatefulWidget { @override @@ -136,11 +137,13 @@ class _ReleaseDynamic extends State { List remoteImageUrls = []; String remoteVideoUrl = ""; + String remoteVideoCoverImg = ""; if (mediaPaths.length > 0) { if (dynamicType == 1) { remoteImageUrls = mediaPaths.map((e) => e.remotePath).toList(); } else if (dynamicType == 2) { remoteVideoUrl = mediaPaths[0].remotePath; + remoteVideoCoverImg = mediaPaths[0].thumbPath; } } @@ -149,6 +152,7 @@ class _ReleaseDynamic extends State { "subject": dynamicText, "subjectType": subjectType, "video": remoteVideoUrl, + "coverImg": remoteVideoCoverImg, }).catchError((onError) { EasyLoading.dismiss(); }); @@ -172,8 +176,31 @@ class _ReleaseDynamic extends State { element.path != null && element.path != "" && await File(element.path).exists())) { + File file = File(element.path); + if (dynamicType == 2) { + String thumbnail; + if (element.thumbPath != null && element.thumbPath != "" && await File(element.thumbPath).exists()) { + thumbnail = element.thumbPath; + } else { + thumbnail = await Thumbnails.getThumbnail( + videoFile: file.path, + imageType: ThumbFormat.WEBP, + quality: 10, + ); + } + if (thumbnail != null && thumbnail != "" && await File(thumbnail).exists()) { + BaseData baseData = await apiService.upload( + File(thumbnail), + 123123123, + ); + if (baseData != null && baseData.isSuccess) { + UploadResult uploadResult = baseData.data; + mediaPaths[mediaPaths.indexOf(element)].thumbPath = uploadResult.url; + } + } + } BaseData baseData = await apiService.upload( - File(element.path), + file, 123123123, ); if (baseData != null && baseData.isSuccess) { diff --git a/lib/retrofit/data/comunity_comment.dart b/lib/retrofit/data/comunity_comment.dart index a9fe7bc2..3cb78955 100644 --- a/lib/retrofit/data/comunity_comment.dart +++ b/lib/retrofit/data/comunity_comment.dart @@ -20,7 +20,8 @@ class ComunityComment { int comments, bool selfLike, bool selfFollow, - String createTime,}){ + String createTime, + String coverImg,}){ this.id = id; this.subject = subject; this.subjectInfo = subjectInfo; @@ -31,6 +32,7 @@ class ComunityComment { this.selfLike = selfLike; this.selfFollow = selfFollow; this.createTime = createTime; + this.coverImg = coverImg; } ComunityComment.fromJson(dynamic json) { @@ -44,6 +46,7 @@ class ComunityComment { this.selfLike = json['selfLike']; this.selfFollow = json['selfFollow']; this.createTime = json['createTime']; + this.coverImg = json['coverImg']; } String id; String subject; @@ -55,6 +58,7 @@ class ComunityComment { bool selfLike; bool selfFollow; String createTime; + String coverImg; Map toJson() { final map = {}; @@ -72,6 +76,7 @@ class ComunityComment { map['selfLike'] = this.selfLike; map['selfFollow'] = this.selfFollow; map['createTime'] = this.createTime; + map['coverImg'] = this.coverImg; return map; } @@ -118,7 +123,8 @@ class SubjectInfo { SubjectInfo({ String type, List images, - String video,}){ + String video, + String coverImg,}){ this.type = type; this.images = images; this.video = video; diff --git a/lib/view_widget/custom_image.dart b/lib/view_widget/custom_image.dart index efbd7416..dbe05a58 100644 --- a/lib/view_widget/custom_image.dart +++ b/lib/view_widget/custom_image.dart @@ -1,3 +1,5 @@ +import 'dart:io'; + import 'package:cached_network_image/cached_network_image.dart'; import 'package:flutter_cache_manager/flutter_cache_manager.dart'; import 'package:flutter/material.dart'; @@ -29,49 +31,65 @@ class MImage extends StatelessWidget { @override Widget build(BuildContext context) { - Widget image = LayoutBuilder(builder: (context, constraints) { - String imageUrl = ""; - if (src != null && src != "") { - imageUrl = - "$src?imageMogr2/thumbnail/${constraints.constrainWidth() * scaleIndex}" - "x${constraints.constrainHeight() * scaleIndex}/format/webp/quality/100"; - } + Widget image = LayoutBuilder( + builder: (context, constraints) { + String imageUrl = ""; + if (src != null && src != "" && src.startsWith("http")) { + imageUrl = + "$src?imageMogr2/thumbnail/${constraints.constrainWidth() * scaleIndex}" + "x${constraints.constrainHeight() * scaleIndex}/format/webp/quality/100"; + } - print("constrainWidth: ${constraints.constrainWidth()}"); - print("constrainHeight: ${constraints.constrainHeight()}"); + // print("constrainWidth: ${constraints.constrainWidth()}"); + // print("constrainHeight: ${constraints.constrainHeight()}"); - if (imageUrl == null || imageUrl == "") { - return Image.asset( - "assets/image/default_2_1.png", - fit: fit, - ); - } - CachedNetworkImage cachedNetworkImage = CachedNetworkImage( - imageUrl: imageUrl, - cacheManager: DefaultCacheManager(), - fadeInDuration: Duration(milliseconds: 300), - fadeOutDuration: Duration(milliseconds: 300), - imageBuilder: (context, provide) { - return Image( - image: provide, - fit: fit, - ); - }, - errorWidget: (context, error, stackTrace) { + if (imageUrl == null || imageUrl == "") { return Image.asset( - errorSrc, + "assets/image/default_2_1.png", fit: fit, ); - }, - placeholder: (context, placeholder) { - return Image.asset( - fadeSrc, + } + Widget cachedNetworkImage; + if (src.startsWith("http")) { + cachedNetworkImage = CachedNetworkImage( + imageUrl: imageUrl, + cacheManager: DefaultCacheManager(), + fadeInDuration: Duration(milliseconds: 300), + fadeOutDuration: Duration(milliseconds: 300), + imageBuilder: (context, provide) { + return Image( + image: provide, + fit: fit, + ); + }, + errorWidget: (context, error, stackTrace) { + return Image.asset( + errorSrc, + fit: fit, + ); + }, + placeholder: (context, placeholder) { + return Image.asset( + fadeSrc, + fit: fit, + ); + }, + ); + } else if (src.startsWith("file")) { + cachedNetworkImage = Image.file( + File(src), fit: fit, + errorBuilder: (context, error, stackTrace) { + return Image.asset( + errorSrc, + fit: fit, + ); + }, ); - }, - ); - return cachedNetworkImage; - }); + } + return cachedNetworkImage; + }, + ); var clipRRect; if (isCircle) { diff --git a/pubspec.lock b/pubspec.lock index c39c4206..418f36f6 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -335,7 +335,7 @@ packages: name: font_awesome_flutter url: "https://pub.flutter-io.cn" source: hosted - version: "9.1.0" + version: "9.2.0" graphs: dependency: transitive description: @@ -370,7 +370,7 @@ packages: name: image_pickers url: "https://pub.flutter-io.cn" source: hosted - version: "2.0.0" + version: "2.0.0+1" intl: dependency: "direct main" description: @@ -726,6 +726,13 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "0.3.0" + thumbnails: + dependency: "direct main" + description: + name: thumbnails + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.0.1" tpns_flutter_plugin: dependency: "direct main" description: @@ -881,7 +888,7 @@ packages: name: win32 url: "https://pub.flutter-io.cn" source: hosted - version: "2.2.9" + version: "2.2.10" xdg_directories: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 9f54aad3..b315fcaa 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -68,6 +68,9 @@ dependencies: photo_view: ^0.11.1 video_player: ^2.2.3 + thumbnails: ^1.0.1 +# media_info: ^0.9.0 +# flutter_ffmpeg: ^0.4.2 package_info: ^2.0.2 From 5bc392b1c2fd01c804a7e4ff044b22f26fce8686 Mon Sep 17 00:00:00 2001 From: fmk Date: Tue, 26 Oct 2021 14:06:03 +0800 Subject: [PATCH 18/20] safety --- README.md | 7 ++++++- ios/Podfile.lock | 8 +++++++- .../community_view/community_dynamic.dart | 20 +++++++++++-------- lib/union/union_page.dart | 3 --- 4 files changed, 25 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 60789a18..72c0cabb 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ For help getting started with Flutter, view our samples, guidance on mobile development, and a full API reference. - +#1.0 登录页 发送验证码 @@ -64,3 +64,8 @@ samples, guidance on mobile development, and a full API reference. 订单详情 (订单生成时间) 取消订单 取件码 + +#说明: + huixiang_app/pubspec.yaml #依赖 + + diff --git a/ios/Podfile.lock b/ios/Podfile.lock index 022bd440..8e55d92b 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -103,6 +103,8 @@ PODS: - Flutter - FMDB (>= 2.7.5) - SSZipArchive (2.4.2) + - thumbnails (0.0.1): + - Flutter - TPNS-iOS (1.3.3.0) - tpns_flutter_plugin (1.1.2): - Flutter @@ -136,6 +138,7 @@ DEPENDENCIES: - sharesdk_plugin (from `.symlinks/plugins/sharesdk_plugin/ios`) - sqflite (from `.symlinks/plugins/sqflite/ios`) - SSZipArchive (~> 2.4.2) + - thumbnails (from `.symlinks/plugins/thumbnails/ios`) - tpns_flutter_plugin (from `.symlinks/plugins/tpns_flutter_plugin/ios`) - url_launcher (from `.symlinks/plugins/url_launcher/ios`) - video_player (from `.symlinks/plugins/video_player/ios`) @@ -188,6 +191,8 @@ EXTERNAL SOURCES: :path: ".symlinks/plugins/sharesdk_plugin/ios" sqflite: :path: ".symlinks/plugins/sqflite/ios" + thumbnails: + :path: ".symlinks/plugins/thumbnails/ios" tpns_flutter_plugin: :path: ".symlinks/plugins/tpns_flutter_plugin/ios" url_launcher: @@ -212,7 +217,7 @@ SPEC CHECKSUMS: flutter_scankit: 16936d86b3de3f83c122e763f4c24c5da214c78f fluwx: c192ef1ea3617badb813fa1a761ffc5c9c12208a FMDB: 2ce00b547f966261cd18927a3ddb07cb6f3db82a - image_pickers: 25c8916d358bc9d2707cb470ba3d57497f105773 + image_pickers: 5e6ec7083f9363d014c0fb061f1b9cd97bb5e451 mob_sharesdk: c771f001e00739d24301a9fa250247601efe7a3c MOBFoundation: 2abd23c80c33d1337d30dc4b0018ed914cef8f8e package_info: 873975fc26034f0b863a300ad47e7f1ac6c7ec62 @@ -224,6 +229,7 @@ SPEC CHECKSUMS: sharesdk_plugin: 6d6634bb480174b607030f19fc9d84d68cfbf326 sqflite: 6d358c025f5b867b29ed92fc697fd34924e11904 SSZipArchive: e7b4f3d9e780c2acc1764cd88fbf2de28f26e5b2 + thumbnails: bb4f4e9bb4b51c8ae4e6ad9a2fa81373f9b634ad TPNS-iOS: 57a146496858ba2fb5d43e5f240feb19243b69cb tpns_flutter_plugin: a366649c8ad71f19dfb864d3c994ed0480b69daa url_launcher: 6fef411d543ceb26efce54b05a0a40bfd74cbbef diff --git a/lib/community/community_view/community_dynamic.dart b/lib/community/community_view/community_dynamic.dart index eb6276fa..d2a9518f 100644 --- a/lib/community/community_view/community_dynamic.dart +++ b/lib/community/community_view/community_dynamic.dart @@ -408,16 +408,20 @@ class _CommunityDynamic extends State { )) : Container( width: width, - height: width / 3 * 2, + height: width / 7 * 5, + color: Colors.black, child: Stack( children: [ - MImage( - src, - width: width, - height: width / 3 * 2, - fit: BoxFit.cover, - errorSrc: "assets/image/default_2_1.png", - fadeSrc: "assets/image/default_2_1.png", + Center( + child: MImage( + src, + aspectRatio: videoPlayerController != null + ? videoPlayerController.value.aspectRatio + : (width / 7 * 5), + fit: BoxFit.cover, + errorSrc: "assets/image/default_2_1.png", + fadeSrc: "assets/image/default_2_1.png", + ), ), Center( child: Icon( diff --git a/lib/union/union_page.dart b/lib/union/union_page.dart index b976bd82..b3b3b22f 100644 --- a/lib/union/union_page.dart +++ b/lib/union/union_page.dart @@ -12,7 +12,6 @@ import 'package:huixiang/generated/l10n.dart'; import 'package:huixiang/main.dart'; import 'package:huixiang/retrofit/data/base_data.dart'; import 'package:huixiang/retrofit/data/store.dart'; -import 'package:huixiang/retrofit/data/store_type.dart'; import 'package:huixiang/retrofit/retrofit_api.dart'; import 'package:huixiang/store/scan.dart'; import 'package:huixiang/utils/event_type.dart'; @@ -22,8 +21,6 @@ import 'package:huixiang/view_widget/custom_image.dart'; import 'package:huixiang/view_widget/icon_text.dart'; import 'package:huixiang/view_widget/item_title.dart'; import 'package:huixiang/view_widget/my_appbar.dart'; -import 'package:huixiang/view_widget/request_permission.dart'; -import 'package:permission_handler/permission_handler.dart'; import 'package:pull_to_refresh/pull_to_refresh.dart'; import 'package:shared_preferences/shared_preferences.dart'; import 'package:flutter/rendering.dart'; From f6c2d80884a90e0d44a67847eb378c9ecc51d723 Mon Sep 17 00:00:00 2001 From: fmk Date: Tue, 26 Oct 2021 14:18:35 +0800 Subject: [PATCH 19/20] safety --- README.md | 7 ++++++- ios/Runner.xcodeproj/project.pbxproj | 4 ++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 72c0cabb..f21b5446 100644 --- a/README.md +++ b/README.md @@ -68,4 +68,9 @@ samples, guidance on mobile development, and a full API reference. #说明: huixiang_app/pubspec.yaml #依赖 - + 接口build 依赖(注释了) + # retrofit_generator: ^1.4.1+3 + # build_runner: ^1.11.5 + # json_serializable: ^3.5.1 + + \ No newline at end of file diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index 1d593ab0..f085d3f6 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -979,7 +979,7 @@ "$(PROJECT_DIR)/Runner/baidu", ); MARKETING_VERSION = 1.0.38; - ONLY_ACTIVE_ARCH = NO; + ONLY_ACTIVE_ARCH = YES; OTHER_LDFLAGS = ( "$(inherited)", "-ObjC", @@ -1342,7 +1342,7 @@ "$(PROJECT_DIR)/Runner/baidu", ); MARKETING_VERSION = 1.0.38; - ONLY_ACTIVE_ARCH = NO; + ONLY_ACTIVE_ARCH = YES; OTHER_LDFLAGS = ( "$(inherited)", "-ObjC", From 374718e489c4a4cd7257751341b8cb099446fff2 Mon Sep 17 00:00:00 2001 From: fmk Date: Tue, 26 Oct 2021 14:35:47 +0800 Subject: [PATCH 20/20] safety --- README.md | 14 ++++++++++++-- lib/main.dart | 1 - 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index f21b5446..03bc7567 100644 --- a/README.md +++ b/README.md @@ -68,9 +68,19 @@ samples, guidance on mobile development, and a full API reference. #说明: huixiang_app/pubspec.yaml #依赖 - 接口build 依赖(注释了) + 接口build 依赖(注释了) 命令: 项目根目录 > flutter pub run build_runner build # retrofit_generator: ^1.4.1+3 # build_runner: ^1.11.5 # json_serializable: ^3.5.1 - \ No newline at end of file + http接口需要build生成 需要上面3个依赖 + min_api.dart 调用小程序的接口 + retrofit_api.dart 调用app的接口 + + main.dart 程序入口 三方sdk初始化 路由 + + 华为开放平台 15827991714 密码: fmk7895123654 (有问题➕手机号码微信) + + 小米开放平台 83364300@qq.com 具体问 :(汪姐) + + 推送:使用腾讯云推送 tpns 需扫码登录 (有问题同华为➕微信||或重新注册账号替换相关appKey) \ No newline at end of file diff --git a/lib/main.dart b/lib/main.dart index d560c536..fbdd0f24 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -304,7 +304,6 @@ Map routers = { '/router/qr_share': (context, {arguments}) => QrSharePage(), '/router/main_page': (context, {arguments}) => MainPage(), '/router/test_page': (context, {arguments}) => TestPage(), - // '/router/ui_test': (context, {arguments}) => UITest(), '/router/communityFollow': (context, {arguments}) => CommunityFollow(), '/router/releasePage': (context, {arguments}) => ReleasePage(), '/router/activity_list': (context, {arguments}) => ActivityList(),