Browse Source

会员码页面优化;

选套餐待解决
wr_2023_new_business_new
wurong 4 months ago
parent
commit
667f31c7e8
  1. 48
      lib/mine/vip_pay_code.dart
  2. 9
      lib/retrofit/data/miNiDetail.dart
  3. 11
      lib/store/shop_details_page.dart
  4. 1130
      lib/store/store_view/product_meals_sku.dart
  5. 34
      lib/store/store_view/shop_goods.dart
  6. 1
      lib/store/store_view/store_order_list.dart

48
lib/mine/vip_pay_code.dart

@ -2,6 +2,7 @@ import 'dart:async';
import 'dart:convert'; import 'dart:convert';
import 'package:dio/dio.dart'; import 'package:dio/dio.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:huixiang/retrofit/data/base_data.dart'; import 'package:huixiang/retrofit/data/base_data.dart';
import 'package:huixiang/retrofit/retrofit_api.dart'; import 'package:huixiang/retrofit/retrofit_api.dart';
import 'package:huixiang/utils/font_weight.dart'; import 'package:huixiang/utils/font_weight.dart';
@ -27,7 +28,9 @@ class _VipPayCode extends State<VipPayCode> {
@override @override
void dispose() { void dispose() {
super.dispose(); super.dispose();
refreshController.dispose(); refreshController?.dispose();
_timer?.cancel();
isDispose = true;
} }
@override @override
@ -44,40 +47,47 @@ class _VipPayCode extends State<VipPayCode> {
/// ///
queryUser() async { queryUser() async {
try{ SharedPreferences prefs;
SharedPreferences value = await SharedPreferences.getInstance(); try {
prefs = await SharedPreferences.getInstance();
if (prefs.getString("bannerData") != null) {
userInfo = UserInfo.fromJson(jsonDecode(prefs.getString('userInfo')));
setState(() {});
}
if (apiService == null) if (apiService == null)
apiService = ApiService( apiService = ApiService(
Dio(), Dio(),
context: context, context: context,
token: value.getString("token"), token: prefs.getString("token"),
showLoading: true
); );
BaseData<UserInfo> baseData = BaseData<UserInfo> baseData = await apiService.queryInfo().catchError((onError) {
await apiService.queryInfo().catchError((onError) { refreshController.refreshFailed();
refreshController.refreshFailed();}); });
if (baseData != null && baseData.isSuccess) { if (baseData != null && baseData.isSuccess) {
userInfo = baseData.data; userInfo = baseData.data;
SharedPreferences.getInstance().then((value) => { prefs.setString('userInfo', jsonEncode(baseData.data));
value.setString('user', jsonEncode(baseData.data)),
});
setState(() {}); setState(() {});
refreshController.refreshCompleted(); refreshController.refreshCompleted();
}else{ } else {
refreshController.refreshFailed(); refreshController.refreshFailed();
} }
}finally{ } finally {
refreshCode(); refreshCode();
EasyLoading.dismiss();
} }
} }
refreshCode(){ refreshCode(){
if (_timer != null) return; if (_timer != null) return;
const oneSec = const Duration(minutes: 2); const oneSec = const Duration(minutes: 2);
var callback = ((timer) { _timer = Timer.periodic(oneSec, (timer) {
if (isDispose) return; if (isDispose) {
timer.cancel();
return;
}
queryUser(); queryUser();
}); });
_timer = Timer.periodic(oneSec, callback);
} }
@override @override
@ -132,9 +142,7 @@ class _VipPayCode extends State<VipPayCode> {
), ),
SizedBox(height: 30.h,), SizedBox(height: 30.h,),
QrImage( QrImage(
data: userInfo != null data:userInfo?.vipScanNo ?? "622868c3c2c5a02508ed7064c7c27387a1c2c0cb2052ba344d82266a64feb1cfc75014532616b2fb179024c83a6066757cf2639efca8f2731c54a24859e200ca",
? (userInfo?.vipScanNo ?? "")
: "",
version: QrVersions.auto, version: QrVersions.auto,
size: 200.w, size: 200.w,
gapless: true, gapless: true,

9
lib/retrofit/data/miNiDetail.dart

@ -416,6 +416,7 @@ class ProductSetMeals {
int _totalNumber; int _totalNumber;
int _optionalNumber; int _optionalNumber;
List<ProductInfoList> _productInfoList; List<ProductInfoList> _productInfoList;
int checkIndex = 0;
ProductSetMeals copyWith({ ProductSetMeals copyWith({
String groupName, String groupName,
@ -686,16 +687,19 @@ class SkuInfoList {
SkuInfoList({ SkuInfoList({
String id, String id,
String skuName, String skuName,
String skuPrice,
List<ProductSkuAttrList> productSkuAttrList, List<ProductSkuAttrList> productSkuAttrList,
}) { }) {
_id = id; _id = id;
_skuName = skuName; _skuName = skuName;
_skuPrice = skuPrice;
_productSkuAttrList = productSkuAttrList; _productSkuAttrList = productSkuAttrList;
} }
SkuInfoList.fromJson(dynamic json) { SkuInfoList.fromJson(dynamic json) {
_id = json['id']; _id = json['id'];
_skuName = json['skuName']; _skuName = json['skuName'];
_skuPrice = json['skuPrice'];
if (json['productSkuAttrList'] != null) { if (json['productSkuAttrList'] != null) {
_productSkuAttrList = []; _productSkuAttrList = [];
json['productSkuAttrList'].forEach((v) { json['productSkuAttrList'].forEach((v) {
@ -706,17 +710,20 @@ class SkuInfoList {
String _id; String _id;
String _skuName; String _skuName;
String _skuPrice;
bool _isSelected = false; bool _isSelected = false;
List<ProductSkuAttrList> _productSkuAttrList; List<ProductSkuAttrList> _productSkuAttrList;
SkuInfoList copyWith({ SkuInfoList copyWith({
String id, String id,
String skuName, String skuName,
String skuPrice,
List<ProductSkuAttrList> productSkuAttrList, List<ProductSkuAttrList> productSkuAttrList,
}) => }) =>
SkuInfoList( SkuInfoList(
id: id ?? _id, id: id ?? _id,
skuName: skuName ?? _skuName, skuName: skuName ?? _skuName,
skuPrice: skuPrice ?? _skuPrice,
productSkuAttrList: productSkuAttrList ?? _productSkuAttrList, productSkuAttrList: productSkuAttrList ?? _productSkuAttrList,
); );
@ -724,6 +731,8 @@ class SkuInfoList {
String get skuName => _skuName; String get skuName => _skuName;
String get skuPrice => _skuPrice;
List<ProductSkuAttrList> get productSkuAttrList => _productSkuAttrList; List<ProductSkuAttrList> get productSkuAttrList => _productSkuAttrList;
bool get isSelected => _isSelected; bool get isSelected => _isSelected;

11
lib/store/shop_details_page.dart

@ -77,13 +77,13 @@ class _ShopDetailsPage extends State<ShopDetailsPage> {
GlobalKey _key = GlobalKey(); GlobalKey _key = GlobalKey();
Offset _endOffset; Offset _endOffset;
double rightOffset = 23.0; double rightOffset = 23.0;
int _jumpType = -1;
@override @override
void initState() { void initState() {
super.initState(); super.initState();
id = widget.arguments["id"]; id = widget.arguments["id"];
storeId = widget.arguments["storeId"]; storeId = widget.arguments["storeId"];
isSetMeal = widget.arguments["isSetMeal"] ?? false;
scrollController.addListener(() { scrollController.addListener(() {
if(scIndex == 0 && scrollController.offset > (MediaQuery.of(context).size.height >= 750 ? 392.h : 400.h)){ if(scIndex == 0 && scrollController.offset > (MediaQuery.of(context).size.height >= 750 ? 392.h : 400.h)){
setState(() { setState(() {
@ -206,6 +206,11 @@ class _ShopDetailsPage extends State<ShopDetailsPage> {
miNiDetail = baseData.data; miNiDetail = baseData.data;
miNiDetail.attrList.forEach((element) { miNiDetail.attrList.forEach((element) {
selectSkus.add(element.attrValueList[0].attrValue); selectSkus.add(element.attrValueList[0].attrValue);
if (baseData.data.productSkuVOList[0].productSetMeals.length == 0) {
_jumpType = 0;
} else {
_jumpType = 1;
}
}); });
}); });
SharedPreferences.getInstance().then( SharedPreferences.getInstance().then(
@ -944,7 +949,7 @@ class _ShopDetailsPage extends State<ShopDetailsPage> {
if (storeInfo.posType.code == "NORMALSTORE" && if (storeInfo.posType.code == "NORMALSTORE" &&
tableId == 0) { tableId == 0) {
showDeleteDialog(); showDeleteDialog();
} else if (isSetMeal == true) { } else if (_jumpType == 1) {
await Navigator.of(context).pushNamed( await Navigator.of(context).pushNamed(
'/router/product_meals_sku', '/router/product_meals_sku',
arguments: { arguments: {
@ -1111,7 +1116,7 @@ class _ShopDetailsPage extends State<ShopDetailsPage> {
if (storeInfo.posType.code == "NORMALSTORE" && if (storeInfo.posType.code == "NORMALSTORE" &&
tableId == 0) { tableId == 0) {
showDeleteDialog(); showDeleteDialog();
} else if (isSetMeal == true) { } else if (_jumpType == 1) {
await Navigator.of(context).pushNamed( await Navigator.of(context).pushNamed(
'/router/product_meals_sku', '/router/product_meals_sku',
arguments: { arguments: {

1130
lib/store/store_view/product_meals_sku.dart

File diff suppressed because it is too large Load Diff

34
lib/store/store_view/shop_goods.dart

@ -430,22 +430,24 @@ class _ShopGoods extends State<ShopGoods> {
// SmartDialog.showToast("库存不足", // SmartDialog.showToast("库存不足",
// alignment: Alignment.center); // alignment: Alignment.center);
// } else // } else
/// widget overlayEntry if(_jumpType != 1){
var _overlayEntry = OverlayEntry(builder: (_) { /// widget overlayEntry
RenderBox box = context.findRenderObject(); var _overlayEntry = OverlayEntry(builder: (_) {
var offset = box.localToGlobal(Offset.zero); RenderBox box = context.findRenderObject();
return RedDotPage( var offset = box.localToGlobal(Offset.zero);
startPosition: offset, return RedDotPage(
endPosition: widget.endOffset, startPosition: offset,
); endPosition: widget.endOffset,
}); );
// Overlay });
Overlay.of(context).insert(_overlayEntry); // Overlay
// Overlay.of(context).insert(_overlayEntry);
Future.delayed(Duration(milliseconds: 800), () { //
_overlayEntry.remove(); Future.delayed(Duration(milliseconds: 800), () {
_overlayEntry = null; _overlayEntry.remove();
}); _overlayEntry = null;
});
}
if (_jumpType == -1) if (_jumpType == -1)
queryMiNiDetail(widget.productListBean.id); queryMiNiDetail(widget.productListBean.id);
else if (_jumpType == 0) else if (_jumpType == 0)

1
lib/store/store_view/store_order_list.dart

@ -213,7 +213,6 @@ class _StoreOrderListPage extends State<StoreOrderListPage> {
.pushNamed('/router/shop_details_page', arguments: { .pushNamed('/router/shop_details_page', arguments: {
"id": e.id, "id": e.id,
"storeId": e.storeId, "storeId": e.storeId,
"isSetMeal":e.isSetMeal,
"minQty":e.minQty, "minQty":e.minQty,
}); });
widget.queryShoppingCart(); widget.queryShoppingCart();

Loading…
Cancel
Save