diff --git a/lib/community/community_details.dart b/lib/community/community_details.dart index 776df1fa..ded19a6e 100644 --- a/lib/community/community_details.dart +++ b/lib/community/community_details.dart @@ -211,7 +211,7 @@ class _CommunityDetails extends State with WidgetsBindingObser "content": content, "parentId": parenId, "relationalId": comunity.id, - "relationalType":4 + "relationalType":1 }).catchError((error) {}); if (baseData != null && baseData.isSuccess) { CommentListState state = commentKey.currentState; diff --git a/lib/main.dart b/lib/main.dart index b3cc5ded..ef5a3403 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -283,9 +283,9 @@ Map routers = { '/router/activity_prefecture_details': (context, {arguments}) => ActivityPrefectureDetails(arguments: arguments), '/router/shopping_goods_details': (context, {arguments}) => - ShoppingGoodsDetails(), + ShoppingGoodsDetails(arguments: arguments), '/router/search_page': (context, {arguments}) => - SearchPage(), + SearchPage(arguments:arguments), '/router/vip_balance': (context, {arguments}) => VipBalancePage(arguments: arguments), '/router/exchange_order_details': (context, {arguments}) => diff --git a/lib/mine/mine_wallet_page.dart b/lib/mine/mine_wallet_page.dart index 1a3eb244..01ff8ccd 100644 --- a/lib/mine/mine_wallet_page.dart +++ b/lib/mine/mine_wallet_page.dart @@ -200,7 +200,6 @@ class _MineWalletPage extends State { Expanded( flex: 1, child: Container( - height: 34.h, child: Column( mainAxisAlignment: MainAxisAlignment.spaceAround, crossAxisAlignment: CrossAxisAlignment.start, diff --git a/lib/retrofit/data/home_recommend_list.dart b/lib/retrofit/data/home_recommend_list.dart new file mode 100644 index 00000000..9b45b10c --- /dev/null +++ b/lib/retrofit/data/home_recommend_list.dart @@ -0,0 +1,416 @@ +/// id : "1473532263365869568" +/// createTime : "2021-12-22 13:54:03" +/// createUser : "1364043181062094848" +/// updateTime : "2021-12-22 13:54:03" +/// updateUser : "1364043181062094848" +/// supplierName : "测试" +/// storeId : "1364043181120815104" +/// categoryId : "1343391656220557312" +/// groupId : "1473531667711787008" +/// shortName : "可爱" +/// productName : "回乡牛公仔" +/// sellDesc : "" +/// productCode : "PRO202112221354030000000000004" +/// weight : "0" +/// applyPrice : "0.00" +/// price : "49.00" +/// stock : 0 +/// sellCount : 0 +/// needLogistics : 1 +/// oversold : 1 +/// organic : 0 +/// status : 1 +/// posShow : true +/// productType : 0 +/// productNumber : 1 +/// setMeal : 1 +/// attrStyle : 0 +/// detail : "" +/// isDelete : 0 +/// printerFlag : "DEFAULT" +/// materialId : null +/// imgs : ["https://pos.upload.gznl.top/1179/2021/12/1bff0936-f2a2-401e-befd-e00b416763ad.png"] +/// productSkuList : [{"id":"1473532264519303168","createTime":"2021-12-22 13:54:03","createUser":"1364043181062094848","updateTime":"2021-12-22 13:54:03","updateUser":"1364043181062094848","storeId":"1364043181120815104","skuCode":"P202112221354035","skuNameStr":"","productId":"1473532263365869568","skuPrice":"49.00","applyPrice":"0.00","vipPrice":null,"skuImg":null,"skuStock":0,"sort":50,"setMeal":"","weight":0.0,"volume":0.0,"isDelete":0,"material":null,"version":0}] + +class HomeRecommendList { + HomeRecommendList({ + String id, + String createTime, + String createUser, + String updateTime, + String updateUser, + String supplierName, + String storeId, + String categoryId, + String groupId, + String shortName, + String productName, + String sellDesc, + String productCode, + String weight, + String applyPrice, + String price, + int stock, + int sellCount, + int needLogistics, + int oversold, + int organic, + int status, + bool posShow, + int productType, + int productNumber, + int setMeal, + int attrStyle, + String detail, + int isDelete, + String printerFlag, + dynamic materialId, + List imgs, + List productSkuList,}){ + _id = id; + _createTime = createTime; + _createUser = createUser; + _updateTime = updateTime; + _updateUser = updateUser; + _supplierName = supplierName; + _storeId = storeId; + _categoryId = categoryId; + _groupId = groupId; + _shortName = shortName; + _productName = productName; + _sellDesc = sellDesc; + _productCode = productCode; + _weight = weight; + _applyPrice = applyPrice; + _price = price; + _stock = stock; + _sellCount = sellCount; + _needLogistics = needLogistics; + _oversold = oversold; + _organic = organic; + _status = status; + _posShow = posShow; + _productType = productType; + _productNumber = productNumber; + _setMeal = setMeal; + _attrStyle = attrStyle; + _detail = detail; + _isDelete = isDelete; + _printerFlag = printerFlag; + _materialId = materialId; + _imgs = imgs; + _productSkuList = productSkuList; +} + + HomeRecommendList.fromJson(dynamic json) { + _id = json['id']; + _createTime = json['createTime']; + _createUser = json['createUser']; + _updateTime = json['updateTime']; + _updateUser = json['updateUser']; + _supplierName = json['supplierName']; + _storeId = json['storeId']; + _categoryId = json['categoryId']; + _groupId = json['groupId']; + _shortName = json['shortName']; + _productName = json['productName']; + _sellDesc = json['sellDesc']; + _productCode = json['productCode']; + _weight = json['weight']; + _applyPrice = json['applyPrice']; + _price = json['price']; + _stock = json['stock']; + _sellCount = json['sellCount']; + _needLogistics = json['needLogistics']; + _oversold = json['oversold']; + _organic = json['organic']; + _status = json['status']; + _posShow = json['posShow']; + _productType = json['productType']; + _productNumber = json['productNumber']; + _setMeal = json['setMeal']; + _attrStyle = json['attrStyle']; + _detail = json['detail']; + _isDelete = json['isDelete']; + _printerFlag = json['printerFlag']; + _materialId = json['materialId']; + _imgs = json['imgs'] != null ? json['imgs'].cast() : []; + if (json['productSkuList'] != null) { + _productSkuList = []; + json['productSkuList'].forEach((v) { + _productSkuList.add(ProductSkuList.fromJson(v)); + }); + } + } + String _id; + String _createTime; + String _createUser; + String _updateTime; + String _updateUser; + String _supplierName; + String _storeId; + String _categoryId; + String _groupId; + String _shortName; + String _productName; + String _sellDesc; + String _productCode; + String _weight; + String _applyPrice; + String _price; + int _stock; + int _sellCount; + int _needLogistics; + int _oversold; + int _organic; + int _status; + bool _posShow; + int _productType; + int _productNumber; + int _setMeal; + int _attrStyle; + String _detail; + int _isDelete; + String _printerFlag; + dynamic _materialId; + List _imgs; + List _productSkuList; + + String get id => _id; + String get createTime => _createTime; + String get createUser => _createUser; + String get updateTime => _updateTime; + String get updateUser => _updateUser; + String get supplierName => _supplierName; + String get storeId => _storeId; + String get categoryId => _categoryId; + String get groupId => _groupId; + String get shortName => _shortName; + String get productName => _productName; + String get sellDesc => _sellDesc; + String get productCode => _productCode; + String get weight => _weight; + String get applyPrice => _applyPrice; + String get price => _price; + int get stock => _stock; + int get sellCount => _sellCount; + int get needLogistics => _needLogistics; + int get oversold => _oversold; + int get organic => _organic; + int get status => _status; + bool get posShow => _posShow; + int get productType => _productType; + int get productNumber => _productNumber; + int get setMeal => _setMeal; + int get attrStyle => _attrStyle; + String get detail => _detail; + int get isDelete => _isDelete; + String get printerFlag => _printerFlag; + dynamic get materialId => _materialId; + List get imgs => _imgs; + List get productSkuList => _productSkuList; + + Map toJson() { + final map = {}; + map['id'] = _id; + map['createTime'] = _createTime; + map['createUser'] = _createUser; + map['updateTime'] = _updateTime; + map['updateUser'] = _updateUser; + map['supplierName'] = _supplierName; + map['storeId'] = _storeId; + map['categoryId'] = _categoryId; + map['groupId'] = _groupId; + map['shortName'] = _shortName; + map['productName'] = _productName; + map['sellDesc'] = _sellDesc; + map['productCode'] = _productCode; + map['weight'] = _weight; + map['applyPrice'] = _applyPrice; + map['price'] = _price; + map['stock'] = _stock; + map['sellCount'] = _sellCount; + map['needLogistics'] = _needLogistics; + map['oversold'] = _oversold; + map['organic'] = _organic; + map['status'] = _status; + map['posShow'] = _posShow; + map['productType'] = _productType; + map['productNumber'] = _productNumber; + map['setMeal'] = _setMeal; + map['attrStyle'] = _attrStyle; + map['detail'] = _detail; + map['isDelete'] = _isDelete; + map['printerFlag'] = _printerFlag; + map['materialId'] = _materialId; + map['imgs'] = _imgs; + if (_productSkuList != null) { + map['productSkuList'] = _productSkuList.map((v) => v.toJson()).toList(); + } + return map; + } + +} + +/// id : "1473532264519303168" +/// createTime : "2021-12-22 13:54:03" +/// createUser : "1364043181062094848" +/// updateTime : "2021-12-22 13:54:03" +/// updateUser : "1364043181062094848" +/// storeId : "1364043181120815104" +/// skuCode : "P202112221354035" +/// skuNameStr : "" +/// productId : "1473532263365869568" +/// skuPrice : "49.00" +/// applyPrice : "0.00" +/// vipPrice : null +/// skuImg : null +/// skuStock : 0 +/// sort : 50 +/// setMeal : "" +/// weight : 0.0 +/// volume : 0.0 +/// isDelete : 0 +/// material : null +/// version : 0 + +class ProductSkuList { + ProductSkuList({ + String id, + String createTime, + String createUser, + String updateTime, + String updateUser, + String storeId, + String skuCode, + String skuNameStr, + String productId, + String skuPrice, + String applyPrice, + dynamic vipPrice, + dynamic skuImg, + int skuStock, + int sort, + String setMeal, + double weight, + double volume, + int isDelete, + dynamic material, + int version,}){ + _id = id; + _createTime = createTime; + _createUser = createUser; + _updateTime = updateTime; + _updateUser = updateUser; + _storeId = storeId; + _skuCode = skuCode; + _skuNameStr = skuNameStr; + _productId = productId; + _skuPrice = skuPrice; + _applyPrice = applyPrice; + _vipPrice = vipPrice; + _skuImg = skuImg; + _skuStock = skuStock; + _sort = sort; + _setMeal = setMeal; + _weight = weight; + _volume = volume; + _isDelete = isDelete; + _material = material; + _version = version; +} + + ProductSkuList.fromJson(dynamic json) { + _id = json['id']; + _createTime = json['createTime']; + _createUser = json['createUser']; + _updateTime = json['updateTime']; + _updateUser = json['updateUser']; + _storeId = json['storeId']; + _skuCode = json['skuCode']; + _skuNameStr = json['skuNameStr']; + _productId = json['productId']; + _skuPrice = json['skuPrice']; + _applyPrice = json['applyPrice']; + _vipPrice = json['vipPrice']; + _skuImg = json['skuImg']; + _skuStock = json['skuStock']; + _sort = json['sort']; + _setMeal = json['setMeal']; + _weight = json['weight']; + _volume = json['volume']; + _isDelete = json['isDelete']; + _material = json['material']; + _version = json['version']; + } + String _id; + String _createTime; + String _createUser; + String _updateTime; + String _updateUser; + String _storeId; + String _skuCode; + String _skuNameStr; + String _productId; + String _skuPrice; + String _applyPrice; + dynamic _vipPrice; + dynamic _skuImg; + int _skuStock; + int _sort; + String _setMeal; + double _weight; + double _volume; + int _isDelete; + dynamic _material; + int _version; + + String get id => _id; + String get createTime => _createTime; + String get createUser => _createUser; + String get updateTime => _updateTime; + String get updateUser => _updateUser; + String get storeId => _storeId; + String get skuCode => _skuCode; + String get skuNameStr => _skuNameStr; + String get productId => _productId; + String get skuPrice => _skuPrice; + String get applyPrice => _applyPrice; + dynamic get vipPrice => _vipPrice; + dynamic get skuImg => _skuImg; + int get skuStock => _skuStock; + int get sort => _sort; + String get setMeal => _setMeal; + double get weight => _weight; + double get volume => _volume; + int get isDelete => _isDelete; + dynamic get material => _material; + int get version => _version; + + Map toJson() { + final map = {}; + map['id'] = _id; + map['createTime'] = _createTime; + map['createUser'] = _createUser; + map['updateTime'] = _updateTime; + map['updateUser'] = _updateUser; + map['storeId'] = _storeId; + map['skuCode'] = _skuCode; + map['skuNameStr'] = _skuNameStr; + map['productId'] = _productId; + map['skuPrice'] = _skuPrice; + map['applyPrice'] = _applyPrice; + map['vipPrice'] = _vipPrice; + map['skuImg'] = _skuImg; + map['skuStock'] = _skuStock; + map['sort'] = _sort; + map['setMeal'] = _setMeal; + map['weight'] = _weight; + map['volume'] = _volume; + map['isDelete'] = _isDelete; + map['material'] = _material; + map['version'] = _version; + return map; + } + +} \ No newline at end of file diff --git a/lib/retrofit/data/miNiDetail.dart b/lib/retrofit/data/miNiDetail.dart index f7ee0fd5..3a855f87 100644 --- a/lib/retrofit/data/miNiDetail.dart +++ b/lib/retrofit/data/miNiDetail.dart @@ -61,12 +61,14 @@ class MiNiDetail { int sellCount; int needLogistics; int oversold; + int organic; int status; bool posShow; int productType; int productNumber; int setMeal; int attrStyle; + String detail; int isDelete; String printerFlag; dynamic materialId; @@ -106,12 +108,14 @@ class MiNiDetail { miNiDetailBean.sellCount = map['sellCount']; miNiDetailBean.needLogistics = map['needLogistics']; miNiDetailBean.oversold = map['oversold']; + miNiDetailBean.organic = map['organic']; miNiDetailBean.status = map['status']; miNiDetailBean.posShow = map['posShow']; miNiDetailBean.productType = map['productType']; miNiDetailBean.productNumber = map['productNumber']; miNiDetailBean.setMeal = map['setMeal']; miNiDetailBean.attrStyle = map['attrStyle']; + miNiDetailBean.detail = map['detail']; miNiDetailBean.isDelete = map['isDelete']; miNiDetailBean.printerFlag = map['printerFlag']; miNiDetailBean.materialId = map['materialId']; @@ -157,12 +161,14 @@ class MiNiDetail { "sellCount": sellCount, "needLogistics": needLogistics, "oversold": oversold, + "organic" : organic, "status": status, "posShow": posShow, "productType": productType, "productNumber": productNumber, "setMeal": setMeal, "attrStyle": attrStyle, + "detail" :detail, "isDelete": isDelete, "printerFlag": printerFlag, "materialId": materialId, diff --git a/lib/retrofit/data/shoppingCart.dart b/lib/retrofit/data/shoppingCart.dart index 2126eb88..eb18422b 100644 --- a/lib/retrofit/data/shoppingCart.dart +++ b/lib/retrofit/data/shoppingCart.dart @@ -18,6 +18,7 @@ class ShoppingCart { int selectDiscount; String storeName; String tableId; + bool isSelect; List promotionInfoList; List couponList; diff --git a/lib/retrofit/data/shopping_home_config.dart b/lib/retrofit/data/shopping_home_config.dart new file mode 100644 index 00000000..7ebb21ad --- /dev/null +++ b/lib/retrofit/data/shopping_home_config.dart @@ -0,0 +1,740 @@ +/// specialArea : [{"img":"https://pos.upload.gznl.top/1179/2021/12/fe209ded-a504-4319-9c8d-6d8478785e78.jpg","id":"1064355492","productList":[{"productImg":"https://pos.upload.gznl.top/1179/2021/12/755b69d6-0047-44fe-9593-edac72fb9982.png","productSkuVOList":[{"productId":"1473532887297949696","isDelete":0,"setMeal":"","updateUser":"1364043181062094848","skuPrice":"25.00","skuStock":0,"weight":0,"updateTime":"2021-12-22 13:56:32","storeId":"1364043181120815104","volume":0,"skuNameStr":"","createTime":"2021-12-22 13:56:32","createUser":"1364043181062094848","id":"1473532888409440256","applyPrice":"0.00","skuAttrList":[{"attrValueId":"1473532887918706688","isDelete":0,"updateUser":"1364043181062094848","updateTime":"2021-12-22 13:56:32","attrId":"1473532887704797184","createTime":"2021-12-22 13:56:32","createUser":"1364043181062094848","id":"1473532888619155456","skuId":"1473532888409440256"}],"skuCode":"P202112221356324"}],"productName":"有机草莓干","posShow":true,"attrList":[{"productId":"1473532887297949696","isDelete":0,"needImg":false,"attrValueList":[{"isDelete":0,"attrId":"1473532887704797184","id":"1473532887918706688","attrValue":"","attrValueImg":""}],"id":"1473532887704797184","attrName":""}],"price":"25.00","sellCount":0,"id":"1473532887297949696","applyPrice":"0.00","stock":0,"status":1},{"productImg":"https://pos.upload.gznl.top/1179/2021/12/c24dbb2c-91b9-47be-85c5-d9f05ffa4d59.png","productSkuVOList":[{"productId":"1473532682649468928","isDelete":0,"setMeal":"","updateUser":"1364043181062094848","skuPrice":"35.00","skuStock":0,"weight":0,"updateTime":"2021-12-22 13:55:44","storeId":"1364043181120815104","volume":0,"skuNameStr":"","createTime":"2021-12-22 13:55:44","createUser":"1364043181062094848","id":"1473532684721455104","applyPrice":"0.00","skuAttrList":[{"attrValueId":"1473532683257643008","isDelete":0,"updateUser":"1364043181062094848","updateTime":"2021-12-22 13:55:44","attrId":"1473532683052122112","createTime":"2021-12-22 13:55:44","createUser":"1364043181062094848","id":"1473532684935364608","skuId":"1473532684721455104"}],"skuCode":"P202112221355432"}],"productName":"有机午餐一顿","posShow":true,"attrList":[{"productId":"1473532682649468928","isDelete":0,"needImg":false,"attrValueList":[{"isDelete":0,"attrId":"1473532683052122112","id":"1473532683257643008","attrValue":"","attrValueImg":""}],"id":"1473532683052122112","attrName":""}],"price":"35.00","sellCount":0,"id":"1473532682649468928","applyPrice":"0.00","stock":0,"status":1}]},{"img":"https://pos.upload.gznl.top/1179/2021/12/24fe72c9-8a2b-4a9d-968f-2037d71a1705.jpg","id":"8828438334","productList":[{"productImg":"https://pos.upload.gznl.top/1179/2021/12/755b69d6-0047-44fe-9593-edac72fb9982.png","productSkuVOList":[{"productId":"1473532887297949696","isDelete":0,"setMeal":"","updateUser":"1364043181062094848","skuPrice":"25.00","skuStock":0,"weight":0,"updateTime":"2021-12-22 13:56:32","storeId":"1364043181120815104","volume":0,"skuNameStr":"","createTime":"2021-12-22 13:56:32","createUser":"1364043181062094848","id":"1473532888409440256","applyPrice":"0.00","skuAttrList":[{"attrValueId":"1473532887918706688","isDelete":0,"updateUser":"1364043181062094848","updateTime":"2021-12-22 13:56:32","attrId":"1473532887704797184","createTime":"2021-12-22 13:56:32","createUser":"1364043181062094848","id":"1473532888619155456","skuId":"1473532888409440256"}],"skuCode":"P202112221356324"}],"productName":"有机草莓干","posShow":true,"attrList":[{"productId":"1473532887297949696","isDelete":0,"needImg":false,"attrValueList":[{"isDelete":0,"attrId":"1473532887704797184","id":"1473532887918706688","attrValue":"","attrValueImg":""}],"id":"1473532887704797184","attrName":""}],"price":"25.00","sellCount":0,"id":"1473532887297949696","applyPrice":"0.00","stock":0,"status":1},{"productImg":"https://pos.upload.gznl.top/1179/2021/12/c24dbb2c-91b9-47be-85c5-d9f05ffa4d59.png","productSkuVOList":[{"productId":"1473532682649468928","isDelete":0,"setMeal":"","updateUser":"1364043181062094848","skuPrice":"35.00","skuStock":0,"weight":0,"updateTime":"2021-12-22 13:55:44","storeId":"1364043181120815104","volume":0,"skuNameStr":"","createTime":"2021-12-22 13:55:44","createUser":"1364043181062094848","id":"1473532684721455104","applyPrice":"0.00","skuAttrList":[{"attrValueId":"1473532683257643008","isDelete":0,"updateUser":"1364043181062094848","updateTime":"2021-12-22 13:55:44","attrId":"1473532683052122112","createTime":"2021-12-22 13:55:44","createUser":"1364043181062094848","id":"1473532684935364608","skuId":"1473532684721455104"}],"skuCode":"P202112221355432"}],"productName":"有机午餐一顿","posShow":true,"attrList":[{"productId":"1473532682649468928","isDelete":0,"needImg":false,"attrValueList":[{"isDelete":0,"attrId":"1473532683052122112","id":"1473532683257643008","attrValue":"","attrValueImg":""}],"id":"1473532683052122112","attrName":""}],"price":"35.00","sellCount":0,"id":"1473532682649468928","applyPrice":"0.00","stock":0,"status":1},{"productImg":"https://pos.upload.gznl.top/1179/2021/12/1bff0936-f2a2-401e-befd-e00b416763ad.png","productSkuVOList":[{"productId":"1473532263365869568","isDelete":0,"setMeal":"","updateUser":"1364043181062094848","skuPrice":"49.00","skuStock":0,"weight":0,"updateTime":"2021-12-22 13:54:03","storeId":"1364043181120815104","volume":0,"skuNameStr":"","createTime":"2021-12-22 13:54:03","createUser":"1364043181062094848","id":"1473532264519303168","applyPrice":"0.00","skuAttrList":[{"attrValueId":"1473532264032763904","isDelete":0,"updateUser":"1364043181062094848","updateTime":"2021-12-22 13:54:03","attrId":"1473532263827243008","createTime":"2021-12-22 13:54:03","createUser":"1364043181062094848","id":"1473532264716435456","skuId":"1473532264519303168"}],"skuCode":"P202112221354035"}],"productName":"回乡牛公仔","posShow":true,"attrList":[{"productId":"1473532263365869568","isDelete":0,"needImg":false,"attrValueList":[{"isDelete":0,"attrId":"1473532263827243008","id":"1473532264032763904","attrValue":"","attrValueImg":""}],"id":"1473532263827243008","attrName":""}],"price":"49.00","sellCount":0,"id":"1473532263365869568","applyPrice":"0.00","stock":0,"status":1},{"productImg":"https://pos.upload.gznl.top/1179/2021/12/eff19bf8-8986-4b14-aa3a-b39dd7df70ab.png","productSkuVOList":[{"productId":"1473532108914819072","isDelete":0,"setMeal":"","updateUser":"1364043181062094848","skuPrice":"66.00","skuStock":0,"weight":0,"updateTime":"2021-12-22 13:53:27","storeId":"1364043181120815104","volume":0,"skuNameStr":"箱装5000g","createTime":"2021-12-22 13:53:27","createUser":"1364043181062094848","id":"1473532110689009664","applyPrice":"0.00","skuAttrList":[{"attrValueId":"1473532109816594432","isDelete":0,"updateUser":"1364043181062094848","updateTime":"2021-12-22 13:53:27","attrId":"1473532109514604544","createTime":"2021-12-22 13:53:27","createUser":"1364043181062094848","id":"1473532110915502080","skuId":"1473532110689009664"}],"skuCode":"P202112221353262"},{"productId":"1473532108914819072","isDelete":0,"setMeal":"","updateUser":"1364043181062094848","skuPrice":"15.00","skuStock":0,"weight":0,"updateTime":"2021-12-22 13:53:27","storeId":"1364043181120815104","volume":0,"skuNameStr":"袋装1000g","createTime":"2021-12-22 13:53:27","createUser":"1364043181062094848","id":"1473532111414624256","applyPrice":"0.00","skuAttrList":[{"attrValueId":"1473532110051475456","isDelete":0,"updateUser":"1364043181062094848","updateTime":"2021-12-22 13:53:27","attrId":"1473532109514604544","createTime":"2021-12-22 13:53:27","createUser":"1364043181062094848","id":"1473532111624339456","skuId":"1473532111414624256"}],"skuCode":"P202112221353263"}],"productName":"正宗芒果干","posShow":true,"attrList":[{"productId":"1473532108914819072","isDelete":0,"needImg":false,"attrValueList":[{"isDelete":0,"attrId":"1473532109514604544","id":"1473532109816594432","attrValue":"箱装5000g","attrValueImg":""},{"isDelete":0,"attrId":"1473532109514604544","id":"1473532110051475456","attrValue":"袋装1000g","attrValueImg":""}],"id":"1473532109514604544","attrName":"规格"}],"price":"15.00","sellCount":0,"id":"1473532108914819072","applyPrice":"0.00","stock":0,"status":1}]}] +/// quickEntry : [{"img":"https://pos.upload.gznl.top/1179/2021/12/df9db6ba-4ef8-4962-8ae0-57a7d8140462.png","url":"/router/activity_prefecture_details?type=1","id":"4072162773"},{"img":"https://pos.upload.gznl.top/1179/2021/12/56d86c69-4044-4b08-818f-7cda2ae384d0.png","url":"/router/activity_prefecture_details?type=2","id":"4166165221"},{"img":"https://pos.upload.gznl.top/1179/2021/12/ef7da2a6-d501-424e-bc45-4d9f3f315f36.png","url":"/router/activity_prefecture_d3tails?type=3","id":"2717561527"}] +/// hotSearch : ["好","可以","verygod ","ssad","asda"] +/// categoryGroup : [{"groupList":[{"isDelete":0,"updateUser":"1364043181062094848","updateTime":"2021-12-22 13:50:12","groupImg":"https://pos.upload.gznl.top/1179/2021/12/4ff84bf7-1fca-4034-94e7-1c657917716f.png","sort":1,"storeId":"1364043181120815104","groupName":"回乡水果","createTime":"2021-12-22 13:50:12","kitchenGroup":0,"printerId":"1473531135496552448","createUser":"1364043181062094848","isCharge":0,"id":"1473531295907708928"},{"isDelete":0,"updateUser":"1364043181062094848","updateTime":"2021-12-22 13:51:41","groupImg":"https://pos.upload.gznl.top/1179/2021/12/506f72e7-86b8-4bcb-a55b-b48572675d2f.png","sort":1,"storeId":"1364043181120815104","groupName":"回乡周边","createTime":"2021-12-22 13:51:41","kitchenGroup":0,"printerId":"1473531135496552448","createUser":"1364043181062094848","isCharge":0,"id":"1473531667711787008"},{"isDelete":0,"updateUser":"1364043181062094848","updateTime":"2021-12-22 13:55:04","groupImg":"https://pos.upload.gznl.top/1179/2021/12/9864e0ba-dbb2-4bfd-935e-7fc4c0580760.png","sort":1,"storeId":"1364043181120815104","groupName":"回乡门票","createTime":"2021-12-22 13:55:04","kitchenGroup":0,"printerId":"1473531135496552448","createUser":"1364043181062094848","isCharge":0,"id":"1473532517066735616"}],"groupCommodityName":"22","name":"22"},{"groupList":[],"groupCommodityName":"2244","name":"2244"},{"groupList":[],"groupCommodityName":"224455","name":"224455"},{"groupList":[],"groupCommodityName":"22445566","name":"22445566"}] + +class ShoppingHomeConfig { + ShoppingHomeConfig({ + List specialArea, + List quickEntry, + List hotSearch, + List categoryGroup,}){ + _specialArea = specialArea; + _quickEntry = quickEntry; + _hotSearch = hotSearch; + _categoryGroup = categoryGroup; +} + + ShoppingHomeConfig.fromJson(dynamic json) { + if (json['specialArea'] != null) { + _specialArea = []; + json['specialArea'].forEach((v) { + _specialArea.add(SpecialArea.fromJson(v)); + }); + } + if (json['quickEntry'] != null) { + _quickEntry = []; + json['quickEntry'].forEach((v) { + _quickEntry.add(QuickEntry.fromJson(v)); + }); + } + _hotSearch = json['hotSearch'] != null ? json['hotSearch'].cast() : []; + if (json['categoryGroup'] != null) { + _categoryGroup = []; + json['categoryGroup'].forEach((v) { + _categoryGroup.add(CategoryGroup.fromJson(v)); + }); + } + } + List _specialArea; + List _quickEntry; + List _hotSearch; + List _categoryGroup; + + List get specialArea => _specialArea; + List get quickEntry => _quickEntry; + List get hotSearch => _hotSearch; + List get categoryGroup => _categoryGroup; + + Map toJson() { + final map = {}; + if (_specialArea != null) { + map['specialArea'] = _specialArea.map((v) => v.toJson()).toList(); + } + if (_quickEntry != null) { + map['quickEntry'] = _quickEntry.map((v) => v.toJson()).toList(); + } + map['hotSearch'] = _hotSearch; + if (_categoryGroup != null) { + map['categoryGroup'] = _categoryGroup.map((v) => v.toJson()).toList(); + } + return map; + } + +} + +/// groupList : [{"isDelete":0,"updateUser":"1364043181062094848","updateTime":"2021-12-22 13:50:12","groupImg":"https://pos.upload.gznl.top/1179/2021/12/4ff84bf7-1fca-4034-94e7-1c657917716f.png","sort":1,"storeId":"1364043181120815104","groupName":"回乡水果","createTime":"2021-12-22 13:50:12","kitchenGroup":0,"printerId":"1473531135496552448","createUser":"1364043181062094848","isCharge":0,"id":"1473531295907708928"},{"isDelete":0,"updateUser":"1364043181062094848","updateTime":"2021-12-22 13:51:41","groupImg":"https://pos.upload.gznl.top/1179/2021/12/506f72e7-86b8-4bcb-a55b-b48572675d2f.png","sort":1,"storeId":"1364043181120815104","groupName":"回乡周边","createTime":"2021-12-22 13:51:41","kitchenGroup":0,"printerId":"1473531135496552448","createUser":"1364043181062094848","isCharge":0,"id":"1473531667711787008"},{"isDelete":0,"updateUser":"1364043181062094848","updateTime":"2021-12-22 13:55:04","groupImg":"https://pos.upload.gznl.top/1179/2021/12/9864e0ba-dbb2-4bfd-935e-7fc4c0580760.png","sort":1,"storeId":"1364043181120815104","groupName":"回乡门票","createTime":"2021-12-22 13:55:04","kitchenGroup":0,"printerId":"1473531135496552448","createUser":"1364043181062094848","isCharge":0,"id":"1473532517066735616"}] +/// groupCommodityName : "22" +/// name : "22" + +class CategoryGroup { + CategoryGroup({ + List groupList, + String groupCommodityName, + String name,}){ + _groupList = groupList; + _groupCommodityName = groupCommodityName; + _name = name; +} + + CategoryGroup.fromJson(dynamic json) { + if (json['groupList'] != null) { + _groupList = []; + json['groupList'].forEach((v) { + _groupList.add(GroupList.fromJson(v)); + }); + } + _groupCommodityName = json['groupCommodityName']; + _name = json['name']; + } + List _groupList; + String _groupCommodityName; + String _name; + + List get groupList => _groupList; + String get groupCommodityName => _groupCommodityName; + String get name => _name; + + Map toJson() { + final map = {}; + if (_groupList != null) { + map['groupList'] = _groupList.map((v) => v.toJson()).toList(); + } + map['groupCommodityName'] = _groupCommodityName; + map['name'] = _name; + return map; + } + +} + +/// isDelete : 0 +/// updateUser : "1364043181062094848" +/// updateTime : "2021-12-22 13:50:12" +/// groupImg : "https://pos.upload.gznl.top/1179/2021/12/4ff84bf7-1fca-4034-94e7-1c657917716f.png" +/// sort : 1 +/// storeId : "1364043181120815104" +/// groupName : "回乡水果" +/// createTime : "2021-12-22 13:50:12" +/// kitchenGroup : 0 +/// printerId : "1473531135496552448" +/// createUser : "1364043181062094848" +/// isCharge : 0 +/// id : "1473531295907708928" + +class GroupList { + GroupList({ + int isDelete, + String updateUser, + String updateTime, + String groupImg, + int sort, + String storeId, + String groupName, + String createTime, + int kitchenGroup, + String printerId, + String createUser, + int isCharge, + String id,}){ + _isDelete = isDelete; + _updateUser = updateUser; + _updateTime = updateTime; + _groupImg = groupImg; + _sort = sort; + _storeId = storeId; + _groupName = groupName; + _createTime = createTime; + _kitchenGroup = kitchenGroup; + _printerId = printerId; + _createUser = createUser; + _isCharge = isCharge; + _id = id; +} + + GroupList.fromJson(dynamic json) { + _isDelete = json['isDelete']; + _updateUser = json['updateUser']; + _updateTime = json['updateTime']; + _groupImg = json['groupImg']; + _sort = json['sort']; + _storeId = json['storeId']; + _groupName = json['groupName']; + _createTime = json['createTime']; + _kitchenGroup = json['kitchenGroup']; + _printerId = json['printerId']; + _createUser = json['createUser']; + _isCharge = json['isCharge']; + _id = json['id']; + } + int _isDelete; + String _updateUser; + String _updateTime; + String _groupImg; + int _sort; + String _storeId; + String _groupName; + String _createTime; + int _kitchenGroup; + String _printerId; + String _createUser; + int _isCharge; + String _id; + + int get isDelete => _isDelete; + String get updateUser => _updateUser; + String get updateTime => _updateTime; + String get groupImg => _groupImg; + int get sort => _sort; + String get storeId => _storeId; + String get groupName => _groupName; + String get createTime => _createTime; + int get kitchenGroup => _kitchenGroup; + String get printerId => _printerId; + String get createUser => _createUser; + int get isCharge => _isCharge; + String get id => _id; + + Map toJson() { + final map = {}; + map['isDelete'] = _isDelete; + map['updateUser'] = _updateUser; + map['updateTime'] = _updateTime; + map['groupImg'] = _groupImg; + map['sort'] = _sort; + map['storeId'] = _storeId; + map['groupName'] = _groupName; + map['createTime'] = _createTime; + map['kitchenGroup'] = _kitchenGroup; + map['printerId'] = _printerId; + map['createUser'] = _createUser; + map['isCharge'] = _isCharge; + map['id'] = _id; + return map; + } + +} + +/// img : "https://pos.upload.gznl.top/1179/2021/12/df9db6ba-4ef8-4962-8ae0-57a7d8140462.png" +/// url : "/router/activity_prefecture_details?type=1" +/// id : "4072162773" + +class QuickEntry { + QuickEntry({ + String img, + String url, + String id,}){ + _img = img; + _url = url; + _id = id; +} + + QuickEntry.fromJson(dynamic json) { + _img = json['img']; + _url = json['url']; + _id = json['id']; + } + String _img; + String _url; + String _id; + + String get img => _img; + String get url => _url; + String get id => _id; + + Map toJson() { + final map = {}; + map['img'] = _img; + map['url'] = _url; + map['id'] = _id; + return map; + } + +} + +/// img : "https://pos.upload.gznl.top/1179/2021/12/fe209ded-a504-4319-9c8d-6d8478785e78.jpg" +/// id : "1064355492" +/// productList : [{"productImg":"https://pos.upload.gznl.top/1179/2021/12/755b69d6-0047-44fe-9593-edac72fb9982.png","productSkuVOList":[{"productId":"1473532887297949696","isDelete":0,"setMeal":"","updateUser":"1364043181062094848","skuPrice":"25.00","skuStock":0,"weight":0,"updateTime":"2021-12-22 13:56:32","storeId":"1364043181120815104","volume":0,"skuNameStr":"","createTime":"2021-12-22 13:56:32","createUser":"1364043181062094848","id":"1473532888409440256","applyPrice":"0.00","skuAttrList":[{"attrValueId":"1473532887918706688","isDelete":0,"updateUser":"1364043181062094848","updateTime":"2021-12-22 13:56:32","attrId":"1473532887704797184","createTime":"2021-12-22 13:56:32","createUser":"1364043181062094848","id":"1473532888619155456","skuId":"1473532888409440256"}],"skuCode":"P202112221356324"}],"productName":"有机草莓干","posShow":true,"attrList":[{"productId":"1473532887297949696","isDelete":0,"needImg":false,"attrValueList":[{"isDelete":0,"attrId":"1473532887704797184","id":"1473532887918706688","attrValue":"","attrValueImg":""}],"id":"1473532887704797184","attrName":""}],"price":"25.00","sellCount":0,"id":"1473532887297949696","applyPrice":"0.00","stock":0,"status":1},{"productImg":"https://pos.upload.gznl.top/1179/2021/12/c24dbb2c-91b9-47be-85c5-d9f05ffa4d59.png","productSkuVOList":[{"productId":"1473532682649468928","isDelete":0,"setMeal":"","updateUser":"1364043181062094848","skuPrice":"35.00","skuStock":0,"weight":0,"updateTime":"2021-12-22 13:55:44","storeId":"1364043181120815104","volume":0,"skuNameStr":"","createTime":"2021-12-22 13:55:44","createUser":"1364043181062094848","id":"1473532684721455104","applyPrice":"0.00","skuAttrList":[{"attrValueId":"1473532683257643008","isDelete":0,"updateUser":"1364043181062094848","updateTime":"2021-12-22 13:55:44","attrId":"1473532683052122112","createTime":"2021-12-22 13:55:44","createUser":"1364043181062094848","id":"1473532684935364608","skuId":"1473532684721455104"}],"skuCode":"P202112221355432"}],"productName":"有机午餐一顿","posShow":true,"attrList":[{"productId":"1473532682649468928","isDelete":0,"needImg":false,"attrValueList":[{"isDelete":0,"attrId":"1473532683052122112","id":"1473532683257643008","attrValue":"","attrValueImg":""}],"id":"1473532683052122112","attrName":""}],"price":"35.00","sellCount":0,"id":"1473532682649468928","applyPrice":"0.00","stock":0,"status":1}] + +class SpecialArea { + SpecialArea({ + String img, + String id, + List productList,}){ + _img = img; + _id = id; + _productList = productList; +} + + SpecialArea.fromJson(dynamic json) { + _img = json['img']; + _id = json['id']; + if (json['productList'] != null) { + _productList = []; + json['productList'].forEach((v) { + _productList.add(ProductList.fromJson(v)); + }); + } + } + String _img; + String _id; + List _productList; + + String get img => _img; + String get id => _id; + List get productList => _productList; + + Map toJson() { + final map = {}; + map['img'] = _img; + map['id'] = _id; + if (_productList != null) { + map['productList'] = _productList.map((v) => v.toJson()).toList(); + } + return map; + } + +} + +/// productImg : "https://pos.upload.gznl.top/1179/2021/12/755b69d6-0047-44fe-9593-edac72fb9982.png" +/// productSkuVOList : [{"productId":"1473532887297949696","isDelete":0,"setMeal":"","updateUser":"1364043181062094848","skuPrice":"25.00","skuStock":0,"weight":0,"updateTime":"2021-12-22 13:56:32","storeId":"1364043181120815104","volume":0,"skuNameStr":"","createTime":"2021-12-22 13:56:32","createUser":"1364043181062094848","id":"1473532888409440256","applyPrice":"0.00","skuAttrList":[{"attrValueId":"1473532887918706688","isDelete":0,"updateUser":"1364043181062094848","updateTime":"2021-12-22 13:56:32","attrId":"1473532887704797184","createTime":"2021-12-22 13:56:32","createUser":"1364043181062094848","id":"1473532888619155456","skuId":"1473532888409440256"}],"skuCode":"P202112221356324"}] +/// productName : "有机草莓干" +/// posShow : true +/// attrList : [{"productId":"1473532887297949696","isDelete":0,"needImg":false,"attrValueList":[{"isDelete":0,"attrId":"1473532887704797184","id":"1473532887918706688","attrValue":"","attrValueImg":""}],"id":"1473532887704797184","attrName":""}] +/// price : "25.00" +/// sellCount : 0 +/// id : "1473532887297949696" +/// applyPrice : "0.00" +/// stock : 0 +/// status : 1 + +class ProductList { + ProductList({ + String productImg, + List productSkuVOList, + String productName, + bool posShow, + List attrList, + String price, + int sellCount, + String id, + String applyPrice, + int stock, + int status,}){ + _productImg = productImg; + _productSkuVOList = productSkuVOList; + _productName = productName; + _posShow = posShow; + _attrList = attrList; + _price = price; + _sellCount = sellCount; + _id = id; + _applyPrice = applyPrice; + _stock = stock; + _status = status; +} + + ProductList.fromJson(dynamic json) { + _productImg = json['productImg']; + if (json['productSkuVOList'] != null) { + _productSkuVOList = []; + json['productSkuVOList'].forEach((v) { + _productSkuVOList.add(ProductSkuVOList.fromJson(v)); + }); + } + _productName = json['productName']; + _posShow = json['posShow']; + if (json['attrList'] != null) { + _attrList = []; + json['attrList'].forEach((v) { + _attrList.add(AttrList.fromJson(v)); + }); + } + _price = json['price']; + _sellCount = json['sellCount']; + _id = json['id']; + _applyPrice = json['applyPrice']; + _stock = json['stock']; + _status = json['status']; + } + String _productImg; + List _productSkuVOList; + String _productName; + bool _posShow; + List _attrList; + String _price; + int _sellCount; + String _id; + String _applyPrice; + int _stock; + int _status; + + String get productImg => _productImg; + List get productSkuVOList => _productSkuVOList; + String get productName => _productName; + bool get posShow => _posShow; + List get attrList => _attrList; + String get price => _price; + int get sellCount => _sellCount; + String get id => _id; + String get applyPrice => _applyPrice; + int get stock => _stock; + int get status => _status; + + Map toJson() { + final map = {}; + map['productImg'] = _productImg; + if (_productSkuVOList != null) { + map['productSkuVOList'] = _productSkuVOList.map((v) => v.toJson()).toList(); + } + map['productName'] = _productName; + map['posShow'] = _posShow; + if (_attrList != null) { + map['attrList'] = _attrList.map((v) => v.toJson()).toList(); + } + map['price'] = _price; + map['sellCount'] = _sellCount; + map['id'] = _id; + map['applyPrice'] = _applyPrice; + map['stock'] = _stock; + map['status'] = _status; + return map; + } + +} + +/// productId : "1473532887297949696" +/// isDelete : 0 +/// needImg : false +/// attrValueList : [{"isDelete":0,"attrId":"1473532887704797184","id":"1473532887918706688","attrValue":"","attrValueImg":""}] +/// id : "1473532887704797184" +/// attrName : "" + +class AttrList { + AttrList({ + String productId, + int isDelete, + bool needImg, + List attrValueList, + String id, + String attrName,}){ + _productId = productId; + _isDelete = isDelete; + _needImg = needImg; + _attrValueList = attrValueList; + _id = id; + _attrName = attrName; +} + + AttrList.fromJson(dynamic json) { + _productId = json['productId']; + _isDelete = json['isDelete']; + _needImg = json['needImg']; + if (json['attrValueList'] != null) { + _attrValueList = []; + json['attrValueList'].forEach((v) { + _attrValueList.add(AttrValueList.fromJson(v)); + }); + } + _id = json['id']; + _attrName = json['attrName']; + } + String _productId; + int _isDelete; + bool _needImg; + List _attrValueList; + String _id; + String _attrName; + + String get productId => _productId; + int get isDelete => _isDelete; + bool get needImg => _needImg; + List get attrValueList => _attrValueList; + String get id => _id; + String get attrName => _attrName; + + Map toJson() { + final map = {}; + map['productId'] = _productId; + map['isDelete'] = _isDelete; + map['needImg'] = _needImg; + if (_attrValueList != null) { + map['attrValueList'] = _attrValueList.map((v) => v.toJson()).toList(); + } + map['id'] = _id; + map['attrName'] = _attrName; + return map; + } + +} + +/// isDelete : 0 +/// attrId : "1473532887704797184" +/// id : "1473532887918706688" +/// attrValue : "" +/// attrValueImg : "" + +class AttrValueList { + AttrValueList({ + int isDelete, + String attrId, + String id, + String attrValue, + String attrValueImg,}){ + _isDelete = isDelete; + _attrId = attrId; + _id = id; + _attrValue = attrValue; + _attrValueImg = attrValueImg; +} + + AttrValueList.fromJson(dynamic json) { + _isDelete = json['isDelete']; + _attrId = json['attrId']; + _id = json['id']; + _attrValue = json['attrValue']; + _attrValueImg = json['attrValueImg']; + } + int _isDelete; + String _attrId; + String _id; + String _attrValue; + String _attrValueImg; + + int get isDelete => _isDelete; + String get attrId => _attrId; + String get id => _id; + String get attrValue => _attrValue; + String get attrValueImg => _attrValueImg; + + Map toJson() { + final map = {}; + map['isDelete'] = _isDelete; + map['attrId'] = _attrId; + map['id'] = _id; + map['attrValue'] = _attrValue; + map['attrValueImg'] = _attrValueImg; + return map; + } + +} + +/// productId : "1473532887297949696" +/// isDelete : 0 +/// setMeal : "" +/// updateUser : "1364043181062094848" +/// skuPrice : "25.00" +/// skuStock : 0 +/// weight : 0 +/// updateTime : "2021-12-22 13:56:32" +/// storeId : "1364043181120815104" +/// volume : 0 +/// skuNameStr : "" +/// createTime : "2021-12-22 13:56:32" +/// createUser : "1364043181062094848" +/// id : "1473532888409440256" +/// applyPrice : "0.00" +/// skuAttrList : [{"attrValueId":"1473532887918706688","isDelete":0,"updateUser":"1364043181062094848","updateTime":"2021-12-22 13:56:32","attrId":"1473532887704797184","createTime":"2021-12-22 13:56:32","createUser":"1364043181062094848","id":"1473532888619155456","skuId":"1473532888409440256"}] +/// skuCode : "P202112221356324" + +class ProductSkuVOList { + ProductSkuVOList({ + String productId, + int isDelete, + String setMeal, + String updateUser, + String skuPrice, + int skuStock, + int weight, + String updateTime, + String storeId, + int volume, + String skuNameStr, + String createTime, + String createUser, + String id, + String applyPrice, + List skuAttrList, + String skuCode,}){ + _productId = productId; + _isDelete = isDelete; + _setMeal = setMeal; + _updateUser = updateUser; + _skuPrice = skuPrice; + _skuStock = skuStock; + _weight = weight; + _updateTime = updateTime; + _storeId = storeId; + _volume = volume; + _skuNameStr = skuNameStr; + _createTime = createTime; + _createUser = createUser; + _id = id; + _applyPrice = applyPrice; + _skuAttrList = skuAttrList; + _skuCode = skuCode; +} + + ProductSkuVOList.fromJson(dynamic json) { + _productId = json['productId']; + _isDelete = json['isDelete']; + _setMeal = json['setMeal']; + _updateUser = json['updateUser']; + _skuPrice = json['skuPrice']; + _skuStock = json['skuStock']; + _weight = json['weight']; + _updateTime = json['updateTime']; + _storeId = json['storeId']; + _volume = json['volume']; + _skuNameStr = json['skuNameStr']; + _createTime = json['createTime']; + _createUser = json['createUser']; + _id = json['id']; + _applyPrice = json['applyPrice']; + if (json['skuAttrList'] != null) { + _skuAttrList = []; + json['skuAttrList'].forEach((v) { + _skuAttrList.add(SkuAttrList.fromJson(v)); + }); + } + _skuCode = json['skuCode']; + } + String _productId; + int _isDelete; + String _setMeal; + String _updateUser; + String _skuPrice; + int _skuStock; + int _weight; + String _updateTime; + String _storeId; + int _volume; + String _skuNameStr; + String _createTime; + String _createUser; + String _id; + String _applyPrice; + List _skuAttrList; + String _skuCode; + + String get productId => _productId; + int get isDelete => _isDelete; + String get setMeal => _setMeal; + String get updateUser => _updateUser; + String get skuPrice => _skuPrice; + int get skuStock => _skuStock; + int get weight => _weight; + String get updateTime => _updateTime; + String get storeId => _storeId; + int get volume => _volume; + String get skuNameStr => _skuNameStr; + String get createTime => _createTime; + String get createUser => _createUser; + String get id => _id; + String get applyPrice => _applyPrice; + List get skuAttrList => _skuAttrList; + String get skuCode => _skuCode; + + Map toJson() { + final map = {}; + map['productId'] = _productId; + map['isDelete'] = _isDelete; + map['setMeal'] = _setMeal; + map['updateUser'] = _updateUser; + map['skuPrice'] = _skuPrice; + map['skuStock'] = _skuStock; + map['weight'] = _weight; + map['updateTime'] = _updateTime; + map['storeId'] = _storeId; + map['volume'] = _volume; + map['skuNameStr'] = _skuNameStr; + map['createTime'] = _createTime; + map['createUser'] = _createUser; + map['id'] = _id; + map['applyPrice'] = _applyPrice; + if (_skuAttrList != null) { + map['skuAttrList'] = _skuAttrList.map((v) => v.toJson()).toList(); + } + map['skuCode'] = _skuCode; + return map; + } + +} + +/// attrValueId : "1473532887918706688" +/// isDelete : 0 +/// updateUser : "1364043181062094848" +/// updateTime : "2021-12-22 13:56:32" +/// attrId : "1473532887704797184" +/// createTime : "2021-12-22 13:56:32" +/// createUser : "1364043181062094848" +/// id : "1473532888619155456" +/// skuId : "1473532888409440256" + +class SkuAttrList { + SkuAttrList({ + String attrValueId, + int isDelete, + String updateUser, + String updateTime, + String attrId, + String createTime, + String createUser, + String id, + String skuId,}){ + _attrValueId = attrValueId; + _isDelete = isDelete; + _updateUser = updateUser; + _updateTime = updateTime; + _attrId = attrId; + _createTime = createTime; + _createUser = createUser; + _id = id; + _skuId = skuId; +} + + SkuAttrList.fromJson(dynamic json) { + _attrValueId = json['attrValueId']; + _isDelete = json['isDelete']; + _updateUser = json['updateUser']; + _updateTime = json['updateTime']; + _attrId = json['attrId']; + _createTime = json['createTime']; + _createUser = json['createUser']; + _id = json['id']; + _skuId = json['skuId']; + } + String _attrValueId; + int _isDelete; + String _updateUser; + String _updateTime; + String _attrId; + String _createTime; + String _createUser; + String _id; + String _skuId; + + String get attrValueId => _attrValueId; + int get isDelete => _isDelete; + String get updateUser => _updateUser; + String get updateTime => _updateTime; + String get attrId => _attrId; + String get createTime => _createTime; + String get createUser => _createUser; + String get id => _id; + String get skuId => _skuId; + + Map toJson() { + final map = {}; + map['attrValueId'] = _attrValueId; + map['isDelete'] = _isDelete; + map['updateUser'] = _updateUser; + map['updateTime'] = _updateTime; + map['attrId'] = _attrId; + map['createTime'] = _createTime; + map['createUser'] = _createUser; + map['id'] = _id; + map['skuId'] = _skuId; + return map; + } + +} \ No newline at end of file diff --git a/lib/retrofit/min_api.dart b/lib/retrofit/min_api.dart index eaceffa8..3bbcaac4 100644 --- a/lib/retrofit/min_api.dart +++ b/lib/retrofit/min_api.dart @@ -14,10 +14,13 @@ import 'package:huixiang/retrofit/data/wx_pay.dart'; import 'package:huixiang/view_widget/login_tips_dialog.dart'; import 'package:retrofit/retrofit.dart'; +import 'data/activity_area_list.dart'; import 'data/findMiNiGroupList.dart'; +import 'data/home_recommend_list.dart'; import 'data/miNiDetail.dart'; import 'data/settleOrderInfo.dart'; import 'data/shoppingCart.dart'; +import 'data/shopping_home_config.dart'; part 'min_api.g.dart'; @@ -28,14 +31,14 @@ part 'min_api.g.dart'; // const base_url = "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 baseUrl = "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 base_url = "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 baseUrl = "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/";///詹云久 ///调用小程序的接口 @RestApi(baseUrl: baseUrl) @@ -199,8 +202,21 @@ abstract class MinApiService { @POST("store/getStore") Future queryStoreInfo1(@Body() Map param); - // 父订单信息 + /// 父订单信息 @GET("order/getParentInfo?tableId={tableId}") Future getParentInfo(@Path("tableId") String tableId); + /// 小程序商品推荐/为你推荐 + @GET("product/recommendList") + Future>> recommendList(); + + ///获取门店首页配置 + @GET("store/homeConfig") + Future> homeConfig(); + + ///活动专区,秒杀,砍价,拼团 + @GET("/actTemplate/findActListByType?allDay={allDay}&type={type}") + Future> findActListByType(@Path("allDay") bool allDay, + @Path("type") String type); + } diff --git a/lib/retrofit/min_api.g.dart b/lib/retrofit/min_api.g.dart index ef360ca1..cdf05a72 100644 --- a/lib/retrofit/min_api.g.dart +++ b/lib/retrofit/min_api.g.dart @@ -9,7 +9,7 @@ part of 'min_api.dart'; class _MinApiService implements MinApiService { _MinApiService(this._dio, {this.baseUrl}) { ArgumentError.checkNotNull(_dio, '_dio'); - baseUrl ??= 'http://192.168.10.142:8765/app/'; + baseUrl ??= 'http://192.168.10.236:8765/app/'; } final Dio _dio; @@ -400,4 +400,71 @@ class _MinApiService implements MinApiService { ); return value; } + + @override + Future>> recommendList() async { + const _extra = {}; + final queryParameters = {}; + final _data = {}; + final _result = await _dio.request>( + 'product/recommendList', + queryParameters: queryParameters, + options: RequestOptions( + method: 'GET', + headers: {}, + extra: _extra, + baseUrl: baseUrl), + data: _data); + final value = BaseData>.fromJson( + _result.data, + (json) => (json as List) + .map((i) => HomeRecommendList.fromJson(i as Map)) + .toList()); + return value; + } + + @override + Future> homeConfig() async { + const _extra = {}; + final queryParameters = {}; + final _data = {}; + final _result = await _dio.request>( + 'store/homeConfig', + queryParameters: queryParameters, + options: RequestOptions( + method: 'GET', + headers: {}, + extra: _extra, + baseUrl: baseUrl), + data: _data); + final value = BaseData.fromJson( + _result.data, + (json) => ShoppingHomeConfig.fromJson(json), + ); + return value; + } + + @override + Future> findActListByType(allDay,type) async { + ArgumentError.checkNotNull(allDay, 'allDay'); + ArgumentError.checkNotNull(type, 'type'); + const _extra = {}; + final queryParameters = {}; + final _data = {}; + final _result = await _dio.request>( + '/actTemplate/findActListByType?allDay=$allDay&type=$type', + queryParameters: queryParameters, + options: RequestOptions( + method: 'GET', + headers: {}, + extra: _extra, + baseUrl: baseUrl), + data: _data); + final value = BaseData.fromJson( + _result.data, + (json) => ActivityAreaList.fromJson(json), + ); + return value; + } + } diff --git a/lib/retrofit/retrofit_api.dart b/lib/retrofit/retrofit_api.dart index 21274fd8..61080c22 100644 --- a/lib/retrofit/retrofit_api.dart +++ b/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 baseUrl = "http://platform.prod.kunqi.lotus-wallet.com/app/"; ///222 -// 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/"; -const base_url = "http://192.168.10.142:8766/app/";///詹云久 -const baseUrl = "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/";///詹云久 @RestApi(baseUrl: baseUrl) abstract class ApiService { @@ -482,9 +482,7 @@ abstract class ApiService { @GET("/information/category/{id}") Future> headlinesDetails(@Path("id") String id); - ///活动专区,秒杀,砍价,拼团 - @GET("/actTemplate/findActListByType?allDay={allDay}&type={type}") - Future> findActListByType(@Path("allDay") bool allDay, @Path("type") int type); + } diff --git a/lib/retrofit/retrofit_api.g.dart b/lib/retrofit/retrofit_api.g.dart index 4f0a56ba..1eb48e20 100644 --- a/lib/retrofit/retrofit_api.g.dart +++ b/lib/retrofit/retrofit_api.g.dart @@ -9,7 +9,7 @@ part of 'retrofit_api.dart'; class _ApiService implements ApiService { _ApiService(this._dio, {this.baseUrl}) { ArgumentError.checkNotNull(_dio, '_dio'); - baseUrl ??= 'http://192.168.10.142:8766/app/'; + baseUrl ??= 'http://192.168.10.236:8766/app/'; } final Dio _dio; @@ -1773,27 +1773,4 @@ class _ApiService implements ApiService { return value; } - @override - Future> findActListByType(allDay,type) async { - ArgumentError.checkNotNull(allDay, 'allDay'); - ArgumentError.checkNotNull(type, 'type'); - const _extra = {}; - final queryParameters = {}; - final _data = {}; - final _result = await _dio.request>( - '/actTemplate/findActListByType?allDay=$allDay&type=$type', - queryParameters: queryParameters, - options: RequestOptions( - method: 'GET', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData.fromJson( - _result.data, - (json) => ActivityAreaList.fromJson(json), - ); - return value; - } - } diff --git a/lib/store/shopping/activity_prefecture_details.dart b/lib/store/shopping/activity_prefecture_details.dart index cab7d39f..9f67cbca 100644 --- a/lib/store/shopping/activity_prefecture_details.dart +++ b/lib/store/shopping/activity_prefecture_details.dart @@ -1,9 +1,15 @@ +import 'dart:async'; + import 'package:dio/dio.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_easyloading/flutter_easyloading.dart'; +import 'package:huixiang/generated/l10n.dart'; +import 'package:huixiang/retrofit/data/activity.dart'; import 'package:huixiang/retrofit/data/activity_area_list.dart'; import 'package:huixiang/retrofit/data/base_data.dart'; -import 'package:huixiang/retrofit/data/product.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/utils/font_weight.dart'; import 'package:huixiang/view_widget/custom_image.dart'; @@ -23,6 +29,7 @@ class ActivityPrefectureDetails extends StatefulWidget { class _ActivityPrefectureDetails extends State { ApiService apiService; + MinApiService minService; int seckillIndex = 0; RefreshController refreshController = RefreshController(); ScrollController _scrollController; @@ -30,9 +37,30 @@ class _ActivityPrefectureDetails extends State { bool scrollFlag = false; List actTimeList = []; List productList = []; + List activitys; ActTemplate actTemplate; int actTimeListIndex = 0; - int pageType = 1; + StoreInfo storeInfo; + String pageType = "1"; + String storeId; + String tenant; + String minToken; + Timer _timer; + String testTime = "2021-12-30 10:00:00"; + int tempDay = 0; + int tempHour = 0; + int tempM = 0; + int tempS = 0; + bool isDispose = false; + + @override + void dispose() { + super.dispose(); + isDispose = true; + if (_timer != null) { + _timer.cancel(); + } + } @override void initState() { @@ -48,28 +76,78 @@ class _ActivityPrefectureDetails extends State { } }); }); - pageType =widget.arguments["type"]; + + // testTime = "${DateTime.now().year}-${DateTime.now().month}-${DateTime.now().day} 08:00:20"; + + pageType = widget.arguments["type"]; + storeId = widget.arguments["storeId"]; + tenant = widget.arguments["tenant"]; + SharedPreferences.getInstance().then((value) { - apiService = - ApiService(Dio(), context: context, token: value.getString("token")); + minLogin(value); + queryStoreInfo(); + }); + } + + /// 小程序登录 + minLogin(SharedPreferences shared) async { + EasyLoading.show(status: S.of(context).zhengzaijiazai); + apiService = ApiService( + Dio(), + context: context, + token: shared.getString('token'), + showLoading: false, + ); + apiService.minLogin(storeId).catchError((onError) { + debugPrint(onError); + }).then((baseData) { + if (baseData != null && baseData.isSuccess) { + Map minStoreInfo = baseData.data; + minToken = minStoreInfo["token"]; + queryStoreInfo(); + SharedPreferences.getInstance().then( + (value) => { + value.setString('minToken', minToken), + value.setString('tenant', tenant), + value.setString('storeId', storeId), + }, + ); + minService = MinApiService( + Dio(), + context: context, + token: minToken, + tenant: tenant, + storeId: storeId, + showLoading: false, + ); + queryFindActListByType(pageType == "2" ?false:true); + + EasyLoading.dismiss(); + } + }); + } - queryFindActListByType(pageType == 2 ?false:true); + /// 查询店铺信息 + queryStoreInfo() async { + BaseData baseData = await apiService.queryStoreInfo(storeId).catchError((error) { + debugPrint(error); }); + if (baseData != null && baseData.isSuccess) { + storeInfo = StoreInfo.fromJson(baseData.data); + activitys = storeInfo.informationVOPageVO.list + .map((e) => Activity.fromJson(e)) + .toList(); + if (mounted) { + setState(() {}); + } + } + EasyLoading.dismiss(); } ///秒杀/砍价/拼团列表 queryFindActListByType(allDay) async { - if (apiService == null) { - SharedPreferences value = await SharedPreferences.getInstance(); - apiService = ApiService( - Dio(), - context: context, - token: value.getString("token"), - - ); - } BaseData baseData = - await apiService.findActListByType(allDay,pageType).catchError((error) { + await minService.findActListByType(allDay,pageType).catchError((error) { refreshController.refreshFailed(); }); setState(() { @@ -89,6 +167,7 @@ class _ActivityPrefectureDetails extends State { } if (actTimeList.length > actTimeListIndex) productList.addAll(actTimeList[actTimeListIndex].productList); + startCountdownTimer(); refreshController.refreshCompleted(); }); } else { @@ -96,6 +175,32 @@ class _ActivityPrefectureDetails extends State { } } + ///限天秒杀时间 + startCountdownTimer() { + if(_timer != null) + return; + const oneSec = const Duration(seconds: 1); + var callback = ((timer){ + if(isDispose) + return; + setState(() { + var tempDateTime = DateTime.parse(actTemplate.endTime).difference(DateTime.now()); + if(tempDateTime.inSeconds <0){ + tempDay = 0; + tempHour = 0; + tempM = 0; + tempS = 0; + return; + } + tempDay = tempDateTime.inDays; + tempHour = tempDateTime.inHours - (tempDateTime.inDays * 24); + tempM = tempDateTime.inMinutes - (tempDateTime.inHours *60); + tempS = tempDateTime.inSeconds - (tempDateTime.inMinutes*60); + }); + }); + _timer = Timer.periodic(oneSec, callback); + } + @override Widget build(BuildContext context) { return SingleChildScrollView( @@ -130,7 +235,7 @@ class _ActivityPrefectureDetails extends State { child: Column( children: [ swiper(), - pageType == 2?(seckillIndex == 0 + pageType == "2"?(seckillIndex == 0 ? Container( width: double.infinity, alignment: Alignment.center, @@ -200,7 +305,7 @@ class _ActivityPrefectureDetails extends State { ), ), TextSpan( - text: "0", + text: tempDay.toString(), style: TextStyle( fontSize: 14.sp, fontWeight: MyFontWeight.semi_bold, @@ -235,7 +340,7 @@ class _ActivityPrefectureDetails extends State { color: Color(0xFFFB312B), borderRadius: BorderRadius.circular(1)), child: Text( - "22", + tempHour.toString(), style: TextStyle( color: Colors.white, fontSize: 14.sp, @@ -263,7 +368,7 @@ class _ActivityPrefectureDetails extends State { color: Color(0xFFFB312B), borderRadius: BorderRadius.circular(1)), child: Text( - "22", + tempM.toString(), style: TextStyle( color: Colors.white, fontSize: 14.sp, @@ -292,7 +397,7 @@ class _ActivityPrefectureDetails extends State { color: Color(0xFFFB312B), borderRadius: BorderRadius.circular(1)), child: Text( - "22", + tempS.toString(), style: TextStyle( color: Colors.white, fontSize: 14.sp, @@ -311,6 +416,7 @@ class _ActivityPrefectureDetails extends State { ); } + ///头部图片 Widget swiper() { return Container( child: AspectRatio( @@ -341,7 +447,7 @@ class _ActivityPrefectureDetails extends State { ), ), ), - pageType == 2 ? + pageType == "2" ? Align( alignment: Alignment.topCenter, child: Container( @@ -351,7 +457,7 @@ class _ActivityPrefectureDetails extends State { color: Color.fromRGBO(0, 0, 0, 69000000), ), width: 160.w, - height: 30.h, + height:35.h, child: Row( children: [ GestureDetector( @@ -364,7 +470,7 @@ class _ActivityPrefectureDetails extends State { child: Container( alignment: Alignment.center, width: 72.w, - height: 22.h, + height: 25.h, margin: EdgeInsets.only(left: 6.w), decoration: BoxDecoration( gradient: new LinearGradient( @@ -409,7 +515,7 @@ class _ActivityPrefectureDetails extends State { child: Container( alignment: Alignment.center, width: 72.w, - height: 22.h, + height: 25.h, margin: EdgeInsets.only(left: 6.w), decoration: BoxDecoration( gradient: new LinearGradient( @@ -456,13 +562,26 @@ class _ActivityPrefectureDetails extends State { ///秒杀列表 Widget seckilList() { + // var tStatus = timeFlag(actTimeList[actTimeListIndex].actTime.startHour); return Container( height: MediaQuery.of(context).size.height - 62.h - MediaQuery.of(context).padding.top, padding: EdgeInsets.fromLTRB(16.w, 16.h, 16.w, 16.h), color: Colors.white, - child: ListView.builder( + child: productList.length == 0 ? + Container( + width: double.infinity, + alignment: Alignment.topCenter, + child:Text( + "暂无商品参与活动", + style: TextStyle( + fontSize:18.sp, + fontWeight: MyFontWeight.medium, + color: Colors.black, + ), + ), + ):ListView.builder( padding: EdgeInsets.zero, itemCount: productList?.length ?? 0, scrollDirection: Axis.vertical, @@ -472,6 +591,14 @@ class _ActivityPrefectureDetails extends State { return GestureDetector( onTap: () { setState(() { + Navigator.of(context).pushNamed( + '/router/shopping_goods_details', + arguments: { + "id":productList[position].id, + "storeId":storeId, + "tenant":tenant, + }, + ); }); }, child: seckilItem(productList[position]), @@ -482,6 +609,8 @@ class _ActivityPrefectureDetails extends State { } int timeFlag(String time) { + if(time == null) + return 0; var now = DateTime.now().hour; var tHour = int.tryParse(time.substring(0, 2)); if (now < tHour) @@ -501,7 +630,7 @@ class _ActivityPrefectureDetails extends State { crossAxisAlignment: CrossAxisAlignment.center, children: [ Text( - actTimeList.actTime.startHour, + actTimeList?.actTime?.startHour ?? "", style: TextStyle( fontSize: 17.sp, fontWeight: MyFontWeight.semi_bold, @@ -608,6 +737,7 @@ class _ActivityPrefectureDetails extends State { Widget seckilItem(ProductList productList) { var tStatus = timeFlag(actTimeList[actTimeListIndex].actTime.startHour); return Container( + // height:94.h, margin: EdgeInsets.only(right: 12.w, top: 12.h, bottom: 12.h), child: Row( mainAxisAlignment: MainAxisAlignment.start, @@ -625,7 +755,7 @@ class _ActivityPrefectureDetails extends State { width: 12.w, ), Expanded( - child: Column( + child:Column( mainAxisAlignment: MainAxisAlignment.spaceAround, crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -647,43 +777,70 @@ class _ActivityPrefectureDetails extends State { color: Color(0xFF4D4D4D), ), ), - Row( - children: [ - ClipRRect( - borderRadius: BorderRadius.circular(6.5), - child: Stack( - children: [ - Container( - width: 180.w, - height: 8.h, - color: Color(0xFFF5F5F5), - ), - Container( - width: 100.w, - height: 8.h, - decoration: BoxDecoration( - gradient: LinearGradient( - begin: Alignment.centerLeft, - end: Alignment.centerRight, - colors: [ - Color(0xFFFDBA56), - Color(0xFFFB2B2B) - ])), - ) - ], - )), - SizedBox( - width: 5, - ), - Text( - "已售${productList.sellCount}", - style: TextStyle( - fontSize: 10.sp, - fontWeight: MyFontWeight.regular, - color: Color(0xFF353535), + if(pageType == "2") + Row( + children: [ + ClipRRect( + borderRadius: BorderRadius.circular(6.5), + child: Stack( + children: [ + Container( + width: 180.w, + height: 8.h, + color: Color(0xFFF5F5F5), + ), + Container( + width: 100.w, + height: 8.h, + decoration: BoxDecoration( + gradient: LinearGradient( + begin: Alignment.centerLeft, + end: Alignment.centerRight, + colors: [ + Color(0xFFFDBA56), + Color(0xFFFB2B2B) + ])), + ) + ], + )), + SizedBox( + width: 5, ), - ), - ], + Text( + "已售${productList.sellCount}", + style: TextStyle( + fontSize: 10.sp, + fontWeight: MyFontWeight.regular, + color: Color(0xFF353535), + ), + ), + ], + ), + if(pageType == "3") + Row( + children: [ + Container( + padding: EdgeInsets.only(left: 2, right: 2), + height: 22.h, + alignment: Alignment.center, + decoration: BoxDecoration( + color: Color(0xFFFFCD00), + ), + child: Text( + "最高可砍50元", + style: TextStyle( + fontSize: 12.sp, + fontWeight: MyFontWeight.semi_bold, + color: Colors.white, + ), + ), + ), + Spacer(), + ], + ), + if(pageType == "1") + Container( + height: 22.h, ), Row( children: [ @@ -695,7 +852,7 @@ class _ActivityPrefectureDetails extends State { style: TextStyle( fontSize: 14.sp, fontWeight: MyFontWeight.semi_bold, - color: Color(0xFFFB2E2C), + color: pageType == "3" ?Color(0xFF9476F7) : Color(0xFFFB2E2C), ), ), TextSpan( @@ -703,7 +860,7 @@ class _ActivityPrefectureDetails extends State { style: TextStyle( fontSize: 18.sp, fontWeight: MyFontWeight.semi_bold, - color: Color(0xFFFB2E2C), + color:pageType == "3" ?Color(0xFF9476F7) : Color(0xFFFB2E2C), ), ), ], @@ -713,91 +870,169 @@ class _ActivityPrefectureDetails extends State { child: Text( productList.productPrice, style: TextStyle( - fontSize: 10.sp, + fontSize:11.sp, decoration: TextDecoration.lineThrough, - decorationColor: Color(0xFF585858), + decorationColor: Color(0xFF353535), fontWeight: MyFontWeight.regular, color: Color(0xFF353535), ), ), ), - tStatus == 0 - ? Container( - alignment: Alignment.center, - width: 60.w, - height: 24.h, - decoration: BoxDecoration( - color: Color(0xFFE2F6EA), - borderRadius: BorderRadius.circular(12), - boxShadow: [ - BoxShadow( - color: Colors.black.withAlpha(12), - offset: Offset(0, 3), - blurRadius: 14, - spreadRadius: 0, - ), - ], + if(pageType == "2") + (seckillIndex == 0 ? + (tStatus == 0 + ? Container( + alignment: Alignment.center, + width: 60.w, + height: 24.h, + decoration: BoxDecoration( + color: Color(0xFFE2F6EA), + borderRadius: BorderRadius.circular(12), + boxShadow: [ + BoxShadow( + color: Colors.black.withAlpha(12), + offset: Offset(0, 3), + blurRadius: 14, + spreadRadius: 0, ), - child: Text( - "即将开始", - style: TextStyle( - fontSize: 12.sp, - fontWeight: MyFontWeight.medium, - color: Color(0xFF52AF79), - ), + ], + ), + child: Text( + "即将开始", + style: TextStyle( + fontSize: 12.sp, + fontWeight: MyFontWeight.medium, + color: Color(0xFF52AF79), + ), + ), + ) + : (tStatus == 1 + ? Container( + alignment: Alignment.center, + width: 60.w, + height: 24.h, + decoration: BoxDecoration( + color: Color(0xFFFB312B), + borderRadius: BorderRadius.circular(12), + boxShadow: [ + BoxShadow( + color: Colors.black.withAlpha(12), + offset: Offset(0, 3), + blurRadius: 14, + spreadRadius: 0, ), - ) - : (tStatus == 1 - ? Container( - alignment: Alignment.center, - width: 60.w, - height: 24.h, - decoration: BoxDecoration( - color: Color(0xFFFB312B), - borderRadius: BorderRadius.circular(12), - boxShadow: [ - BoxShadow( - color: Colors.black.withAlpha(12), - offset: Offset(0, 3), - blurRadius: 14, - spreadRadius: 0, - ), - ], - ), - child: Text( - "马上抢", - style: TextStyle( - fontSize: 12.sp, - fontWeight: MyFontWeight.medium, - color: Colors.white, - ), - ), - ) - : Container( - alignment: Alignment.center, - width: 60.w, - height: 24.h, - decoration: BoxDecoration( - color: Colors.transparent, - borderRadius: BorderRadius.circular(12), - boxShadow: [ - BoxShadow( - color: Colors.black.withAlpha(12), - offset: Offset(0, 3), - blurRadius: 14, - spreadRadius: 0, - ), - ], - ), - child: Text( - "已结束", - style: TextStyle( - fontSize: 12.sp, - fontWeight: MyFontWeight.medium, - color: Color(0xFFADADAD), - ), - ), - )), + ], + ), + child: Text( + "马上抢", + style: TextStyle( + fontSize: 12.sp, + fontWeight: MyFontWeight.medium, + color: Colors.white, + ), + ), + ) + : Container( + alignment: Alignment.center, + width: 60.w, + height: 24.h, + decoration: BoxDecoration( + color: Colors.transparent, + borderRadius: BorderRadius.circular(12), + boxShadow: [ + BoxShadow( + color: Colors.black.withAlpha(12), + offset: Offset(0, 3), + blurRadius: 14, + spreadRadius: 0, + ), + ], + ), + child: Text( + "已结束", + style: TextStyle( + fontSize: 12.sp, + fontWeight: MyFontWeight.medium, + color: Color(0xFFADADAD), + ), + ), + ))) : Container( + alignment: Alignment.center, + width: 60.w, + height: 24.h, + decoration: BoxDecoration( + color: Color(0xFFFB312B), + borderRadius: BorderRadius.circular(12), + boxShadow: [ + BoxShadow( + color: Colors.black.withAlpha(12), + offset: Offset(0, 3), + blurRadius: 14, + spreadRadius: 0, + ), + ], + ), + child: Text( + "马上抢", + style: TextStyle( + fontSize: 12.sp, + fontWeight: MyFontWeight.medium, + color: Colors.white, + ), + ), + )), + if(pageType == "1") + Container( + alignment: Alignment.center, + width: 60.w, + height: 24.h, + decoration: BoxDecoration( + color: Color(0xFFFB2E2C), + borderRadius: BorderRadius.circular(12), + boxShadow: [ + BoxShadow( + color: Colors.black.withAlpha(12), + offset: Offset(0, 3), + blurRadius: 14, + spreadRadius: 0, + ), + ], + ), + child: Text( + "立即开团", + style: TextStyle( + fontSize: 12.sp, + fontWeight: MyFontWeight.medium, + color: Colors.white, + ), + ), + ), + if(pageType == "3") + Container( + alignment: Alignment.center, + width: 60.w, + height: 24.h, + decoration: BoxDecoration( + color: Color(0xFF9476F7), + borderRadius: BorderRadius.circular(12), + boxShadow: [ + BoxShadow( + color: Colors.black.withAlpha(12), + offset: Offset(0, 3), + blurRadius: 14, + spreadRadius: 0, + ), + ], + ), + child: Text( + "我要砍价", + style: TextStyle( + fontSize: 12.sp, + fontWeight: MyFontWeight.medium, + color: Colors.white, + ), + ), + ) ], ), ], diff --git a/lib/store/shopping/shopping_cart/shopping_cart_page.dart b/lib/store/shopping/shopping_cart/shopping_cart_page.dart index abd87a31..5610cb72 100644 --- a/lib/store/shopping/shopping_cart/shopping_cart_page.dart +++ b/lib/store/shopping/shopping_cart/shopping_cart_page.dart @@ -1,9 +1,12 @@ +import 'package:dio/dio.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_easyloading/flutter_easyloading.dart'; import 'package:flutter_swiper/flutter_swiper.dart'; import 'package:huixiang/generated/l10n.dart'; import 'package:huixiang/retrofit/data/base_data.dart'; import 'package:huixiang/retrofit/data/shoppingCart.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/shopping/shopping_home/recommend_goods_list_view.dart'; @@ -13,10 +16,16 @@ import 'package:huixiang/view_widget/my_appbar.dart'; import 'package:huixiang/view_widget/round_button.dart'; import 'package:pull_to_refresh/pull_to_refresh.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:shared_preferences/shared_preferences.dart'; import 'cart_goods_list.dart'; class ShoppingCartPage extends StatefulWidget { + final String minToken; + final String storeId; + final String tenant; + + ShoppingCartPage(this.minToken,this.storeId, this.tenant); @override State createState() { return _ShoppingCartPage(); @@ -27,17 +36,30 @@ class _ShoppingCartPage extends State with AutomaticKeepAliveClientMixin { ApiService apiService; MinApiService minService; - ShoppingCart shopCarGoods; + // ShoppingCart shopCarGoods; + List shopCarGoods = []; String pName; String pid; String cName; String cid; int tableId = 0; + bool topIndex = false; @override void initState() { super.initState(); + SharedPreferences.getInstance().then((value) { + minService = MinApiService( + Dio(), + context: context, + token: widget.minToken, + tenant: widget.tenant, + storeId: widget.storeId, + showLoading: false, + ); + queryShopCar(); + }); } ///清空购物车 @@ -49,77 +71,94 @@ class _ShoppingCartPage extends State } } - ///查询购物车 - Future queryShopCar() async { - pName="";//活动 - pid="";//活动 - cName="";//优惠券 - cid="";//优惠券 - BaseData> baseDate = - await minService.getShoppingCart(tableId); - if (baseDate != null && - baseDate.isSuccess && - baseDate.data != null && - baseDate.data.length > 0) { - if( baseDate.data[0].selectDiscount ==1){ - baseDate.data[0].couponList.forEach((element) { - if(element.isMaxCoupon){ - cName = element.promotionName; - cid = element.id; - } - }); - }else if(baseDate.data[0].selectDiscount==2){ - baseDate.data[0].promotionInfoList.forEach((element) { - if(element.isMaxPromotion){ - pName=element.name; - pid=element.id; - } - }); - } - return baseDate.data[0]; + ///查询购物商品 + queryShopCar() async { + BaseData> baseData = + await minService.getShoppingCart(tableId).catchError((error) { + refreshController.refreshFailed(); + }); + if (baseData != null && baseData.isSuccess) { + setState(() { + shopCarGoods.clear(); + shopCarGoods.addAll(baseData.data); + refreshController.refreshCompleted(); + }); } else { - return null; + refreshController.refreshFailed(); } } + ///查询购物车 + // Future queryShopCar() async { + // pName="";//活动 + // pid="";//活动 + // cName="";//优惠券 + // cid="";//优惠券 + // BaseData> baseDate = + // await minService.getShoppingCart(tableId); + // if (baseDate != null && + // baseDate.isSuccess && + // baseDate.data != null && + // baseDate.data.length > 0) { + // if( baseDate.data[0].selectDiscount ==1){ + // baseDate.data[0].couponList.forEach((element) { + // if(element.isMaxCoupon){ + // cName = element.promotionName; + // cid = element.id; + // } + // }); + // }else if(baseDate.data[0].selectDiscount==2){ + // baseDate.data[0].promotionInfoList.forEach((element) { + // if(element.isMaxPromotion){ + // pName=element.name; + // pid=element.id; + // } + // }); + // } + // return baseDate.data[0]; + // } else { + // return null; + // } + // } + /// 购物车的key,用于刷新UI GlobalKey shopCartKey = GlobalKey(); ///购物车➕1 - Future shopCartAdd( - ShoppingCartSkuItemListBean cartSkuItem) async { - Map shopCarTemp = shopCarGoods.toJson(); - cartSkuItem.buyNum += 1; - shopCarTemp["shoppingCartSkuItemList"] = [cartSkuItem.toJson()]; - BaseData> baseDate = - await minService.shoppingCartSingle(shopCarTemp); - if (baseDate.isSuccess) { - this.shopCarGoods = await queryShopCar(); - if (shopCartKey != null) { - shopCartKey.currentState.setState(() {}); - } - setState(() {}); - } - return this.shopCarGoods; - } - - ///购物车➖1 - Future shopCartReduce( - ShoppingCartSkuItemListBean cartSkuItem) async { - Map shopCarTemp = shopCarGoods.toJson(); - cartSkuItem.buyNum -= 1; - shopCarTemp["shoppingCartSkuItemList"] = [cartSkuItem.toJson()]; - BaseData> baseDate = - await minService.shoppingCartSingle(shopCarTemp); - if (baseDate.isSuccess) { - this.shopCarGoods = await queryShopCar(); - if (shopCartKey != null) { - shopCartKey.currentState.setState(() {}); - } - setState(() {}); - } - return this.shopCarGoods; - } + // Future shopCartAdd( + // ShoppingCartSkuItemListBean cartSkuItem) async { + // Map shopCarTemp = shopCarGoods.toJson(); + // cartSkuItem.buyNum += 1; + // shopCarTemp["shoppingCartSkuItemList"] = [cartSkuItem.toJson()]; + // BaseData> baseDate = + // await minService.shoppingCartSingle(shopCarTemp); + // if (baseDate.isSuccess) { + // this.shopCarGoods = await queryShopCar(); + // if (shopCartKey != null) { + // shopCartKey.currentState.setState(() {}); + // } + // setState(() {}); + // } + // return this.shopCarGoods; + // } + // + // ///购物车➖1 + // Future shopCartReduce( + // ShoppingCartSkuItemListBean cartSkuItem) async { + // Map shopCarTemp = shopCarGoods.toJson(); + // cartSkuItem.buyNum -= 1; + // shopCarTemp["shoppingCartSkuItemList"] = [cartSkuItem.toJson()]; + // BaseData> baseDate = + // await minService.shoppingCartSingle(shopCarTemp); + // if (baseDate.isSuccess) { + // this.shopCarGoods = await queryShopCar(); + // if (shopCartKey != null) { + // shopCartKey.currentState.setState(() {}); + // } + // setState(() {}); + // } + // return this.shopCarGoods; + // } final SwiperController controller = SwiperController(); @@ -144,14 +183,16 @@ class _ShoppingCartPage extends State leadingColor: Colors.black, background: Colors.transparent, actions: [ - Container( - alignment: Alignment.center, - margin: EdgeInsets.only(right: 12.w), - child: GestureDetector( - onTap: () { - - }, - child: Text("管理", + GestureDetector( + onTap: (){ + setState(() { + topIndex = !topIndex; + }); + }, + child: Container( + alignment: Alignment.center, + margin: EdgeInsets.only(right: 12.w), + child: Text(topIndex ? "管理" :S.of(context).quxiao, style: TextStyle( fontSize: 18.sp, fontWeight: MyFontWeight.semi_bold, @@ -159,23 +200,7 @@ class _ShoppingCartPage extends State ), ), ), - ), - // Container( - // alignment: Alignment.center, - // margin: EdgeInsets.only(right: 12.w), - // child: GestureDetector( - // onTap: () { - // - // }, - // child: Text(S.of(context).quxiao, - // style: TextStyle( - // fontSize: 18.sp, - // fontWeight: MyFontWeight.semi_bold, - // color:Colors.black, - // ), - // ), - // ), - // ), + ) ], ), Expanded( diff --git a/lib/store/shopping/shopping_goods_details.dart b/lib/store/shopping/shopping_goods_details.dart index 72b7bb27..c7564a29 100644 --- a/lib/store/shopping/shopping_goods_details.dart +++ b/lib/store/shopping/shopping_goods_details.dart @@ -3,21 +3,34 @@ import 'dart:convert'; import 'package:dio/dio.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_easyloading/flutter_easyloading.dart'; import 'package:flutter_html/flutter_html.dart'; import 'package:flutter_html/image_render.dart'; import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:flutter_swiper/flutter_swiper.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'; import 'package:huixiang/retrofit/data/goods.dart'; +import 'package:huixiang/retrofit/data/miNiDetail.dart'; +import 'package:huixiang/retrofit/data/shoppingCart.dart'; +import 'package:huixiang/retrofit/data/store_info.dart'; import 'package:huixiang/retrofit/data/user_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/store_order_list.dart'; import 'package:huixiang/utils/font_weight.dart'; import 'package:huixiang/view_widget/my_appbar.dart'; import 'package:shared_preferences/shared_preferences.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:url_launcher/url_launcher.dart'; class ShoppingGoodsDetails extends StatefulWidget { + final Map arguments; + + ShoppingGoodsDetails({this.arguments}); @override State createState() { return _ShoppingGoodsDetails(); @@ -26,17 +39,205 @@ class ShoppingGoodsDetails extends StatefulWidget { class _ShoppingGoodsDetails extends State { ApiService apiService; + MinApiService minService; + String tenant; + String storeId; + String minToken; + String id; + StoreInfo storeInfo; + MiNiDetail miNiDetail; + bool dialogShowing = false; + String skuId1; + String skuValue1; + int count1 = 0; + int tableId = 0; + String parentId = ""; + String parentCode = ""; + int numberOfPeople = 0; + List activitys; + ProductSkuVOListBean productSku; @override void initState() { super.initState(); + storeId = widget.arguments["storeId"]; + tenant = widget.arguments["tenant"]; + id = widget.arguments["id"]; SharedPreferences.getInstance().then((value) { - apiService = - ApiService(Dio(), context: context, token: value.getString("token")); + minService = MinApiService( + Dio(), + context: context, + token: minToken, + tenant: tenant, + storeId: storeId, + showLoading: false, + ); + minLogin(value); + queryStoreInfo(); + queryMiNiDetail(id); + }); + } + + /// 小程序登录 + minLogin(SharedPreferences shared) async { + EasyLoading.show(status: S.of(context).zhengzaijiazai); + apiService = ApiService( + Dio(), + context: context, + token: shared.getString('token'), + showLoading: false, + ); + apiService.minLogin(storeId).catchError((onError) { + debugPrint(onError); + }).then((baseData) { + if (baseData != null && baseData.isSuccess) { + Map minStoreInfo = baseData.data; + minToken = minStoreInfo["token"]; + queryStoreInfo(); + SharedPreferences.getInstance().then( + (value) => { + value.setString('minToken', minToken), + value.setString('tenant', tenant), + value.setString('storeId', storeId), + }, + ); + minService = MinApiService( + Dio(), + context: context, + token: minToken, + tenant: tenant, + storeId: storeId, + showLoading: false, + ); + EasyLoading.dismiss(); + } + }); + } + + /// 查询店铺信息 + queryStoreInfo() async { + BaseData baseData = await apiService.queryStoreInfo(storeId).catchError((error) { + debugPrint(error); }); + if (baseData != null && baseData.isSuccess) { + storeInfo = StoreInfo.fromJson(baseData.data); + activitys = storeInfo.informationVOPageVO.list + .map((e) => Activity.fromJson(e)) + .toList(); + if (mounted) { + setState(() {}); + } + } + EasyLoading.dismiss(); + } + + ///商品详情 + queryMiNiDetail(id) async { + EasyLoading.show(status: S.current.zhengzaijiazai); + BaseData baseData = await minService.miNiDetail(id); + if (baseData != null && baseData.isSuccess) { + miNiDetail = baseData.data; + + } + EasyLoading.dismiss(); + } + + ///选规格弹窗 + showStoreSelector(MiNiDetail miNiDetail, String id,int count) async { + if (miNiDetail.attrList != null && miNiDetail.attrList.length == 1 + && miNiDetail.attrList[0].attrValueList.length == 1) { + _addShopCar(miNiDetail, [], count); + } else { + EasyLoading.dismiss(); + dialogShowing = true; + SmartDialog.show( + widget: ProductSku( + miNiDetail, + null, + id, + _addShopCar, + add, + reduce, + buttonType: 1, + ), + onDismiss: () { + dialogShowing = false; + }, + alignmentTemp: Alignment.bottomCenter, + ); + } + } + + ///选规格添加购物车 + Future _addShopCar(MiNiDetail miNiDetail, selectSkus, int count) async { + if (selectSkus!= null && selectSkus.length == 0) { + productSku = miNiDetail.productSkuVOList.first; + } else { + productSku = miNiDetail.productSkuVOList.firstWhere((element) { + bool gg = true; + selectSkus.forEach((element1) { + if (element.skuNameStr.indexOf(element1) < 0) { + gg = false; + return gg; + } + }); + return gg; + }); + } + if (productSku == null) return; + String skuId = productSku.id; + String skuValue = selectSkus + .toString() + .replaceAll("[", "") + .replaceAll("]", "") + .replaceAll(",", ""); + setState(() { + skuId1 = skuId; + skuValue1 = skuValue; + count1 = count; + }); + } + + ///商品➕1 + add(MiNiDetail miNiDetail, selectSkus) async { + + } + ///商品➖1 + reduce(MiNiDetail miNiDetail, selectSkus) async { + + } + + ///添加购物车按钮 + addShoppingCar() async { + BaseData> baseDate = await minService.addShoppingCart({ + "storeId":storeId, + "storeName": storeInfo?.storeName ?? "", + "numberOfPeople": numberOfPeople, + "tableId": tableId, + "parentId": parentId, + "parentCode": parentCode, + "shoppingCartSkuItemList": [ + { + "buyNum": count1, + "id":skuId1, + "productId": miNiDetail.id, + "productName": miNiDetail.productName, + "skuName": skuValue1, + "storeId":storeId, + "skuPrice": productSku.skuPrice, + "skuStock": productSku.skuStock, + "tableId": tableId, + }, + ], + }); + EasyLoading.dismiss(); + if (baseDate != null && baseDate.isSuccess) { + SmartDialog.showToast("添加购物车成功", alignment: Alignment.center); + } } + @override Widget build(BuildContext context) { return Stack( @@ -89,8 +290,9 @@ class _ShoppingGoodsDetails extends State { ), Container( color: Colors.white, + margin: EdgeInsets.only(bottom:72.h), child: Html( - data: "", + data:miNiDetail?.detail ?? "", customImageRenders: { networkSourceMatcher(): networkImageRender( loadingWidget: () { @@ -162,7 +364,7 @@ class _ShoppingGoodsDetails extends State { GestureDetector( onTap: () { setState(() { - // showCallMobile)(); + showCallMobile(); }); }, child: Column( @@ -199,12 +401,76 @@ class _ShoppingGoodsDetails extends State { return Container( child: Row( children: [ + GestureDetector( + onTap: (){ + setState(() { + addShoppingCar(); + }); + }, + child:Container( + alignment: Alignment.center, + width: 120.w, + height:37.h, + margin: EdgeInsets.only(left:6.w), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(16), + border: Border.all( + width: 1, + color: Color(0xFF32A060), + style: BorderStyle.solid, + ), + ), + child: Text( + "加入购物车", + style: TextStyle( + fontSize: 16.sp, + fontWeight: MyFontWeight.regular, + color: Color(0xFF32A060), + ), + ), + ), + ), + GestureDetector( + onTap: (){ + // toDownOrder(); + }, + child: Container( + alignment: Alignment.center, + width: 120.w, + height:37.h, + margin: EdgeInsets.only(left:6.w), + decoration: BoxDecoration( + color: Color(0xFF32A060), + borderRadius: BorderRadius.circular(16), + boxShadow: [ + BoxShadow( + color: Colors.black.withAlpha(12), + offset: Offset(0, 3), + blurRadius: 14, + spreadRadius: 0, + ), + ], + ), + child: Text( + "立即购买", + style: TextStyle( + fontSize: 16.sp, + fontWeight: MyFontWeight.regular, + color: Colors.white, + ), + ), + ) + ), + ///秒杀按钮 // GestureDetector( - // child:Container( + // onTap: (){ + // Navigator.of(context).popAndPushNamed('/router/group_details'); + // }, + // child: Container( // alignment: Alignment.center, // width: 120.w, - // height:37.h, - // margin: EdgeInsets.only(left:6.w), + // height:40.h, + // margin: EdgeInsets.only(left: 6.w), // decoration: BoxDecoration( // borderRadius: BorderRadius.circular(16), // border: Border.all( @@ -213,161 +479,276 @@ class _ShoppingGoodsDetails extends State { // style: BorderStyle.solid, // ), // ), - // child: Text( - // "加入购物车", - // style: TextStyle( - // fontSize: 16.sp, - // fontWeight: MyFontWeight.regular, - // color: Color(0xFF32A060), - // ), + // child: Column( + // children: [ + // Text.rich( + // TextSpan( + // children: [ + // TextSpan( + // text: "¥", + // style: TextStyle( + // fontSize: 7.sp, + // fontWeight: MyFontWeight.medium, + // color: Color(0xFF32A060), + // ), + // ), + // TextSpan( + // text: "284.00", + // style: TextStyle( + // fontSize: 10.sp, + // fontWeight: MyFontWeight.medium, + // color: Color(0xFF32A060), + // ), + // ), + // ], + // ), + // ), + // Expanded(child: + // Text( + // "原价购买", + // style: TextStyle( + // fontSize: 12.sp, + // fontWeight: MyFontWeight.medium, + // color: Color(0xFF32A060), + // ), + // )), + // ], // ), // ), // ), // GestureDetector( + // onTap: (){ + // Navigator.of(context).popAndPushNamed('/router/bargain_details'); + // }, + // child: Container( + // alignment: Alignment.center, + // width: 120.w, + // height: 40.h, + // margin: EdgeInsets.only(left: 6.w), + // decoration: BoxDecoration( + // color: Color(0xFF32A060), + // borderRadius: BorderRadius.circular(16), + // boxShadow: [ + // BoxShadow( + // color: Colors.black.withAlpha(12), + // offset: Offset(0, 3), + // blurRadius: 14, + // spreadRadius: 0, + // ), + // ], + // ), + // child: Column( + // children: [ + // Text.rich( + // TextSpan( + // children: [ + // TextSpan( + // text: "¥", + // style: TextStyle( + // fontSize: 7.sp, + // fontWeight: MyFontWeight.medium, + // color: Colors.white, + // ), + // ), + // TextSpan( + // text: "284.00", + // style: TextStyle( + // fontSize: 10.sp, + // fontWeight: MyFontWeight.medium, + // color: Colors.white, + // ), + // ), + // ], + // ), + // ), + // Expanded(child: + // Text( + // "我要秒杀", + // style: TextStyle( + // fontSize: 12.sp, + // fontWeight: MyFontWeight.medium, + // color: Colors.white, + // ), + // ),), + // ], + // ), + // )), + ///砍价 + // GestureDetector( + // onTap: (){ + // Navigator.of(context).popAndPushNamed('/router/bargain_details'); + // }, + // child: Container( + // alignment: Alignment.center, + // width: 120.w, + // height: 40.h, + // margin: EdgeInsets.only(left: 6.w), + // decoration: BoxDecoration( + // color: Color(0xFF32A060), + // borderRadius: BorderRadius.circular(16), + // boxShadow: [ + // BoxShadow( + // color: Colors.black.withAlpha(12), + // offset: Offset(0, 3), + // blurRadius: 14, + // spreadRadius: 0, + // ), + // ], + // ), + // child: Column( + // children: [ + // Text.rich( + // TextSpan( + // children: [ + // TextSpan( + // text: "¥", + // style: TextStyle( + // fontSize: 7.sp, + // fontWeight: MyFontWeight.medium, + // color: Colors.white, + // ), + // ), + // TextSpan( + // text: "284.00", + // style: TextStyle( + // fontSize: 10.sp, + // fontWeight: MyFontWeight.medium, + // color: Colors.white, + // ), + // ), + // ], + // ), + // ), + // Expanded(child: + // Text( + // "我要砍价", + // style: TextStyle( + // fontSize: 12.sp, + // fontWeight: MyFontWeight.medium, + // color: Colors.white, + // ), + // ),), + // ], + // ), + // )), + ///拼团按钮 + // GestureDetector( + // onTap: (){ + // Navigator.of(context).popAndPushNamed('/router/group_details'); + // }, // child: Container( // alignment: Alignment.center, // width: 120.w, - // height:37.h, - // margin: EdgeInsets.only(left:6.w), + // height:40.h, + // margin: EdgeInsets.only(left: 6.w), // decoration: BoxDecoration( - // color: Color(0xFF32A060), // borderRadius: BorderRadius.circular(16), - // boxShadow: [ - // BoxShadow( - // color: Colors.black.withAlpha(12), - // offset: Offset(0, 3), - // blurRadius: 14, - // spreadRadius: 0, + // border: Border.all( + // width: 1, + // color: Color(0xFF32A060), + // style: BorderStyle.solid, + // ), + // ), + // child: Column( + // children: [ + // Text.rich( + // TextSpan( + // children: [ + // TextSpan( + // text: "¥", + // style: TextStyle( + // fontSize: 7.sp, + // fontWeight: MyFontWeight.medium, + // color: Color(0xFF32A060), + // ), + // ), + // TextSpan( + // text: "284.00", + // style: TextStyle( + // fontSize: 10.sp, + // fontWeight: MyFontWeight.medium, + // color: Color(0xFF32A060), + // ), + // ), + // ], + // ), // ), + // Expanded(child: + // Text( + // "单人购买", + // style: TextStyle( + // fontSize: 12.sp, + // fontWeight: MyFontWeight.medium, + // color: Color(0xFF32A060), + // ), + // )), // ], // ), - // child: Text( - // "立即购买", - // style: TextStyle( - // fontSize: 16.sp, - // fontWeight: MyFontWeight.regular, - // color: Colors.white, - // ), - // ), - // ) + // ), // ), - ///秒杀按钮 - GestureDetector( - onTap: (){ - Navigator.of(context).popAndPushNamed('/router/group_details'); - }, - child: Container( - alignment: Alignment.center, - width: 120.w, - height:40.h, - margin: EdgeInsets.only(left: 6.w), - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(16), - border: Border.all( - width: 1, - color: Color(0xFF32A060), - style: BorderStyle.solid, - ), - ), - child: Column( - children: [ - Text.rich( - TextSpan( - children: [ - TextSpan( - text: "¥", - style: TextStyle( - fontSize: 7.sp, - fontWeight: MyFontWeight.medium, - color: Color(0xFF32A060), - ), - ), - TextSpan( - text: "284.00", - style: TextStyle( - fontSize: 10.sp, - fontWeight: MyFontWeight.medium, - color: Color(0xFF32A060), - ), - ), - ], - ), - ), - Expanded(child: - Text( - "原价购买", - style: TextStyle( - fontSize: 12.sp, - fontWeight: MyFontWeight.medium, - color: Color(0xFF32A060), - ), - )), - ], - ), - ), - ), - GestureDetector( - onTap: (){ - Navigator.of(context).popAndPushNamed('/router/bargain_details'); - }, - child: Container( - alignment: Alignment.center, - width: 120.w, - height: 40.h, - margin: EdgeInsets.only(left: 6.w), - decoration: BoxDecoration( - color: Color(0xFF32A060), - borderRadius: BorderRadius.circular(16), - boxShadow: [ - BoxShadow( - color: Colors.black.withAlpha(12), - offset: Offset(0, 3), - blurRadius: 14, - spreadRadius: 0, - ), - ], - ), - child: Column( - children: [ - Text.rich( - TextSpan( - children: [ - TextSpan( - text: "¥", - style: TextStyle( - fontSize: 7.sp, - fontWeight: MyFontWeight.medium, - color: Colors.white, - ), - ), - TextSpan( - text: "284.00", - style: TextStyle( - fontSize: 10.sp, - fontWeight: MyFontWeight.medium, - color: Colors.white, - ), - ), - ], - ), - ), - Expanded(child: - Text( - "我要秒杀", - style: TextStyle( - fontSize: 12.sp, - fontWeight: MyFontWeight.medium, - color: Colors.white, - ), - ),), - ], - ), - )), + // GestureDetector( + // onTap: (){ + // Navigator.of(context).popAndPushNamed('/router/bargain_details'); + // }, + // child: Container( + // alignment: Alignment.center, + // width: 120.w, + // height: 40.h, + // margin: EdgeInsets.only(left: 6.w), + // decoration: BoxDecoration( + // color: Color(0xFF32A060), + // borderRadius: BorderRadius.circular(16), + // boxShadow: [ + // BoxShadow( + // color: Colors.black.withAlpha(12), + // offset: Offset(0, 3), + // blurRadius: 14, + // spreadRadius: 0, + // ), + // ], + // ), + // child: Column( + // children: [ + // Text.rich( + // TextSpan( + // children: [ + // TextSpan( + // text: "¥", + // style: TextStyle( + // fontSize: 7.sp, + // fontWeight: MyFontWeight.medium, + // color: Colors.white, + // ), + // ), + // TextSpan( + // text: "284.00", + // style: TextStyle( + // fontSize: 10.sp, + // fontWeight: MyFontWeight.medium, + // color: Colors.white, + // ), + // ), + // ], + // ), + // ), + // Expanded(child: + // Text( + // "我要开团", + // style: TextStyle( + // fontSize: 12.sp, + // fontWeight: MyFontWeight.medium, + // color: Colors.white, + // ), + // ),), + // ], + // ), + // )), ], ), ); } + ///商品top Widget buildColumn() { return Container( decoration: BoxDecoration( @@ -413,7 +794,7 @@ class _ShoppingGoodsDetails extends State { ), ), TextSpan( - text: "282.00", + text:miNiDetail?.price ?? "", style: TextStyle( fontSize: 28.sp, fontWeight: MyFontWeight.semi_bold, @@ -439,7 +820,7 @@ class _ShoppingGoodsDetails extends State { ), ), Text( - "已售12件", + "已售${miNiDetail?.sellCount ?? 0}件", style: TextStyle( fontWeight: MyFontWeight.medium, fontSize: 10.sp, @@ -455,7 +836,7 @@ class _ShoppingGoodsDetails extends State { padding: EdgeInsets.fromLTRB(16.w, 16.h, 16.w, 16.h), child: Column( mainAxisAlignment: MainAxisAlignment.spaceAround, - crossAxisAlignment: CrossAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.start, children: [ Row( mainAxisAlignment: MainAxisAlignment.spaceAround, @@ -463,7 +844,7 @@ class _ShoppingGoodsDetails extends State { children: [ Expanded( child: Text( - "[前进麦味]全麦吐司250g", + miNiDetail?.productName ?? "", style: TextStyle( fontWeight: MyFontWeight.semi_bold, fontSize: 15.sp, @@ -481,7 +862,7 @@ class _ShoppingGoodsDetails extends State { color: Color(0xFF5A5A5A), ), child: Text( - "中国大陆5仓", + miNiDetail?.supplierName ?? "", style: TextStyle( fontSize: 10.sp, fontWeight: MyFontWeight.regular, @@ -495,7 +876,7 @@ class _ShoppingGoodsDetails extends State { height: 8.h, ), Text( - "人生没有标准答案,一切答案都在行动中,前进卖完也是一样,用真诚行动践行标准的定义", + miNiDetail?.shortName ?? "", maxLines: 2, overflow: TextOverflow.ellipsis, style: TextStyle( @@ -531,16 +912,16 @@ class _ShoppingGoodsDetails extends State { ), itemBuilder: (context, position) { return - // goods == null - // ? + miNiDetail == null + ? Container() - // : Image.network( - // goods.viceImgPaths.elementAt(position), - // fit: BoxFit.cover, - // ) + : Image.network( + miNiDetail.imgs.elementAt(position), + fit: BoxFit.cover, + ) ; }, - itemCount: 3, + itemCount:miNiDetail?.imgs?.length ?? 0, ), GestureDetector( onTap: () { @@ -638,7 +1019,7 @@ class _ShoppingGoodsDetails extends State { ), Expanded( child: Text( - "250ml/瓶*2(礼盒装)", + ( skuValue1 ?? "请选择規格") + (count1 > 0 ? "x${count1}" : ""), overflow: TextOverflow.ellipsis, maxLines: 2, style: TextStyle( @@ -649,7 +1030,11 @@ class _ShoppingGoodsDetails extends State { ), ), GestureDetector( - onTap: () {}, + onTap: () { + setState(() { + showStoreSelector(miNiDetail, id,1); + }); + }, child: Icon( Icons.arrow_forward_ios, color: Colors.black, @@ -1192,44 +1577,44 @@ class _ShoppingGoodsDetails extends State { } ///联系电话 -// showCallMobile() { -// showCupertinoModalPopup( -// context: context, -// builder: (context) { -// return CupertinoActionSheet( -// title: Text(S.of(context).bodadianhua), -// actions: [ -// if (widget.storeInfo != null && -// widget.storeInfo.tel != null && -// widget.storeInfo.tel != "") -// CupertinoActionSheetAction( -// child: Text(widget.storeInfo.tel), -// onPressed: () { -// callMobile(widget.storeInfo.tel); -// Navigator.of(context).pop(); -// }, -// isDefaultAction: true, -// isDestructiveAction: false, -// ), -// ], -// cancelButton: CupertinoActionSheetAction( -// onPressed: () { -// Navigator.of(context).pop(); -// }, -// child: Text(S.of(context).quxiao), -// isDestructiveAction: true, -// ), -// ); -// }); -// } -// -// callMobile(mobile) async { -// String url = "tel:$mobile"; -// if (await canLaunch(url)) { -// await launch(url); -// } else { -// throw 'Could not launch $url'; -// } -// } +showCallMobile() { + showCupertinoModalPopup( + context: context, + builder: (context) { + return CupertinoActionSheet( + title: Text(S.of(context).bodadianhua), + actions: [ + if (storeInfo != null && + storeInfo.tel != null && + storeInfo.tel != "") + CupertinoActionSheetAction( + child: Text(storeInfo.tel), + onPressed: () { + callMobile(storeInfo.tel); + Navigator.of(context).pop(); + }, + isDefaultAction: true, + isDestructiveAction: false, + ), + ], + cancelButton: CupertinoActionSheetAction( + onPressed: () { + Navigator.of(context).pop(); + }, + child: Text(S.of(context).quxiao), + isDestructiveAction: true, + ), + ); + }); +} + +callMobile(mobile) async { + String url = "tel:$mobile"; + if (await canLaunch(url)) { + await launch(url); + } else { + throw 'Could not launch $url'; + } +} } diff --git a/lib/store/shopping/shopping_home/activity_banner.dart b/lib/store/shopping/shopping_home/activity_banner.dart index 83bf20ce..8698b1cc 100644 --- a/lib/store/shopping/shopping_home/activity_banner.dart +++ b/lib/store/shopping/shopping_home/activity_banner.dart @@ -3,6 +3,7 @@ import 'dart:convert'; import 'package:flutter/material.dart'; import 'package:flutter_swiper/flutter_swiper.dart'; import 'package:huixiang/retrofit/data/banner.dart'; +import 'package:huixiang/retrofit/data/shopping_home_config.dart'; import 'package:huixiang/retrofit/retrofit_api.dart'; import 'package:huixiang/view_widget/custom_image.dart'; import 'package:pull_to_refresh/pull_to_refresh.dart'; @@ -10,10 +11,12 @@ import 'package:huixiang/utils/font_weight.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; class ActivityBanner extends StatefulWidget { - final List bannerData; - final SwiperController controller; + final List specialArea; + final String minToken; + final String storeId; + final String tenant; - ActivityBanner(this.bannerData, this.controller); + ActivityBanner(this.specialArea,this.minToken,this.storeId,this.tenant); @override State createState() { @@ -24,17 +27,21 @@ class ActivityBanner extends StatefulWidget { class _ActivityBanner extends State { ApiService apiService; final RefreshController refreshController = RefreshController(); - List bannerData = []; + + @override + void initState() { + super.initState(); + } @override Widget build(BuildContext context) { return Container( margin: EdgeInsets.only(bottom:10), child: AspectRatio( - aspectRatio: 1.23, + aspectRatio: 1.32, child: Swiper( viewportFraction: 0.9, - scale: 0.73, + scale: 0.7, pagination: SwiperPagination( alignment: Alignment.bottomCenter, builder: DotSwiperPaginationBuilder( @@ -51,29 +58,26 @@ class _ActivityBanner extends State { children: [ InkWell( onTap: () { - bannerClick(widget.bannerData[position]); + setState(() { + }); }, - child: - // MImage( - // (widget.bannerData != null && - // position < widget.bannerData.length) - // ? widget.bannerData[position].imgUrl - // : "", - // width:double.infinity, - // fit: BoxFit.cover, - // errorSrc: "assets/image/default_2_1.png", - // fadeSrc: "assets/image/default_2_1.png", - // ), - Image.asset( - "assets/image/icon_story_td.png", - height:185, - width:double.infinity, + child: ClipRRect( + child:Image.network( + widget?.specialArea[position]?.img ?? "", + width: double.infinity, + height: 165.h, fit: BoxFit.cover, ), + borderRadius: BorderRadius.only( + topLeft: Radius.circular(8), + topRight: Radius.circular(8), + bottomLeft: Radius.circular(0), + bottomRight: Radius.circular(0), + ), + ) ), - // Expanded(child: child) Container( - height: 138, + height: 143, decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.vertical(bottom: Radius.circular(8)), @@ -82,16 +86,20 @@ class _ActivityBanner extends State { scrollDirection: Axis.horizontal, physics: BouncingScrollPhysics(), padding: EdgeInsets.symmetric(horizontal: 12), - itemCount: 4, - itemBuilder: (context, position) { + itemCount:widget?.specialArea[position]?.productList?.length ?? 0, + itemBuilder: (context, index) { return GestureDetector( onTap: () { Navigator.of(context).pushNamed( '/router/shopping_goods_details', - arguments: {}, + arguments: { + "id":widget.specialArea[position].productList[index].id, + "storeId":widget.storeId, + "tenant":widget.tenant, + }, ); }, - child: activityBannerItem(), + child: activityBannerItem(widget.specialArea[position].productList[index]), ); }, ), @@ -99,41 +107,38 @@ class _ActivityBanner extends State { ], ); }, - itemCount: - (widget.bannerData != null && widget.bannerData.length > 0) - ? widget.bannerData.length - : 1), + itemCount:widget?.specialArea?.length ?? 0, + ), ), ); } - Widget activityBannerItem() { + Widget activityBannerItem(ProductList productList) { return Container( margin: EdgeInsets.only(right:7.w,left:7.w), child: Column( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, children: [ - // MImage( - // "assets/image/icon_story_td.png", - // isCircle: true, - // width: 70.w, - // height: 70.h, - // fit: BoxFit.cover, - // errorSrc: "assets/image/default_1.png", - // fadeSrc: "assets/image/default_1.png", - // ), - Image.asset( - "assets/image/icon_story_td.png", + Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.vertical(top: Radius.circular(8)), + ), + child: + MImage( + productList?.productImg ?? "", + isCircle: true, width: 70, height: 70, fit: BoxFit.cover, - ), + errorSrc: "assets/image/default_1.png", + fadeSrc: "assets/image/default_1.png", + )), SizedBox( height: 4, ), Text( - "[一心回乡]甄果", + productList?.productName ?? "", style: TextStyle( fontSize: 10.sp, fontWeight: MyFontWeight.regular, @@ -152,7 +157,7 @@ class _ActivityBanner extends State { ), ), TextSpan( - text: "12.60", + text:productList?.price ?? "", style: TextStyle( fontSize: 14.sp, fontWeight: MyFontWeight.semi_bold, @@ -166,40 +171,4 @@ class _ActivityBanner extends State { ), ); } - - /// contentType 跳转类型(0:不跳转,1:积分商品,2:活动,3:文章,4:页面跳转,5:课程) - bannerClick(BannerData bannerData) async { - switch (bannerData.contentType) { - case 1: - Navigator.of(context).pushNamed('/router/integral_store_page', - arguments: {"goodsId": bannerData.content}); - break; - case 2: - Navigator.of(context).pushNamed('/router/web_page', arguments: { - "activityId": bannerData.content, - }); - break; - case 3: - Navigator.of(context).pushNamed('/router/web_page', arguments: { - "articleId": bannerData.content, - }); - break; - case 4: - String router = bannerData.content; - if (router.contains("?")) { - String params = router.substring(router.indexOf("?")); - params = params.replaceAll("?", ""); - Map map = jsonDecode(params); - Navigator.of(context).pushNamed(router, arguments: map); - } else { - Navigator.of(context).pushNamed(router); - } - break; - case 5: - Navigator.of(context).pushNamed('/router/class_details', arguments: { - "id": bannerData.content, - }); - break; - } - } } diff --git a/lib/store/shopping/shopping_home/classify_list.dart b/lib/store/shopping/shopping_home/classify_list.dart index aaeecec4..a0255a5b 100644 --- a/lib/store/shopping/shopping_home/classify_list.dart +++ b/lib/store/shopping/shopping_home/classify_list.dart @@ -1,11 +1,19 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_baidu_mapapi_base/flutter_baidu_mapapi_base.dart'; +import 'package:huixiang/retrofit/data/shopping_home_config.dart'; import 'package:huixiang/retrofit/retrofit_api.dart'; import 'package:huixiang/utils/font_weight.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:huixiang/view_widget/custom_image.dart'; class ClassifyList extends StatefulWidget { + final List groupList; + final String minToken; + final String storeId; + final String tenant; + + ClassifyList(this.groupList,this.minToken,this.storeId,this.tenant); @override State createState() { @@ -15,9 +23,6 @@ class ClassifyList extends StatefulWidget { class _ClassifyList extends State { ApiService apiService; - BMFCoordinate latLng; - - final TextEditingController editingController = TextEditingController(); @override void initState() { @@ -46,44 +51,44 @@ class _ClassifyList extends State { scrollDirection: Axis.horizontal, physics: BouncingScrollPhysics(), padding: EdgeInsets.symmetric(horizontal: 14), - itemCount:15, + itemCount:widget?.groupList?.length ?? 0, itemBuilder: (context, position) { return GestureDetector( onTap: () { Navigator.of(context) - .pushNamed('/router/search_page'); + .pushNamed('/router/search_page', + arguments: { + "minToken": widget.minToken, + "tenant": widget.tenant, + "storeId": widget.storeId, + "searchKey":widget.groupList[position].groupName, + }); }, - child: classifyItem(), + child: classifyItem(widget.groupList[position]), ); }, ), ); } - Widget classifyItem() { + Widget classifyItem(GroupList groupList) { return Container( - // height:94.h, + height:94.h, margin: EdgeInsets.only(right: 19.w), child: Column( children: [ - // MImage( - // "assets/image/icon_story_td.png", - // isCircle: true, - // width: 48.w, - // height: 48.h, - // fit: BoxFit.cover, - // errorSrc: "assets/image/default_1.png", - // fadeSrc: "assets/image/default_1.png", - // ), - Image.asset( - "assets/image/icon_story_td.png", + MImage( + groupList?.groupImg ?? "", + isCircle: true, width: 48, height: 48, fit: BoxFit.cover, + errorSrc: "assets/image/default_1.png", + fadeSrc: "assets/image/default_1.png", ), SizedBox(height: 4,), Text( - "时令水果", + groupList?.groupName ?? "", style: TextStyle( fontSize: 11.sp, fontWeight: MyFontWeight.regular, diff --git a/lib/store/shopping/shopping_home/recommend_goods_list_view.dart b/lib/store/shopping/shopping_home/recommend_goods_list_view.dart index b98bfa1b..0aa43985 100644 --- a/lib/store/shopping/shopping_home/recommend_goods_list_view.dart +++ b/lib/store/shopping/shopping_home/recommend_goods_list_view.dart @@ -1,9 +1,19 @@ import 'package:flutter/material.dart'; +import 'package:huixiang/retrofit/data/home_recommend_list.dart'; +import 'package:huixiang/retrofit/data/store_info.dart'; import 'package:huixiang/utils/flutter_utils.dart'; import 'package:huixiang/utils/font_weight.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:huixiang/view_widget/custom_image.dart'; class RecommendGoodsListView extends StatefulWidget { + final List homeRecommendList; + final String storeId; + final String tenant; + + + RecommendGoodsListView(this.homeRecommendList,this.storeId,this.tenant); + @override State createState() { return _RecommendGoodsListView(); @@ -11,6 +21,12 @@ class RecommendGoodsListView extends StatefulWidget { } class _RecommendGoodsListView extends State { + + @override + void initState() { + super.initState(); + } + @override Widget build(BuildContext context) { return Column( @@ -31,7 +47,7 @@ class _RecommendGoodsListView extends State { height: 5.h, ), GridView.builder( - itemCount: 6, + itemCount:widget.homeRecommendList == null ? 0 : widget.homeRecommendList.length, padding: EdgeInsets.only( left: 16.w, right: 16.w, @@ -56,10 +72,14 @@ class _RecommendGoodsListView extends State { onTap: () { Navigator.of(context).pushNamed( '/router/shopping_goods_details', - arguments: {}, + arguments: { + "id":widget.homeRecommendList[index].id, + "storeId":widget.storeId, + "tenant":widget.tenant, + }, ); }, - child: goodsListItem(), + child: goodsListItem(widget.homeRecommendList[index]), ); }, ) @@ -67,7 +87,7 @@ class _RecommendGoodsListView extends State { ); } - Widget goodsListItem() { + Widget goodsListItem(HomeRecommendList homeRecommendList) { return Container( decoration: BoxDecoration( borderRadius: BorderRadius.vertical( @@ -102,19 +122,14 @@ class _RecommendGoodsListView extends State { ], ), child: - // MImage( - // "", - // width: double.infinity, - // height: 166, - // fit: BoxFit.cover, - // errorSrc: "assets/image/default_1.png", - // fadeSrc: "assets/image/default_1.png", - // ), - Image.asset( - "assets/image/icon_story_td.png", - width: double.infinity, - fit: BoxFit.cover, - ), + MImage( + homeRecommendList.imgs[0], + width: double.infinity, + height: 166, + fit: BoxFit.cover, + errorSrc: "assets/image/default_1.png", + fadeSrc: "assets/image/default_1.png", + ), ), Expanded( child: Container( @@ -137,7 +152,7 @@ class _RecommendGoodsListView extends State { color: Color(0xFF5A5A5A), ), child: Text( - "中国大陆5仓", + homeRecommendList?.supplierName ?? "", style: TextStyle( fontSize: 10.sp, fontWeight: MyFontWeight.regular, @@ -146,7 +161,7 @@ class _RecommendGoodsListView extends State { ), ), Text( - "已售12件", + "已售${homeRecommendList?.sellCount ?? 0}件", style: TextStyle( fontSize: 12.sp, fontWeight: MyFontWeight.regular, @@ -156,7 +171,7 @@ class _RecommendGoodsListView extends State { ], ), Text( - "SWISSGEAR瑞士军刀联名款马克杯", + homeRecommendList?.productName ?? "", maxLines: 2, overflow: TextOverflow.ellipsis, style: TextStyle( @@ -181,7 +196,7 @@ class _RecommendGoodsListView extends State { ), ), TextSpan( - text: "284.00", + text:homeRecommendList?.price ??"", style: TextStyle( fontSize: 18.sp, fontWeight: MyFontWeight.semi_bold, diff --git a/lib/store/shopping/shopping_home/search_page.dart b/lib/store/shopping/shopping_home/search_page.dart index f6482224..7ac7e71d 100644 --- a/lib/store/shopping/shopping_home/search_page.dart +++ b/lib/store/shopping/shopping_home/search_page.dart @@ -1,48 +1,162 @@ import 'package:dio/dio.dart'; import 'package:flutter/material.dart'; -import 'package:flutter/services.dart'; -import 'package:flutter_easyloading/flutter_easyloading.dart'; -import 'package:flutter_html/flutter_html.dart'; +import 'package:flutter_baidu_mapapi_base/flutter_baidu_mapapi_base.dart'; import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; -import 'package:fluwx/fluwx.dart'; -import 'package:huixiang/generated/l10n.dart'; import 'package:huixiang/retrofit/data/base_data.dart'; -import 'package:huixiang/retrofit/data/vip_benefit_list.dart'; -import 'package:huixiang/retrofit/data/vip_rule_details.dart'; -import 'package:huixiang/retrofit/data/wx_pay.dart'; +import 'package:huixiang/retrofit/data/findMiNiGroupList.dart'; +import 'package:huixiang/retrofit/min_api.dart'; import 'package:huixiang/retrofit/retrofit_api.dart'; import 'package:huixiang/utils/flutter_utils.dart'; import 'package:huixiang/utils/font_weight.dart'; -import 'package:huixiang/utils/min.dart'; import 'package:huixiang/view_widget/classic_header.dart'; -import 'package:huixiang/view_widget/icon_text.dart'; -import 'package:huixiang/view_widget/item_input_widget.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; -import 'package:huixiang/view_widget/my_appbar.dart'; +import 'package:huixiang/view_widget/custom_image.dart'; import 'package:huixiang/view_widget/round_button.dart'; import 'package:pull_to_refresh/pull_to_refresh.dart'; import 'package:shared_preferences/shared_preferences.dart'; class SearchPage extends StatefulWidget { + final Map arguments; + + SearchPage({this.arguments}); @override State createState() { return _SearchPage(); } } -class _SearchPage extends State { +class _SearchPage extends State with AutomaticKeepAliveClientMixin, WidgetsBindingObserver { ApiService apiService; - TextEditingController controller = TextEditingController(); + MinApiService minService; + final TextEditingController editingController = TextEditingController(); final RefreshController refreshController = RefreshController(); int optionIndex = 0; + bool isKeyBoardShow = false; + List productListBeans = []; + List hotSearch =[]; + List historySearch = []; + FocusNode _focusNode = FocusNode(); + bool hasFocus = true; + + @override + void didChangeMetrics() { + super.didChangeMetrics(); + WidgetsBinding.instance.addPostFrameCallback((_) { + setState(() { + print("object: ${MediaQuery.of(context).viewInsets.bottom}"); + if (MediaQuery.of(context).viewInsets.bottom == 0) { + if (isKeyBoardShow) { + isKeyBoardShow = false; + //关闭键盘 软键盘关闭了, 清除输入控件的焦点, 否则重新进入页面会导致软键盘再弹出问题 + FocusScope.of(context).requestFocus(FocusNode()); + } + } else { + isKeyBoardShow = true; + } + }); + }); + } + + ///离开页面记着销毁和清除 + @override + void dispose() { + _focusNode.unfocus(); + super.dispose(); + } @override void initState() { super.initState(); + setState(() { + if(widget.arguments["hotSearch"] != null) + hotSearch.addAll(widget.arguments["hotSearch"]); + }); + _focusNode.addListener((){ + setState(() { + hasFocus = _focusNode.hasFocus; + }); + }); + if(widget.arguments["searchKey"] != null){ + setState(() { + editingController.text =widget.arguments["searchKey"]; + }); + appletGoods(widget.arguments["searchKey"]); + + } + } + + ///获取保存列表 + getHistorySearch()async{ + SharedPreferences value = await SharedPreferences.getInstance(); + var str = value.getString("historySearch"); + if(str == null ) + return; + var strArr = str.split("&"); + strArr.removeAt(strArr.length - 1); + setState(() { + historySearch.clear(); + historySearch.addAll(strArr); + }); + } + + ///保存列表 + setHistorySearch(String text)async{ + SharedPreferences value = await SharedPreferences.getInstance(); + var str = value.getString("historySearch"); + if(str == null ) + str = ""; + var strArr = str.split("&"); + if(strArr.length >30){ + str = strArr.getRange(0, 29).join("&"); + } else{ + str = strArr.join("&"); + } + str += text + "&"; + value.setString("historySearch", str); + getHistorySearch(); + } + + ///删除历史列表 + delHistorySearch()async{ + SharedPreferences value = await SharedPreferences.getInstance(); + value.setString("historySearch", ""); + getHistorySearch(); + } + + ///小程序查询分组及商品列表 + appletGoods(String text) async { + if(minService == null) + minService = MinApiService( + Dio(), + context: context, + token: widget.arguments["minToken"], + tenant:widget.arguments["tenant"], + storeId: widget.arguments["storeId"], + ); + + BaseData> baseData = + await minService.findMiNiGroupList({ + "id":widget.arguments["storeId"], + "searchKey" :text, + }).catchError((error) { + refreshController.refreshFailed(); + }); + + if (baseData != null && baseData.isSuccess) { + refreshController.refreshCompleted(); + setState(() { + productListBeans.clear(); + if(baseData.data.length > 0) + productListBeans.addAll(baseData.data[0].productList); + }); + } else { + refreshController.refreshFailed(); + } - SharedPreferences.getInstance().then((value) { - apiService = ApiService(Dio(), - context: context, token: value.getString("token"), pay: true); + setHistorySearch(text); + setState(() { + hasFocus = false; + FocusScope.of(context).requestFocus(FocusNode()); }); } @@ -86,60 +200,117 @@ class _SearchPage extends State { child: Row( children: [ GestureDetector( - onTap: (){ + onTap: () { Navigator.of(context).pop(); }, - child: Icon( + child: Icon( Icons.arrow_back_ios, size: 24, color: Colors.black, ), ), Expanded( - child: Container( - height: 30.h, - margin: EdgeInsets.fromLTRB(0.w, 0, 8.w, 0.h), - padding: EdgeInsets.fromLTRB(12.w, 7.h, 0, 7.h), - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.circular(18), - boxShadow: [ - BoxShadow( - color: Colors.black.withAlpha(12), - offset: Offset(0, 3), - blurRadius: 14, - spreadRadius: 0, + child: + Container( + height: 36.h, + margin: EdgeInsets.fromLTRB(6.w, 0, 14.w, 0), + padding: EdgeInsets.fromLTRB(0, 6.h, 0, 6.h), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(4), + boxShadow: [ + BoxShadow( + color: Colors.black.withAlpha(12), + offset: Offset(0, 3), + blurRadius: 14, + spreadRadius: 0, + ), + ], ), - ], - ), - child: GestureDetector( - onTap: () {}, - child: Row( - children: [ - Icon( - Icons.search, - size: 16, - color: Color(0xFFABACAB), - ), - SizedBox( - width: 3.w, - ), - Text( - "前进麦味", - style: TextStyle( - fontSize: 12.sp, - fontWeight: MyFontWeight.regular, - color: Color(0xFF727272), + child: TextField( + focusNode:_focusNode, + textInputAction: TextInputAction.search, + onEditingComplete: () { + // startLocation(); + }, + controller: editingController, + cursorHeight: 30.h, + decoration: InputDecoration( + contentPadding: EdgeInsets.symmetric( + vertical: 12.h, + ), + prefixIcon: Icon( + Icons.search, + size: 24, + color: Colors.black, ), + suffixIcon: InkWell( + onTap: () { + editingController.clear(); + }, + child: Icon( + Icons.close, + size: 19, + color: Colors.grey, + ), + ), + border: InputBorder.none, ), - ], - ), - ), - )), + ), + ) + // Container( + // height: 30.h, + // margin: EdgeInsets.fromLTRB(0.w, 0, 8.w, 0.h), + // padding: EdgeInsets.fromLTRB(12.w, 7.h, 0, 0.h), + // decoration: BoxDecoration( + // color: Colors.white, + // borderRadius: BorderRadius.circular(18), + // boxShadow: [ + // BoxShadow( + // color: Colors.black.withAlpha(12), + // offset: Offset(0, 3), + // blurRadius: 14, + // spreadRadius: 0, + // ), + // ], + // ), + // child: GestureDetector( + // onTap: () {}, + // child: Row( + // children: [ + // Icon( + // Icons.search, + // size: 16, + // color: Color(0xFFABACAB), + // ), + // SizedBox( + // width: 3.w, + // ), + // Text( + // "前进麦味", + // style: TextStyle( + // fontSize: 12.sp, + // fontWeight: MyFontWeight.regular, + // color: Color(0xFF727272), + // ), + // ), + // ], + // ), + // ), + // ) + ), Container( alignment: Alignment.center, child: GestureDetector( - onTap: () {}, + onTap: () { + setState(() { + if(editingController.text.trim() == ""){ + SmartDialog.showToast("请输入搜索内容", alignment: Alignment.center); + return; + } + appletGoods(editingController.text); + }); + }, child: Text( "搜索", style: TextStyle( @@ -165,7 +336,8 @@ class _SearchPage extends State { topRight: Radius.circular(8), ), ), - padding: EdgeInsets.only(left: 17.w, top: 16.h,right: 17.w), + padding: + EdgeInsets.only(left: 17.w, top: 16.h, right: 17.w), child: SmartRefresher( controller: refreshController, enablePullDown: true, @@ -182,8 +354,11 @@ class _SearchPage extends State { builder: (context, snapshot) { return Column( children: [ - // hotSearch(), - // historySearch(), + if(hasFocus) + hotSearchWords(), + if(hasFocus) + historySearchWords(), + if(!hasFocus) searchList() ], ); @@ -202,7 +377,7 @@ class _SearchPage extends State { } ///热门搜索 - Widget hotSearch() { + Widget hotSearchWords() { return Container( width: double.infinity, child: Column( @@ -219,13 +394,13 @@ class _SearchPage extends State { ), SizedBox(height: 16.h), GridView.builder( - itemCount: 6, + itemCount:hotSearch?.length ?? 0, shrinkWrap: true, padding: EdgeInsets.zero, physics: NeverScrollableScrollPhysics(), gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( //一行的Widget数量 - crossAxisCount: 4, + crossAxisCount:4, //水平子Widget之间间距 crossAxisSpacing: 6.w, //垂直子Widget之间间距 @@ -235,8 +410,9 @@ class _SearchPage extends State { ), itemBuilder: (context, index) { return GestureDetector( - onTap: () {}, - child: hotSearchItem(), + onTap: () { + }, + child: hotSearchItem(hotSearch[index]), ); }, ), @@ -245,16 +421,16 @@ class _SearchPage extends State { ); } - Widget hotSearchItem() { + Widget hotSearchItem(String hotSearch) { return Container( child: Row( mainAxisAlignment: MainAxisAlignment.spaceAround, crossAxisAlignment: CrossAxisAlignment.start, children: [ RoundButton( - width: 68.w, + padding: EdgeInsets.only(left: 4, right: 4), height: 29.h, - text: "稻田里的书店", + text:hotSearch, textColor: Color(0xFF181818), fontWeight: MyFontWeight.regular, radius: 4, @@ -267,7 +443,7 @@ class _SearchPage extends State { } ///历史搜索 - Widget historySearch() { + Widget historySearchWords() { return Container( width: double.infinity, child: Column( @@ -276,7 +452,8 @@ class _SearchPage extends State { children: [ Row( children: [ - Expanded(child:Text( + Expanded( + child: Text( "历史搜索", style: TextStyle( fontSize: 15.sp, @@ -287,28 +464,34 @@ class _SearchPage extends State { Image.asset( "assets/image/icon_delete.png", width: 22.w, - height:20.h, + height: 20.h, ), - Text( - "删除", - style: TextStyle( - fontSize: 15.sp, - fontWeight: MyFontWeight.semi_bold, - color: Color(0xFF181818), + GestureDetector( + onTap: (){ + setState(() { + delHistorySearch(); + }); + }, + child:Text( + "删除", + style: TextStyle( + fontSize: 15.sp, + fontWeight: MyFontWeight.semi_bold, + color: Color(0xFF181818), + ), ), - ), + ) ], ), - SizedBox(height: 16.h), GridView.builder( - itemCount: 6, + itemCount:historySearch?.length ?? 0, shrinkWrap: true, padding: EdgeInsets.zero, physics: NeverScrollableScrollPhysics(), gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( //一行的Widget数量 - crossAxisCount: 4, + crossAxisCount:4, //水平子Widget之间间距 crossAxisSpacing: 6.w, //垂直子Widget之间间距 @@ -318,10 +501,8 @@ class _SearchPage extends State { ), itemBuilder: (context, index) { return GestureDetector( - onTap: () { - - }, - child: historySearchItem(), + onTap: () {}, + child: historySearchItem(historySearch[index]), ); }, ), @@ -330,16 +511,16 @@ class _SearchPage extends State { ); } - Widget historySearchItem() { + Widget historySearchItem(String historySearch) { return Container( child: Row( mainAxisAlignment: MainAxisAlignment.spaceAround, crossAxisAlignment: CrossAxisAlignment.start, children: [ RoundButton( - width: 68.w, + padding: EdgeInsets.only(left: 4, right: 4), height: 29.h, - text: "稻田里的书店", + text:historySearch, textColor: Color(0xFF181818), fontWeight: MyFontWeight.regular, radius: 4, @@ -364,69 +545,87 @@ class _SearchPage extends State { crossAxisAlignment: CrossAxisAlignment.start, children: [ GestureDetector( - onTap: (){ + onTap: () { setState(() { - optionIndex = 0 ; + optionIndex = 0; }); }, child: Text( "默认推荐", style: TextStyle( - fontSize: optionIndex == 0 ? 15.sp :14.sp, - fontWeight: optionIndex == 0 ? MyFontWeight.semi_bold : MyFontWeight.regular, - color: optionIndex == 0 ? Color(0xFF181818) : Color(0xFF4D4D4D), + fontSize: optionIndex == 0 ? 15.sp : 14.sp, + fontWeight: optionIndex == 0 + ? MyFontWeight.semi_bold + : MyFontWeight.regular, + color: optionIndex == 0 + ? Color(0xFF181818) + : Color(0xFF4D4D4D), ), ), ), GestureDetector( - onTap: (){ + onTap: () { setState(() { - optionIndex = 1 ; + optionIndex = 1; }); }, - child:Text( + child: Text( "销量", style: TextStyle( - fontSize: optionIndex == 1 ? 15.sp :14.sp, - fontWeight: optionIndex == 1 ? MyFontWeight.semi_bold : MyFontWeight.regular, - color: optionIndex == 1 ? Color(0xFF181818) : Color(0xFF4D4D4D), + fontSize: optionIndex == 1 ? 15.sp : 14.sp, + fontWeight: optionIndex == 1 + ? MyFontWeight.semi_bold + : MyFontWeight.regular, + color: optionIndex == 1 + ? Color(0xFF181818) + : Color(0xFF4D4D4D), ), ), ), GestureDetector( - onTap: (){ + onTap: () { setState(() { - optionIndex = 2 ; + optionIndex = 2; }); }, - child:Row(children: [ - Text( - "价格", - style: TextStyle( - fontSize: optionIndex == 2 ? 15.sp :14.sp, - fontWeight: optionIndex == 2 ? MyFontWeight.semi_bold : MyFontWeight.regular, - color: optionIndex == 2 ? Color(0xFF181818) : Color(0xFF4D4D4D), + child: Row( + children: [ + Text( + "价格", + style: TextStyle( + fontSize: optionIndex == 2 ? 15.sp : 14.sp, + fontWeight: optionIndex == 2 + ? MyFontWeight.semi_bold + : MyFontWeight.regular, + color: optionIndex == 2 + ? Color(0xFF181818) + : Color(0xFF4D4D4D), + ), ), - ), - Image.asset( - "assets/image/jg.png", - width:16, - height:16, - ), - ],), + Image.asset( + "assets/image/jg.png", + width: 16, + height: 16, + ), + ], + ), ), GestureDetector( - onTap: (){ + onTap: () { setState(() { - optionIndex = 3 ; + optionIndex = 3; }); }, child: Text( "专区", style: TextStyle( - fontSize: optionIndex == 3 ? 15.sp :14.sp, - fontWeight: optionIndex == 3 ? MyFontWeight.semi_bold : MyFontWeight.regular, - color: optionIndex == 3 ? Color(0xFF181818) : Color(0xFF4D4D4D), + fontSize: optionIndex == 3 ? 15.sp : 14.sp, + fontWeight: optionIndex == 3 + ? MyFontWeight.semi_bold + : MyFontWeight.regular, + color: optionIndex == 3 + ? Color(0xFF181818) + : Color(0xFF4D4D4D), ), ), ), @@ -434,28 +633,33 @@ class _SearchPage extends State { ), SizedBox(height: 16.h), GridView.builder( - itemCount:6, + itemCount:productListBeans?.length ?? 0, shrinkWrap: true, physics: NeverScrollableScrollPhysics(), gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( //一行的Widget数量 - crossAxisCount:2, + crossAxisCount: 2, //水平子Widget之间间距 crossAxisSpacing: 11.w, //垂直子Widget之间间距 mainAxisSpacing: 16.w, //子Widget宽高比例 0.59 childAspectRatio: - 185 / (281 / 2 + (281 / 2) * AppUtils.textScale(context)), + 185 / (281 / 2 + (281 / 2) * AppUtils.textScale(context)), ), itemBuilder: (context, index) { return GestureDetector( onTap: () { - Navigator.of(context).pushNamed('/router/shopping_mall_home',arguments: { - "type" : 1, - }); + Navigator.of(context).pushNamed( + '/router/shopping_goods_details', + arguments: { + "id":productListBeans[index].id, + "storeId":widget.arguments["storeId"], + "tenant":widget.arguments["tenant"], + }, + ); }, - child: searchListItem(), + child: searchListItem(productListBeans[index]), ); }, ) @@ -464,7 +668,7 @@ class _SearchPage extends State { ); } - Widget searchListItem() { + Widget searchListItem(ProductListBean productListBeans) { return Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(4), @@ -497,111 +701,111 @@ class _SearchPage extends State { ], ), child: - // MImage( - // "", - // width: double.infinity, - // height: 166, - // fit: BoxFit.cover, - // errorSrc: "assets/image/default_1.png", - // fadeSrc: "assets/image/default_1.png", - // ), - Image.asset( - "assets/image/icon_story_td.png", - width:double.infinity, - fit: BoxFit.cover, - ), + MImage( + productListBeans?.imgPath ??"", + width: double.infinity, + height: 166, + fit: BoxFit.cover, + errorSrc: "assets/image/default_1.png", + fadeSrc: "assets/image/default_1.png", + ), ), - Expanded(child:Container( - padding: EdgeInsets.only(left:8.w,right:8.w), - child: Column( - mainAxisAlignment: MainAxisAlignment.spaceAround, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - crossAxisAlignment: CrossAxisAlignment.end, - children: [ - Container( - margin: EdgeInsets.only(top: 8, right: 8), - padding: EdgeInsets.only(left: 2, right: 2), - height: 17.h, - alignment: Alignment.center, - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(2), - color: Color(0xFF5A5A5A), + Expanded( + child: Container( + padding: EdgeInsets.only(left: 8.w, right: 8.w), + child: Column( + mainAxisAlignment: MainAxisAlignment.spaceAround, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.end, + children: [ + Container( + margin: EdgeInsets.only(top: 8, right: 8), + padding: EdgeInsets.only(left: 2, right: 2), + height: 17.h, + alignment: Alignment.center, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(2), + color: Color(0xFF5A5A5A), + ), + child: Text( + productListBeans.supplierName, + style: TextStyle( + fontSize: 10.sp, + fontWeight: MyFontWeight.regular, + color: Colors.white, + ), + ), ), - child: Text( - "中国大陆5仓", + Text( + "已售${productListBeans?.sellCount ?? 0}件", style: TextStyle( - fontSize: 10.sp, + fontSize: 12.sp, fontWeight: MyFontWeight.regular, - color: Colors.white, + color: Color(0xFF5D5D5D), ), ), + ], + ), + Text( + productListBeans?.productName ?? "", + maxLines: 2, + overflow: TextOverflow.ellipsis, + style: TextStyle( + fontSize: 16.sp, + fontWeight: MyFontWeight.medium, + color: Color(0xFF353535), ), - Text( - "已售12件", - style: TextStyle( - fontSize: 12.sp, - fontWeight: MyFontWeight.regular, - color: Color(0xFF5D5D5D), - ), - ), - ], - ), - Text( - "SWISSGEAR瑞士军刀联名款马克杯", - maxLines: 2, - overflow: TextOverflow.ellipsis, - style: TextStyle( - fontSize: 16.sp, - fontWeight: MyFontWeight.medium, - color: Color(0xFF353535), ), - ), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - crossAxisAlignment: CrossAxisAlignment.end, - children: [ - Text.rich( - TextSpan( - children: [ - TextSpan( - text: "¥", - style: TextStyle( - fontSize: 12.sp, - fontWeight: MyFontWeight.semi_bold, - color: Color(0xFF32A060), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.end, + children: [ + Text.rich( + TextSpan( + children: [ + TextSpan( + text: "¥", + style: TextStyle( + fontSize: 12.sp, + fontWeight: MyFontWeight.semi_bold, + color: Color(0xFF32A060), + ), ), - ), - TextSpan( - text: "284.00", - style: TextStyle( - fontSize:18.sp, - fontWeight: MyFontWeight.semi_bold, - color: Color(0xFF32A060), + TextSpan( + text:productListBeans?.price ?? "", + style: TextStyle( + fontSize: 18.sp, + fontWeight: MyFontWeight.semi_bold, + color: Color(0xFF32A060), + ), ), - ), - ], + ], + ), ), - ), - Text( - "¥283.00", - style: TextStyle( - fontSize:14.sp, - decoration: TextDecoration.lineThrough, - decorationColor: Color(0xFF585858), - fontWeight: MyFontWeight.regular, - color: Color(0xFFA2A2A2), + Text( + "¥283.00", + style: TextStyle( + fontSize: 14.sp, + decoration: TextDecoration.lineThrough, + decorationColor: Color(0xFF585858), + fontWeight: MyFontWeight.regular, + color: Color(0xFFA2A2A2), + ), ), - ), - ], - ), - ], + ], + ), + ], + ), ), - ),) + ) ], ), ); } + + @override + bool get wantKeepAlive => true; } diff --git a/lib/store/shopping/shopping_home/shopping_acticvity.dart b/lib/store/shopping/shopping_home/shopping_acticvity.dart index 0f939ed7..f466ee53 100644 --- a/lib/store/shopping/shopping_home/shopping_acticvity.dart +++ b/lib/store/shopping/shopping_home/shopping_acticvity.dart @@ -5,13 +5,20 @@ 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/page.dart'; +import 'package:huixiang/retrofit/data/shopping_home_config.dart'; import 'package:huixiang/retrofit/retrofit_api.dart'; import 'package:huixiang/utils/font_weight.dart'; +import 'package:huixiang/view_widget/custom_image.dart'; import 'package:huixiang/view_widget/item_title.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:shared_preferences/shared_preferences.dart'; class ShoppingActivity extends StatefulWidget { + final String storeId; + final String tenant; + final List quickEntry; + + ShoppingActivity(this.storeId,this.tenant,this.quickEntry); @override State createState() { return _ShoppingActivity(); @@ -26,6 +33,28 @@ class _ShoppingActivity extends State { super.initState(); } + ///url跳转 + jumpActivity(String url) { + var router = url.substring(0,url.contains("?")?url.indexOf("?") : (url.length - 1)); + Map argumentsMap = Map(); + argumentsMap["storeId"] =widget.storeId; + argumentsMap["tenant"] =widget.tenant; + if(url.contains("?")){ + var data = url.substring(url.indexOf("?") + 1); + var dataArr = data.split("&"); + dataArr.forEach((element) { + if(element.contains("=")){ + var tempData = element.split("="); + if(tempData.length == 2){ + argumentsMap[tempData[0]] = tempData[1]; + } + } + }); + } + Navigator.of(context).pushNamed(router, + arguments:argumentsMap); + } + @override Widget build(BuildContext context) { return Column( @@ -39,88 +68,92 @@ class _ShoppingActivity extends State { children: [ GestureDetector( onTap: () { - Navigator.of(context).pushNamed('/router/activity_prefecture_details', - arguments: { - "type":2 - }); + jumpActivity(widget?.quickEntry[0].url); }, child: Container( margin: EdgeInsets.symmetric(horizontal: 5.w ), - padding: EdgeInsets.only(left: 12.w), + // padding: EdgeInsets.only(left: 12.w), width: (MediaQuery.of(context).size.width - 42) / 2, height: 195.h, decoration: BoxDecoration( borderRadius: BorderRadius.circular(8), color: Colors.white, ), - child: Column( - mainAxisAlignment: MainAxisAlignment.spaceAround, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - "回乡秒杀", - style: TextStyle( - fontSize: 15.sp, - fontWeight: MyFontWeight.medium, - color: Colors.black, - ), - ), - Text( - "超多好物,等你来秒", - style: TextStyle( - fontSize: 12.sp, - fontWeight: MyFontWeight.regular, - color: Color(0xFF7B7B7B), - ), - ), - GestureDetector( - onTap: (){ - }, - child: Container( - height:20.h, - width: 60.w, - decoration: BoxDecoration( - color: Color(0xFF32A060), - borderRadius: BorderRadius.circular(11.5), - boxShadow: [ - BoxShadow( - color: Colors.black.withAlpha(12), - offset: Offset(0, 3), - blurRadius: 14, - spreadRadius: 0, - ), - ], - ), - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Text( - "10点场", - style: TextStyle( - fontSize: 12.sp, - fontWeight: MyFontWeight.regular, - color: Colors.white, - ), - ), - Icon( - Icons.keyboard_arrow_right, - size: 16, - color: Colors.white, - ), - ], - ), - ), - ), - Padding(padding: EdgeInsets.only(bottom: 10.h),child: - Image.asset( - "assets/image/icon_story_td.png", - width: 87, - height: 87, - fit: BoxFit.cover, - ),) - ], + child: MImage( + widget?.quickEntry[0]?.img ?? "", + width:double.infinity, + fit: BoxFit.contain, + errorSrc: "assets/image/default_2_1.png", + fadeSrc: "assets/image/default_2_1.png", ), + // Column( + // mainAxisAlignment: MainAxisAlignment.spaceAround, + // crossAxisAlignment: CrossAxisAlignment.start, + // children: [ + // Text( + // "回乡秒杀", + // style: TextStyle( + // fontSize: 15.sp, + // fontWeight: MyFontWeight.medium, + // color: Colors.black, + // ), + // ), + // Text( + // "超多好物,等你来秒", + // style: TextStyle( + // fontSize: 12.sp, + // fontWeight: MyFontWeight.regular, + // color: Color(0xFF7B7B7B), + // ), + // ), + // GestureDetector( + // onTap: (){ + // }, + // child: Container( + // height:20.h, + // width: 60.w, + // decoration: BoxDecoration( + // color: Color(0xFF32A060), + // borderRadius: BorderRadius.circular(11.5), + // boxShadow: [ + // BoxShadow( + // color: Colors.black.withAlpha(12), + // offset: Offset(0, 3), + // blurRadius: 14, + // spreadRadius: 0, + // ), + // ], + // ), + // child: Row( + // mainAxisAlignment: MainAxisAlignment.center, + // crossAxisAlignment: CrossAxisAlignment.center, + // children: [ + // Text( + // "10点场", + // style: TextStyle( + // fontSize: 12.sp, + // fontWeight: MyFontWeight.regular, + // color: Colors.white, + // ), + // ), + // Icon( + // Icons.keyboard_arrow_right, + // size: 16, + // color: Colors.white, + // ), + // ], + // ), + // ), + // ), + // Padding(padding: EdgeInsets.only(bottom: 10.h),child: + // Image.asset( + // "assets/image/icon_story_td.png", + // width: 87, + // height: 87, + // fit: BoxFit.cover, + // ),) + // ], + // ), ), ), Expanded( @@ -130,92 +163,100 @@ class _ShoppingActivity extends State { children: [ GestureDetector( onTap: () { - Navigator.of(context).pushNamed('/router/activity_prefecture_details', - arguments: { "type":3}); + jumpActivity(widget?.quickEntry[1].url); }, child: Container( margin: EdgeInsets.symmetric(horizontal: 5.w), - padding: EdgeInsets.only(left: 12.w,right: 11.w), + // padding: EdgeInsets.only(left: 12.w,right: 11.w), width: (MediaQuery.of(context).size.width - 42) / 2, height: 195.h / 2, decoration: BoxDecoration( borderRadius: BorderRadius.circular(8), color: Colors.white, ), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - crossAxisAlignment: CrossAxisAlignment.end, - children: [ - Expanded(child: Column( - mainAxisAlignment: MainAxisAlignment.spaceAround, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - "好价我砍", - style: TextStyle( - fontSize: 15.sp, - fontWeight: MyFontWeight.medium, - color: Colors.black, - ), - ), - Text( - "拉友同优", - style: TextStyle( - fontSize: 12.sp, - fontWeight: MyFontWeight.regular, - color: Color(0xFF7B7B7B), - ), - ), - GestureDetector( - onTap: (){ - }, - child: Container( - height: 18.h, - width: 48.w, - decoration: BoxDecoration( - color: Color(0xFF32A060), - borderRadius: BorderRadius.circular(11.5), - boxShadow: [ - BoxShadow( - color: Colors.black.withAlpha(12), - offset: Offset(0, 3), - blurRadius: 14, - spreadRadius: 0, - ), - ], - ), - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Text( - "GO", - style: TextStyle( - fontSize: 12.sp, - fontWeight: MyFontWeight.regular, - color: Colors.white, - ), - ), - Icon( - Icons.keyboard_arrow_right, - size: 16, - color: Colors.white, - ), - ], - ), - ), - ), - ], - ),), - Padding(padding: EdgeInsets.only(bottom: 10.h),child: - Image.asset( - "assets/image/icon_story_td.png", - width: 44, - height: 44, - fit: BoxFit.cover, - ),) - ], + child: MImage( + widget?.quickEntry[1]?.img ?? "", + width:double.infinity, + fit: BoxFit.contain, + errorSrc: "assets/image/default_2_1.png", + fadeSrc: "assets/image/default_2_1.png", ), + // Row( + // mainAxisAlignment: MainAxisAlignment.spaceEvenly, + // crossAxisAlignment: CrossAxisAlignment.end, + // children: [ + // Expanded(child: + // Column( + // mainAxisAlignment: MainAxisAlignment.spaceAround, + // crossAxisAlignment: CrossAxisAlignment.start, + // children: [ + // Text( + // "好价我砍", + // style: TextStyle( + // fontSize: 15.sp, + // fontWeight: MyFontWeight.medium, + // color: Colors.black, + // ), + // ), + // Text( + // "拉友同优", + // style: TextStyle( + // fontSize: 12.sp, + // fontWeight: MyFontWeight.regular, + // color: Color(0xFF7B7B7B), + // ), + // ), + // GestureDetector( + // onTap: (){ + // }, + // child: Container( + // height: 18.h, + // width: 48.w, + // decoration: BoxDecoration( + // color: Color(0xFF32A060), + // borderRadius: BorderRadius.circular(11.5), + // boxShadow: [ + // BoxShadow( + // color: Colors.black.withAlpha(12), + // offset: Offset(0, 3), + // blurRadius: 14, + // spreadRadius: 0, + // ), + // ], + // ), + // child: Row( + // mainAxisAlignment: MainAxisAlignment.center, + // crossAxisAlignment: CrossAxisAlignment.center, + // children: [ + // Text( + // "GO", + // style: TextStyle( + // fontSize: 12.sp, + // fontWeight: MyFontWeight.regular, + // color: Colors.white, + // ), + // ), + // Icon( + // Icons.keyboard_arrow_right, + // size: 16, + // color: Colors.white, + // ), + // ], + // ), + // ), + // ), + // ], + // ), + // ), + // Padding(padding: EdgeInsets.only(bottom: 10.h),child: + // Image.asset( + // "assets/image/icon_story_td.png", + // width: 44, + // height: 44, + // fit: BoxFit.cover, + // ),) + // ], + // ), ), ), SizedBox( @@ -223,92 +264,98 @@ class _ShoppingActivity extends State { ), GestureDetector( onTap: () { - Navigator.of(context).pushNamed('/router/activity_prefecture_details', - arguments: { "type":1}); + jumpActivity(widget?.quickEntry[2].url); }, child: Container( margin: EdgeInsets.symmetric(horizontal: 5.w), - padding: EdgeInsets.only(left: 12.w,right: 11.w), + // padding: EdgeInsets.only(left: 12.w,right: 11.w), width: (MediaQuery.of(context).size.width - 42) / 2, height: 195.h / 2, decoration: BoxDecoration( borderRadius: BorderRadius.circular(8), color: Colors.white, ), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - crossAxisAlignment: CrossAxisAlignment.end, - children: [ - Expanded(child: Column( - mainAxisAlignment: MainAxisAlignment.spaceAround, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - "拼团专场", - style: TextStyle( - fontSize: 15.sp, - fontWeight: MyFontWeight.medium, - color: Colors.black, - ), - ), - Text( - "优惠齐享", - style: TextStyle( - fontSize: 12.sp, - fontWeight: MyFontWeight.regular, - color: Color(0xFF7B7B7B), - ), - ), - GestureDetector( - onTap: (){ - }, - child: Container( - height: 18.h, - width: 48.w, - decoration: BoxDecoration( - color: Color(0xFF32A060), - borderRadius: BorderRadius.circular(11.5), - boxShadow: [ - BoxShadow( - color: Colors.black.withAlpha(12), - offset: Offset(0, 3), - blurRadius: 14, - spreadRadius: 0, - ), - ], - ), - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Text( - "GO", - style: TextStyle( - fontSize: 12.sp, - fontWeight: MyFontWeight.regular, - color: Colors.white, - ), - ), - Icon( - Icons.keyboard_arrow_right, - size: 16, - color: Colors.white, - ), - ], - ), - ), - ), - ], - ),), - Padding(padding: EdgeInsets.only(bottom: 10.h),child: - Image.asset( - "assets/image/icon_story_td.png", - width: 44, - height: 44, - fit: BoxFit.cover, - ),) - ], + child:MImage( + widget?.quickEntry[2]?.img ?? "", + width:double.infinity, + fit: BoxFit.contain, + errorSrc: "assets/image/default_2_1.png", + fadeSrc: "assets/image/default_2_1.png", ), + // Row( + // mainAxisAlignment: MainAxisAlignment.spaceEvenly, + // crossAxisAlignment: CrossAxisAlignment.end, + // children: [ + // Expanded(child: Column( + // mainAxisAlignment: MainAxisAlignment.spaceAround, + // crossAxisAlignment: CrossAxisAlignment.start, + // children: [ + // Text( + // "拼团专场", + // style: TextStyle( + // fontSize: 15.sp, + // fontWeight: MyFontWeight.medium, + // color: Colors.black, + // ), + // ), + // Text( + // "优惠齐享", + // style: TextStyle( + // fontSize: 12.sp, + // fontWeight: MyFontWeight.regular, + // color: Color(0xFF7B7B7B), + // ), + // ), + // GestureDetector( + // onTap: (){ + // }, + // child: Container( + // height: 18.h, + // width: 48.w, + // decoration: BoxDecoration( + // color: Color(0xFF32A060), + // borderRadius: BorderRadius.circular(11.5), + // boxShadow: [ + // BoxShadow( + // color: Colors.black.withAlpha(12), + // offset: Offset(0, 3), + // blurRadius: 14, + // spreadRadius: 0, + // ), + // ], + // ), + // child: Row( + // mainAxisAlignment: MainAxisAlignment.center, + // crossAxisAlignment: CrossAxisAlignment.center, + // children: [ + // Text( + // "GO", + // style: TextStyle( + // fontSize: 12.sp, + // fontWeight: MyFontWeight.regular, + // color: Colors.white, + // ), + // ), + // Icon( + // Icons.keyboard_arrow_right, + // size: 16, + // color: Colors.white, + // ), + // ], + // ), + // ), + // ), + // ], + // ),), + // Padding(padding: EdgeInsets.only(bottom: 10.h),child: + // Image.asset( + // "assets/image/icon_story_td.png", + // width: 44, + // height: 44, + // fit: BoxFit.cover, + // ),) + // ], + // ), ), ), ], diff --git a/lib/store/shopping/shopping_home/shopping_home_page.dart b/lib/store/shopping/shopping_home/shopping_home_page.dart index 31c6c58e..700f7ea8 100644 --- a/lib/store/shopping/shopping_home/shopping_home_page.dart +++ b/lib/store/shopping/shopping_home/shopping_home_page.dart @@ -1,24 +1,38 @@ +import 'package:dio/dio.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_easyloading/flutter_easyloading.dart'; import 'package:flutter_swiper/flutter_swiper.dart'; -import 'package:huixiang/main.dart'; +import 'package:huixiang/generated/l10n.dart'; +import 'package:huixiang/retrofit/data/base_data.dart'; +import 'package:huixiang/retrofit/data/findMiNiGroupList.dart'; +import 'package:huixiang/retrofit/data/home_recommend_list.dart'; +import 'package:huixiang/retrofit/data/miNiDetail.dart'; +import 'package:huixiang/retrofit/data/shopping_home_config.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/shopping/shopping_home/recommend_goods_list_view.dart'; import 'package:huixiang/store/shopping/shopping_home/shopping_acticvity.dart'; -import 'package:huixiang/utils/event_type.dart'; +import 'package:huixiang/store/shopping/shopping_home/shopping_title_tab.dart'; import 'package:huixiang/utils/font_weight.dart'; import 'package:huixiang/view_widget/classic_header.dart'; import 'package:huixiang/view_widget/custom_image.dart'; import 'package:huixiang/view_widget/my_appbar.dart'; +import 'package:huixiang/view_widget/my_footer.dart'; import 'package:pull_to_refresh/pull_to_refresh.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:shared_preferences/shared_preferences.dart'; +import 'activity_banner.dart'; import 'classify_list.dart'; class ShoppingHomePage extends StatefulWidget { + final String minToken; final StoreInfo storeInfo; + final String storeId; + final String tenant; - ShoppingHomePage(this.storeInfo); + ShoppingHomePage(this.minToken, this.storeInfo, this.storeId, this.tenant); @override State createState() { @@ -29,21 +43,73 @@ class ShoppingHomePage extends StatefulWidget { class _ShoppingHomePage extends State with AutomaticKeepAliveClientMixin { ApiService apiService; + MinApiService minService; + final SwiperController controller = SwiperController(); + final RefreshController refreshController = RefreshController(); + final ScrollController scrollController = ScrollController(); + ShoppingHomeConfig shoppingHomeConfig; + int checkNC = 0; + List homeRecommendList = []; @override void initState() { super.initState(); + SharedPreferences.getInstance().then((value) { + minService = MinApiService( + Dio(), + context: context, + token: widget.minToken, + tenant: widget.tenant, + storeId: widget.storeId, + showLoading: false, + ); + queryHomeConfig(); + queryRecommendList(); + }); } - final SwiperController controller = SwiperController(); - @override void dispose() { super.dispose(); if (refreshController != null) refreshController.dispose(); } - final RefreshController refreshController = RefreshController(); + ///获取门店首页配置 + queryHomeConfig() async { + BaseData baseData = + await minService.homeConfig().catchError((error) { + refreshController.refreshFailed(); + }); + if (baseData != null && baseData.isSuccess) { + setState(() { + shoppingHomeConfig = baseData.data; + refreshController.refreshCompleted(); + }); + } else { + refreshController.refreshFailed(); + } + } + + ///首页为你推荐列表 + queryRecommendList() async { + BaseData> baseData = + await minService.recommendList().catchError((onError) { + refreshController.loadFailed(); + refreshController.refreshFailed(); + }); + if (baseData != null && baseData.isSuccess) { + setState(() { + homeRecommendList.clear(); + homeRecommendList.addAll(baseData.data); + }); + } + EasyLoading.dismiss(); + } + + _onRefresh(){ + queryHomeConfig(); + queryRecommendList(); + } @override Widget build(BuildContext context) { @@ -64,39 +130,60 @@ class _ShoppingHomePage extends State enablePullUp: false, header: MyHeader(), physics: BouncingScrollPhysics(), + scrollController: scrollController, + footer: CustomFooter( + builder: (context, mode) { + return MyFooter(mode); + }, + ), onRefresh: () { - setState(() {}); + setState(() { + _onRefresh(); + }); }, child: SingleChildScrollView( - physics: NeverScrollableScrollPhysics(), - child: FutureBuilder( - // future: queryHome(), - builder: (context, snapshot) { - return Column( - children: [ - buildSearchItem(), - - buildSwiper(), - - ///分类导航栏 - // ShoppingTitleTab(), - - ///分类列表 - ClassifyList(), - - ///专区活动 - ShoppingActivity(), - - ///严选活动 - // ActivityBanner(), - - ///为你推荐 - RecommendGoodsListView(), - ], - ); - }, - ), - ), + physics: NeverScrollableScrollPhysics(), + child: Column( + children: [ + if(shoppingHomeConfig != null) + buildSearchItem(), + + buildSwiper(), + + ///分类导航栏 + if(shoppingHomeConfig != null) + ShoppingTitleTab(shoppingHomeConfig.categoryGroup, + (index) { + setState(() { + checkNC = index; + }); + }), + + ///分类列表 + if(shoppingHomeConfig != null) + ClassifyList( + shoppingHomeConfig.categoryGroup[checkNC].groupList, + widget.minToken, + widget.storeId, + widget.tenant + ), + + ///专区活动 + if(shoppingHomeConfig != null) + ShoppingActivity(widget.storeId, widget.tenant, + shoppingHomeConfig.quickEntry), + + ///严选活动 + if(shoppingHomeConfig != null) + ActivityBanner(shoppingHomeConfig.specialArea, widget.minToken, + widget.storeId, + widget.tenant), + + ///为你推荐 + RecommendGoodsListView(homeRecommendList, + widget.storeId, widget.tenant), + ], + )), ), ), ), @@ -108,26 +195,31 @@ class _ShoppingHomePage extends State } Widget buildSearchItem() { - return Container( - height: 36.h, - margin: EdgeInsets.fromLTRB(16.w, 0, 16.w, 16.h), - padding: EdgeInsets.fromLTRB(12.w, 6.h, 0, 6.h), - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.circular(18), - boxShadow: [ - BoxShadow( - color: Colors.black.withAlpha(12), - offset: Offset(0, 3), - blurRadius: 14, - spreadRadius: 0, - ), - ], - ), - child: GestureDetector( - onTap: () { - Navigator.of(context).pushNamed('/router/search_page'); - }, + return GestureDetector( + onTap: () { + Navigator.of(context).pushNamed('/router/search_page', arguments: { + "minToken": widget.minToken, + "tenant": widget.tenant, + "storeId": widget.storeId, + "hotSearch":shoppingHomeConfig.hotSearch, + }); + }, + child:Container( + height: 36.h, + margin: EdgeInsets.fromLTRB(16.w, 0, 16.w, 16.h), + padding: EdgeInsets.fromLTRB(12.w, 6.h, 0, 6.h), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(18), + boxShadow: [ + BoxShadow( + color: Colors.black.withAlpha(12), + offset: Offset(0, 3), + blurRadius: 14, + spreadRadius: 0, + ), + ], + ), child: Row( children: [ Icon( @@ -156,7 +248,7 @@ class _ShoppingHomePage extends State return Container( width: double.infinity, height: 160.h, - margin: EdgeInsets.only(left: 16,right: 16), + margin: EdgeInsets.only(left: 16, right: 16), decoration: BoxDecoration( borderRadius: BorderRadius.circular(8), ), @@ -175,8 +267,8 @@ class _ShoppingHomePage extends State return Container( child: MImage( (widget.storeInfo != null && - widget.storeInfo.bannerList != null && - position < widget.storeInfo.bannerList.length) + widget.storeInfo.bannerList != null && + position < widget.storeInfo.bannerList.length) ? widget.storeInfo.bannerList[position].imgUrl : "", fit: BoxFit.cover, @@ -186,9 +278,10 @@ class _ShoppingHomePage extends State ), ); }, - itemCount: (widget.storeInfo != null && widget.storeInfo.bannerList != null) - ? widget.storeInfo.bannerList.length - : 1, + itemCount: + (widget.storeInfo != null && widget.storeInfo.bannerList != null) + ? widget.storeInfo.bannerList.length + : 1, ), ); } diff --git a/lib/store/shopping/shopping_home/shopping_title_tab.dart b/lib/store/shopping/shopping_home/shopping_title_tab.dart index 7a3c4a74..a9f931af 100644 --- a/lib/store/shopping/shopping_home/shopping_title_tab.dart +++ b/lib/store/shopping/shopping_home/shopping_title_tab.dart @@ -1,16 +1,14 @@ import 'package:flutter/material.dart'; -import 'package:huixiang/generated/l10n.dart'; -import 'package:huixiang/retrofit/data/category_select_list.dart'; -import 'package:huixiang/retrofit/data/goods_category.dart'; +import 'package:huixiang/retrofit/data/shopping_home_config.dart'; import 'package:huixiang/utils/font_weight.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:huixiang/view_widget/my_tab.dart'; class ShoppingTitleTab extends StatefulWidget { - final List classSelectList; + final List categoryGroup; final Function notifyClassSelectList; - ShoppingTitleTab(this.classSelectList,this.notifyClassSelectList); + ShoppingTitleTab(this.categoryGroup,this.notifyClassSelectList); @override State createState() { @@ -25,7 +23,6 @@ class _ClassTitleTab extends State @override void initState() { super.initState(); - } @override @@ -33,9 +30,7 @@ class _ClassTitleTab extends State return Container( alignment: Alignment.centerLeft, child: DefaultTabController( - length:widget.classSelectList == null - ? 0 - : widget.classSelectList.length, + length:widget?.categoryGroup?.length ?? 0, child: TabBar( isScrollable: true, //可滚动 @@ -57,9 +52,9 @@ class _ClassTitleTab extends State widget.notifyClassSelectList(index); }, //指示器与文字等宽 - tabs:widget.classSelectList == null + tabs:widget.categoryGroup == null ? [] - : widget.classSelectList + : widget.categoryGroup .map((e) => MyTab(text: e.name)) .toList(), ), diff --git a/lib/store/shopping/shopping_mall_home.dart b/lib/store/shopping/shopping_mall_home.dart index 38c4128e..14608397 100644 --- a/lib/store/shopping/shopping_mall_home.dart +++ b/lib/store/shopping/shopping_mall_home.dart @@ -2,22 +2,15 @@ import 'package:dio/dio.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_easyloading/flutter_easyloading.dart'; -import 'package:flutter_swiper/flutter_swiper.dart'; import 'package:huixiang/generated/l10n.dart'; -import 'package:huixiang/main.dart'; import 'package:huixiang/retrofit/data/activity.dart'; -import 'package:huixiang/retrofit/data/banner.dart'; import 'package:huixiang/retrofit/data/base_data.dart'; -import 'package:huixiang/retrofit/data/brand.dart'; -import 'package:huixiang/retrofit/data/page.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/shopping/shopping_cart/shopping_cart_page.dart'; import 'package:huixiang/store/shopping/shopping_home/shopping_home_page.dart'; -import 'package:huixiang/utils/event_type.dart'; import 'package:huixiang/utils/font_weight.dart'; -import 'package:pull_to_refresh/pull_to_refresh.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:shared_preferences/shared_preferences.dart'; @@ -36,12 +29,7 @@ class _ShoppingMallHome extends State with AutomaticKeepAliveClientMixin { ApiService apiService; MinApiService minService; - List brands = []; - List bannerData = []; int choiceIndex = 0; - bool dialogShowing = false; - final RefreshController refreshController = RefreshController(); - final SwiperController controller = SwiperController(); String storeId = ""; String tenant = ""; @@ -98,6 +86,7 @@ class _ShoppingMallHome extends State showLoading: false, ); + // queryShopCar().then((value) { // this.shopCarGoods = value; // setState(() {}); @@ -128,11 +117,225 @@ class _ShoppingMallHome extends State EasyLoading.dismiss(); } - @override - void dispose() { - super.dispose(); - if (refreshController != null) refreshController.dispose(); - } + // ///选规格 + // _queryMiNiDetail(String id,int count) async { + // EasyLoading.show(status: S.current.zhengzaijiazai); + // BaseData baseData = await minService.miNiDetail(id); + // if (baseData != null && baseData.isSuccess) { + // showStoreSelector(baseData.data, id,count); + // } + // } + // + // ///选规格弹窗 + // showStoreSelector(MiNiDetail miNiDetail, String id,int count) async { + // if (miNiDetail.attrList != null && miNiDetail.attrList.length == 1 + // && miNiDetail.attrList[0].attrValueList.length == 1) { + // _addShopCar(miNiDetail, [], count); + // } else { + // EasyLoading.dismiss(); + // dialogShowing = true; + // SmartDialog.show( + // widget: ProductSku( + // miNiDetail, + // shopCarGoods, + // id, + // _addShopCar, + // add, + // reduce, + // ), + // onDismiss: () { + // dialogShowing = false; + // }, + // alignmentTemp: Alignment.bottomCenter, + // ); + // } + // } + // + // ///添加购物车 + // Future _addShopCar(MiNiDetail miNiDetail, selectSkus, int count) async { + // ProductSkuVOListBean productSku; + // if (selectSkus!= null && selectSkus.length == 0) { + // productSku = miNiDetail.productSkuVOList.first; + // } else { + // productSku = miNiDetail.productSkuVOList.firstWhere((element) { + // bool gg = true; + // selectSkus.forEach((element1) { + // if (element.skuNameStr.indexOf(element1) < 0) { + // gg = false; + // return gg; + // } + // }); + // return gg; + // }); + // } + // if (productSku == null) return; + // String skuId = productSku.id; + // String skuValue = selectSkus + // .toString() + // .replaceAll("[", "") + // .replaceAll("]", "") + // .replaceAll(",", ""); + // + // if (miNiDetail != null) { + // BaseData> baseDate = await minService.addShoppingCart({ + // "storeId": storeInfo.id, + // "storeName": storeInfo.storeName ?? "", + // "numberOfPeople": numberOfPeople, + // "tableId": tableId, + // "parentId": parentId, + // "parentCode": parentCode, + // "shoppingCartSkuItemList": [ + // { + // "buyNum": count, + // "id": skuId, + // "productId": miNiDetail.id, + // "productName": miNiDetail.productName, + // "skuName": skuValue, + // "storeId": storeInfo.id, + // "skuPrice": productSku.skuPrice, + // "skuStock": productSku.skuStock, + // "tableId": tableId, + // }, + // ], + // }); + // EasyLoading.dismiss(); + // if (baseDate != null && baseDate.isSuccess) { + // queryShopCar().then((value) { + // this.shopCarGoods = value; + // setState(() {}); + // }); + // } + // } + // } + // + // ///商品➕1 + // add(MiNiDetail miNiDetail, selectSkus) async { + // ProductSkuVOListBean productSku = + // miNiDetail.productSkuVOList.firstWhere((element) { + // return skuY(element, selectSkus); + // }); + // + // if (productSku == null) return; + // String skuId = productSku.id; + // if (shopCarGoods == null) { + // await _addShopCar(miNiDetail, selectSkus, 2); + // return; + // } + // int shopSkuIndex = shopCarGoods.shoppingCartSkuItemList + // .indexWhere((element) => skuId == element.id); + // Map shopCarTemp = shopCarGoods.toJson(); + // shopCarGoods.tableId = "$tableId"; + // + // if (shopSkuIndex >= 0) { + // shopCarGoods.shoppingCartSkuItemList[shopSkuIndex].buyNum += 1; + // ShoppingCartSkuItemListBean cartSkuItem = shopCarGoods + // .shoppingCartSkuItemList + // .firstWhere((element) => skuId == element.id); + // shopCarTemp["shoppingCartSkuItemList"] = [cartSkuItem.toJson()]; + // } else { + // await _addShopCar(miNiDetail, selectSkus, 2); + // return; + // } + // + // BaseData> baseDate = + // await minService.shoppingCartSingle(shopCarTemp); + // if (baseDate.isSuccess) { + // queryShopCar().then((value) { + // this.shopCarGoods = value; + // setState(() {}); + // }); + // } + // } + // + // ///商品➖1 + // reduce(MiNiDetail miNiDetail, selectSkus) async { + // ProductSkuVOListBean productSku = + // miNiDetail.productSkuVOList.firstWhere((element) { + // return skuY(element, selectSkus); + // }); + // + // if (productSku == null) return; + // String skuId = productSku.id; + // if (shopCarGoods == null) { + // await _addShopCar(miNiDetail, selectSkus, 2); + // return; + // } + // ShoppingCartSkuItemListBean shopSkuItem = shopCarGoods + // .shoppingCartSkuItemList + // .firstWhere((element) => skuId == element.skuId); + // int shopSkuIndex = shopCarGoods.shoppingCartSkuItemList + // .indexWhere((element) => skuId == element.skuId); + // + // if (shopSkuItem != null) { + // if (shopSkuItem.buyNum > 1) { + // shopCarGoods.shoppingCartSkuItemList[shopSkuIndex].buyNum -= 1; + // } + // } else { + // await _addShopCar(miNiDetail, selectSkus, 2); + // return; + // } + // shopCarGoods.tableId = "$tableId"; + // + // Map shopCarTemp = shopCarGoods.toJson(); + // ShoppingCartSkuItemListBean cartSkuItem = shopCarGoods + // .shoppingCartSkuItemList + // .firstWhere((element) => skuId == element.id); + // shopCarTemp["shoppingCartSkuItemList"] = [cartSkuItem.toJson()]; + // + // BaseData> baseDate = + // await minService.shoppingCartSingle(shopCarTemp); + // if (baseDate.isSuccess) { + // queryShopCar().then((value) { + // this.shopCarGoods = value; + // setState(() {}); + // }); + // } + // } + // + // bool skuY(ProductSkuVOListBean productSku, selectSkus) { + // bool gg = true; + // selectSkus.forEach((element1) { + // if (productSku.skuNameStr.indexOf(element1) < 0) { + // gg = false; + // return gg; + // } + // }); + // return gg; + // } + + // ///查询购物车 + // Future queryShopCar() async { + // pName="";//活动 + // pid="";//活动 + // cName="";//优惠券 + // cid="";//优惠券 + // BaseData> baseDate = + // await minService.getShoppingCart(tableId); + // if (baseDate != null && + // baseDate.isSuccess && + // baseDate.data != null && + // baseDate.data.length > 0) { + // if( baseDate.data[0].selectDiscount ==1){ + // baseDate.data[0].couponList.forEach((element) { + // if(element.isMaxCoupon){ + // cName = element.promotionName; + // cid = element.id; + // } + // }); + // }else if(baseDate.data[0].selectDiscount==2){ + // baseDate.data[0].promotionInfoList.forEach((element) { + // if(element.isMaxPromotion){ + // pName=element.name; + // pid=element.id; + // } + // }); + // } + // return baseDate.data[0]; + // } else { + // return null; + // } + // } + @override Widget build(BuildContext context) { @@ -159,9 +362,15 @@ class _ShoppingMallHome extends State ), if (choiceIndex == 0) ShoppingHomePage( + minToken, storeInfo, + storeId, + tenant, ), if (choiceIndex == 1) ShoppingCartPage( + minToken, + storeId, + tenant, ), Align( alignment: Alignment.bottomCenter, diff --git a/lib/store/store_order.dart b/lib/store/store_order.dart index c7593b54..22ce3360 100644 --- a/lib/store/store_order.dart +++ b/lib/store/store_order.dart @@ -283,7 +283,7 @@ class _StoreOrderPage extends State ], ), top: 0, - bottom: 0, + bottom:0, left: 0, right: 0, ), @@ -314,8 +314,8 @@ class _StoreOrderPage extends State ], ), ), - top: 110.h, - bottom: 0, + top:80.h, + bottom:0, left: 0, right: 0, ), @@ -670,6 +670,7 @@ class _StoreOrderPage extends State _addShopCar, add, reduce, + buttonType: 0, ), onDismiss: () { dialogShowing = false; diff --git a/lib/store/store_view/product_sku.dart b/lib/store/store_view/product_sku.dart index abea0f39..c6092ff4 100644 --- a/lib/store/store_view/product_sku.dart +++ b/lib/store/store_view/product_sku.dart @@ -16,6 +16,7 @@ class ProductSku extends StatefulWidget { final Function(MiNiDetail miNiDetail, List selectSkus) add; final Function(MiNiDetail miNiDetail, List selectSkus) reduce; final ShoppingCart shopCarGoods; + final int buttonType; ProductSku( this.miNiDetail, @@ -24,6 +25,7 @@ class ProductSku extends StatefulWidget { this.addShopCar, this.add, this.reduce, + { this.buttonType} ); @override @@ -269,20 +271,390 @@ class _ProductSku extends State { SizedBox( height: 24, ), - RoundButton( - width: double.infinity, - height: 54.h, - text: "加入购物车", - textColor: Colors.white, - fontWeight: MyFontWeight.semi_bold, - radius: 27, - backgroup: Color(0xFF32A060), - fontSize: 16.sp, - callback: () { - // Navigator.of(context).pop(); - SmartDialog.dismiss(); - widget.addShopCar(widget.miNiDetail, selectSkus, 1); - }, + if(widget.buttonType == 0) + RoundButton( + width: double.infinity, + height: 54.h, + text: "加入购物车", + textColor: Colors.white, + fontWeight: MyFontWeight.semi_bold, + radius: 27, + backgroup: Color(0xFF32A060), + fontSize: 16.sp, + callback: () { + // Navigator.of(context).pop(); + SmartDialog.dismiss(); + widget.addShopCar(widget.miNiDetail, selectSkus, 1); + }, + ), + if(widget.buttonType == 1) + RoundButton( + width: double.infinity, + height: 54.h, + text: "确认", + textColor: Colors.white, + fontWeight: MyFontWeight.semi_bold, + radius: 27, + backgroup: Color(0xFF32A060), + fontSize: 16.sp, + callback: () { + // Navigator.of(context).pop(); + SmartDialog.dismiss(); + widget.addShopCar(widget.miNiDetail, selectSkus,count); + }, + ), + ///秒杀按钮 + if(widget.buttonType == 2) + Row( + children: [ + Expanded(child: GestureDetector( + onTap: (){ + Navigator.of(context).popAndPushNamed('/router/group_details'); + }, + child: Container( + alignment: Alignment.center, + width: 120.w, + height:40.h, + margin: EdgeInsets.only(left: 6.w), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(16), + border: Border.all( + width: 1, + color: Color(0xFF32A060), + style: BorderStyle.solid, + ), + ), + child: Column( + children: [ + Text.rich( + TextSpan( + children: [ + TextSpan( + text: "¥", + style: TextStyle( + fontSize: 7.sp, + fontWeight: MyFontWeight.medium, + color: Color(0xFF32A060), + ), + ), + TextSpan( + text: "284.00", + style: TextStyle( + fontSize: 10.sp, + fontWeight: MyFontWeight.medium, + color: Color(0xFF32A060), + ), + ), + ], + ), + ), + Expanded(child: + Text( + "原价购买", + style: TextStyle( + fontSize: 12.sp, + fontWeight: MyFontWeight.medium, + color: Color(0xFF32A060), + ), + )), + ], + ), + ), + ),), + Expanded(child: GestureDetector( + onTap: (){ + Navigator.of(context).popAndPushNamed('/router/bargain_details'); + }, + child: Container( + alignment: Alignment.center, + width: 120.w, + height: 40.h, + margin: EdgeInsets.only(left: 6.w), + decoration: BoxDecoration( + color: Color(0xFF32A060), + borderRadius: BorderRadius.circular(16), + boxShadow: [ + BoxShadow( + color: Colors.black.withAlpha(12), + offset: Offset(0, 3), + blurRadius: 14, + spreadRadius: 0, + ), + ], + ), + child: Column( + children: [ + Text.rich( + TextSpan( + children: [ + TextSpan( + text: "¥", + style: TextStyle( + fontSize: 7.sp, + fontWeight: MyFontWeight.medium, + color: Colors.white, + ), + ), + TextSpan( + text: "284.00", + style: TextStyle( + fontSize: 10.sp, + fontWeight: MyFontWeight.medium, + color: Colors.white, + ), + ), + ], + ), + ), + Expanded(child: + Text( + "我要砍价", + style: TextStyle( + fontSize: 12.sp, + fontWeight: MyFontWeight.medium, + color: Colors.white, + ), + ),), + ], + ), + )),), + + + ], + ), + ///砍价 + if(widget.buttonType == 3) + Row( + children: [ + Expanded(child:GestureDetector( + onTap: (){ + Navigator.of(context).popAndPushNamed('/router/group_details'); + }, + child: Container( + alignment: Alignment.center, + width: 120.w, + height:40.h, + margin: EdgeInsets.only(left: 6.w), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(16), + border: Border.all( + width: 1, + color: Color(0xFF32A060), + style: BorderStyle.solid, + ), + ), + child: Column( + children: [ + Text.rich( + TextSpan( + children: [ + TextSpan( + text: "¥", + style: TextStyle( + fontSize: 7.sp, + fontWeight: MyFontWeight.medium, + color: Color(0xFF32A060), + ), + ), + TextSpan( + text: "284.00", + style: TextStyle( + fontSize: 10.sp, + fontWeight: MyFontWeight.medium, + color: Color(0xFF32A060), + ), + ), + ], + ), + ), + Expanded(child: + Text( + "原价购买", + style: TextStyle( + fontSize: 12.sp, + fontWeight: MyFontWeight.medium, + color: Color(0xFF32A060), + ), + )), + ], + ), + ), + ),), + Expanded(child:GestureDetector( + onTap: (){ + Navigator.of(context).popAndPushNamed('/router/bargain_details'); + }, + child: Container( + alignment: Alignment.center, + width: 120.w, + height: 40.h, + margin: EdgeInsets.only(left: 6.w), + decoration: BoxDecoration( + color: Color(0xFF32A060), + borderRadius: BorderRadius.circular(16), + boxShadow: [ + BoxShadow( + color: Colors.black.withAlpha(12), + offset: Offset(0, 3), + blurRadius: 14, + spreadRadius: 0, + ), + ], + ), + child: Column( + children: [ + Text.rich( + TextSpan( + children: [ + TextSpan( + text: "¥", + style: TextStyle( + fontSize: 7.sp, + fontWeight: MyFontWeight.medium, + color: Colors.white, + ), + ), + TextSpan( + text: "284.00", + style: TextStyle( + fontSize: 10.sp, + fontWeight: MyFontWeight.medium, + color: Colors.white, + ), + ), + ], + ), + ), + Expanded(child: + Text( + "我要秒杀", + style: TextStyle( + fontSize: 12.sp, + fontWeight: MyFontWeight.medium, + color: Colors.white, + ), + ),), + ], + ), + )),), + ], + ), + ///拼团按钮 + if(widget.buttonType == 4) + Row( + children: [ + Expanded(child: GestureDetector( + onTap: (){ + Navigator.of(context).popAndPushNamed('/router/group_details'); + }, + child: Container( + alignment: Alignment.center, + width: 120.w, + height:40.h, + margin: EdgeInsets.only(left: 6.w), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(16), + border: Border.all( + width: 1, + color: Color(0xFF32A060), + style: BorderStyle.solid, + ), + ), + child: Column( + children: [ + Text.rich( + TextSpan( + children: [ + TextSpan( + text: "¥", + style: TextStyle( + fontSize: 7.sp, + fontWeight: MyFontWeight.medium, + color: Color(0xFF32A060), + ), + ), + TextSpan( + text: "284.00", + style: TextStyle( + fontSize: 10.sp, + fontWeight: MyFontWeight.medium, + color: Color(0xFF32A060), + ), + ), + ], + ), + ), + Expanded(child: + Text( + "单人购买", + style: TextStyle( + fontSize: 12.sp, + fontWeight: MyFontWeight.medium, + color: Color(0xFF32A060), + ), + )), + ], + ), + ), + )), + Expanded(child:GestureDetector( + onTap: (){ + Navigator.of(context).popAndPushNamed('/router/bargain_details'); + }, + child: Container( + alignment: Alignment.center, + width: 120.w, + height: 40.h, + margin: EdgeInsets.only(left: 6.w), + decoration: BoxDecoration( + color: Color(0xFF32A060), + borderRadius: BorderRadius.circular(16), + boxShadow: [ + BoxShadow( + color: Colors.black.withAlpha(12), + offset: Offset(0, 3), + blurRadius: 14, + spreadRadius: 0, + ), + ], + ), + child: Column( + children: [ + Text.rich( + TextSpan( + children: [ + TextSpan( + text: "¥", + style: TextStyle( + fontSize: 7.sp, + fontWeight: MyFontWeight.medium, + color: Colors.white, + ), + ), + TextSpan( + text: "284.00", + style: TextStyle( + fontSize: 10.sp, + fontWeight: MyFontWeight.medium, + color: Colors.white, + ), + ), + ], + ), + ), + Expanded(child: + Text( + "我要开团", + style: TextStyle( + fontSize: 12.sp, + fontWeight: MyFontWeight.medium, + color: Colors.white, + ), + ),), + ], + ), + )),), + ], ), SizedBox( height: 21.h, diff --git a/pubspec.lock b/pubspec.lock index 0fe9042a..bba09c34 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -269,7 +269,7 @@ packages: name: flutter_screenutil url: "https://pub.flutter-io.cn" source: hosted - version: "5.0.1+3" + version: "5.0.2" flutter_smart_dialog: dependency: "direct main" description: