diff --git a/android/app/src/main/kotlin/com/zsw/huixiang/MinPlugin.kt b/android/app/src/main/kotlin/com/zsw/huixiang/MinPlugin.kt index 2b7663d3..9c49e748 100644 --- a/android/app/src/main/kotlin/com/zsw/huixiang/MinPlugin.kt +++ b/android/app/src/main/kotlin/com/zsw/huixiang/MinPlugin.kt @@ -55,6 +55,9 @@ class MinPlugin: FlutterPlugin, MethodCallHandler { } else if (call.method == "isExistsApp") { var appid = call.argument("appid"); result.success(DCUniMPSDK.getInstance().isExistsApp(appid)) + } else if (call.method == "getAppVersionInfo") { + var appid = call.argument("appid"); + result.success(DCUniMPSDK.getInstance().getAppVersionInfo(appid)["code"]) } else if (call.method == "closeCurrentApp") { result.success(DCUniMPSDK.getInstance().closeCurrentApp()) } else if (call.method == "getAppBasePath") { diff --git a/ios/Podfile b/ios/Podfile index 2f39f781..f7d6a5e6 100644 --- a/ios/Podfile +++ b/ios/Podfile @@ -29,7 +29,6 @@ flutter_ios_podfile_setup target 'Runner' do flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__)) - pod 'AFNetworking', '~> 4.0' end post_install do |installer| diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index 836005a4..8e17538a 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -771,14 +771,11 @@ ENABLE_BITCODE = NO; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", - "$(PROJECT_DIR)/Runner/Libs", "$(PROJECT_DIR)/Runner/UniMP/Libs", ); HEADER_SEARCH_PATHS = ( "$(inherited)", "\"${PODS_ROOT}/Headers/Public\"", - "\"${PODS_ROOT}/Headers/Public/AFNetworking\"", - "\"${PODS_ROOT}/Headers/Public/FMDB\"", "\"${PODS_ROOT}/Headers/Public/TOCropViewController\"", "\"${PODS_ROOT}/Headers/Public/Toast\"", "\"${PODS_ROOT}/Headers/Public/amap_flutter_location\"", @@ -801,7 +798,6 @@ ); LIBRARY_SEARCH_PATHS = ( "$(inherited)", - "$(PROJECT_DIR)/Runner/Libs", "$(PROJECT_DIR)/Runner/UniMP/Libs", ); MARKETING_VERSION = 1.0.2; @@ -932,14 +928,11 @@ ENABLE_BITCODE = NO; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", - "$(PROJECT_DIR)/Runner/Libs", "$(PROJECT_DIR)/Runner/UniMP/Libs", ); HEADER_SEARCH_PATHS = ( "$(inherited)", "\"${PODS_ROOT}/Headers/Public\"", - "\"${PODS_ROOT}/Headers/Public/AFNetworking\"", - "\"${PODS_ROOT}/Headers/Public/FMDB\"", "\"${PODS_ROOT}/Headers/Public/TOCropViewController\"", "\"${PODS_ROOT}/Headers/Public/Toast\"", "\"${PODS_ROOT}/Headers/Public/amap_flutter_location\"", @@ -962,7 +955,6 @@ ); LIBRARY_SEARCH_PATHS = ( "$(inherited)", - "$(PROJECT_DIR)/Runner/Libs", "$(PROJECT_DIR)/Runner/UniMP/Libs", ); MARKETING_VERSION = 1.0.2; @@ -986,14 +978,11 @@ ENABLE_BITCODE = NO; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", - "$(PROJECT_DIR)/Runner/Libs", "$(PROJECT_DIR)/Runner/UniMP/Libs", ); HEADER_SEARCH_PATHS = ( "$(inherited)", "\"${PODS_ROOT}/Headers/Public\"", - "\"${PODS_ROOT}/Headers/Public/AFNetworking\"", - "\"${PODS_ROOT}/Headers/Public/FMDB\"", "\"${PODS_ROOT}/Headers/Public/TOCropViewController\"", "\"${PODS_ROOT}/Headers/Public/Toast\"", "\"${PODS_ROOT}/Headers/Public/amap_flutter_location\"", @@ -1016,7 +1005,6 @@ ); LIBRARY_SEARCH_PATHS = ( "$(inherited)", - "$(PROJECT_DIR)/Runner/Libs", "$(PROJECT_DIR)/Runner/UniMP/Libs", ); MARKETING_VERSION = 1.0.2; diff --git a/ios/Runner/AppDelegate.m b/ios/Runner/AppDelegate.m index cb844bd7..c7ecbd0a 100644 --- a/ios/Runner/AppDelegate.m +++ b/ios/Runner/AppDelegate.m @@ -25,11 +25,7 @@ FlutterMethodChannel* uniAppChannel = [FlutterMethodChannel methodChannelWithName:@"zsw" binaryMessenger:controller]; MinPlugin * plugin = [[MinPlugin alloc] init]; [DCUniMPSDKEngine setDelegate:plugin]; - - - - [uniAppChannel setMethodCallHandler:^(FlutterMethodCall * _Nonnull call, FlutterResult _Nonnull result) { NSLog(@"arg:%@",call.arguments); if ([call.method isEqual:@"open"]){ @@ -37,10 +33,7 @@ } else if ([call.method isEqual:@"openUniApp"]) { NSDictionary * dict = @{@"token":call.arguments[0],@"storeId":@""}; [plugin openUniApp:call.arguments[0] dict:dict]; - - } - - else{ + }else{ result(FlutterMethodNotImplemented); } }]; diff --git a/ios/Runner/MinPlugin.h b/ios/Runner/MinPlugin.h index e1913456..126ba7d7 100644 --- a/ios/Runner/MinPlugin.h +++ b/ios/Runner/MinPlugin.h @@ -10,7 +10,6 @@ #import "DCUniMP.h" #import -#import "AFNetworking.h" #endif /* MinPlugin_h */ diff --git a/ios/Runner/MinPlugin.m b/ios/Runner/MinPlugin.m index 75c7a0bf..d7ce0cd3 100644 --- a/ios/Runner/MinPlugin.m +++ b/ios/Runner/MinPlugin.m @@ -8,19 +8,36 @@ #import "MinPlugin.h" #import + @implementation MinPlugin --(void)open:(NSString *)appid url:(NSString *)wgtUrl param:(NSDictionary *)dict block:(void (^)(void))block{ - if (![DCUniMPSDKEngine isExistsApp:appid]) { - //不存在准备下载 - [self downloadWgt:wgtUrl appid:appid block:nil success:^{ - [self openUniApp:appid dict:dict]; - }]; - }else{ - [self openUniApp:appid dict:dict]; - } ++ (void)registerWithRegistrar:(NSObject*)registrar { + FlutterMethodChannel* channel = [FlutterMethodChannel methodChannelWithName:@"min" binaryMessenger:[registrar messenger]]; + + MinPlugin* instance = [[MinPlugin alloc] init]; + [registrar addMethodCallDelegate:instance channel:channel]; + } +- (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result { + if ([@"initialize" isEqualToString:call.method]) { + result([@"iOS " stringByAppendingString:[[UIDevice currentDevice] systemVersion]]); + } else { + result(FlutterMethodNotImplemented); + } +} + +//-(void)open:(NSString *)appid url:(NSString *)wgtUrl param:(NSDictionary *)dict block:(void (^)(void))block{ +// if (![DCUniMPSDKEngine isExistsApp:appid]) { +// //不存在准备下载 +// [self downloadWgt:wgtUrl appid:appid block:nil success:^{ +// [self openUniApp:appid dict:dict]; +// }]; +// }else{ +// [self openUniApp:appid dict:dict]; +// } +//} + -(void)openUniApp:(NSString *)name dict:(NSDictionary *)dict{ DCUniMPConfiguration *configuration = [[DCUniMPConfiguration alloc] init]; @@ -39,30 +56,30 @@ } --(void)downloadWgt:(NSString *)url appid:(NSString *)appid block:(void (^)(NSString *))block success:(void (^)(void))success{ - NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration]; - AFURLSessionManager *manager = [[AFURLSessionManager alloc] initWithSessionConfiguration:configuration]; - NSLog(@"url:%@",url); - NSURL *URL = [NSURL URLWithString:url]; - NSURLRequest *request = [NSURLRequest requestWithURL:URL]; - - NSURLSessionDownloadTask *downloadTask = [manager downloadTaskWithRequest:request progress:^(NSProgress * _Nonnull downloadProgress) { - // - NSLog(@"downloadProgress:%f",downloadProgress.fractionCompleted); - //block([NSString stringWithFormat:@"loading...%f",downloadProgress.fractionCompleted]); - } destination:^NSURL * _Nonnull(NSURL * _Nonnull targetPath, NSURLResponse * _Nonnull response) { - NSURL *documentsDirectoryURL = [[NSFileManager defaultManager] URLForDirectory:NSDocumentDirectory inDomain:NSUserDomainMask appropriateForURL:nil create:NO error:nil]; - return [documentsDirectoryURL URLByAppendingPathComponent:[response suggestedFilename]]; - } completionHandler:^(NSURLResponse * _Nonnull response, NSURL * _Nullable filePath, NSError * _Nullable error) { - NSLog(@"File downloaded to: %@", filePath); - if ([DCUniMPSDKEngine releaseAppResourceToRunPathWithAppid:appid resourceFilePath:filePath.path]) { - NSLog(@"应用资源文件部署成功"); - //直接打开 - success(); - } - }]; - [downloadTask resume]; -} +//-(void)downloadWgt:(NSString *)url appid:(NSString *)appid block:(void (^)(NSString *))block success:(void (^)(void))success{ +// NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration]; +// AFURLSessionManager *manager = [[AFURLSessionManager alloc] initWithSessionConfiguration:configuration]; +// NSLog(@"url:%@",url); +// NSURL *URL = [NSURL URLWithString:url]; +// NSURLRequest *request = [NSURLRequest requestWithURL:URL]; +// +// NSURLSessionDownloadTask *downloadTask = [manager downloadTaskWithRequest:request progress:^(NSProgress * _Nonnull downloadProgress) { +// // +// NSLog(@"downloadProgress:%f",downloadProgress.fractionCompleted); +// //block([NSString stringWithFormat:@"loading...%f",downloadProgress.fractionCompleted]); +// } destination:^NSURL * _Nonnull(NSURL * _Nonnull targetPath, NSURLResponse * _Nonnull response) { +// NSURL *documentsDirectoryURL = [[NSFileManager defaultManager] URLForDirectory:NSDocumentDirectory inDomain:NSUserDomainMask appropriateForURL:nil create:NO error:nil]; +// return [documentsDirectoryURL URLByAppendingPathComponent:[response suggestedFilename]]; +// } completionHandler:^(NSURLResponse * _Nonnull response, NSURL * _Nullable filePath, NSError * _Nullable error) { +// NSLog(@"File downloaded to: %@", filePath); +// if ([DCUniMPSDKEngine releaseAppResourceToRunPathWithAppid:appid resourceFilePath:filePath.path]) { +// NSLog(@"应用资源文件部署成功"); +// //直接打开 +// success(); +// } +// }]; +// [downloadTask resume]; +//} -(void)uniMPOnClose:(NSString *)appid{ diff --git a/lib/home/activity_list_page.dart b/lib/home/activity_list_page.dart index ef9e858c..a951fc93 100644 --- a/lib/home/activity_list_page.dart +++ b/lib/home/activity_list_page.dart @@ -9,9 +9,7 @@ import 'package:huixiang/retrofit/data/page.dart'; import 'package:huixiang/retrofit/retrofit_api.dart'; import 'package:huixiang/view_widget/classic_header.dart'; import 'package:huixiang/view_widget/custom_image.dart'; -import 'package:huixiang/view_widget/item_title.dart'; import 'package:huixiang/view_widget/loading_view.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'; @@ -22,7 +20,7 @@ class ActivityListPage extends StatefulWidget { } } -class _ActivityListPage extends State { +class _ActivityListPage extends State with AutomaticKeepAliveClientMixin { ApiService apiService; @override @@ -209,4 +207,8 @@ class _ActivityListPage extends State { ), ); } + + @override + bool get wantKeepAlive => true; + } diff --git a/lib/home/home_page.dart b/lib/home/home_page.dart index 862b7fa2..0b09360e 100644 --- a/lib/home/home_page.dart +++ b/lib/home/home_page.dart @@ -26,7 +26,7 @@ class HomePage extends StatefulWidget { } } -class _HomePage extends State { +class _HomePage extends State with AutomaticKeepAliveClientMixin { ApiService apiService; @override @@ -345,6 +345,7 @@ class _HomePage extends State { children: [ Text( goods.name, + overflow: TextOverflow.ellipsis, style: TextStyle( color: Colors.black, fontWeight: FontWeight.bold, @@ -362,12 +363,16 @@ class _HomePage extends State { decorationColor: Color(0xFF585858), fontSize: 12), ), - Text( - S.of(context).jifen_(goods.price), - style: TextStyle( - color: Color(0xFF32A060), - fontSize: 14, - fontWeight: FontWeight.bold), + Expanded( + child: Text( + S.of(context).jifen_(goods.price), + overflow: TextOverflow.ellipsis, + style: TextStyle( + color: Color(0xFF32A060), + fontSize: 14, + fontWeight: FontWeight.bold), + ), + flex: 1, ), ], ), @@ -454,7 +459,7 @@ class _HomePage extends State { borderRadius: BorderRadius.all(Radius.circular(8)), ), child: MImage( - brandData[position].imgUrl, + brandData[position].imgUrl, radius: BorderRadius.all(Radius.circular(8)), fit: BoxFit.cover, errorSrc: "assets/image/default_2_1.png", @@ -479,7 +484,6 @@ class _HomePage extends State { child: AspectRatio( aspectRatio: 2, child: Swiper( - autoplay: false, pagination: SwiperPagination( margin: EdgeInsets.only(bottom: 20), alignment: Alignment.bottomCenter, @@ -491,28 +495,29 @@ class _HomePage extends State { color: Colors.white.withAlpha(76), ), ), + physics: BouncingScrollPhysics(), + loop: false, itemBuilder: (context, position) { return Container( margin: EdgeInsets.all(16), decoration: BoxDecoration( borderRadius: BorderRadius.all(Radius.circular(8))), child: MImage( - (bannerData != null && position < bannerData.length) ? bannerData[position].imgUrl : "", + (bannerData != null && position < bannerData.length) + ? bannerData[position].imgUrl + : "", radius: BorderRadius.all(Radius.circular(8)), fit: BoxFit.cover, errorSrc: "assets/image/default_2_1.png", fadeSrc: "assets/image/default_2_1.png", ), - // child: ClipRRect( - // borderRadius: BorderRadius.all(Radius.circular(8)), - // child: Image( - // fit: BoxFit.cover, - // image: NetworkImage(images.elementAt(position))), - // ), ); }, itemCount: bannerData != null ? bannerData.length : 1), ), ); } + + @override + bool get wantKeepAlive => true; } diff --git a/lib/home/huixiang_brand_page.dart b/lib/home/huixiang_brand_page.dart index c9802e77..c792486f 100644 --- a/lib/home/huixiang_brand_page.dart +++ b/lib/home/huixiang_brand_page.dart @@ -145,6 +145,7 @@ class _BrandPage extends State elevation: 0, ), body: Container( + padding: EdgeInsets.only(bottom: 76.h), child: Stack( children: [ Container( @@ -422,6 +423,7 @@ class _BrandPage extends State color: Colors.black.withAlpha(76), ), ), + physics: BouncingScrollPhysics(), itemBuilder: (context, position) { return MImage( (bannerData != null && @@ -434,7 +436,7 @@ class _BrandPage extends State fadeSrc: "assets/image/default_2_1.png", ); }, - itemCount: (bannerData != null) + itemCount: (bannerData != null && bannerData.length > 0) ? bannerData.length : 1), ), diff --git a/lib/home/main_home_page.dart b/lib/home/main_home_page.dart index 546e65e6..faacda62 100644 --- a/lib/home/main_home_page.dart +++ b/lib/home/main_home_page.dart @@ -2,9 +2,9 @@ import 'package:flutter/material.dart'; import 'package:huixiang/generated/l10n.dart'; import 'package:huixiang/home/activity_list_page.dart'; import 'package:huixiang/home/home_page.dart'; -import 'package:huixiang/home/huixiang_brand_page.dart'; import 'package:huixiang/home/points_mall_page.dart'; import 'package:huixiang/view_widget/my_tab.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; class MainHomePage extends StatefulWidget { @override @@ -83,9 +83,12 @@ class _MainHomePage extends State ), ]), ), - body: TabBarView( - children: _widgetOptions, - controller: tabcontroller, + body: Container( + padding: EdgeInsets.only(bottom: 76.h), + child: TabBarView( + children: _widgetOptions, + controller: tabcontroller, + ), ), )); } diff --git a/lib/home/points_mall_page.dart b/lib/home/points_mall_page.dart index 209c6b07..fd24eee9 100644 --- a/lib/home/points_mall_page.dart +++ b/lib/home/points_mall_page.dart @@ -29,7 +29,7 @@ class PointsMallPage extends StatefulWidget { } } -class _PointsMallPage extends State { +class _PointsMallPage extends State with AutomaticKeepAliveClientMixin { var _itemText = S.current.morenpaixu; ApiService client; @@ -349,6 +349,7 @@ class _PointsMallPage extends State { children: [ Text( goods.name, + overflow: TextOverflow.ellipsis, style: TextStyle( color: Colors.black, fontWeight: FontWeight.bold, @@ -537,4 +538,8 @@ class _PointsMallPage extends State { ), ); } + + @override + bool get wantKeepAlive => true; + } diff --git a/lib/main_page.dart b/lib/main_page.dart index 88b5d730..7a3711be 100644 --- a/lib/main_page.dart +++ b/lib/main_page.dart @@ -7,6 +7,7 @@ import 'package:huixiang/home/main_home_page.dart'; import 'package:huixiang/mine/mine_page.dart'; import 'package:huixiang/union/union_page.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:permission_handler/permission_handler.dart'; class MainPage extends StatefulWidget { @override @@ -48,6 +49,15 @@ class _MainPage extends State { "assets/image/icon_meng_n.png", "assets/image/icon_wo_n.png", ]; + + } + + requestPermission() async { + + if(!await Permission.storage.isGranted) { + await Permission.storage.request(); + } + } PageController pageController = PageController(); @@ -55,6 +65,7 @@ class _MainPage extends State { @override Widget build(BuildContext context) { return Scaffold( + resizeToAvoidBottomInset: false, body: Container( child: PageView( controller: pageController, @@ -65,23 +76,25 @@ class _MainPage extends State { setState(() {}); }, ), - margin: EdgeInsets.only(bottom: 76), ), extendBody: true, bottomNavigationBar: Container( alignment: Platform.isAndroid ? Alignment.center : Alignment.topCenter, decoration: BoxDecoration( - color: Colors.white, - boxShadow: [ - BoxShadow( - color: Colors.black.withAlpha(12), - offset: Offset(0, 2), - blurRadius: 4, - spreadRadius: 0, - ) - ], - borderRadius: BorderRadius.only( - topRight: Radius.circular(4), topLeft: Radius.circular(4))), + color: Colors.white, + boxShadow: [ + BoxShadow( + color: Colors.black.withAlpha(12), + offset: Offset(0, 2), + blurRadius: 4, + spreadRadius: 0, + ) + ], + borderRadius: BorderRadius.only( + topRight: Radius.circular(4), + topLeft: Radius.circular(4), + ), + ), height: 82.h, child: Row( mainAxisAlignment: MainAxisAlignment.spaceAround, @@ -117,7 +130,7 @@ class _MainPage extends State { : MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.center, children: [ - if(Platform.isIOS) + if (Platform.isIOS) SizedBox( height: 4.h, ), @@ -189,7 +202,7 @@ class _MainPage extends State { : MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.center, children: [ - if(Platform.isIOS) + if (Platform.isIOS) SizedBox( height: 4.h, ), diff --git a/lib/mine/mine_page.dart b/lib/mine/mine_page.dart index af1c336d..85e85314 100644 --- a/lib/mine/mine_page.dart +++ b/lib/mine/mine_page.dart @@ -12,6 +12,7 @@ import 'package:huixiang/view_widget/loading_view.dart'; import 'package:huixiang/view_widget/mine_vip_view.dart'; import 'package:shared_preferences/shared_preferences.dart'; import 'package:dio/dio.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; class MinePage extends StatefulWidget { @override @@ -82,6 +83,7 @@ class _MinePage extends State with AutomaticKeepAliveClientMixin { return Scaffold( backgroundColor: Color(0xFFF7F7F7), body: Container( + padding: EdgeInsets.only(bottom: 76.h), child: SingleChildScrollView( physics: BouncingScrollPhysics(), child: Container( diff --git a/lib/retrofit/retrofit_api.dart b/lib/retrofit/retrofit_api.dart index d101bf17..c98e5453 100644 --- a/lib/retrofit/retrofit_api.dart +++ b/lib/retrofit/retrofit_api.dart @@ -180,4 +180,8 @@ abstract class ApiService { @GET("/home/brand") Future queryHomeBrand(); + ///小程序会员登录 + @GET("/auth/mini/login/{storeId}") + Future minLogin(@Path("storeId") String storeId); + } diff --git a/lib/union/union_details_page.dart b/lib/union/union_details_page.dart index 832ec94a..208b0ac8 100644 --- a/lib/union/union_details_page.dart +++ b/lib/union/union_details_page.dart @@ -1,11 +1,15 @@ import 'dart:convert'; +import 'dart:io'; import 'package:dio/dio.dart'; +import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter/rendering.dart'; +import 'package:fluttertoast/fluttertoast.dart'; import 'package:huixiang/generated/l10n.dart'; import 'package:huixiang/retrofit/data/base_data.dart'; import 'package:huixiang/retrofit/data/store_info.dart'; +import 'package:huixiang/retrofit/data/user_entity.dart'; import 'package:huixiang/retrofit/data/user_info.dart'; import 'package:huixiang/retrofit/retrofit_api.dart'; import 'package:huixiang/utils/min.dart'; @@ -15,6 +19,7 @@ import 'package:huixiang/view_widget/item_title.dart'; import 'package:huixiang/view_widget/round_button.dart'; import 'package:huixiang/view_widget/separator.dart'; import 'package:flutter_swiper_null_safety/flutter_swiper_null_safety.dart'; +import 'package:path_provider/path_provider.dart'; import 'package:shared_preferences/shared_preferences.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:pull_to_refresh/pull_to_refresh.dart'; @@ -300,7 +305,7 @@ class _UnionDetailsPage extends State { flex: 1, ), InkWell( - onTap: _startMin, + onTap: _loginMin, child: Container( padding: EdgeInsets.only(top: 16.h, bottom: 16.h), decoration: BoxDecoration( @@ -497,7 +502,14 @@ class _UnionDetailsPage extends State { Text( S.of(context).youxiaoqizhi( (storeInfo != null && - storeInfo.couponVOList != null && storeInfo.couponVOList[position].useStartTime != null && storeInfo.couponVOList[position].useEndTime != null) + storeInfo.couponVOList != + null && + storeInfo.couponVOList[position] + .useStartTime != + null && + storeInfo.couponVOList[position] + .useEndTime != + null) ? "${storeInfo.couponVOList[position].useStartTime.replaceAll("-", ".").split(" ")[0]}-${storeInfo.couponVOList[position].useEndTime.replaceAll("-", ".").split(" ")[0]}" : "", ), @@ -626,7 +638,8 @@ class _UnionDetailsPage extends State { ), child: Text( (storeInfo != null && storeInfo.promotionList != null) - ? storeInfo.promotionList[position].activityStartTime.split(" ")[0] + ? storeInfo.promotionList[position].activityStartTime + .split(" ")[0] : "", style: TextStyle( fontWeight: FontWeight.bold, @@ -682,19 +695,46 @@ class _UnionDetailsPage extends State { ); } - _startMin() async { + printMin() async { + print("print isExistsApp: ${await Min.isExistsApp("__UNI__ACD00DA")}"); + print("print getAppBasePath: ${await Min.getAppBasePath()}"); + print("print currentPageUrl: ${await Min.currentPageUrl()}"); + print("print runingAppid: ${await Min.runingAppid()}"); + print("print getAppVersionInfo: ${await Min.getAppVersionInfo("__UNI__ACD00DA")}"); + } + + _loginMin() async { + if (storeInfo == null) return; + BaseData baseData = await apiService.minLogin(storeInfo.id); + if(baseData != null && baseData.isSuccess) { + UserEntity userEntity = UserEntity.fromJson(baseData.data); + startMin(userEntity.token, userEntity.userId); + } else { + Fluttertoast.showToast(msg: baseData.msg); + } + + } + + startMin(token, userId) async { if (storeInfo == null) return; if (!(await Min.isInitialize())) { await Min.initialize(); } + printMin(); Min.clickListener(); if (!(await Min.isExistsApp("__UNI__ACD00DA"))) { - await Min.reloadWgt("__UNI__ACD00DA", - "/storage/emulated/0/Android/data/com.zsw.huixiang/files/__UNI__ACD00DA.wgt"); + String filePath = ""; + if(Platform.isAndroid) { + filePath = (await getExternalStorageDirectory()).path; + } else { + filePath = (await getApplicationDocumentsDirectory()).path; + } + filePath = "$filePath/__UNI__ACD00DA.wgt"; + + await downloadWgt("__UNI__ACD00DA", filePath); + await Min.reloadWgt("__UNI__ACD00DA",filePath); } SharedPreferences sharedPreferences = await SharedPreferences.getInstance(); - String token = sharedPreferences.getString("token"); - String userId = sharedPreferences.getString("userId"); String nickname = sharedPreferences.getString("nick"); String mobile = sharedPreferences.getString("mobile"); String user = sharedPreferences.getString('user'); @@ -714,4 +754,76 @@ class _UnionDetailsPage extends State { }, }); } + + Function state; + double progressValue = 0; + String downText = "正在下载中..."; + + downloadWgt(appid, savePath) async { + showCupertinoDialog( + context: context, + barrierDismissible: true, + builder: (context) { + return Material( + type: MaterialType.transparency, + child: StatefulBuilder(builder: (context, status) { + state = status; + return Center( + child: Container( + width: 130, + height: 130, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(8), + color: Colors.white, + ), + child: Column( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + SizedBox( + //限制进度条的高度 + height: 40.0, + //限制进度条的宽度 + width: 40, + child: CircularProgressIndicator( + value: progressValue, + backgroundColor: Colors.yellow, + color: Colors.blue, + valueColor: AlwaysStoppedAnimation(Colors.red), + ), + ), + Text( + downText, + style: TextStyle( + color: Colors.black, + fontSize: 16, + fontWeight: FontWeight.bold, + ), + ) + ], + ), + ), + ); + }), + ); + }); + + Response response = await Dio().download( + "https://qiniu.upload.gznl.top/__UNI__ACD00DA.wgt", + savePath, + onReceiveProgress: (progress, max) { + progressValue = progress.toDouble() / max.toDouble(); + print("print progressValue: $progressValue"); + state(() {}); + }); + if (response.statusCode == 200) { + downText = "下载完成"; + state(() {}); + Future.delayed(Duration(seconds: 1), () { + if (Navigator.canPop(context)) { + Navigator.of(context).pop(); + } + }); + } + } } diff --git a/lib/union/union_page.dart b/lib/union/union_page.dart index 249973e9..9d848d01 100644 --- a/lib/union/union_page.dart +++ b/lib/union/union_page.dart @@ -219,52 +219,61 @@ class _UnionPage extends State with AutomaticKeepAliveClientMixin { AMapApiKey aMapApiKeys = AMapApiKey( androidKey: 'f39d1daa020a56f208eb2519f63e9534', iosKey: 'feaae7986201b571cace1b83728be5bb'); - return Scaffold( - body: NestedScrollView( - physics: BouncingScrollPhysics(), - headerSliverBuilder: (context, inner) { - return [ - buildSliverAppBar(AMapWidget( - initialCameraPosition: CameraPosition( - target: LatLng(30.553111, 114.342366), - zoom: 12.0, - ), - onMapCreated: onMapCreated, - apiKey: aMapApiKeys, - touchPoiEnabled: true, - markers: markers.toSet(), - scrollGesturesEnabled: true, - customStyleOptions: _customStyleOptions, - gestureRecognizers: >[ - Factory( - () => EagerGestureRecognizer()) - ].toSet(), - )), - ]; - }, - body: Container( - child: SmartRefresher( - controller: refreshController, - enablePullUp: false, - enablePullDown: true, - physics: BouncingScrollPhysics(), - header: MyHeader(), - onRefresh: () { - startLocation(); - }, - child: ListView.builder( - itemCount: storeList == null ? 0 : storeList.length, - padding: EdgeInsets.only(top: 8.h, bottom: 8.h), - itemBuilder: (context, position) { - return GestureDetector( - onTap: () { - Navigator.of(context).pushNamed( - '/router/union_detail_page', - arguments: {"id": storeList[position].id}); - }, - child: buildStoreItem(storeList[position], position), - ); - }), + return GestureDetector( + onTap: (){ + FocusScope.of(context).requestFocus(FocusNode()); + }, + child: Scaffold( + resizeToAvoidBottomInset: true, + body: NestedScrollView( + physics: BouncingScrollPhysics(), + headerSliverBuilder: (context, inner) { + return [ + buildSliverAppBar(AMapWidget( + initialCameraPosition: CameraPosition( + target: LatLng(30.553111, 114.342366), + zoom: 12.0, + ), + onMapCreated: onMapCreated, + apiKey: aMapApiKeys, + touchPoiEnabled: true, + markers: markers.toSet(), + scrollGesturesEnabled: true, + customStyleOptions: _customStyleOptions, + onPoiTouched: (poiTouch){ + FocusScope.of(context).requestFocus(FocusNode()); + }, + gestureRecognizers: >[ + Factory( + () => EagerGestureRecognizer()), + ].toSet(), + )), + ]; + }, + body: Container( + child: SmartRefresher( + controller: refreshController, + enablePullUp: false, + enablePullDown: true, + physics: BouncingScrollPhysics(), + header: MyHeader(), + onRefresh: () { + startLocation(); + }, + child: ListView.builder( + itemCount: storeList == null ? 0 : storeList.length, + padding: EdgeInsets.only(top: 8.h, bottom: 84.h), + itemBuilder: (context, position) { + return GestureDetector( + onTap: () { + Navigator.of(context).pushNamed( + '/router/union_detail_page', + arguments: {"id": storeList[position].id}); + }, + child: buildStoreItem(storeList[position], position), + ); + }), + ), ), ), ), @@ -294,6 +303,7 @@ class _UnionPage extends State with AutomaticKeepAliveClientMixin { } else { await Permission.location.request(); startLocation(); + getLatLng(); } } else { //enabledLocation diff --git a/lib/utils/min.dart b/lib/utils/min.dart index 68eb0b90..6d6858fb 100644 --- a/lib/utils/min.dart +++ b/lib/utils/min.dart @@ -16,6 +16,12 @@ class Min { return isExists; } + static Future getAppVersionInfo(appid) async { + final String code = await _channel + .invokeMethod('getAppVersionInfo', {"appid": appid}); + return code; + } + static Future getAppBasePath() async { final String getAppBasePath = await _channel.invokeMethod( 'getAppBasePath', diff --git a/pubspec.lock b/pubspec.lock index f2c85e2d..b8e0f496 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -526,7 +526,7 @@ packages: source: hosted version: "0.2.1" path_provider: - dependency: transitive + dependency: "direct main" description: name: path_provider url: "https://pub.dartlang.org" diff --git a/pubspec.yaml b/pubspec.yaml index c6496c93..c74493d8 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -64,6 +64,7 @@ dependencies: # flukit: ^1.0.2 # azlistview: ^1.1.1 + path_provider: ^1.2.0 cached_network_image: ^2.0.0 flutter_html: ^1.3.0 #2.1.0