Browse Source

购物车,秒杀bug处理

zyh
w-R 3 years ago
parent
commit
16e7c313a5
  1. 172
      lib/retrofit/data/activity_area_list.dart
  2. 28
      lib/retrofit/min_api.dart
  3. 41
      lib/retrofit/min_api.g.dart
  4. 8
      lib/retrofit/retrofit_api.dart
  5. 2
      lib/retrofit/retrofit_api.g.dart
  6. 974
      lib/store/shopping/activity_prefecture_details.dart
  7. 13
      lib/store/shopping/shopping_cart/shopping_cart_page.dart
  8. 5
      lib/store/shopping/shopping_home/recommend_goods_list_view.dart
  9. 7
      lib/utils/flutter_utils.dart

172
lib/retrofit/data/activity_area_list.dart

File diff suppressed because one or more lines are too long

28
lib/retrofit/min_api.dart

@ -31,14 +31,14 @@ part 'min_api.g.dart';
// const base_url = "http://user.prod.kunqi.lotus-wallet.com/app/"; ///222 // const base_url = "http://user.prod.kunqi.lotus-wallet.com/app/"; ///222
// const baseUrl = "http://user.prod.kunqi.lotus-wallet.com/app/"; ///222 // const baseUrl = "http://user.prod.kunqi.lotus-wallet.com/app/"; ///222
const base_url = "http://192.168.10.236:8765/app/";/// // const base_url = "http://192.168.10.236:8765/app/";///
const baseUrl = "http://192.168.10.236:8765/app/";/// // const baseUrl = "http://192.168.10.236:8765/app/";///
// const base_url = "http://192.168.10.37:8766/app/"; // const base_url = "http://192.168.10.37:8766/app/";
// const baseUrl = "http://192.168.10.37:8766/app/"; // const baseUrl = "http://192.168.10.37:8766/app/";
// const base_url = "http://192.168.10.142:8765/app/";/// const base_url = "http://192.168.10.142:8765/app/";///
// const baseUrl = "http://192.168.10.142:8765/app/";/// const baseUrl = "http://192.168.10.142:8765/app/";///
/// ///
@RestApi(baseUrl: baseUrl) @RestApi(baseUrl: baseUrl)
@ -168,7 +168,7 @@ abstract class MinApiService {
/// ///
@PUT("shoppingcart/single") @PUT("shoppingcart/single")
Future<BaseData<List<ShoppingCart>>> shoppingCartSingle(@Body() Map<String, dynamic> param); Future<BaseData> shoppingCartSingle(@Body() Map<String, dynamic> param);
/// ///
@POST("order/getOrderInfo") @POST("order/getOrderInfo")
@ -215,8 +215,24 @@ abstract class MinApiService {
Future<BaseData<ShoppingHomeConfig>> homeConfig(); Future<BaseData<ShoppingHomeConfig>> homeConfig();
///,,, ///,,,
@GET("/actTemplate/findActListByType?allDay={allDay}&type={type}") @GET("actTemplate/findActListByType?allDay={allDay}&type={type}")
Future<BaseData<ActivityAreaList>> findActListByType(@Path("allDay") bool allDay, Future<BaseData<ActivityAreaList>> findActListByType(@Path("allDay") bool allDay,
@Path("type") String type); @Path("type") String type);
// /// APP
// @GET("actTemplate/viewProduct?actProductId={actProductId}&type={type}")
// Future<BaseData<List<HomeRecommendList>>> viewProduct();
//
// ///
// @POST("actTemplate/actPay")
// Future<BaseData> actPay(@Body() Map<String, dynamic> param);
//
// ///
// @POST("actTemplate/joinAct")
// Future<BaseData> joinAct(@Body() Map<String, dynamic> param);
//
// ///
// @POST("actTemplate/launchAct")
// Future<BaseData> launchAct(@Body() Map<String, dynamic> param);
} }

41
lib/retrofit/min_api.g.dart

@ -9,7 +9,7 @@ part of 'min_api.dart';
class _MinApiService implements MinApiService { class _MinApiService implements MinApiService {
_MinApiService(this._dio, {this.baseUrl}) { _MinApiService(this._dio, {this.baseUrl}) {
ArgumentError.checkNotNull(_dio, '_dio'); ArgumentError.checkNotNull(_dio, '_dio');
baseUrl ??= 'http://192.168.10.236:8765/app/'; baseUrl ??= 'http://192.168.10.142:8765/app/';
} }
final Dio _dio; final Dio _dio;
@ -176,14 +176,13 @@ class _MinApiService implements MinApiService {
} }
@override @override
Future<BaseData<List<ShoppingCart>>> shoppingCartSingle(param) async { Future<BaseData<dynamic>> shoppingCartSingle(param) async {
ArgumentError.checkNotNull(param, 'param'); ArgumentError.checkNotNull(param, 'param');
const _extra = <String, dynamic>{}; const _extra = <String, dynamic>{};
final queryParameters = <String, dynamic>{}; final queryParameters = <String, dynamic>{};
final _data = <String, dynamic>{}; final _data = <String, dynamic>{};
_data.addAll(param ?? <String, dynamic>{}); _data.addAll(param ?? <String, dynamic>{});
final _result = await _dio.request<Map<String, dynamic>>( final _result = await _dio.request<Map<String, dynamic>>('shoppingcart/single',
'shoppingcart/single',
queryParameters: queryParameters, queryParameters: queryParameters,
options: RequestOptions( options: RequestOptions(
method: 'PUT', method: 'PUT',
@ -191,15 +190,14 @@ class _MinApiService implements MinApiService {
extra: _extra, extra: _extra,
baseUrl: baseUrl), baseUrl: baseUrl),
data: _data); data: _data);
final value = BaseData<List<ShoppingCart>>.fromJson( final value = BaseData<dynamic>.fromJson(
_result.data, _result.data,
(json) => (json as List<dynamic>) (json) => json as dynamic,
.map<ShoppingCart>( );
(i) => ShoppingCart.fromJson(i as Map<String, dynamic>))
.toList());
return value; return value;
} }
@override @override
Future<BaseData<SettleOrderInfo>> getOrderInfo(param) async { Future<BaseData<SettleOrderInfo>> getOrderInfo(param) async {
ArgumentError.checkNotNull(param, 'param'); ArgumentError.checkNotNull(param, 'param');
@ -467,4 +465,27 @@ class _MinApiService implements MinApiService {
return value; return value;
} }
// @override
// Future<BaseData<ActivityAreaList>> viewProduct (actProductId,type) async {
// ArgumentError.checkNotNull(actProductId, 'actProductId');
// ArgumentError.checkNotNull(type, 'type');
// const _extra = <String, dynamic>{};
// final queryParameters = <String, dynamic>{};
// final _data = <String, dynamic>{};
// final _result = await _dio.request<Map<String, dynamic>>(
// 'actTemplate/viewProduct?actProductId=$actProductId&type=$type',
// queryParameters: queryParameters,
// options: RequestOptions(
// method: 'GET',
// headers: <String, dynamic>{},
// extra: _extra,
// baseUrl: baseUrl),
// data: _data);
// final value = BaseData<ActivityAreaList>.fromJson(
// _result.data,
// (json) => ActivityAreaList.fromJson(json),
// );
// return value;
// }
} }

8
lib/retrofit/retrofit_api.dart

@ -60,15 +60,15 @@ part 'retrofit_api.g.dart';
// const base_url = "http://platform.prod.kunqi.lotus-wallet.com/app/"; ///222 // const base_url = "http://platform.prod.kunqi.lotus-wallet.com/app/"; ///222
// const baseUrl = "http://platform.prod.kunqi.lotus-wallet.com/app/"; ///222 // const baseUrl = "http://platform.prod.kunqi.lotus-wallet.com/app/"; ///222
const base_url = "http://192.168.10.236:8766/app/"; /// // const base_url = "http://192.168.10.236:8766/app/"; ///
const baseUrl = "http://192.168.10.236:8766/app/"; /// // const baseUrl = "http://192.168.10.236:8766/app/"; ///
// const base_url = "http://192.168.10.37:8766/app/"; // const base_url = "http://192.168.10.37:8766/app/";
// const baseUrl = "http://192.168.10.37:8766/app/"; // const baseUrl = "http://192.168.10.37:8766/app/";
// const base_url = "http://192.168.10.142:8766/app/";/// const base_url = "http://192.168.10.142:8766/app/";///
// const baseUrl = "http://192.168.10.142:8766/app/";/// const baseUrl = "http://192.168.10.142:8766/app/";///
@RestApi(baseUrl: baseUrl) @RestApi(baseUrl: baseUrl)
abstract class ApiService { abstract class ApiService {

2
lib/retrofit/retrofit_api.g.dart

@ -9,7 +9,7 @@ part of 'retrofit_api.dart';
class _ApiService implements ApiService { class _ApiService implements ApiService {
_ApiService(this._dio, {this.baseUrl}) { _ApiService(this._dio, {this.baseUrl}) {
ArgumentError.checkNotNull(_dio, '_dio'); ArgumentError.checkNotNull(_dio, '_dio');
baseUrl ??= 'http://192.168.10.236:8766/app/'; baseUrl ??= 'http://192.168.10.142:8766/app/';
} }
final Dio _dio; final Dio _dio;

974
lib/store/shopping/activity_prefecture_details.dart

File diff suppressed because it is too large Load Diff

13
lib/store/shopping/shopping_cart/shopping_cart_page.dart

@ -53,10 +53,12 @@ class _ShoppingCartPage extends State<ShoppingCartPage>
/// ///
clearShopCar() async { clearShopCar() async {
BaseData<bool> baseData = await minService.clearShoppingCart(); shopCarGoods[0].shoppingCartSkuItemList.forEach((element) {
if (baseData.isSuccess) { if(element.selected == 1){
queryShopCar(); shopCartAdd(element,-element.buyNum,element.selected);
} }
});
queryShopCar();
} }
/// ///
@ -154,7 +156,7 @@ class _ShoppingCartPage extends State<ShoppingCartPage>
cartSkuItem.selected = selected; cartSkuItem.selected = selected;
shopCarTemp["selected"] = selected; shopCarTemp["selected"] = selected;
shopCarTemp["shoppingCartSkuItemList"] = [cartSkuItem.toJson()]; shopCarTemp["shoppingCartSkuItemList"] = [cartSkuItem.toJson()];
BaseData<List<ShoppingCart>> baseDate = BaseData baseDate =
await minService.shoppingCartSingle(shopCarTemp); await minService.shoppingCartSingle(shopCarTemp);
if (baseDate.isSuccess) { if (baseDate.isSuccess) {
setState(() { setState(() {
@ -267,6 +269,7 @@ class _ShoppingCartPage extends State<ShoppingCartPage>
isAllSelect = !isAllSelect; isAllSelect = !isAllSelect;
shopCarGoods[0].shoppingCartSkuItemList.forEach((element) { shopCarGoods[0].shoppingCartSkuItemList.forEach((element) {
element.selected = isAllSelect?1:0; element.selected = isAllSelect?1:0;
shopCartAdd(element,0,element.selected);
}); });
}); });
}, },

5
lib/store/shopping/shopping_home/recommend_goods_list_view.dart

@ -145,14 +145,14 @@ class _RecommendGoodsListView extends State<RecommendGoodsListView> {
Container( Container(
margin: EdgeInsets.only(top: 8, right: 8), margin: EdgeInsets.only(top: 8, right: 8),
padding: EdgeInsets.only(left: 2, right: 2), padding: EdgeInsets.only(left: 2, right: 2),
height: 17.h, height: 18.h,
alignment: Alignment.center, alignment: Alignment.center,
decoration: BoxDecoration( decoration: BoxDecoration(
borderRadius: BorderRadius.circular(2), borderRadius: BorderRadius.circular(2),
color: Color(0xFF5A5A5A), color: Color(0xFF5A5A5A),
), ),
child: Text( child: Text(
homeRecommendList?.supplierName ?? "", AppUtils.textSubStr(homeRecommendList?.supplierName ?? "",8),
style: TextStyle( style: TextStyle(
fontSize: 10.sp, fontSize: 10.sp,
fontWeight: MyFontWeight.regular, fontWeight: MyFontWeight.regular,
@ -226,4 +226,5 @@ class _RecommendGoodsListView extends State<RecommendGoodsListView> {
), ),
); );
} }
} }

7
lib/utils/flutter_utils.dart

@ -164,4 +164,11 @@ class AppUtils {
} }
} }
} }
static String textSubStr(String input, int length) {
length -= 1;
if(length < 0 || input.length < length)
return input;
return "${input.substring(0,length)}...";
}
} }

Loading…
Cancel
Save