From cb9a6a91ba544e027685ca7c26ff7a526f2d5a84 Mon Sep 17 00:00:00 2001 From: fmk Date: Mon, 11 Oct 2021 16:20:19 +0800 Subject: [PATCH] safety --- lib/retrofit/data/findMiNiGroupList.dart | 6 ++--- lib/retrofit/min_api.dart | 12 ++++++--- lib/retrofit/retrofit_api.dart | 8 +++--- lib/store/store_order.dart | 30 +++------------------- lib/store/store_view/store_order_list.dart | 16 +++++++----- lib/union/union_page.dart | 1 + 6 files changed, 30 insertions(+), 43 deletions(-) diff --git a/lib/retrofit/data/findMiNiGroupList.dart b/lib/retrofit/data/findMiNiGroupList.dart index e41b2a90..5f2716c1 100644 --- a/lib/retrofit/data/findMiNiGroupList.dart +++ b/lib/retrofit/data/findMiNiGroupList.dart @@ -15,7 +15,7 @@ class FindMiNiGroupList { List productList; dynamic productPageVO; - static FindMiNiGroupList fromMap(Map map) { + static FindMiNiGroupList fromJson(Map map) { if (map == null) return null; FindMiNiGroupList findMiNiGroupListBean = FindMiNiGroupList(); findMiNiGroupListBean.id = map['id']; @@ -24,7 +24,7 @@ class FindMiNiGroupList { findMiNiGroupListBean.groupImg = map['groupImg']; findMiNiGroupListBean.sort = map['sort']; findMiNiGroupListBean.productList = List()..addAll( - (map['productList'] as List ?? []).map((o) => ProductListBean.fromMap(o)) + (map['productList'] as List ?? []).map((o) => ProductListBean.fromJson(o)) ); findMiNiGroupListBean.productPageVO = map['productPageVO']; return findMiNiGroupListBean; @@ -100,7 +100,7 @@ class ProductListBean { String printerFlag; dynamic markProductNone; - static ProductListBean fromMap(Map map) { + static ProductListBean fromJson(Map map) { if (map == null) return null; ProductListBean productListBean = ProductListBean(); productListBean.id = map['id']; diff --git a/lib/retrofit/min_api.dart b/lib/retrofit/min_api.dart index 3d91dc41..1f0279cf 100644 --- a/lib/retrofit/min_api.dart +++ b/lib/retrofit/min_api.dart @@ -18,8 +18,8 @@ part 'min_api.g.dart'; // const base_url = "https://pos.platform.lotus-wallet.com/app/"; ///正式 // const baseUrl = "https://pos.platform.lotus-wallet.com/app/"; ///正式 -const base_url = "http://192.168.10.236:8766/app/"; ///费韬 -const baseUrl = "http://192.168.10.236:8766/app/"; ///费韬 +const base_url = "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 baseUrl = "http://192.168.10.37:8766/app/"; @@ -31,17 +31,21 @@ abstract class MinApiService { String baseUrl, BuildContext context, String token, + String tenant, bool showLoading = true, bool pay = false, }) { Map headers = (token == null || token == "") ? {} : {'token': "Bearer $token"}; + if (tenant != null && tenant != "") { + headers["tenant"] = tenant; + } if (pay) { headers["Environment"] = "app"; } dio.options = BaseOptions( - connectTimeout: 60000, - receiveTimeout: 60000, + connectTimeout: 10000, + receiveTimeout: 10000, headers: headers, responseType: ResponseType.json, ); diff --git a/lib/retrofit/retrofit_api.dart b/lib/retrofit/retrofit_api.dart index 47280305..c804a5b2 100644 --- a/lib/retrofit/retrofit_api.dart +++ b/lib/retrofit/retrofit_api.dart @@ -37,11 +37,11 @@ import 'data/wx_pay.dart'; part 'retrofit_api.g.dart'; -const base_url = "https://pos.platform.lotus-wallet.com/app/"; ///正式 -const baseUrl = "https://pos.platform.lotus-wallet.com/app/"; ///正式 +// const base_url = "https://pos.platform.lotus-wallet.com/app/"; ///正式 +// const baseUrl = "https://pos.platform.lotus-wallet.com/app/"; ///正式 -// const base_url = "http://192.168.10.236:8766/app/"; ///费韬 -// const baseUrl = "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 base_url = "http://192.168.10.37:8766/app/"; // const baseUrl = "http://192.168.10.37:8766/app/"; diff --git a/lib/store/store_order.dart b/lib/store/store_order.dart index 56a6e9f3..7d4d4566 100644 --- a/lib/store/store_order.dart +++ b/lib/store/store_order.dart @@ -8,6 +8,7 @@ import 'package:huixiang/retrofit/data/activity.dart'; import 'package:huixiang/retrofit/data/base_data.dart'; import 'package:huixiang/retrofit/data/order_info.dart'; import 'package:huixiang/retrofit/data/store_info.dart'; +import 'package:huixiang/retrofit/data/user_entity.dart'; import 'package:huixiang/retrofit/min_api.dart'; import 'package:huixiang/retrofit/retrofit_api.dart'; import 'package:huixiang/store/store_view/store_activity.dart'; @@ -63,7 +64,6 @@ class _StoreOrderPage extends State StoreOrderListPage( widget.arguments, widget.activitys, storeInfo, controller), - ///星店活动, StoreActivity( widget.arguments, @@ -74,27 +74,6 @@ class _StoreOrderPage extends State queryStoreInfo(); } - /// 小程序登录 - minLogin() { - apiService - .minLogin(widget.arguments["id"]) - .catchError((onError) {}) - .then((baseData) { - if (baseData != null && baseData.isSuccess) { - UserEntity userEntity = UserEntity.fromJson(baseData.data); - String minToken = userEntity.token; - SharedPreferences.getInstance().then((value) => { - value.setString('minToken', minToken), - }); - minService = MinApiService( - Dio(), - context: context, - token: minToken, - ); - } - }); - } - /// 查询店铺信息 queryStoreInfo() async { final SharedPreferences value = await SharedPreferences.getInstance(); @@ -104,8 +83,6 @@ class _StoreOrderPage extends State token: value.getString('token'), ); - minLogin(); - BaseData baseData = await apiService .queryStoreInfo(widget.arguments["id"]) .catchError((error) { @@ -243,7 +220,7 @@ class _StoreOrderPage extends State ], ), ), - backgroundColor: Color(0xFFFAFAFA), + backgroundColor: Color(0x33FAFAFA), centerTitle: false, elevation: 0, bottom: PreferredSize( @@ -548,7 +525,7 @@ class _StoreOrderPage extends State ); } - Widget shoppGoodsItem() { + Widget shoppGoodsItem(ProductList pro, position) { return Container( padding: EdgeInsets.only(bottom: 10), child: Row( @@ -698,6 +675,7 @@ class _Title extends State { } if (alpha != alphatemp && mounted) { alpha = alphatemp; + print("object: $alpha"); setState(() {}); } }); diff --git a/lib/store/store_view/store_order_list.dart b/lib/store/store_view/store_order_list.dart index 29fc3454..b1d9f1e9 100644 --- a/lib/store/store_view/store_order_list.dart +++ b/lib/store/store_view/store_order_list.dart @@ -79,15 +79,18 @@ class _StoreOrderListPage extends State<StoreOrderListPage> { apiService.minLogin(widget.arguments["id"]) .catchError((onError){}).then((baseData) { if (baseData != null && baseData.isSuccess) { - UserEntity userEntity = UserEntity.fromJson(baseData.data); - String minToken = userEntity.token; + 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(); } @@ -115,17 +118,18 @@ class _StoreOrderListPage extends State<StoreOrderListPage> { Widget build(BuildContext context) { return Container( width: MediaQuery.of(context).size.width, - height: MediaQuery.of(context).size.height, + height: MediaQuery.of(context).size.height - (kToolbarHeight + 38 + 54.h), + margin: EdgeInsets.only(top: (MediaQuery.of(context).padding.top + 38 + kToolbarHeight)), child: Row( mainAxisAlignment: MainAxisAlignment.start, mainAxisSize: MainAxisSize.max, children: [ Container( width: 100.w, - height: MediaQuery.of(context).size.height, child: ListView.builder( itemCount: appletProducts == null ? 0 : appletProducts.length, - controller: widget.controller, + controller: controller1, + padding: EdgeInsets.zero, itemBuilder: (context, position) { return orderItem(appletProducts[position],position); }, @@ -136,6 +140,7 @@ class _StoreOrderListPage extends State<StoreOrderListPage> { child: ListView.builder( itemCount: productListBeans == null ? 0 : productListBeans.length, // controller: widget.controller, + padding: EdgeInsets.zero, itemBuilder: (context, position) { return goodsItem(productListBeans[position], position); }, @@ -151,7 +156,6 @@ class _StoreOrderListPage extends State<StoreOrderListPage> { Widget orderItem(FindMiNiGroupList findMiNiGroupList,int index) { return Container( - padding: EdgeInsets.only(top:100.h), child: Column( mainAxisAlignment: MainAxisAlignment.spaceAround, crossAxisAlignment: CrossAxisAlignment.center, diff --git a/lib/union/union_page.dart b/lib/union/union_page.dart index 0cd45c2d..a2de2af8 100644 --- a/lib/union/union_page.dart +++ b/lib/union/union_page.dart @@ -279,6 +279,7 @@ class _UnionPage extends State<UnionPage> '/router/store_order', arguments: { "id": storeList[position].id, + "tenant": storeList[position].tenantCode, "storeName": storeList[position].storeName }, );