|
|
|
@ -1,7 +1,5 @@
|
|
|
|
|
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/retrofit/data/activity.dart'; |
|
|
|
|
import 'package:huixiang/retrofit/data/base_data.dart'; |
|
|
|
|
import 'package:huixiang/retrofit/data/findMiNiGroupList.dart'; |
|
|
|
@ -10,9 +8,8 @@ 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/product_sku.dart'; |
|
|
|
|
import 'package:huixiang/store/store_view/shop_goods.dart'; |
|
|
|
|
import 'package:huixiang/utils/font_weight.dart'; |
|
|
|
|
import 'package:huixiang/view_widget/custom_image.dart'; |
|
|
|
|
import 'package:huixiang/view_widget/round_button.dart'; |
|
|
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart'; |
|
|
|
|
import 'package:shared_preferences/shared_preferences.dart'; |
|
|
|
|
|
|
|
|
@ -22,9 +19,16 @@ class StoreOrderListPage extends StatefulWidget {
|
|
|
|
|
final StoreInfo storeInfo; |
|
|
|
|
final ScrollController controller; |
|
|
|
|
final Function(int allCount, double allPrice) fc; |
|
|
|
|
final Function(String id) queryMiNiDetail; |
|
|
|
|
|
|
|
|
|
StoreOrderListPage( |
|
|
|
|
this.arguments, this.activitys, this.storeInfo, this.controller, this.fc); |
|
|
|
|
this.arguments, |
|
|
|
|
this.activitys, |
|
|
|
|
this.storeInfo, |
|
|
|
|
this.controller, |
|
|
|
|
this.queryMiNiDetail, |
|
|
|
|
this.fc, |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
@override |
|
|
|
|
State<StatefulWidget> createState() { |
|
|
|
@ -33,7 +37,6 @@ class StoreOrderListPage extends StatefulWidget {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
class _StoreOrderListPage extends State<StoreOrderListPage> { |
|
|
|
|
|
|
|
|
|
int isSelected = 0; |
|
|
|
|
int tempClickIndex = 0; |
|
|
|
|
ApiService apiService; |
|
|
|
@ -45,47 +48,23 @@ class _StoreOrderListPage extends State<StoreOrderListPage> {
|
|
|
|
|
void initState() { |
|
|
|
|
super.initState(); |
|
|
|
|
|
|
|
|
|
minLogin(); |
|
|
|
|
appletGoods(); |
|
|
|
|
|
|
|
|
|
widget.controller.addListener(() {}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// 小程序登录 |
|
|
|
|
minLogin() async { |
|
|
|
|
final SharedPreferences value = await SharedPreferences.getInstance(); |
|
|
|
|
apiService = ApiService( |
|
|
|
|
///小程序查询分组及商品列表 |
|
|
|
|
appletGoods() async { |
|
|
|
|
SharedPreferences value = await SharedPreferences.getInstance(); |
|
|
|
|
String minToken = value.getString("minToken"); |
|
|
|
|
String tenant = value.getString("tenant"); |
|
|
|
|
minService = MinApiService( |
|
|
|
|
Dio(), |
|
|
|
|
context: context, |
|
|
|
|
token: value.getString('token'), |
|
|
|
|
token: minToken, |
|
|
|
|
tenant: tenant, |
|
|
|
|
); |
|
|
|
|
apiService |
|
|
|
|
.minLogin(widget.arguments["id"]) |
|
|
|
|
.catchError((onError) {}) |
|
|
|
|
.then((baseData) { |
|
|
|
|
if (baseData != null && baseData.isSuccess) { |
|
|
|
|
Map<String, dynamic> minStoreInfo = baseData.data; |
|
|
|
|
String minToken = minStoreInfo["token"]; |
|
|
|
|
String tenant = widget.arguments["tenant"]; |
|
|
|
|
SharedPreferences.getInstance().then( |
|
|
|
|
(value) => { |
|
|
|
|
value.setString('minToken', minToken), |
|
|
|
|
value.setString('tenant', tenant), |
|
|
|
|
}, |
|
|
|
|
); |
|
|
|
|
minService = MinApiService( |
|
|
|
|
Dio(), |
|
|
|
|
context: context, |
|
|
|
|
token: minToken, |
|
|
|
|
tenant: tenant, |
|
|
|
|
); |
|
|
|
|
appletGoods(); |
|
|
|
|
// queryMiNiDetail(widget.arguments["id"]); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
///小程序查询分组及商品列表 |
|
|
|
|
appletGoods() async { |
|
|
|
|
BaseData<List<FindMiNiGroupList>> baseData = |
|
|
|
|
await minService.findMiNiGroupList( |
|
|
|
|
{ |
|
|
|
@ -101,28 +80,6 @@ class _StoreOrderListPage extends State<StoreOrderListPage> {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
///选规格 |
|
|
|
|
queryMiNiDetail(String id) async { |
|
|
|
|
BaseData<MiNiDetail> baseData = await minService.miNiDetail(id); |
|
|
|
|
if (baseData != null && baseData.isSuccess) { |
|
|
|
|
setState(() { |
|
|
|
|
showStoreSelector(baseData.data); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
///添加购物车 |
|
|
|
|
addsShoppingCart() async { |
|
|
|
|
BaseData baseDate = await apiService.creditOrder({ |
|
|
|
|
"parentId": widget.arguments["parentId"], |
|
|
|
|
"skuImg": widget.arguments["skuImg"], |
|
|
|
|
"skuNameStr": widget.arguments["skuNameStr"], |
|
|
|
|
"skuPrice": widget.arguments["skuPrice"], |
|
|
|
|
"skuStock": widget.arguments["skuStock"], |
|
|
|
|
}); |
|
|
|
|
if (baseDate != null && baseDate.isSuccess) {} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@override |
|
|
|
|
Widget build(BuildContext context) { |
|
|
|
|
return Container( |
|
|
|
@ -202,199 +159,11 @@ class _StoreOrderListPage extends State<StoreOrderListPage> {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Widget goodsItem(position) { |
|
|
|
|
return Container( |
|
|
|
|
color: Colors.white, |
|
|
|
|
padding: EdgeInsets.only(right: 16.w, bottom: 10.h, top: 10.h), |
|
|
|
|
child: Row( |
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start, |
|
|
|
|
mainAxisAlignment: MainAxisAlignment.start, |
|
|
|
|
children: [ |
|
|
|
|
SizedBox(width: 12.w), |
|
|
|
|
MImage( |
|
|
|
|
productListBeans[position] != null |
|
|
|
|
? productListBeans[position].imgPath |
|
|
|
|
: "", |
|
|
|
|
width: 70, |
|
|
|
|
height: 70, |
|
|
|
|
fit: BoxFit.cover, |
|
|
|
|
errorSrc: "assets/image/default_1.png", |
|
|
|
|
fadeSrc: "assets/image/default_1.png", |
|
|
|
|
), |
|
|
|
|
SizedBox( |
|
|
|
|
width: 10, |
|
|
|
|
), |
|
|
|
|
Expanded( |
|
|
|
|
child: Column( |
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start, |
|
|
|
|
children: [ |
|
|
|
|
Text( |
|
|
|
|
productListBeans[position].productName, |
|
|
|
|
style: TextStyle( |
|
|
|
|
color: Colors.black, |
|
|
|
|
fontSize: 13.sp, |
|
|
|
|
fontWeight: MyFontWeight.medium, |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
SizedBox( |
|
|
|
|
height: 2, |
|
|
|
|
), |
|
|
|
|
Row( |
|
|
|
|
children: [ |
|
|
|
|
Expanded( |
|
|
|
|
child: Text( |
|
|
|
|
productListBeans[position].shortName, |
|
|
|
|
overflow: TextOverflow.ellipsis, |
|
|
|
|
maxLines: 2, |
|
|
|
|
style: TextStyle( |
|
|
|
|
color: Color(0xFF4C4C4C), |
|
|
|
|
fontSize: 10.sp, |
|
|
|
|
fontWeight: MyFontWeight.regular, |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
SizedBox( |
|
|
|
|
width: 10, |
|
|
|
|
), |
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
SizedBox( |
|
|
|
|
height: 7, |
|
|
|
|
), |
|
|
|
|
Row( |
|
|
|
|
children: [ |
|
|
|
|
Column( |
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start, |
|
|
|
|
children: [ |
|
|
|
|
Row( |
|
|
|
|
children: [ |
|
|
|
|
Text( |
|
|
|
|
S.of(context).huiyuanjia, |
|
|
|
|
style: TextStyle( |
|
|
|
|
color: Color(0xFFFF7A1A), |
|
|
|
|
fontSize: 10.sp, |
|
|
|
|
fontWeight: MyFontWeight.medium, |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
SizedBox( |
|
|
|
|
width: 4, |
|
|
|
|
), |
|
|
|
|
Text( |
|
|
|
|
"¥${productListBeans[position].price}", |
|
|
|
|
style: TextStyle( |
|
|
|
|
color: Color(0xFFFF7A1A), |
|
|
|
|
fontSize: 11.sp, |
|
|
|
|
fontWeight: MyFontWeight.medium, |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
Row( |
|
|
|
|
children: [ |
|
|
|
|
Text( |
|
|
|
|
S.of(context).yuanjia, |
|
|
|
|
style: TextStyle( |
|
|
|
|
color: Color(0xFFA29E9E), |
|
|
|
|
fontSize: 9.sp, |
|
|
|
|
fontWeight: MyFontWeight.regular, |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
SizedBox( |
|
|
|
|
width: 4, |
|
|
|
|
), |
|
|
|
|
Text( |
|
|
|
|
"¥${productListBeans[position].applyPrice}", |
|
|
|
|
style: TextStyle( |
|
|
|
|
color: Color(0xFFA29E9E), |
|
|
|
|
fontSize: 10.sp, |
|
|
|
|
fontWeight: MyFontWeight.regular, |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
Spacer(), |
|
|
|
|
productListBeans[position].attrStyle == 1 |
|
|
|
|
? GestureDetector( |
|
|
|
|
onTap: () { |
|
|
|
|
queryMiNiDetail(productListBeans[position].id); |
|
|
|
|
}, |
|
|
|
|
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), |
|
|
|
|
), |
|
|
|
|
) |
|
|
|
|
: InkWell( |
|
|
|
|
onTap: () { |
|
|
|
|
setState(() { |
|
|
|
|
{ |
|
|
|
|
if (productListBeans[position].buyNum > 0) |
|
|
|
|
productListBeans[position].buyNum--; |
|
|
|
|
int allCount = 0; |
|
|
|
|
double allPrice = 0; |
|
|
|
|
productListBeans.forEach((element) { |
|
|
|
|
allCount += element.buyNum; |
|
|
|
|
allPrice += double.parse(element.price) * |
|
|
|
|
element.buyNum; |
|
|
|
|
}); |
|
|
|
|
widget.fc(allCount, allPrice); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
child: Image.asset( |
|
|
|
|
"assets/image/reduce.png", |
|
|
|
|
width: 22, |
|
|
|
|
height: 22, |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
if (productListBeans[position].attrStyle == 0) |
|
|
|
|
Padding( |
|
|
|
|
padding: EdgeInsets.only(left: 8, right: 8), |
|
|
|
|
child: Text( |
|
|
|
|
productListBeans[position].buyNum.toString(), |
|
|
|
|
style: TextStyle( |
|
|
|
|
color: Colors.black, |
|
|
|
|
fontSize: 14.sp, |
|
|
|
|
fontWeight: MyFontWeight.medium, |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
if (productListBeans[position].attrStyle == 0) |
|
|
|
|
InkWell( |
|
|
|
|
onTap: () { |
|
|
|
|
setState(() { |
|
|
|
|
{ |
|
|
|
|
productListBeans[position].buyNum++; |
|
|
|
|
int allCount = 0; |
|
|
|
|
double allPrice = 0; |
|
|
|
|
productListBeans.forEach((element) { |
|
|
|
|
allCount += element.buyNum; |
|
|
|
|
allPrice += double.parse(element.price) * |
|
|
|
|
element.buyNum; |
|
|
|
|
}); |
|
|
|
|
widget.fc(allCount, allPrice); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
child: Image.asset( |
|
|
|
|
"assets/image/add.png", |
|
|
|
|
width: 22, |
|
|
|
|
height: 22, |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
) |
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
return ShopGoods( |
|
|
|
|
productListBeans, |
|
|
|
|
position, |
|
|
|
|
widget.queryMiNiDetail, |
|
|
|
|
widget.fc, |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -402,15 +171,4 @@ class _StoreOrderListPage extends State<StoreOrderListPage> {
|
|
|
|
|
return productListBeans; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
///选规格弹窗 |
|
|
|
|
showStoreSelector(MiNiDetail miNiDetail) { |
|
|
|
|
showModalBottomSheet( |
|
|
|
|
context: context, |
|
|
|
|
backgroundColor: Colors.transparent, |
|
|
|
|
builder: (context) { |
|
|
|
|
return ProductSku(miNiDetail); |
|
|
|
|
}, |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|