Browse Source

safety

master
fmk 3 years ago
parent
commit
034ce9d310
  1. 105
      lib/store/store_order.dart
  2. 4
      lib/store/store_view/settlement.dart
  3. 10
      lib/store/store_view/shop_car.dart
  4. 220
      lib/store/store_view/shop_goods.dart
  5. 288
      lib/store/store_view/store_order_list.dart

105
lib/store/store_order.dart

@ -8,10 +8,12 @@ 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/order_info.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/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';
@ -28,7 +30,7 @@ import 'package:pull_to_refresh/pull_to_refresh.dart';
import 'package:shared_preferences/shared_preferences.dart';
class StoreOrderPage extends StatefulWidget {
final Map arguments;
final Map<String, dynamic> arguments;
StoreOrderPage({this.arguments});
@ -63,13 +65,14 @@ class _StoreOrderPage extends State<StoreOrderPage>
);
_widgetOptions = [
StoreOrderListPage(widget.arguments, activitys, storeInfo, controller,
(ac, ap) {
setState(() {
allCount = ac;
allPrice = ap;
});
}),
StoreOrderListPage(
widget.arguments,
activitys,
storeInfo,
controller,
_queryMiNiDetail,
_fc,
),
///,
StoreActivity(
@ -77,10 +80,50 @@ class _StoreOrderPage extends State<StoreOrderPage>
activitys,
),
];
minLogin();
queryStoreInfo();
}
_fc(ac, ap) {
setState(() {
allCount = ac;
allPrice = ap;
});
}
///
minLogin() async {
final SharedPreferences value = await SharedPreferences.getInstance();
apiService = ApiService(
Dio(),
context: context,
token: value.getString('token'),
);
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,
);
}
});
}
///
queryStoreInfo() async {
final SharedPreferences value = await SharedPreferences.getInstance();
@ -307,7 +350,7 @@ class _StoreOrderPage extends State<StoreOrderPage>
onTap: () {
Navigator.of(context).pushNamed(
'/router/settlement',
arguments: {},
arguments: widget.arguments,
);
},
child: RoundButton(
@ -400,7 +443,7 @@ class _StoreOrderPage extends State<StoreOrderPage>
);
}
List<ProductList> productLists = [];
List<ProductListBean> productLists = [];
///
showShoppingCart() {
@ -408,13 +451,47 @@ class _StoreOrderPage extends State<StoreOrderPage>
context: context,
backgroundColor: Colors.transparent,
builder: (context) {
return ShopCar(productLists);
return ShopCar(productLists, _queryMiNiDetail, (ac, ap) {
setState(() {
allCount = ac;
allPrice = ap;
});
});
},
);
}
Widget shoppGoodsItem(ProductList pro, position) {
return ShopGoods(pro, position);
///
_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) {}
}
///
showStoreSelector(MiNiDetail miNiDetail) {
showModalBottomSheet(
context: context,
backgroundColor: Colors.transparent,
builder: (context) {
return ProductSku(miNiDetail);
},
);
}
@override

4
lib/store/store_view/settlement.dart

@ -50,10 +50,8 @@ class _Settlement extends State<Settlement> {
int refundStatus = 0;
// String storeType = "NORMALSTORE"; //NORMALSTORE FASTSTORE RETAILSTORE
queryDetails() async {
BaseData<OrderInfo> baseData =
await apiService.orderDetail(widget.arguments["id"]);
BaseData<OrderInfo> baseData = await apiService.orderDetail(widget.arguments["id"]);
if (baseData != null && baseData.isSuccess) {
orderInfo = baseData.data;
payStatus = orderInfo.payStatus;

10
lib/store/store_view/shop_car.dart

@ -1,5 +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/store/store_view/shop_goods.dart';
import 'package:huixiang/utils/font_weight.dart';
@ -8,9 +9,11 @@ import 'package:flutter_screenutil/flutter_screenutil.dart';
class ShopCar extends StatefulWidget {
final List<ProductList> productLists;
final List<ProductListBean> productLists;
final Function(String id) queryMiNiDetail;
final Function(int allCount, double allPrice) fc;
ShopCar(this.productLists);
ShopCar(this.productLists, this.queryMiNiDetail, this.fc);
@override
State<StatefulWidget> createState() {
@ -79,10 +82,9 @@ class _ShopCar extends State<ShopCar> {
itemCount: widget.productLists == null ? 0 : widget.productLists.length,
physics: BouncingScrollPhysics(),
itemBuilder: (context, position) {
// return shoppGoodsItem();
return GestureDetector(
onTap: () {},
child: ShopGoods(widget.productLists[position], position),
child: ShopGoods(widget.productLists, position, widget.queryMiNiDetail, widget.fc),
);
},
),

220
lib/store/store_view/shop_goods.dart

@ -1,74 +1,92 @@
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';
import 'package:huixiang/view_widget/round_button.dart';
class ShopGoods extends StatefulWidget {
final ProductList pro;
final List<ProductListBean> productListBeans;
final int position;
final Function(String id) queryMiNiDetail;
final Function(int allCount, double allPrice) fc;
ShopGoods(this.pro, this.position);
ShopGoods(
this.productListBeans,
this.position,
this.queryMiNiDetail,
this.fc,
);
@override
State<StatefulWidget> createState() {
return _ShopGoods();
}
}
class _ShopGoods extends State<ShopGoods> {
@override
Widget build(BuildContext context) {
return Container(
padding: EdgeInsets.only(bottom: 10),
color: Colors.white,
padding: EdgeInsets.only(right: 16.w, bottom: 10.h, top: 10.h),
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.start,
children: [
Image.asset(
"assets/image/default_1.png",
width: 60,
height: 60,
SizedBox(width: 12.w),
MImage(
widget.productListBeans[widget.position] != null
? widget.productListBeans[widget.position].imgPath
: "",
width: 70,
height: 70,
fit: BoxFit.cover,
errorSrc: "assets/image/default_1.png",
fadeSrc: "assets/image/default_1.png",
),
SizedBox(
width: 10,
),
SizedBox(width: 10),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
"手工啵啵奶茶",
widget.productListBeans[widget.position].productName,
style: TextStyle(
color: Colors.black,
fontSize: 12.sp,
fontSize: 13.sp,
fontWeight: MyFontWeight.medium,
),
),
SizedBox(height: 2),
SizedBox(
height: 2,
),
Row(
children: [
Text(
"无香精",
style: TextStyle(
color: Color(0xFF4C4C4C),
fontSize: 11.sp,
fontWeight: MyFontWeight.regular,
Expanded(
child: Text(
widget.productListBeans[widget.position].shortName,
overflow: TextOverflow.ellipsis,
maxLines: 2,
style: TextStyle(
color: Color(0xFF4C4C4C),
fontSize: 10.sp,
fontWeight: MyFontWeight.regular,
),
),
),
SizedBox(width: 10),
Text(
"无香精",
style: TextStyle(
color: Color(0xFF4C4C4C),
fontSize: 11.sp,
fontWeight: MyFontWeight.regular,
),
)
SizedBox(
width: 10,
),
],
),
SizedBox(height: 6),
SizedBox(
height: 7,
),
Row(
children: [
Column(
@ -77,62 +95,136 @@ class _ShopGoods extends State<ShopGoods> {
Row(
children: [
Text(
"会员价",
S.of(context).huiyuanjia,
style: TextStyle(
color: Color(0xFFFF7A1A),
fontSize: 13.sp,
fontSize: 10.sp,
fontWeight: MyFontWeight.medium,
),
),
SizedBox(
width: 4,
),
Text(
"¥19.00",
"¥${widget.productListBeans[widget.position].price}",
style: TextStyle(
color: Color(0xFFFF7A1A),
fontSize: 14.sp,
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(
"¥${widget.productListBeans[widget.position].applyPrice}",
style: TextStyle(
color: Color(0xFFA29E9E),
fontSize: 10.sp,
fontWeight: MyFontWeight.regular,
),
),
],
),
],
),
Spacer(),
InkWell(
onTap: () {},
child: Image.asset(
"assets/image/reduce.png",
width: 22,
height: 22,
),
),
Padding(
padding: EdgeInsets.only(left: 8, right: 8),
child: Text(
"1",
style: TextStyle(
color: Colors.black,
fontSize: 14.sp,
fontWeight: MyFontWeight.medium,
widget.productListBeans[widget.position].attrStyle == 1
? 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.productListBeans[widget.position].id);
},
)
: 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);
}
});
},
child: Image.asset(
"assets/image/reduce.png",
width: 22,
height: 22,
),
),
if (widget.productListBeans[widget.position].attrStyle == 0)
Padding(
padding: EdgeInsets.only(left: 8, right: 8),
child: Text(
widget.productListBeans[widget.position].buyNum
.toString(),
style: TextStyle(
color: Colors.black,
fontSize: 14.sp,
fontWeight: MyFontWeight.medium,
),
),
),
),
InkWell(
onTap: () {},
child: Image.asset(
"assets/image/add.png",
width: 22,
height: 22,
if (widget.productListBeans[widget.position].attrStyle == 0)
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);
}
});
},
child: Image.asset(
"assets/image/add.png",
width: 22,
height: 22,
),
),
),
],
),
],
),
flex: 1,
),
)
],
),
);
}
}

288
lib/store/store_view/store_order_list.dart

@ -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);
},
);
}
}

Loading…
Cancel
Save