Browse Source

Merge branches 'dev' and 'master' of https://git.lotus-wallet.com/fmk/huixiang_app

 Conflicts:
	lib/retrofit/min_api.g.dart
	lib/store/store_order.dart
	lib/store/store_view/shop_car.dart
	lib/store/store_view/shop_goods.dart
master
fmk 3 years ago
parent
commit
f716b48bd2
  1. 36
      lib/store/store_order.dart
  2. 47
      lib/store/store_view/shop_car.dart
  3. 35
      lib/store/store_view/shop_goods.dart
  4. 31
      lib/store/store_view/store_order_list.dart

36
lib/store/store_order.dart

@ -15,7 +15,6 @@ import 'package:huixiang/retrofit/min_api.dart';
import 'package:huixiang/retrofit/retrofit_api.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/shop_goods.dart';
import 'package:huixiang/store/store_view/store_activity.dart';
import 'package:huixiang/store/store_view/store_info.dart';
import 'package:huixiang/store/store_view/store_order_list.dart';
@ -51,6 +50,7 @@ class _StoreOrderPage extends State<StoreOrderPage>
List<Widget> _widgetOptions;
int allCount = 0;
double allPrice = 0;
StoreOrderListPage storeOrderListPage;
ScrollController controller = ScrollController();
@ -63,16 +63,11 @@ class _StoreOrderPage extends State<StoreOrderPage>
length: 2,
vsync: this,
);
storeOrderListPage = StoreOrderListPage(widget.arguments, activitys,
storeInfo, controller, _queryMiNiDetail, _fc);
_widgetOptions = [
StoreOrderListPage(
widget.arguments,
activitys,
storeInfo,
controller,
_queryMiNiDetail,
_fc,
),
storeOrderListPage,
///,
StoreActivity(
@ -84,10 +79,27 @@ class _StoreOrderPage extends State<StoreOrderPage>
queryStoreInfo();
}
_fc(ac, ap) {
_fc(ProductListBean plb) {
setState(() {
allCount = ac;
allPrice = ap;
allCount = 0;
allPrice = 0;
bool flag = false;
for (var i = 0; i < productLists.length; i++) {
if (productLists[i].id == plb.id) {
flag = true;
if (plb.buyNum == 0)
productLists.removeAt(i);
else
productLists[i] = plb;
break;
}
}
storeOrderListPage.notifyList(productLists);
if (!flag && plb.buyNum != 0) productLists.add(plb);
productLists.forEach((element) {
allCount += element.buyNum;
allPrice += double.parse(element.price) * element.buyNum;
});
});
}

47
lib/store/store_view/shop_car.dart

@ -8,6 +8,7 @@ import 'package:huixiang/view_widget/round_button.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
class ShopCar extends StatefulWidget {
final List<ProductListBean> productLists;
final Function(String id) queryMiNiDetail;
final Function(int allCount, double allPrice) fc;
@ -29,6 +30,41 @@ class _ShopCar extends State<ShopCar> {
int allCount;
double allPrice;
int allCount = 0;
double allPrice = 0;
@override
void initState() {
super.initState();
_fc(null);
}
_fc(ProductListBean plb) {
setState(() {
if(plb != null){
allCount = 0;
allPrice = 0;
bool flag = false;
for(var i = 0;i < widget.productLists.length;i++){
if(widget.productLists[i].id == plb.id){
flag = true;
if(plb.buyNum == 0)
widget.productLists.removeAt(i);
else widget.productLists[i] = plb;
break;
}
}
if(!flag)
widget.productLists.add(plb);
}
widget.productLists.forEach((element) {
allCount += element.buyNum;
allPrice += double.parse(element.price) *
element.buyNum;
});
});
}
@override
Widget build(BuildContext context) {
return StatefulBuilder(builder: (context1, state) {
@ -67,7 +103,10 @@ class _ShopCar extends State<ShopCar> {
),
),
InkWell(
onTap: () {},
onTap: () {
state(() {
});
},
child: Image.asset(
"assets/image/delete.png",
width: 22,
@ -104,6 +143,10 @@ class _ShopCar extends State<ShopCar> {
});
},
),
// child: ShopGoods(widget.productLists, position, widget.queryMiNiDetail, (plb){setState(() {
// _fc(plb);
// widget.fc(plb);
// });}),
);
},
),
@ -205,4 +248,4 @@ class _ShopCar extends State<ShopCar> {
);
});
}
}
}

35
lib/store/store_view/shop_goods.dart

@ -1,7 +1,6 @@
import 'package:flutter/material.dart';
import 'package:huixiang/generated/l10n.dart';
import 'package:huixiang/retrofit/data/findMiNiGroupList.dart';
import 'package:huixiang/retrofit/data/order_info.dart';
import 'package:huixiang/utils/font_weight.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:huixiang/view_widget/custom_image.dart';
@ -159,19 +158,14 @@ class _ShopGoods extends State<ShopGoods> {
: InkWell(
onTap: () {
setState(() {
if (widget.productListBeans[widget.position]
.buyNum >
0)
widget.productListBeans[widget.position]
.buyNum--;
int allCount = 0;
double allPrice = 0;
widget.productListBeans.forEach((element) {
allCount += element.buyNum;
allPrice += double.parse(element.price) *
element.buyNum;
});
widget.fc(allCount, allPrice);
{
if (widget.productListBeans[widget.position]
.buyNum >
0)
widget.productListBeans[widget.position]
.buyNum--;
widget.fc(widget.productListBeans[widget.position]);
}
});
},
child: Image.asset(
@ -197,17 +191,8 @@ class _ShopGoods extends State<ShopGoods> {
InkWell(
onTap: () {
setState(() {
{
widget.productListBeans[widget.position].buyNum++;
int allCount = 0;
double allPrice = 0;
widget.productListBeans.forEach((element) {
allCount += element.buyNum;
allPrice += double.parse(element.price) *
element.buyNum;
});
widget.fc(allCount, allPrice);
}
widget.productListBeans[widget.position].buyNum++;
widget.fc(widget.productListBeans[widget.position]);
});
},
child: Image.asset(

31
lib/store/store_view/store_order_list.dart

@ -18,8 +18,9 @@ class StoreOrderListPage extends StatefulWidget {
final List<Activity> activitys;
final StoreInfo storeInfo;
final ScrollController controller;
final Function(int allCount, double allPrice) fc;
final Function(ProductListBean plb) fc;
final Function(String id) queryMiNiDetail;
_StoreOrderListPage _storeOrderListPage;
StoreOrderListPage(
this.arguments,
@ -27,12 +28,17 @@ class StoreOrderListPage extends StatefulWidget {
this.storeInfo,
this.controller,
this.queryMiNiDetail,
this.fc,
this.fc
);
@override
State<StatefulWidget> createState() {
return _StoreOrderListPage();
_storeOrderListPage = _StoreOrderListPage();
return _storeOrderListPage;
}
void notifyList(List<ProductListBean> product){
_storeOrderListPage.notifyList(product);
}
}
@ -42,7 +48,18 @@ class _StoreOrderListPage extends State<StoreOrderListPage> {
ApiService apiService;
MinApiService minService;
List<FindMiNiGroupList> appletProducts;
List<ProductListBean> productListBeans;
List<ProductListBean> productListBeans = [];
void notifyList(List<ProductListBean> product){
setState(() {
product.forEach((e0) {
productListBeans.forEach((e1) {
if(e0.id == e1.id)
e1.buyNum = e0.buyNum;
});
});
});
}
@override
void initState() {
@ -74,8 +91,9 @@ class _StoreOrderListPage extends State<StoreOrderListPage> {
if (baseData != null && baseData.isSuccess) {
setState(() {
appletProducts = baseData.data;
productListBeans.clear();
if (appletProducts.length > 0)
productListBeans = appletProducts[0].productList;
productListBeans.addAll(appletProducts[0].productList);
});
}
}
@ -133,7 +151,8 @@ class _StoreOrderListPage extends State<StoreOrderListPage> {
onTap: () {
setState(() {
isSelected = index;
productListBeans = findMiNiGroupList.productList;
productListBeans.clear();
productListBeans.addAll(findMiNiGroupList.productList);
});
},
child: Container(

Loading…
Cancel
Save