Browse Source

首页数据显示完成;

搜索页面完成;专区活动完成;
详情页未完成;购物车未完成;
zyh
w-R 3 years ago
parent
commit
ed942f9b72
  1. 2
      lib/community/community_details.dart
  2. 4
      lib/main.dart
  3. 1
      lib/mine/mine_wallet_page.dart
  4. 416
      lib/retrofit/data/home_recommend_list.dart
  5. 6
      lib/retrofit/data/miNiDetail.dart
  6. 1
      lib/retrofit/data/shoppingCart.dart
  7. 740
      lib/retrofit/data/shopping_home_config.dart
  8. 26
      lib/retrofit/min_api.dart
  9. 69
      lib/retrofit/min_api.g.dart
  10. 12
      lib/retrofit/retrofit_api.dart
  11. 25
      lib/retrofit/retrofit_api.g.dart
  12. 293
      lib/store/shopping/activity_prefecture_details.dart
  13. 195
      lib/store/shopping/shopping_cart/shopping_cart_page.dart
  14. 739
      lib/store/shopping/shopping_goods_details.dart
  15. 133
      lib/store/shopping/shopping_home/activity_banner.dart
  16. 45
      lib/store/shopping/shopping_home/classify_list.dart
  17. 51
      lib/store/shopping/shopping_home/recommend_goods_list_view.dart
  18. 392
      lib/store/shopping/shopping_home/search_page.dart
  19. 501
      lib/store/shopping/shopping_home/shopping_acticvity.dart
  20. 145
      lib/store/shopping/shopping_home/shopping_home_page.dart
  21. 17
      lib/store/shopping/shopping_home/shopping_title_tab.dart
  22. 243
      lib/store/shopping/shopping_mall_home.dart
  23. 3
      lib/store/store_order.dart
  24. 372
      lib/store/store_view/product_sku.dart
  25. 2
      pubspec.lock

2
lib/community/community_details.dart

@ -211,7 +211,7 @@ class _CommunityDetails extends State<CommunityDetails> with WidgetsBindingObser
"content": content,
"parentId": parenId,
"relationalId": comunity.id,
"relationalType":4
"relationalType":1
}).catchError((error) {});
if (baseData != null && baseData.isSuccess) {
CommentListState state = commentKey.currentState;

4
lib/main.dart

@ -283,9 +283,9 @@ Map<String, WidgetBuilder> routers = <String, WidgetBuilder>{
'/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}) =>

1
lib/mine/mine_wallet_page.dart

@ -200,7 +200,6 @@ class _MineWalletPage extends State<MineWalletPage> {
Expanded(
flex: 1,
child: Container(
height: 34.h,
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceAround,
crossAxisAlignment: CrossAxisAlignment.start,

416
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<String> imgs,
List<ProductSkuList> 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<String>() : [];
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<String> _imgs;
List<ProductSkuList> _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<String> get imgs => _imgs;
List<ProductSkuList> get productSkuList => _productSkuList;
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
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<String, dynamic> toJson() {
final map = <String, dynamic>{};
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;
}
}

6
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,

1
lib/retrofit/data/shoppingCart.dart

@ -18,6 +18,7 @@ class ShoppingCart {
int selectDiscount;
String storeName;
String tableId;
bool isSelect;
List<PromotionInfoListBean> promotionInfoList;
List<CouponListBean> couponList;

740
lib/retrofit/data/shopping_home_config.dart

File diff suppressed because one or more lines are too long

26
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<BaseData> queryStoreInfo1(@Body() Map<String, dynamic> param);
//
///
@GET("order/getParentInfo?tableId={tableId}")
Future<BaseData> getParentInfo(@Path("tableId") String tableId);
/// /
@GET("product/recommendList")
Future<BaseData<List<HomeRecommendList>>> recommendList();
///
@GET("store/homeConfig")
Future<BaseData<ShoppingHomeConfig>> homeConfig();
///,,,
@GET("/actTemplate/findActListByType?allDay={allDay}&type={type}")
Future<BaseData<ActivityAreaList>> findActListByType(@Path("allDay") bool allDay,
@Path("type") String type);
}

69
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<BaseData<List<HomeRecommendList>>> recommendList() async {
const _extra = <String, dynamic>{};
final queryParameters = <String, dynamic>{};
final _data = <String, dynamic>{};
final _result = await _dio.request<Map<String, dynamic>>(
'product/recommendList',
queryParameters: queryParameters,
options: RequestOptions(
method: 'GET',
headers: <String, dynamic>{},
extra: _extra,
baseUrl: baseUrl),
data: _data);
final value = BaseData<List<HomeRecommendList>>.fromJson(
_result.data,
(json) => (json as List<dynamic>)
.map<HomeRecommendList>((i) => HomeRecommendList.fromJson(i as Map<String, dynamic>))
.toList());
return value;
}
@override
Future<BaseData<ShoppingHomeConfig>> homeConfig() async {
const _extra = <String, dynamic>{};
final queryParameters = <String, dynamic>{};
final _data = <String, dynamic>{};
final _result = await _dio.request<Map<String, dynamic>>(
'store/homeConfig',
queryParameters: queryParameters,
options: RequestOptions(
method: 'GET',
headers: <String, dynamic>{},
extra: _extra,
baseUrl: baseUrl),
data: _data);
final value = BaseData<ShoppingHomeConfig>.fromJson(
_result.data,
(json) => ShoppingHomeConfig.fromJson(json),
);
return value;
}
@override
Future<BaseData<ActivityAreaList>> findActListByType(allDay,type) async {
ArgumentError.checkNotNull(allDay, 'allDay');
ArgumentError.checkNotNull(type, 'type');
const _extra = <String, dynamic>{};
final queryParameters = <String, dynamic>{};
final _data = <String, dynamic>{};
final _result = await _dio.request<Map<String, dynamic>>(
'/actTemplate/findActListByType?allDay=$allDay&type=$type',
queryParameters: queryParameters,
options: RequestOptions(
method: 'GET',
headers: <String, dynamic>{},
extra: _extra,
baseUrl: baseUrl),
data: _data);
final value = BaseData<ActivityAreaList>.fromJson(
_result.data,
(json) => ActivityAreaList.fromJson(json),
);
return value;
}
}

12
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<BaseData<HeadlinesListDetails>> headlinesDetails(@Path("id") String id);
///,,,
@GET("/actTemplate/findActListByType?allDay={allDay}&type={type}")
Future<BaseData<ActivityAreaList>> findActListByType(@Path("allDay") bool allDay, @Path("type") int type);
}

25
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<BaseData<ActivityAreaList>> findActListByType(allDay,type) async {
ArgumentError.checkNotNull(allDay, 'allDay');
ArgumentError.checkNotNull(type, 'type');
const _extra = <String, dynamic>{};
final queryParameters = <String, dynamic>{};
final _data = <String, dynamic>{};
final _result = await _dio.request<Map<String, dynamic>>(
'/actTemplate/findActListByType?allDay=$allDay&type=$type',
queryParameters: queryParameters,
options: RequestOptions(
method: 'GET',
headers: <String, dynamic>{},
extra: _extra,
baseUrl: baseUrl),
data: _data);
final value = BaseData<ActivityAreaList>.fromJson(
_result.data,
(json) => ActivityAreaList.fromJson(json),
);
return value;
}
}

293
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<ActivityPrefectureDetails> {
ApiService apiService;
MinApiService minService;
int seckillIndex = 0;
RefreshController refreshController = RefreshController();
ScrollController _scrollController;
@ -30,9 +37,30 @@ class _ActivityPrefectureDetails extends State<ActivityPrefectureDetails> {
bool scrollFlag = false;
List<TimeProductList> actTimeList = [];
List<ProductList> productList = [];
List<Activity> 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<ActivityPrefectureDetails> {
}
});
});
// testTime = "${DateTime.now().year}-${DateTime.now().month}-${DateTime.now().day} 08:00:20";
pageType = widget.arguments["type"];
SharedPreferences.getInstance().then((value) {
apiService =
ApiService(Dio(), context: context, token: value.getString("token"));
storeId = widget.arguments["storeId"];
tenant = widget.arguments["tenant"];
queryFindActListByType(pageType == 2 ?false:true);
SharedPreferences.getInstance().then((value) {
minLogin(value);
queryStoreInfo();
});
}
/////
queryFindActListByType(allDay) async {
if (apiService == null) {
SharedPreferences value = await SharedPreferences.getInstance();
///
minLogin(SharedPreferences shared) async {
EasyLoading.show(status: S.of(context).zhengzaijiazai);
apiService = ApiService(
Dio(),
context: context,
token: value.getString("token"),
token: shared.getString('token'),
showLoading: false,
);
apiService.minLogin(storeId).catchError((onError) {
debugPrint(onError);
}).then((baseData) {
if (baseData != null && baseData.isSuccess) {
Map<String, dynamic> 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();
}
});
}
///
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 {
BaseData<ActivityAreaList> 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<ActivityPrefectureDetails> {
}
if (actTimeList.length > actTimeListIndex)
productList.addAll(actTimeList[actTimeListIndex].productList);
startCountdownTimer();
refreshController.refreshCompleted();
});
} else {
@ -96,6 +175,32 @@ class _ActivityPrefectureDetails extends State<ActivityPrefectureDetails> {
}
}
///
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<ActivityPrefectureDetails> {
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<ActivityPrefectureDetails> {
),
),
TextSpan(
text: "0",
text: tempDay.toString(),
style: TextStyle(
fontSize: 14.sp,
fontWeight: MyFontWeight.semi_bold,
@ -235,7 +340,7 @@ class _ActivityPrefectureDetails extends State<ActivityPrefectureDetails> {
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<ActivityPrefectureDetails> {
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<ActivityPrefectureDetails> {
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<ActivityPrefectureDetails> {
);
}
///
Widget swiper() {
return Container(
child: AspectRatio(
@ -341,7 +447,7 @@ class _ActivityPrefectureDetails extends State<ActivityPrefectureDetails> {
),
),
),
pageType == 2 ?
pageType == "2" ?
Align(
alignment: Alignment.topCenter,
child: Container(
@ -351,7 +457,7 @@ class _ActivityPrefectureDetails extends State<ActivityPrefectureDetails> {
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<ActivityPrefectureDetails> {
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<ActivityPrefectureDetails> {
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<ActivityPrefectureDetails> {
///
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<ActivityPrefectureDetails> {
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<ActivityPrefectureDetails> {
}
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<ActivityPrefectureDetails> {
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<ActivityPrefectureDetails> {
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,
@ -647,6 +777,7 @@ class _ActivityPrefectureDetails extends State<ActivityPrefectureDetails> {
color: Color(0xFF4D4D4D),
),
),
if(pageType == "2")
Row(
children: [
ClipRRect(
@ -685,6 +816,32 @@ class _ActivityPrefectureDetails extends State<ActivityPrefectureDetails> {
),
],
),
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: [
Text.rich(
@ -695,7 +852,7 @@ class _ActivityPrefectureDetails extends State<ActivityPrefectureDetails> {
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<ActivityPrefectureDetails> {
style: TextStyle(
fontSize: 18.sp,
fontWeight: MyFontWeight.semi_bold,
color: Color(0xFFFB2E2C),
color:pageType == "3" ?Color(0xFF9476F7) : Color(0xFFFB2E2C),
),
),
],
@ -713,15 +870,17 @@ class _ActivityPrefectureDetails extends State<ActivityPrefectureDetails> {
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
if(pageType == "2")
(seckillIndex == 0 ?
(tStatus == 0
? Container(
alignment: Alignment.center,
width: 60.w,
@ -797,7 +956,83 @@ class _ActivityPrefectureDetails extends State<ActivityPrefectureDetails> {
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,
),
),
)
],
),
],

195
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<StatefulWidget> createState() {
return _ShoppingCartPage();
@ -27,17 +36,30 @@ class _ShoppingCartPage extends State<ShoppingCartPage>
with AutomaticKeepAliveClientMixin {
ApiService apiService;
MinApiService minService;
ShoppingCart shopCarGoods;
// ShoppingCart shopCarGoods;
List<ShoppingCart> 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<ShoppingCartPage>
}
}
///
Future<ShoppingCart> queryShopCar() async {
pName="";//
pid="";//
cName="";//
cid="";//
BaseData<List<ShoppingCart>> 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;
}
///
queryShopCar() async {
BaseData<List<ShoppingCart>> baseData =
await minService.getShoppingCart(tableId).catchError((error) {
refreshController.refreshFailed();
});
}else if(baseDate.data[0].selectDiscount==2){
baseDate.data[0].promotionInfoList.forEach((element) {
if(element.isMaxPromotion){
pName=element.name;
pid=element.id;
}
if (baseData != null && baseData.isSuccess) {
setState(() {
shopCarGoods.clear();
shopCarGoods.addAll(baseData.data);
refreshController.refreshCompleted();
});
}
return baseDate.data[0];
} else {
return null;
refreshController.refreshFailed();
}
}
///
// Future<ShoppingCart> queryShopCar() async {
// pName="";//
// pid="";//
// cName="";//
// cid="";//
// BaseData<List<ShoppingCart>> 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<ShoppingCart> shopCartAdd(
ShoppingCartSkuItemListBean cartSkuItem) async {
Map<String, dynamic> shopCarTemp = shopCarGoods.toJson();
cartSkuItem.buyNum += 1;
shopCarTemp["shoppingCartSkuItemList"] = [cartSkuItem.toJson()];
BaseData<List<ShoppingCart>> baseDate =
await minService.shoppingCartSingle(shopCarTemp);
if (baseDate.isSuccess) {
this.shopCarGoods = await queryShopCar();
if (shopCartKey != null) {
shopCartKey.currentState.setState(() {});
}
setState(() {});
}
return this.shopCarGoods;
}
///1
Future<ShoppingCart> shopCartReduce(
ShoppingCartSkuItemListBean cartSkuItem) async {
Map<String, dynamic> shopCarTemp = shopCarGoods.toJson();
cartSkuItem.buyNum -= 1;
shopCarTemp["shoppingCartSkuItemList"] = [cartSkuItem.toJson()];
BaseData<List<ShoppingCart>> baseDate =
await minService.shoppingCartSingle(shopCarTemp);
if (baseDate.isSuccess) {
this.shopCarGoods = await queryShopCar();
if (shopCartKey != null) {
shopCartKey.currentState.setState(() {});
}
setState(() {});
}
return this.shopCarGoods;
}
// Future<ShoppingCart> shopCartAdd(
// ShoppingCartSkuItemListBean cartSkuItem) async {
// Map<String, dynamic> shopCarTemp = shopCarGoods.toJson();
// cartSkuItem.buyNum += 1;
// shopCarTemp["shoppingCartSkuItemList"] = [cartSkuItem.toJson()];
// BaseData<List<ShoppingCart>> baseDate =
// await minService.shoppingCartSingle(shopCarTemp);
// if (baseDate.isSuccess) {
// this.shopCarGoods = await queryShopCar();
// if (shopCartKey != null) {
// shopCartKey.currentState.setState(() {});
// }
// setState(() {});
// }
// return this.shopCarGoods;
// }
//
// ///1
// Future<ShoppingCart> shopCartReduce(
// ShoppingCartSkuItemListBean cartSkuItem) async {
// Map<String, dynamic> shopCarTemp = shopCarGoods.toJson();
// cartSkuItem.buyNum -= 1;
// shopCarTemp["shoppingCartSkuItemList"] = [cartSkuItem.toJson()];
// BaseData<List<ShoppingCart>> 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<ShoppingCartPage>
leadingColor: Colors.black,
background: Colors.transparent,
actions: [
Container(
alignment: Alignment.center,
margin: EdgeInsets.only(right: 12.w),
child: GestureDetector(
GestureDetector(
onTap: (){
setState(() {
topIndex = !topIndex;
});
},
child: Text("管理",
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<ShoppingCartPage>
),
),
),
),
// 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(

739
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<String, dynamic> arguments;
ShoppingGoodsDetails({this.arguments});
@override
State<StatefulWidget> createState() {
return _ShoppingGoodsDetails();
@ -26,16 +39,204 @@ class ShoppingGoodsDetails extends StatefulWidget {
class _ShoppingGoodsDetails extends State<ShoppingGoodsDetails> {
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<Activity> 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<String, dynamic> 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<MiNiDetail> 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<List<ShoppingCart>> 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) {
@ -89,8 +290,9 @@ class _ShoppingGoodsDetails extends State<ShoppingGoodsDetails> {
),
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<ShoppingGoodsDetails> {
GestureDetector(
onTap: () {
setState(() {
// showCallMobile)();
showCallMobile();
});
},
child: Column(
@ -199,67 +401,16 @@ class _ShoppingGoodsDetails extends State<ShoppingGoodsDetails> {
return Container(
child: Row(
children: [
// GestureDetector(
// 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(
// 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(
onTap: (){
Navigator.of(context).popAndPushNamed('/router/group_details');
setState(() {
addShoppingCar();
});
},
child:Container(
alignment: Alignment.center,
width: 120.w,
height:40.h,
height:37.h,
margin: EdgeInsets.only(left:6.w),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(16),
@ -269,51 +420,24 @@ class _ShoppingGoodsDetails extends State<ShoppingGoodsDetails> {
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(
"原价购买",
child: Text(
"加入购物车",
style: TextStyle(
fontSize: 12.sp,
fontWeight: MyFontWeight.medium,
fontSize: 16.sp,
fontWeight: MyFontWeight.regular,
color: Color(0xFF32A060),
),
)),
],
),
),
),
GestureDetector(
onTap: (){
Navigator.of(context).popAndPushNamed('/router/bargain_details');
// toDownOrder();
},
child: Container(
alignment: Alignment.center,
width: 120.w,
height: 40.h,
height:37.h,
margin: EdgeInsets.only(left:6.w),
decoration: BoxDecoration(
color: Color(0xFF32A060),
@ -327,47 +451,304 @@ class _ShoppingGoodsDetails extends State<ShoppingGoodsDetails> {
),
],
),
child: Column(
children: [
Text.rich(
TextSpan(
children: [
TextSpan(
text: "",
style: TextStyle(
fontSize: 7.sp,
fontWeight: MyFontWeight.medium,
color: Colors.white,
),
),
TextSpan(
text: "284.00",
child: Text(
"立即购买",
style: TextStyle(
fontSize: 10.sp,
fontWeight: MyFontWeight.medium,
fontSize: 16.sp,
fontWeight: MyFontWeight.regular,
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: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,
// ),
// ),),
// ],
// ),
// )),
///
// 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,
// ),
// ),),
// ],
// ),
// )),
],
),
);
}
///top
Widget buildColumn() {
return Container(
decoration: BoxDecoration(
@ -413,7 +794,7 @@ class _ShoppingGoodsDetails extends State<ShoppingGoodsDetails> {
),
),
TextSpan(
text: "282.00",
text:miNiDetail?.price ?? "",
style: TextStyle(
fontSize: 28.sp,
fontWeight: MyFontWeight.semi_bold,
@ -439,7 +820,7 @@ class _ShoppingGoodsDetails extends State<ShoppingGoodsDetails> {
),
),
Text(
"已售12",
"已售${miNiDetail?.sellCount ?? 0}",
style: TextStyle(
fontWeight: MyFontWeight.medium,
fontSize: 10.sp,
@ -455,7 +836,7 @@ class _ShoppingGoodsDetails extends State<ShoppingGoodsDetails> {
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<ShoppingGoodsDetails> {
children: [
Expanded(
child: Text(
"[前进麦味]全麦吐司250g",
miNiDetail?.productName ?? "",
style: TextStyle(
fontWeight: MyFontWeight.semi_bold,
fontSize: 15.sp,
@ -481,7 +862,7 @@ class _ShoppingGoodsDetails extends State<ShoppingGoodsDetails> {
color: Color(0xFF5A5A5A),
),
child: Text(
"中国大陆5仓",
miNiDetail?.supplierName ?? "",
style: TextStyle(
fontSize: 10.sp,
fontWeight: MyFontWeight.regular,
@ -495,7 +876,7 @@ class _ShoppingGoodsDetails extends State<ShoppingGoodsDetails> {
height: 8.h,
),
Text(
"人生没有标准答案,一切答案都在行动中,前进卖完也是一样,用真诚行动践行标准的定义",
miNiDetail?.shortName ?? "",
maxLines: 2,
overflow: TextOverflow.ellipsis,
style: TextStyle(
@ -531,16 +912,16 @@ class _ShoppingGoodsDetails extends State<ShoppingGoodsDetails> {
),
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<ShoppingGoodsDetails> {
),
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<ShoppingGoodsDetails> {
),
),
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<ShoppingGoodsDetails> {
}
///
// 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';
}
}
}

133
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> bannerData;
final SwiperController controller;
final List<SpecialArea> 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<StatefulWidget> createState() {
@ -24,17 +27,21 @@ class ActivityBanner extends StatefulWidget {
class _ActivityBanner extends State<ActivityBanner> {
ApiService apiService;
final RefreshController refreshController = RefreshController();
List<BannerData> 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<ActivityBanner> {
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,
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<ActivityBanner> {
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<ActivityBanner> {
],
);
},
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<ActivityBanner> {
),
),
TextSpan(
text: "12.60",
text:productList?.price ?? "",
style: TextStyle(
fontSize: 14.sp,
fontWeight: MyFontWeight.semi_bold,
@ -166,40 +171,4 @@ class _ActivityBanner extends State<ActivityBanner> {
),
);
}
/// contentType 0123,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;
}
}
}

45
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> groupList;
final String minToken;
final String storeId;
final String tenant;
ClassifyList(this.groupList,this.minToken,this.storeId,this.tenant);
@override
State<StatefulWidget> createState() {
@ -15,9 +23,6 @@ class ClassifyList extends StatefulWidget {
class _ClassifyList extends State<ClassifyList> {
ApiService apiService;
BMFCoordinate latLng;
final TextEditingController editingController = TextEditingController();
@override
void initState() {
@ -46,44 +51,44 @@ class _ClassifyList extends State<ClassifyList> {
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,

51
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> homeRecommendList;
final String storeId;
final String tenant;
RecommendGoodsListView(this.homeRecommendList,this.storeId,this.tenant);
@override
State<StatefulWidget> createState() {
return _RecommendGoodsListView();
@ -11,6 +21,12 @@ class RecommendGoodsListView extends StatefulWidget {
}
class _RecommendGoodsListView extends State<RecommendGoodsListView> {
@override
void initState() {
super.initState();
}
@override
Widget build(BuildContext context) {
return Column(
@ -31,7 +47,7 @@ class _RecommendGoodsListView extends State<RecommendGoodsListView> {
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<RecommendGoodsListView> {
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<RecommendGoodsListView> {
);
}
Widget goodsListItem() {
Widget goodsListItem(HomeRecommendList homeRecommendList) {
return Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.vertical(
@ -102,18 +122,13 @@ class _RecommendGoodsListView extends State<RecommendGoodsListView> {
],
),
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",
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(
@ -137,7 +152,7 @@ class _RecommendGoodsListView extends State<RecommendGoodsListView> {
color: Color(0xFF5A5A5A),
),
child: Text(
"中国大陆5仓",
homeRecommendList?.supplierName ?? "",
style: TextStyle(
fontSize: 10.sp,
fontWeight: MyFontWeight.regular,
@ -146,7 +161,7 @@ class _RecommendGoodsListView extends State<RecommendGoodsListView> {
),
),
Text(
"已售12",
"已售${homeRecommendList?.sellCount ?? 0}",
style: TextStyle(
fontSize: 12.sp,
fontWeight: MyFontWeight.regular,
@ -156,7 +171,7 @@ class _RecommendGoodsListView extends State<RecommendGoodsListView> {
],
),
Text(
"SWISSGEAR瑞士军刀联名款马克杯",
homeRecommendList?.productName ?? "",
maxLines: 2,
overflow: TextOverflow.ellipsis,
style: TextStyle(
@ -181,7 +196,7 @@ class _RecommendGoodsListView extends State<RecommendGoodsListView> {
),
),
TextSpan(
text: "284.00",
text:homeRecommendList?.price ??"",
style: TextStyle(
fontSize: 18.sp,
fontWeight: MyFontWeight.semi_bold,

392
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<String, dynamic> arguments;
SearchPage({this.arguments});
@override
State<StatefulWidget> createState() {
return _SearchPage();
}
}
class _SearchPage extends State<SearchPage> {
class _SearchPage extends State<SearchPage> 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<ProductListBean> productListBeans = [];
List<String> hotSearch =[];
List<String> 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"]);
}
}
SharedPreferences.getInstance().then((value) {
apiService = ApiService(Dio(),
context: context, token: value.getString("token"), pay: true);
///
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<List<FindMiNiGroupList>> 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();
}
setHistorySearch(text);
setState(() {
hasFocus = false;
FocusScope.of(context).requestFocus(FocusNode());
});
}
@ -96,13 +210,14 @@ class _SearchPage extends State<SearchPage> {
),
),
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),
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(18),
borderRadius: BorderRadius.circular(4),
boxShadow: [
BoxShadow(
color: Colors.black.withAlpha(12),
@ -112,34 +227,90 @@ class _SearchPage extends State<SearchPage> {
),
],
),
child: GestureDetector(
onTap: () {},
child: Row(
children: [
Icon(
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: 16,
color: Color(0xFFABACAB),
size: 24,
color: Colors.black,
),
SizedBox(
width: 3.w,
suffixIcon: InkWell(
onTap: () {
editingController.clear();
},
child: Icon(
Icons.close,
size: 19,
color: Colors.grey,
),
Text(
"前进麦味",
style: TextStyle(
fontSize: 12.sp,
fontWeight: MyFontWeight.regular,
color: Color(0xFF727272),
),
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<SearchPage> {
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<SearchPage> {
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<SearchPage> {
}
///
Widget hotSearch() {
Widget hotSearchWords() {
return Container(
width: double.infinity,
child: Column(
@ -219,7 +394,7 @@ class _SearchPage extends State<SearchPage> {
),
SizedBox(height: 16.h),
GridView.builder(
itemCount: 6,
itemCount:hotSearch?.length ?? 0,
shrinkWrap: true,
padding: EdgeInsets.zero,
physics: NeverScrollableScrollPhysics(),
@ -235,8 +410,9 @@ class _SearchPage extends State<SearchPage> {
),
itemBuilder: (context, index) {
return GestureDetector(
onTap: () {},
child: hotSearchItem(),
onTap: () {
},
child: hotSearchItem(hotSearch[index]),
);
},
),
@ -245,16 +421,16 @@ class _SearchPage extends State<SearchPage> {
);
}
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<SearchPage> {
}
///
Widget historySearch() {
Widget historySearchWords() {
return Container(
width: double.infinity,
child: Column(
@ -276,7 +452,8 @@ class _SearchPage extends State<SearchPage> {
children: [
Row(
children: [
Expanded(child:Text(
Expanded(
child: Text(
"历史搜索",
style: TextStyle(
fontSize: 15.sp,
@ -289,7 +466,13 @@ class _SearchPage extends State<SearchPage> {
width: 22.w,
height: 20.h,
),
Text(
GestureDetector(
onTap: (){
setState(() {
delHistorySearch();
});
},
child:Text(
"删除",
style: TextStyle(
fontSize: 15.sp,
@ -297,12 +480,12 @@ class _SearchPage extends State<SearchPage> {
color: Color(0xFF181818),
),
),
)
],
),
SizedBox(height: 16.h),
GridView.builder(
itemCount: 6,
itemCount:historySearch?.length ?? 0,
shrinkWrap: true,
padding: EdgeInsets.zero,
physics: NeverScrollableScrollPhysics(),
@ -318,10 +501,8 @@ class _SearchPage extends State<SearchPage> {
),
itemBuilder: (context, index) {
return GestureDetector(
onTap: () {
},
child: historySearchItem(),
onTap: () {},
child: historySearchItem(historySearch[index]),
);
},
),
@ -330,16 +511,16 @@ class _SearchPage extends State<SearchPage> {
);
}
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,
@ -373,8 +554,12 @@ class _SearchPage extends State<SearchPage> {
"默认推荐",
style: TextStyle(
fontSize: optionIndex == 0 ? 15.sp : 14.sp,
fontWeight: optionIndex == 0 ? MyFontWeight.semi_bold : MyFontWeight.regular,
color: optionIndex == 0 ? Color(0xFF181818) : Color(0xFF4D4D4D),
fontWeight: optionIndex == 0
? MyFontWeight.semi_bold
: MyFontWeight.regular,
color: optionIndex == 0
? Color(0xFF181818)
: Color(0xFF4D4D4D),
),
),
),
@ -388,8 +573,12 @@ class _SearchPage extends State<SearchPage> {
"销量",
style: TextStyle(
fontSize: optionIndex == 1 ? 15.sp : 14.sp,
fontWeight: optionIndex == 1 ? MyFontWeight.semi_bold : MyFontWeight.regular,
color: optionIndex == 1 ? Color(0xFF181818) : Color(0xFF4D4D4D),
fontWeight: optionIndex == 1
? MyFontWeight.semi_bold
: MyFontWeight.regular,
color: optionIndex == 1
? Color(0xFF181818)
: Color(0xFF4D4D4D),
),
),
),
@ -399,13 +588,18 @@ class _SearchPage extends State<SearchPage> {
optionIndex = 2;
});
},
child:Row(children: [
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),
fontWeight: optionIndex == 2
? MyFontWeight.semi_bold
: MyFontWeight.regular,
color: optionIndex == 2
? Color(0xFF181818)
: Color(0xFF4D4D4D),
),
),
Image.asset(
@ -413,7 +607,8 @@ class _SearchPage extends State<SearchPage> {
width: 16,
height: 16,
),
],),
],
),
),
GestureDetector(
onTap: () {
@ -425,8 +620,12 @@ class _SearchPage extends State<SearchPage> {
"专区",
style: TextStyle(
fontSize: optionIndex == 3 ? 15.sp : 14.sp,
fontWeight: optionIndex == 3 ? MyFontWeight.semi_bold : MyFontWeight.regular,
color: optionIndex == 3 ? Color(0xFF181818) : Color(0xFF4D4D4D),
fontWeight: optionIndex == 3
? MyFontWeight.semi_bold
: MyFontWeight.regular,
color: optionIndex == 3
? Color(0xFF181818)
: Color(0xFF4D4D4D),
),
),
),
@ -434,7 +633,7 @@ class _SearchPage extends State<SearchPage> {
),
SizedBox(height: 16.h),
GridView.builder(
itemCount:6,
itemCount:productListBeans?.length ?? 0,
shrinkWrap: true,
physics: NeverScrollableScrollPhysics(),
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
@ -451,11 +650,16 @@ class _SearchPage extends State<SearchPage> {
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<SearchPage> {
);
}
Widget searchListItem() {
Widget searchListItem(ProductListBean productListBeans) {
return Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(4),
@ -497,21 +701,17 @@ class _SearchPage extends State<SearchPage> {
],
),
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",
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(
Expanded(
child: Container(
padding: EdgeInsets.only(left: 8.w, right: 8.w),
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceAround,
@ -531,7 +731,7 @@ class _SearchPage extends State<SearchPage> {
color: Color(0xFF5A5A5A),
),
child: Text(
"中国大陆5仓",
productListBeans.supplierName,
style: TextStyle(
fontSize: 10.sp,
fontWeight: MyFontWeight.regular,
@ -540,7 +740,7 @@ class _SearchPage extends State<SearchPage> {
),
),
Text(
"已售12",
"已售${productListBeans?.sellCount ?? 0}",
style: TextStyle(
fontSize: 12.sp,
fontWeight: MyFontWeight.regular,
@ -550,7 +750,7 @@ class _SearchPage extends State<SearchPage> {
],
),
Text(
"SWISSGEAR瑞士军刀联名款马克杯",
productListBeans?.productName ?? "",
maxLines: 2,
overflow: TextOverflow.ellipsis,
style: TextStyle(
@ -575,7 +775,7 @@ class _SearchPage extends State<SearchPage> {
),
),
TextSpan(
text: "284.00",
text:productListBeans?.price ?? "",
style: TextStyle(
fontSize: 18.sp,
fontWeight: MyFontWeight.semi_bold,
@ -599,9 +799,13 @@ class _SearchPage extends State<SearchPage> {
),
],
),
),)
),
)
],
),
);
}
@override
bool get wantKeepAlive => true;
}

501
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> quickEntry;
ShoppingActivity(this.storeId,this.tenant,this.quickEntry);
@override
State<StatefulWidget> createState() {
return _ShoppingActivity();
@ -26,6 +33,28 @@ class _ShoppingActivity extends State<ShoppingActivity> {
super.initState();
}
///url跳转
jumpActivity(String url) {
var router = url.substring(0,url.contains("?")?url.indexOf("?") : (url.length - 1));
Map<String, dynamic> 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<ShoppingActivity> {
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<ShoppingActivity> {
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<ShoppingActivity> {
),
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,
// ),)
// ],
// ),
),
),
],

145
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<StatefulWidget> createState() {
@ -29,21 +43,73 @@ class ShoppingHomePage extends StatefulWidget {
class _ShoppingHomePage extends State<ShoppingHomePage>
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> 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<ShoppingHomeConfig> 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<List<HomeRecommendList>> 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<ShoppingHomePage>
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(
child: Column(
children: [
if(shoppingHomeConfig != null)
buildSearchItem(),
buildSwiper(),
///
// ShoppingTitleTab(),
if(shoppingHomeConfig != null)
ShoppingTitleTab(shoppingHomeConfig.categoryGroup,
(index) {
setState(() {
checkNC = index;
});
}),
///
ClassifyList(),
if(shoppingHomeConfig != null)
ClassifyList(
shoppingHomeConfig.categoryGroup[checkNC].groupList,
widget.minToken,
widget.storeId,
widget.tenant
),
///
ShoppingActivity(),
if(shoppingHomeConfig != null)
ShoppingActivity(widget.storeId, widget.tenant,
shoppingHomeConfig.quickEntry),
///
// ActivityBanner(),
if(shoppingHomeConfig != null)
ActivityBanner(shoppingHomeConfig.specialArea, widget.minToken,
widget.storeId,
widget.tenant),
///
RecommendGoodsListView(),
RecommendGoodsListView(homeRecommendList,
widget.storeId, widget.tenant),
],
);
},
),
),
)),
),
),
),
@ -108,7 +195,16 @@ class _ShoppingHomePage extends State<ShoppingHomePage>
}
Widget buildSearchItem() {
return Container(
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),
@ -124,10 +220,6 @@ class _ShoppingHomePage extends State<ShoppingHomePage>
),
],
),
child: GestureDetector(
onTap: () {
Navigator.of(context).pushNamed('/router/search_page');
},
child: Row(
children: [
Icon(
@ -186,7 +278,8 @@ class _ShoppingHomePage extends State<ShoppingHomePage>
),
);
},
itemCount: (widget.storeInfo != null && widget.storeInfo.bannerList != null)
itemCount:
(widget.storeInfo != null && widget.storeInfo.bannerList != null)
? widget.storeInfo.bannerList.length
: 1,
),

17
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<CategorySelectList> classSelectList;
final List<CategoryGroup> categoryGroup;
final Function notifyClassSelectList;
ShoppingTitleTab(this.classSelectList,this.notifyClassSelectList);
ShoppingTitleTab(this.categoryGroup,this.notifyClassSelectList);
@override
State<StatefulWidget> createState() {
@ -25,7 +23,6 @@ class _ClassTitleTab extends State<ShoppingTitleTab>
@override
void initState() {
super.initState();
}
@override
@ -33,9 +30,7 @@ class _ClassTitleTab extends State<ShoppingTitleTab>
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<ShoppingTitleTab>
widget.notifyClassSelectList(index);
},
//
tabs:widget.classSelectList == null
tabs:widget.categoryGroup == null
? []
: widget.classSelectList
: widget.categoryGroup
.map((e) => MyTab(text: e.name))
.toList(),
),

243
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<ShoppingMallHome>
with AutomaticKeepAliveClientMixin {
ApiService apiService;
MinApiService minService;
List<Brand> brands = [];
List<BannerData> 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<ShoppingMallHome>
showLoading: false,
);
// queryShopCar().then((value) {
// this.shopCarGoods = value;
// setState(() {});
@ -128,11 +117,225 @@ class _ShoppingMallHome extends State<ShoppingMallHome>
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<MiNiDetail> 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<List<ShoppingCart>> 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<String, dynamic> 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<List<ShoppingCart>> 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<String, dynamic> shopCarTemp = shopCarGoods.toJson();
// ShoppingCartSkuItemListBean cartSkuItem = shopCarGoods
// .shoppingCartSkuItemList
// .firstWhere((element) => skuId == element.id);
// shopCarTemp["shoppingCartSkuItemList"] = [cartSkuItem.toJson()];
//
// BaseData<List<ShoppingCart>> 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<ShoppingCart> queryShopCar() async {
// pName="";//
// pid="";//
// cName="";//
// cid="";//
// BaseData<List<ShoppingCart>> 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<ShoppingMallHome>
),
if (choiceIndex == 0)
ShoppingHomePage(
minToken,
storeInfo,
storeId,
tenant,
),
if (choiceIndex == 1) ShoppingCartPage(
minToken,
storeId,
tenant,
),
Align(
alignment: Alignment.bottomCenter,

3
lib/store/store_order.dart

@ -314,7 +314,7 @@ class _StoreOrderPage extends State<StoreOrderPage>
],
),
),
top: 110.h,
top:80.h,
bottom:0,
left: 0,
right: 0,
@ -670,6 +670,7 @@ class _StoreOrderPage extends State<StoreOrderPage>
_addShopCar,
add,
reduce,
buttonType: 0,
),
onDismiss: () {
dialogShowing = false;

372
lib/store/store_view/product_sku.dart

@ -16,6 +16,7 @@ class ProductSku extends StatefulWidget {
final Function(MiNiDetail miNiDetail, List<String> selectSkus) add;
final Function(MiNiDetail miNiDetail, List<String> 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,6 +271,7 @@ class _ProductSku extends State<ProductSku> {
SizedBox(
height: 24,
),
if(widget.buttonType == 0)
RoundButton(
width: double.infinity,
height: 54.h,
@ -284,6 +287,375 @@ class _ProductSku extends State<ProductSku> {
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,
),

2
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:

Loading…
Cancel
Save