diff --git a/lib/community/community_child_page.dart b/lib/community/community_child_page.dart index 00152673..8eb6e72b 100644 --- a/lib/community/community_child_page.dart +++ b/lib/community/community_child_page.dart @@ -100,9 +100,10 @@ class _CommunityChildPage extends State { physics: NeverScrollableScrollPhysics(), itemBuilder: (context, position) { return InkWell( - child: CommunityDynamic(comments[position],0,exitFull: (){setState(() { - - });},), + child: CommunityDynamic(comments[position],0, + exitFull: (){ + _onRefresh(); + },), onTap: () { Navigator.of(context).pushNamed( '/router/community_details', diff --git a/lib/community/community_details.dart b/lib/community/community_details.dart index d657e54b..17d44953 100644 --- a/lib/community/community_details.dart +++ b/lib/community/community_details.dart @@ -161,7 +161,7 @@ class _CommunityDetails extends State bottom: PreferredSize( preferredSize: Size( MediaQuery.of(context).size.width, - 46, + 46, ), child: Container( padding: EdgeInsets.all(16), diff --git a/lib/community/community_view/community_dynamic.dart b/lib/community/community_view/community_dynamic.dart index bfca430e..92e2150a 100644 --- a/lib/community/community_view/community_dynamic.dart +++ b/lib/community/community_view/community_dynamic.dart @@ -70,8 +70,8 @@ class _CommunityDynamic extends State { _deleteDynamic(id) async { BaseData baseData = await apiService.deleteTrend(id); if (baseData != null && baseData.isSuccess) { + widget.exitFull(); SmartDialog.showToast("删除成功", alignment: Alignment.center); - } else { SmartDialog.showToast(baseData.msg, alignment: Alignment.center); } @@ -261,8 +261,8 @@ class _CommunityDynamic extends State { child: MImage( subjectInfo.images[0], fit: BoxFit.cover, - width: MediaQuery.of(context).size.width / 2, - height: MediaQuery.of(context).size.width /1, + width: MediaQuery.of(context).size.width / 1.5, + height: MediaQuery.of(context).size.width /1.5, errorSrc: "assets/image/default_2_1.png", fadeSrc: "assets/image/default_2_1.png", ), @@ -299,7 +299,7 @@ class _CommunityDynamic extends State { subjectInfo.video.isNotEmpty) { widget = videoWidget( MediaQuery.of(context).size.width - 32, - MediaQuery.of(context).size.width /2, + MediaQuery.of(context).size.width /1.5, subjectInfo.video); } diff --git a/lib/community/release_dynamic.dart b/lib/community/release_dynamic.dart index 144a6ac6..c804cdf6 100644 --- a/lib/community/release_dynamic.dart +++ b/lib/community/release_dynamic.dart @@ -85,7 +85,7 @@ class _ReleaseDynamic extends State { child: Column( children: [ buildEdit(), - GridView.builder( + Expanded(child: GridView.builder( gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( crossAxisCount: 3, crossAxisSpacing: 12.w, @@ -105,11 +105,11 @@ class _ReleaseDynamic extends State { itemCount: (mediaPaths.length == 0) ? 1 : ((dynamicType == 2) - ? 1 - : mediaPaths.length >= 9 - ? 9 - : (mediaPaths.length + 1)), - ), + ? 1 + : mediaPaths.length >= 9 + ? 9 + : (mediaPaths.length + 1)), + ),) ], ), ), diff --git a/lib/home/home_view/activity_list.dart b/lib/home/home_view/activity_list.dart new file mode 100644 index 00000000..826e916d --- /dev/null +++ b/lib/home/home_view/activity_list.dart @@ -0,0 +1,265 @@ +import 'package:dio/dio.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:huixiang/generated/l10n.dart'; +import 'package:huixiang/main.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/retrofit_api.dart'; +import 'package:huixiang/utils/event_type.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:keframe/frame_separate_widget.dart'; +import 'package:keframe/size_cache_widget.dart'; +import 'package:pull_to_refresh/pull_to_refresh.dart'; +import 'package:shared_preferences/shared_preferences.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; + +class ActivityList extends StatefulWidget { + @override + State createState() { + return _ActivityList(); + } +} + +class _ActivityList extends State + with AutomaticKeepAliveClientMixin { + ApiService apiService; + + @override + void initState() { + super.initState(); + + eventBus.on().listen((event) { + if (event.type < 3) { + setState(() {}); + } + }); + } + + List activityList; + + queryActivity() async { + final SharedPreferences value = await SharedPreferences.getInstance(); + apiService = + ApiService(Dio(), context: context, token: value.getString('token')); + BaseData> baseData = await apiService.informationList({ + "pageNum": 1, + "pageSize": 10, + "searchKey": "", + "type": 1, + "state": 1 + }).catchError((error) { + _refreshController.refreshFailed(); + }); + if (baseData != null && baseData.isSuccess) { + _refreshController.refreshCompleted(); + activityList = baseData.data.list; + } + } + + @override + void dispose() { + super.dispose(); + _refreshController.dispose(); + } + + RefreshController _refreshController = RefreshController(); + + @override + Widget build(BuildContext context) { + super.build(context); + return Container( + child: FutureBuilder( + future: queryActivity(), + builder: (context, snapshot) { + return Scaffold( + appBar: MyAppBar( + background: Color(0xFFFFFFFF), + leadingColor: Colors.black, + title:S.of(context).huodongliebiao, + titleColor: Colors.black, + titleSize: 18.sp, + ), + body: SizeCacheWidget( + child: SmartRefresher( + controller: _refreshController, + enablePullDown: true, + enablePullUp: false, + header: MyHeader(), + physics: BouncingScrollPhysics(), + onRefresh: () { + setState(() {}); + }, + child: ListView.builder( + itemCount: activityList == null ? 0 : activityList.length, + physics: NeverScrollableScrollPhysics(), + itemBuilder: (context, position) { + return InkWell( + onTap: () { + Navigator.of(context).pushNamed( + '/router/web_page', + arguments: {"activityId": activityList[position].id}); + }, + child: FrameSeparateWidget( + child: activityItem(activityList[position]), + placeHolder: AspectRatio( + aspectRatio: 1.34, + child: Container( + margin: EdgeInsets.symmetric( + horizontal: 16.w, vertical: 8.h), + decoration: BoxDecoration( + color: Colors.white, + boxShadow: [ + BoxShadow( + color: Colors.black.withAlpha(12), + offset: Offset(0, 3), + blurRadius: 14, + spreadRadius: 0, + ) + ], + borderRadius: BorderRadius.circular(8), + ), + ), + ), + ), + ); + }, + ), + ), + ), + ); + }, + ), + ); + } + + Widget activityItem(Activity activity) { + return Container( + margin: EdgeInsets.only( + left: 16.w, + right: 16.w, + top: 8.h, + bottom: 12.h, + ), + decoration: BoxDecoration( + color: Colors.white, + boxShadow: [ + BoxShadow( + color: Colors.black.withAlpha(12), + offset: Offset(0, 3), + blurRadius: 14, + spreadRadius: 0, + ) + ], + borderRadius: BorderRadius.circular(8), + ), + child: Column( + children: [ + MImage( + activity.coverImg, + aspectRatio: 2.1, + radius: BorderRadius.only( + topLeft: Radius.circular(8), + topRight: Radius.circular(8), + ), + fit: BoxFit.cover, + errorSrc: "assets/image/default_2_1.png", + fadeSrc: "assets/image/default_2_1.png", + ), + Container( + padding: EdgeInsets.only( + left: 16.w, + right: 16.w, + top: 8.h, + bottom: 12.h, + ), + child: Column( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + activity.mainTitle, + maxLines: 1, + overflow: TextOverflow.ellipsis, + style: TextStyle( + fontWeight: MyFontWeight.medium, + fontSize: 14.sp, + color: Colors.black, + ), + ), + SizedBox( + height: 4.h, + ), + Text( + activity.viceTitle ?? "", + maxLines: 1, + overflow: TextOverflow.ellipsis, + style: TextStyle( + fontSize: 10.sp, + fontWeight: MyFontWeight.regular, + color: Color(0xFF4C4C4C), + ), + ), + SizedBox( + height: 12.h, + ), + ConstrainedBox( + constraints: BoxConstraints( + maxWidth: double.infinity, + minWidth: double.infinity, + ), + child: Row( + crossAxisAlignment: CrossAxisAlignment.end, + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + activity.storeName == null ? "" : activity.storeName, + style: TextStyle( + color: Color(0xFF060606), + fontWeight: MyFontWeight.regular, + fontSize: 12.sp, + ), + ), + Row( + // crossAxisAlignment: CrossAxisAlignment.end, + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Text( + activity.startTime.split(" ")[0], + style: TextStyle( + color: Color(0xFFB5B5B5), + fontSize: 12.sp, + fontWeight: MyFontWeight.regular, + ), + ), + SizedBox( + width: 4.w, + ), + Text( + activity.startTime.split(" ")[1], + style: TextStyle( + color: Color(0xFFB5B5B5), + fontSize: 12.sp, + fontWeight: MyFontWeight.regular, + ), + ), + ], + ), + ], + ), + ), + ], + ), + ), + ], + ), + ); + } + + @override + bool get wantKeepAlive => true; +} diff --git a/lib/home/home_view/coupon.dart b/lib/home/home_view/coupon.dart index dad9e698..61551b19 100644 --- a/lib/home/home_view/coupon.dart +++ b/lib/home/home_view/coupon.dart @@ -1,11 +1,19 @@ +import 'package:dio/dio.dart'; import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:huixiang/generated/l10n.dart'; +import 'package:huixiang/retrofit/data/base_data.dart'; +import 'package:huixiang/retrofit/data/coupon.dart'; +import 'package:huixiang/retrofit/data/page.dart'; +import 'package:huixiang/retrofit/retrofit_api.dart'; import 'package:huixiang/utils/font_weight.dart'; import 'package:huixiang/view_widget/item_title.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:huixiang/view_widget/receive_success.dart'; import 'package:huixiang/view_widget/round_button.dart'; +import 'package:huixiang/view_widget/selector_store_dialog.dart'; import 'package:huixiang/view_widget/separator.dart'; +import 'package:shared_preferences/shared_preferences.dart'; class CouponView extends StatefulWidget { @override @@ -15,6 +23,46 @@ class CouponView extends StatefulWidget { } class _CouponView extends State { + ApiService apiService; + int pageNum = 1; + List coupons = []; + + + @override + void initState() { + super.initState(); + + SharedPreferences.getInstance().then((value) => { + apiService = ApiService( + Dio(), + context: context, + token: value.getString('token'), + ), + queryCoupon(), + }); + } + + queryCoupon() async { + BaseData> baseData = await apiService.queryCoupon({ + "centre": true, + "pageNum": pageNum, + "pageSize": 10, + "searchKey": "", + "state": 0 + }).catchError((onError) { + }); + if (pageNum == 1) coupons.clear(); + if (baseData != null && baseData.isSuccess) { + coupons.addAll(baseData.data.list); + if (baseData.data.pageNum == baseData.data.pages) { + } else { + pageNum += 1; + } + setState(() {}); + } else { + } + } + @override Widget build(BuildContext context) { return Column( @@ -34,16 +82,16 @@ class _CouponView extends State { physics: BouncingScrollPhysics(), padding: EdgeInsets.symmetric(horizontal: 10), itemBuilder: (context, position) { - return couponItem(); + return couponItem(coupons[position]); }, - itemCount: 10, + itemCount:coupons == null ? 0 : coupons.length, ), ), ], ); } - Widget couponItem() { + Widget couponItem(Coupon coupon) { return Container( width: 0.9.sw, height: 122.h, @@ -97,7 +145,11 @@ class _CouponView extends State { ), ), TextSpan( - text: "20", + text: coupon != null + ? double.tryParse("${coupon.discountAmount}" ?? "0") + .toInt() + .toString() + : "", style: TextStyle( fontSize: 25.sp, fontWeight: MyFontWeight.regular, @@ -108,7 +160,11 @@ class _CouponView extends State { ), ), Text( - "抵扣劵", + S.of(context).manyuankeyong(coupon != null + ? double.tryParse("${coupon.fullAmount}" ?? "0") + .toInt() + .toString() + : ""), style: TextStyle( fontWeight: MyFontWeight.regular, fontSize: 14.sp, @@ -141,7 +197,8 @@ class _CouponView extends State { crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( - "海峡姐妹(楚河汉街店)", + (coupon != null && coupon.storeList != null && coupon.storeList.length > 0) ? coupon.storeList[0].storeName ?? "" : "", + overflow: TextOverflow.ellipsis, style: TextStyle( color: Color(0xFF181818), fontWeight: MyFontWeight.medium, @@ -150,19 +207,19 @@ class _CouponView extends State { ), Row( children: [ + // Text( + // "1张", + // style: TextStyle( + // color: Color(0xFF868686), + // fontWeight: MyFontWeight.regular, + // fontSize: 12.sp, + // ), + // ), + // SizedBox( + // width: 4.w, + // ), Text( - "1张", - style: TextStyle( - color: Color(0xFF868686), - fontWeight: MyFontWeight.regular, - fontSize: 12.sp, - ), - ), - SizedBox( - width: 4.w, - ), - Text( - "20元无门槛抵扣 ", + coupon != null ? coupon.couponName ?? "" : "", style: TextStyle( color: Color(0xFF868686), fontWeight: MyFontWeight.regular, @@ -179,7 +236,10 @@ class _CouponView extends State { crossAxisAlignment: CrossAxisAlignment.end, children: [ Text( - "2021/10/11到期", + (coupon.useStartTime == null && + coupon.useEndTime == null) + ? S.of(context).quantian + : "${coupon.useStartTime.replaceAll("-", ".").split(" ")[0]} - ${coupon.useEndTime.replaceAll("-", ".").split(" ")[0]}", style: TextStyle( color: Color(0xFF868686), fontWeight: MyFontWeight.semi_bold, @@ -190,12 +250,16 @@ class _CouponView extends State { child: Container(), flex: 1, ), - RoundButton( - text: "领取", - textColor: Colors.white, - backgroup: Color(0xFF32A060), - radius: 100, - padding: EdgeInsets.symmetric(vertical: 3.h, horizontal: 14.w), + GestureDetector( + onTap: (){ + }, + child:RoundButton( + text: "领取", + textColor: Colors.white, + backgroup: Color(0xFF32A060), + radius: 100, + padding: EdgeInsets.symmetric(vertical: 3.h, horizontal: 14.w), + ), ), SizedBox( width: 10.w, @@ -214,4 +278,6 @@ class _CouponView extends State { ), ); } + + } diff --git a/lib/home/home_view/featured_acticvity.dart b/lib/home/home_view/featured_acticvity.dart index e9be0578..3d1b9736 100644 --- a/lib/home/home_view/featured_acticvity.dart +++ b/lib/home/home_view/featured_acticvity.dart @@ -1,8 +1,15 @@ +import 'package:dio/dio.dart'; +import 'package:flutter/cupertino.dart'; import 'package:flutter/material.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/page.dart'; +import 'package:huixiang/retrofit/retrofit_api.dart'; import 'package:huixiang/utils/font_weight.dart'; import 'package:huixiang/view_widget/item_title.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:shared_preferences/shared_preferences.dart'; class FeaturedActivity extends StatefulWidget { @override @@ -12,15 +19,48 @@ class FeaturedActivity extends StatefulWidget { } class _FeaturedActivity extends State { + ApiService apiService; + + @override + void initState() { + super.initState(); + queryActivity(); + } + + List activityList; + + queryActivity() async { + final SharedPreferences value = await SharedPreferences.getInstance(); + apiService = + ApiService(Dio(), context: context, token: value.getString('token')); + BaseData> baseData = await apiService.informationList({ + "pageNum": 1, + "pageSize": 10, + "searchKey": "", + "type": 1, + "state": 1 + }).catchError((error) { + }); + if (baseData != null && baseData.isSuccess) { + activityList = baseData.data.list; + if(activityList != null && activityList.length == 1) + activityList.add(activityList[0]); + if(activityList != null && activityList.length == 2) + activityList.add(activityList[1]); + } + } + @override Widget build(BuildContext context) { return Column( children: [ ItemTitle( - text: S.of(context).jifenshangcheng, + text: "精选活动", imgPath: "assets/image/icon_points_mall.png", moreText: S.of(context).chakangengduo, - onTap: () {}, + onTap: () { + Navigator.of(context).pushNamed('/router/activity_list'); + }, ), SizedBox( height: 10.h, @@ -29,53 +69,56 @@ class _FeaturedActivity extends State { margin: EdgeInsets.symmetric(horizontal: 9.w), child: Row( children: [ + if(activityList != null && activityList.length > 0) Container( - child: stackItem(18.sp), + child: stackItem(18.sp,activityList[0]), margin: EdgeInsets.symmetric(horizontal: 5.w), width: (MediaQuery.of(context).size.width - 42) / 2, - height: 180.h, + height: 190.h, decoration: BoxDecoration( borderRadius: BorderRadius.circular(4), color: Colors.red, image: DecorationImage( - image: AssetImage( - "assets/image/share_image_bg.png", + image: NetworkImage( + activityList[0].coverImg, ), fit: BoxFit.cover, ), ), ), + if(activityList != null && activityList.length > 1) Container( child: Column( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ Container( - child: stackItem(14.sp), + child: stackItem(12.sp,activityList[1]), margin: EdgeInsets.symmetric(horizontal: 5.w), width: (MediaQuery.of(context).size.width - 42) / 2, - height: 170.h / 2, + height: 190.h / 2, decoration: BoxDecoration( borderRadius: BorderRadius.circular(4), color: Colors.green, image: DecorationImage( - image: AssetImage( - "assets/image/share_image_bg.png", + image: NetworkImage( + activityList[1].coverImg, ), fit: BoxFit.cover, ), ), ), + SizedBox(height: 5,), Container( - child: stackItem(14.sp), + child: stackItem(12.sp,activityList[2]), margin: EdgeInsets.symmetric(horizontal: 5.w), width: (MediaQuery.of(context).size.width - 42) / 2, - height: 170.h / 2, + height: 190.h / 2, decoration: BoxDecoration( borderRadius: BorderRadius.circular(4), color: Colors.blue, image: DecorationImage( - image: AssetImage( - "assets/image/share_image_bg.png", + image: NetworkImage( + activityList[2].coverImg, ), fit: BoxFit.cover, ), @@ -94,7 +137,7 @@ class _FeaturedActivity extends State { ); } - Widget stackItem(double textSize) { + Widget stackItem(double textSize,Activity activity) { return Column( mainAxisAlignment: MainAxisAlignment.spaceBetween, crossAxisAlignment: CrossAxisAlignment.start, @@ -105,7 +148,7 @@ class _FeaturedActivity extends State { crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( - "第二件半价!", + activity.mainTitle, style: TextStyle( fontWeight: MyFontWeight.semi_bold, fontSize: textSize, @@ -116,7 +159,7 @@ class _FeaturedActivity extends State { height: 2, ), Text( - "仅限指定饮品", + activity.viceTitle, style: TextStyle( fontWeight: MyFontWeight.semi_bold, fontSize: 12.sp, diff --git a/lib/home/home_view/quick_order.dart b/lib/home/home_view/quick_order.dart index 258fb70f..ade976ee 100644 --- a/lib/home/home_view/quick_order.dart +++ b/lib/home/home_view/quick_order.dart @@ -1,9 +1,18 @@ +import 'package:dio/dio.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_baidu_mapapi_base/flutter_baidu_mapapi_base.dart'; +import 'package:flutter_baidu_mapapi_map/flutter_baidu_mapapi_map.dart'; +import 'package:flutter_baidu_mapapi_utils/flutter_baidu_mapapi_utils.dart'; import 'package:flutter_svg/flutter_svg.dart'; -import 'package:huixiang/generated/l10n.dart'; +import 'package:huixiang/utils/location.dart'; +import 'package:huixiang/retrofit/data/base_data.dart'; +import 'package:huixiang/retrofit/data/store.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 QuickOrder extends StatefulWidget { @override @@ -13,6 +22,133 @@ class QuickOrder extends StatefulWidget { } class _QuickOrder extends State { + ApiService apiService; + List storeList; + BMFCoordinate latLng; + + BMFMapController _mapController; + final TextEditingController editingController = TextEditingController(); + + @override + void initState() { + super.initState(); + getLatLng(); + startLocation(); + } + + ///门店列表 + queryStore(latitude, longitude, province, city, district, searchKey) async { + BaseData> baseData = await apiService.queryStore({ + // "city": city, + // "district": district, + // "province": province, + "latitude": latitude, + "longitude": longitude, + "searchKey": searchKey + }).catchError((error) { + }); + if (baseData != null && baseData.isSuccess) { + storeList = baseData.data; + } + setState(() {}); + } + + getLatLng() async { + SharedPreferences.getInstance().then( + (value) => { + apiService = ApiService(Dio(), + context: context, + token: value.getString('token'), + showLoading: false), + if (value.containsKey("latitude") && + value.containsKey("longitude") && + value.containsKey("province") && + value.containsKey("city") && + value.containsKey("district")) + { + latLng = BMFCoordinate(double.tryParse(value.getString("latitude")), + double.tryParse(value.getString("longitude"))), + queryStore( + value.getString("latitude"), + value.getString("longitude"), + value.getString("province"), + value.getString("city"), + value.getString("district"), + editingController.text, + ), + setState(() { + if (_mapController != null) { + _mapController.updateMapOptions(BMFMapOptions( + center: latLng, + zoomLevel: 15, + )); + } + }) + } + else + { + queryStore("", "", "", "", "", editingController.text), + } + }, + ); + } + + startLocation() async { + Location.getInstance() + .aMapFlutterLocation + .onResultCallback() + .listen((event) { + if (event != null && + event["latitude"] != null && + event["longitude"] != null) { + print("location: $event"); + if (event["latitude"] is String && event["longitude"] is String) { + latLng = BMFCoordinate(double.tryParse(event["latitude"]), + double.tryParse(event["longitude"])); + } else { + latLng = BMFCoordinate(event["latitude"], event["longitude"]); + } + BMFCalculateUtils.coordConvert( + coordinate: latLng, + fromType: BMF_COORD_TYPE.BD09LL, + toType: BMF_COORD_TYPE.COMMON) + .then((value) { + this.latLng = value; + saveLatLng( + value, event["province"], event["city"], event["district"]); + print("union: Location result ${value.latitude} " + "${value.longitude}"); + Location.getInstance().stopLocation(); + queryStore( + "${value.latitude}", + "${value.longitude}", + event["province"], + event["city"], + event["district"], + editingController.text); + if (_mapController != null) + _mapController.updateMapOptions(BMFMapOptions( + center: value, + zoomLevel: 15, + )); + }); + } + }); + + Location.getInstance().prepareLoc(); + Location.getInstance().startLocation(context).then((value) { + }); + } + + saveLatLng(BMFCoordinate latLng, province, city, district) async { + SharedPreferences prefs = await SharedPreferences.getInstance(); + await prefs.setString("latitude", "${latLng.latitude}"); + await prefs.setString("longitude", "${latLng.longitude}"); + if (province != null) await prefs.setString("province", province); + if (city != null) await prefs.setString("city", city); + if (district != null) await prefs.setString("district", district); + } + @override Widget build(BuildContext context) { return Column( @@ -28,17 +164,29 @@ class _QuickOrder extends State { scrollDirection: Axis.horizontal, physics: BouncingScrollPhysics(), padding: EdgeInsets.symmetric(horizontal: 10), + itemCount:storeList == null ? 0 : storeList.length, itemBuilder: (context, position) { - return storeItem(); + return GestureDetector( + onTap: () { + Navigator.of(context).pushNamed( + '/router/store_order', + arguments: { + "id": storeList[position].id, + "tenant": storeList[position].tenantCode, + "storeName": storeList[position].storeName + }, + ); + }, + child: storeItem(storeList[position],position), + ); }, - itemCount: 10, ), ), ], ); } - Widget storeItem() { + Widget storeItem(Store store,position) { return Container( width: 160, height: 160, @@ -96,13 +244,16 @@ class _QuickOrder extends State { mainAxisAlignment: MainAxisAlignment.spaceEvenly, crossAxisAlignment: CrossAxisAlignment.center, children: [ - Image.asset( - "assets/image/default_user.png", + MImage( + store.logo, width: 32, height: 32, + fit: BoxFit.cover, + errorSrc: "assets/image/default_1.png", + fadeSrc: "assets/image/default_1.png", ), Text( - "百年川椒", + store.storeName, style: TextStyle( fontSize: 14.sp, fontWeight: MyFontWeight.medium, @@ -110,7 +261,7 @@ class _QuickOrder extends State { ), ), Text( - "正宗重庆老味道", + store?.remark ??"", style: TextStyle( fontSize: 10.sp, fontWeight: MyFontWeight.medium, diff --git a/lib/main.dart b/lib/main.dart index c8cf3cd4..93928147 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -71,6 +71,7 @@ import 'package:tpns_flutter_plugin/tpns_flutter_plugin.dart'; import 'package:flutter_baidu_mapapi_base/flutter_baidu_mapapi_base.dart'; import 'home/guide_page.dart'; +import 'home/home_view/activity_list.dart'; import 'main_page.dart'; import 'mine/fans_page.dart'; import 'mine/follow_page.dart'; @@ -305,7 +306,6 @@ Map routers = { '/router/test_page': (context, {arguments}) => TestPage(), // '/router/ui_test': (context, {arguments}) => UITest(), '/router/communityFollow': (context, {arguments}) => CommunityFollow(), - '/router/followPage': (context, {arguments}) => FollowPage(), - '/router/fansPage': (context, {arguments}) => FansPage(), '/router/releasePage': (context, {arguments}) => ReleasePage(), + '/router/activity_list': (context, {arguments}) => ActivityList(), }; diff --git a/lib/mine/fans_page.dart b/lib/mine/fans_page.dart index 7c3ee5d8..d819ab69 100644 --- a/lib/mine/fans_page.dart +++ b/lib/mine/fans_page.dart @@ -1,7 +1,9 @@ import 'package:dio/dio.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:huixiang/retrofit/data/base_data.dart'; +import 'package:huixiang/retrofit/data/comunity_comment.dart'; import 'package:huixiang/retrofit/data/follow_list.dart'; import 'package:huixiang/retrofit/data/page.dart'; import 'package:huixiang/retrofit/retrofit_api.dart'; @@ -9,11 +11,18 @@ 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_footer.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'; import 'package:flutter_screenutil/flutter_screenutil.dart'; class FansPage extends StatefulWidget { + final Function refresh; + + FansPage( + this.refresh + ); + @override State createState() { return _FansPage(); @@ -72,12 +81,23 @@ class _FansPage extends State { } } + //关注/取关会员 + _vipFollow(followId) async { + BaseData baseData = await apiService.follow(followId); + if (baseData != null && baseData.isSuccess) { + widget.refresh(); + SmartDialog.showToast("关注成功", alignment: Alignment.center); + } else { + SmartDialog.showToast(baseData.msg, alignment: Alignment.center); + } + } + @override Widget build(BuildContext context) { return Scaffold( body: Container( margin: EdgeInsets.only(top: 2), - color:Colors.white, + color: Colors.white, child: SmartRefresher( enablePullDown: true, enablePullUp: false, @@ -90,7 +110,7 @@ class _FansPage extends State { controller: _refreshController, // onRefresh: , physics: BouncingScrollPhysics(), - child: ListView.builder( + child: ListView.builder( itemCount: list == null ? 0 : list.length, padding: EdgeInsets.symmetric(vertical: 8.h), shrinkWrap: true, @@ -98,30 +118,28 @@ class _FansPage extends State { scrollDirection: Axis.vertical, itemBuilder: (context, position) { return GestureDetector( - onTap: () { - }, + onTap: () {}, child: fansItem(list[position]), ); }, ) - // NoDataView( - // isShowBtn: false, - // text: "共关注0人", - // fontSize: 16.sp, - // margin: EdgeInsets.only(top: 120.h), - // ), - ), + // NoDataView( + // isShowBtn: false, + // text: "共关注0人", + // fontSize: 16.sp, + // margin: EdgeInsets.only(top: 120.h), + // ), + ), ), ); } - Widget fansItem(ListData list) { return Container( margin: EdgeInsets.symmetric(horizontal: 16.w, vertical: 16.h), - child:Row( + child: Row( mainAxisAlignment: MainAxisAlignment.spaceAround, - crossAxisAlignment:CrossAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, children: [ MImage( list != null ? (list.avatar ?? "") : "", @@ -133,9 +151,11 @@ class _FansPage extends State { fadeSrc: "assets/image/default_1.png", ), SizedBox( - width:8, + width: 8, ), - Expanded(child:Text( + Expanded( + flex: 1, + child: Text( list != null ? (list.nickname ?? "") : "", style: TextStyle( color: Color(0xFF1A1A1A), @@ -150,7 +170,48 @@ class _FansPage extends State { borderRadius: BorderRadius.circular(11.w), color: Color(0xFF32A060), ), - child:Row( + child: + // GestureDetector( + // onTap: () { + // setState(() { + // if (widget.commentType == 0) { + // comment?.selfFollow = + // !(comment?.selfFollow ?? false); + // _vipFollow(list.mid); + // } + // }); + // }, + // child: (widget.commentType == 0) + // ? RoundButton( + // padding: EdgeInsets.symmetric( + // horizontal: 8, + // vertical: 3, + // ), + // backgroup: (comment?.selfFollow ?? false) + // ? Color(0xFFE6E6E6) + // : Color(0xFF32A060), + // textColor: (comment?.selfFollow ?? false) + // ? Color(0xFF808080) + // : Colors.white, + // text: (comment?.selfFollow ?? false) ? "已关注" : "关注", + // radius: 20, + // icons: Icon( + // (comment?.selfFollow ?? false) + // ? Icons.check + // : Icons.add, + // color: (comment?.selfFollow ?? false) + // ? Color(0xFF808080) + // : Colors.white, + // size: 14, + // ), + // ) + // : Icon( + // Icons.close, + // color: Colors.black, + // size: 16, + // ), + // ), + Row( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment:CrossAxisAlignment.center, children: [ diff --git a/lib/mine/follow_page.dart b/lib/mine/follow_page.dart index cf0f71f0..6e99d0d7 100644 --- a/lib/mine/follow_page.dart +++ b/lib/mine/follow_page.dart @@ -1,6 +1,7 @@ import 'package:dio/dio.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:huixiang/generated/l10n.dart'; import 'package:huixiang/retrofit/data/base_data.dart'; import 'package:huixiang/retrofit/data/follow_list.dart'; @@ -17,6 +18,12 @@ import 'package:shared_preferences/shared_preferences.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; class FollowPage extends StatefulWidget { + final Function refresh; + + FollowPage( + this.refresh + ); + @override State createState() { return _FollowPage(); @@ -75,6 +82,18 @@ class _FollowPage extends State { } } + ///关注/取关会员 + _vipFollow(followId) async { + BaseData baseData = await apiService.follow(followId); + if (baseData != null && baseData.isSuccess) { + widget.refresh(); + _queryFollowList(); + SmartDialog.showToast("取关成功", alignment: Alignment.center); + } else { + SmartDialog.showToast(baseData.msg, alignment: Alignment.center); + } + } + @override Widget build(BuildContext context) { return Scaffold( @@ -152,6 +171,10 @@ class _FollowPage extends State { borderRadius: BorderRadius.circular(11.w), color: Color(0xFFE6E6E6), ), + child: + GestureDetector(onTap: (){ + _vipFollow(list.mid); + }, child:Row( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment:CrossAxisAlignment.center, @@ -173,7 +196,7 @@ class _FollowPage extends State { ), ), ], - ), + ),), ), ], ), diff --git a/lib/mine/mine_page.dart b/lib/mine/mine_page.dart index 2e81586d..f2769eab 100644 --- a/lib/mine/mine_page.dart +++ b/lib/mine/mine_page.dart @@ -7,6 +7,7 @@ import 'package:huixiang/generated/l10n.dart'; import 'package:huixiang/main.dart'; import 'package:huixiang/mine/mine_view/mine_order.dart'; import 'package:huixiang/retrofit/data/base_data.dart'; +import 'package:huixiang/retrofit/data/comunity_comment.dart'; import 'package:huixiang/retrofit/data/rank.dart'; import 'package:huixiang/retrofit/data/sign_info.dart'; import 'package:huixiang/retrofit/data/social_info.dart'; diff --git a/lib/mine/mine_view/community_follow.dart b/lib/mine/mine_view/community_follow.dart index 1eed9d6e..54b1c50b 100644 --- a/lib/mine/mine_view/community_follow.dart +++ b/lib/mine/mine_view/community_follow.dart @@ -4,17 +4,18 @@ import 'package:flutter/material.dart'; import 'package:flutter_easyloading/flutter_easyloading.dart'; import 'package:huixiang/mine/follow_page.dart'; import 'package:huixiang/retrofit/data/base_data.dart'; +import 'package:huixiang/retrofit/data/comunity_comment.dart'; +import 'package:huixiang/retrofit/data/page.dart'; import 'package:huixiang/retrofit/data/social_info.dart'; import 'package:huixiang/retrofit/retrofit_api.dart'; import 'package:huixiang/utils/font_weight.dart'; import 'package:huixiang/view_widget/my_appbar.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:huixiang/view_widget/my_tab.dart'; +import 'package:pull_to_refresh/pull_to_refresh.dart'; import 'package:shared_preferences/shared_preferences.dart'; - import '../fans_page.dart'; - class CommunityFollow extends StatefulWidget { @override State createState() { @@ -53,6 +54,7 @@ class _CommunityFollow extends State EasyLoading.dismiss(); } + @override Widget build(BuildContext context) { return DefaultTabController( @@ -88,7 +90,7 @@ class _CommunityFollow extends State ), ), body: TabBarView( - children: [FollowPage(),FansPage()], + children: [FollowPage((){querySocialInfo();}),FansPage((){querySocialInfo();})], ), ), ); diff --git a/lib/mine/release_page.dart b/lib/mine/release_page.dart index 1e3e809a..dd0a21c1 100644 --- a/lib/mine/release_page.dart +++ b/lib/mine/release_page.dart @@ -109,7 +109,7 @@ class _ReleasePage extends State { child: CommunityDynamic( comments[position], 1,exitFull: (){setState(() { - + _onRefresh(); });}, removalDynamic: () { _onRefresh();