Browse Source

修改

null_safety
fmk 4 years ago
parent
commit
6a2059f602
  1. 3
      android/app/src/main/kotlin/com/zsw/huixiang/MinPlugin.kt
  2. 1
      ios/Podfile
  3. 12
      ios/Runner.xcodeproj/project.pbxproj
  4. 9
      ios/Runner/AppDelegate.m
  5. 1
      ios/Runner/MinPlugin.h
  6. 81
      ios/Runner/MinPlugin.m
  7. 8
      lib/home/activity_list_page.dart
  8. 25
      lib/home/home_page.dart
  9. 4
      lib/home/huixiang_brand_page.dart
  10. 7
      lib/home/main_home_page.dart
  11. 7
      lib/home/points_mall_page.dart
  12. 21
      lib/main_page.dart
  13. 2
      lib/mine/mine_page.dart
  14. 4
      lib/retrofit/retrofit_api.dart
  15. 128
      lib/union/union_details_page.dart
  16. 16
      lib/union/union_page.dart
  17. 6
      lib/utils/min.dart
  18. 2
      pubspec.lock
  19. 1
      pubspec.yaml

3
android/app/src/main/kotlin/com/zsw/huixiang/MinPlugin.kt

@ -55,6 +55,9 @@ class MinPlugin: FlutterPlugin, MethodCallHandler {
} else if (call.method == "isExistsApp") { } else if (call.method == "isExistsApp") {
var appid = call.argument<String>("appid"); var appid = call.argument<String>("appid");
result.success(DCUniMPSDK.getInstance().isExistsApp(appid)) result.success(DCUniMPSDK.getInstance().isExistsApp(appid))
} else if (call.method == "getAppVersionInfo") {
var appid = call.argument<String>("appid");
result.success(DCUniMPSDK.getInstance().getAppVersionInfo(appid)["code"])
} else if (call.method == "closeCurrentApp") { } else if (call.method == "closeCurrentApp") {
result.success(DCUniMPSDK.getInstance().closeCurrentApp()) result.success(DCUniMPSDK.getInstance().closeCurrentApp())
} else if (call.method == "getAppBasePath") { } else if (call.method == "getAppBasePath") {

1
ios/Podfile

@ -29,7 +29,6 @@ flutter_ios_podfile_setup
target 'Runner' do target 'Runner' do
flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__)) flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
pod 'AFNetworking', '~> 4.0'
end end
post_install do |installer| post_install do |installer|

12
ios/Runner.xcodeproj/project.pbxproj

@ -771,14 +771,11 @@
ENABLE_BITCODE = NO; ENABLE_BITCODE = NO;
FRAMEWORK_SEARCH_PATHS = ( FRAMEWORK_SEARCH_PATHS = (
"$(inherited)", "$(inherited)",
"$(PROJECT_DIR)/Runner/Libs",
"$(PROJECT_DIR)/Runner/UniMP/Libs", "$(PROJECT_DIR)/Runner/UniMP/Libs",
); );
HEADER_SEARCH_PATHS = ( HEADER_SEARCH_PATHS = (
"$(inherited)", "$(inherited)",
"\"${PODS_ROOT}/Headers/Public\"", "\"${PODS_ROOT}/Headers/Public\"",
"\"${PODS_ROOT}/Headers/Public/AFNetworking\"",
"\"${PODS_ROOT}/Headers/Public/FMDB\"",
"\"${PODS_ROOT}/Headers/Public/TOCropViewController\"", "\"${PODS_ROOT}/Headers/Public/TOCropViewController\"",
"\"${PODS_ROOT}/Headers/Public/Toast\"", "\"${PODS_ROOT}/Headers/Public/Toast\"",
"\"${PODS_ROOT}/Headers/Public/amap_flutter_location\"", "\"${PODS_ROOT}/Headers/Public/amap_flutter_location\"",
@ -801,7 +798,6 @@
); );
LIBRARY_SEARCH_PATHS = ( LIBRARY_SEARCH_PATHS = (
"$(inherited)", "$(inherited)",
"$(PROJECT_DIR)/Runner/Libs",
"$(PROJECT_DIR)/Runner/UniMP/Libs", "$(PROJECT_DIR)/Runner/UniMP/Libs",
); );
MARKETING_VERSION = 1.0.2; MARKETING_VERSION = 1.0.2;
@ -932,14 +928,11 @@
ENABLE_BITCODE = NO; ENABLE_BITCODE = NO;
FRAMEWORK_SEARCH_PATHS = ( FRAMEWORK_SEARCH_PATHS = (
"$(inherited)", "$(inherited)",
"$(PROJECT_DIR)/Runner/Libs",
"$(PROJECT_DIR)/Runner/UniMP/Libs", "$(PROJECT_DIR)/Runner/UniMP/Libs",
); );
HEADER_SEARCH_PATHS = ( HEADER_SEARCH_PATHS = (
"$(inherited)", "$(inherited)",
"\"${PODS_ROOT}/Headers/Public\"", "\"${PODS_ROOT}/Headers/Public\"",
"\"${PODS_ROOT}/Headers/Public/AFNetworking\"",
"\"${PODS_ROOT}/Headers/Public/FMDB\"",
"\"${PODS_ROOT}/Headers/Public/TOCropViewController\"", "\"${PODS_ROOT}/Headers/Public/TOCropViewController\"",
"\"${PODS_ROOT}/Headers/Public/Toast\"", "\"${PODS_ROOT}/Headers/Public/Toast\"",
"\"${PODS_ROOT}/Headers/Public/amap_flutter_location\"", "\"${PODS_ROOT}/Headers/Public/amap_flutter_location\"",
@ -962,7 +955,6 @@
); );
LIBRARY_SEARCH_PATHS = ( LIBRARY_SEARCH_PATHS = (
"$(inherited)", "$(inherited)",
"$(PROJECT_DIR)/Runner/Libs",
"$(PROJECT_DIR)/Runner/UniMP/Libs", "$(PROJECT_DIR)/Runner/UniMP/Libs",
); );
MARKETING_VERSION = 1.0.2; MARKETING_VERSION = 1.0.2;
@ -986,14 +978,11 @@
ENABLE_BITCODE = NO; ENABLE_BITCODE = NO;
FRAMEWORK_SEARCH_PATHS = ( FRAMEWORK_SEARCH_PATHS = (
"$(inherited)", "$(inherited)",
"$(PROJECT_DIR)/Runner/Libs",
"$(PROJECT_DIR)/Runner/UniMP/Libs", "$(PROJECT_DIR)/Runner/UniMP/Libs",
); );
HEADER_SEARCH_PATHS = ( HEADER_SEARCH_PATHS = (
"$(inherited)", "$(inherited)",
"\"${PODS_ROOT}/Headers/Public\"", "\"${PODS_ROOT}/Headers/Public\"",
"\"${PODS_ROOT}/Headers/Public/AFNetworking\"",
"\"${PODS_ROOT}/Headers/Public/FMDB\"",
"\"${PODS_ROOT}/Headers/Public/TOCropViewController\"", "\"${PODS_ROOT}/Headers/Public/TOCropViewController\"",
"\"${PODS_ROOT}/Headers/Public/Toast\"", "\"${PODS_ROOT}/Headers/Public/Toast\"",
"\"${PODS_ROOT}/Headers/Public/amap_flutter_location\"", "\"${PODS_ROOT}/Headers/Public/amap_flutter_location\"",
@ -1016,7 +1005,6 @@
); );
LIBRARY_SEARCH_PATHS = ( LIBRARY_SEARCH_PATHS = (
"$(inherited)", "$(inherited)",
"$(PROJECT_DIR)/Runner/Libs",
"$(PROJECT_DIR)/Runner/UniMP/Libs", "$(PROJECT_DIR)/Runner/UniMP/Libs",
); );
MARKETING_VERSION = 1.0.2; MARKETING_VERSION = 1.0.2;

9
ios/Runner/AppDelegate.m

@ -26,10 +26,6 @@
MinPlugin * plugin = [[MinPlugin alloc] init]; MinPlugin * plugin = [[MinPlugin alloc] init];
[DCUniMPSDKEngine setDelegate:plugin]; [DCUniMPSDKEngine setDelegate:plugin];
[uniAppChannel setMethodCallHandler:^(FlutterMethodCall * _Nonnull call, FlutterResult _Nonnull result) { [uniAppChannel setMethodCallHandler:^(FlutterMethodCall * _Nonnull call, FlutterResult _Nonnull result) {
NSLog(@"arg:%@",call.arguments); NSLog(@"arg:%@",call.arguments);
if ([call.method isEqual:@"open"]){ if ([call.method isEqual:@"open"]){
@ -37,10 +33,7 @@
} else if ([call.method isEqual:@"openUniApp"]) { } else if ([call.method isEqual:@"openUniApp"]) {
NSDictionary * dict = @{@"token":call.arguments[0],@"storeId":@""}; NSDictionary * dict = @{@"token":call.arguments[0],@"storeId":@""};
[plugin openUniApp:call.arguments[0] dict:dict]; [plugin openUniApp:call.arguments[0] dict:dict];
}else{
}
else{
result(FlutterMethodNotImplemented); result(FlutterMethodNotImplemented);
} }
}]; }];

1
ios/Runner/MinPlugin.h

@ -10,7 +10,6 @@
#import "DCUniMP.h" #import "DCUniMP.h"
#import <Flutter/Flutter.h> #import <Flutter/Flutter.h>
#import "AFNetworking.h"
#endif /* MinPlugin_h */ #endif /* MinPlugin_h */

81
ios/Runner/MinPlugin.m

@ -8,19 +8,36 @@
#import "MinPlugin.h" #import "MinPlugin.h"
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>
@implementation MinPlugin @implementation MinPlugin
-(void)open:(NSString *)appid url:(NSString *)wgtUrl param:(NSDictionary *)dict block:(void (^)(void))block{ + (void)registerWithRegistrar:(NSObject<FlutterPluginRegistrar>*)registrar {
if (![DCUniMPSDKEngine isExistsApp:appid]) { FlutterMethodChannel* channel = [FlutterMethodChannel methodChannelWithName:@"min" binaryMessenger:[registrar messenger]];
//不存在准备下载
[self downloadWgt:wgtUrl appid:appid block:nil success:^{ MinPlugin* instance = [[MinPlugin alloc] init];
[self openUniApp:appid dict:dict]; [registrar addMethodCallDelegate:instance channel:channel];
}];
}else{ }
[self openUniApp:appid dict:dict];
- (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{ -(void)openUniApp:(NSString *)name dict:(NSDictionary *)dict{
DCUniMPConfiguration *configuration = [[DCUniMPConfiguration alloc] init]; DCUniMPConfiguration *configuration = [[DCUniMPConfiguration alloc] init];
@ -39,30 +56,30 @@
} }
-(void)downloadWgt:(NSString *)url appid:(NSString *)appid block:(void (^)(NSString *))block success:(void (^)(void))success{ //-(void)downloadWgt:(NSString *)url appid:(NSString *)appid block:(void (^)(NSString *))block success:(void (^)(void))success{
NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration]; // NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration];
AFURLSessionManager *manager = [[AFURLSessionManager alloc] initWithSessionConfiguration:configuration]; // AFURLSessionManager *manager = [[AFURLSessionManager alloc] initWithSessionConfiguration:configuration];
NSLog(@"url:%@",url); // NSLog(@"url:%@",url);
NSURL *URL = [NSURL URLWithString:url]; // NSURL *URL = [NSURL URLWithString:url];
NSURLRequest *request = [NSURLRequest requestWithURL:URL]; // NSURLRequest *request = [NSURLRequest requestWithURL:URL];
//
NSURLSessionDownloadTask *downloadTask = [manager downloadTaskWithRequest:request progress:^(NSProgress * _Nonnull downloadProgress) { // NSURLSessionDownloadTask *downloadTask = [manager downloadTaskWithRequest:request progress:^(NSProgress * _Nonnull downloadProgress) {
// // //
NSLog(@"downloadProgress:%f",downloadProgress.fractionCompleted); // NSLog(@"downloadProgress:%f",downloadProgress.fractionCompleted);
//block([NSString stringWithFormat:@"loading...%f",downloadProgress.fractionCompleted]); // //block([NSString stringWithFormat:@"loading...%f",downloadProgress.fractionCompleted]);
} destination:^NSURL * _Nonnull(NSURL * _Nonnull targetPath, NSURLResponse * _Nonnull response) { // } destination:^NSURL * _Nonnull(NSURL * _Nonnull targetPath, NSURLResponse * _Nonnull response) {
NSURL *documentsDirectoryURL = [[NSFileManager defaultManager] URLForDirectory:NSDocumentDirectory inDomain:NSUserDomainMask appropriateForURL:nil create:NO error:nil]; // NSURL *documentsDirectoryURL = [[NSFileManager defaultManager] URLForDirectory:NSDocumentDirectory inDomain:NSUserDomainMask appropriateForURL:nil create:NO error:nil];
return [documentsDirectoryURL URLByAppendingPathComponent:[response suggestedFilename]]; // return [documentsDirectoryURL URLByAppendingPathComponent:[response suggestedFilename]];
} completionHandler:^(NSURLResponse * _Nonnull response, NSURL * _Nullable filePath, NSError * _Nullable error) { // } completionHandler:^(NSURLResponse * _Nonnull response, NSURL * _Nullable filePath, NSError * _Nullable error) {
NSLog(@"File downloaded to: %@", filePath); // NSLog(@"File downloaded to: %@", filePath);
if ([DCUniMPSDKEngine releaseAppResourceToRunPathWithAppid:appid resourceFilePath:filePath.path]) { // if ([DCUniMPSDKEngine releaseAppResourceToRunPathWithAppid:appid resourceFilePath:filePath.path]) {
NSLog(@"应用资源文件部署成功"); // NSLog(@"应用资源文件部署成功");
//直接打开 // //直接打开
success(); // success();
} // }
}]; // }];
[downloadTask resume]; // [downloadTask resume];
} //}
-(void)uniMPOnClose:(NSString *)appid{ -(void)uniMPOnClose:(NSString *)appid{

8
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/retrofit/retrofit_api.dart';
import 'package:huixiang/view_widget/classic_header.dart'; import 'package:huixiang/view_widget/classic_header.dart';
import 'package:huixiang/view_widget/custom_image.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/loading_view.dart';
import 'package:huixiang/view_widget/round_button.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart'; import 'package:pull_to_refresh/pull_to_refresh.dart';
import 'package:shared_preferences/shared_preferences.dart'; import 'package:shared_preferences/shared_preferences.dart';
@ -22,7 +20,7 @@ class ActivityListPage extends StatefulWidget {
} }
} }
class _ActivityListPage extends State<ActivityListPage> { class _ActivityListPage extends State<ActivityListPage> with AutomaticKeepAliveClientMixin {
ApiService apiService; ApiService apiService;
@override @override
@ -209,4 +207,8 @@ class _ActivityListPage extends State<ActivityListPage> {
), ),
); );
} }
@override
bool get wantKeepAlive => true;
} }

25
lib/home/home_page.dart

@ -26,7 +26,7 @@ class HomePage extends StatefulWidget {
} }
} }
class _HomePage extends State<HomePage> { class _HomePage extends State<HomePage> with AutomaticKeepAliveClientMixin {
ApiService apiService; ApiService apiService;
@override @override
@ -345,6 +345,7 @@ class _HomePage extends State<HomePage> {
children: [ children: [
Text( Text(
goods.name, goods.name,
overflow: TextOverflow.ellipsis,
style: TextStyle( style: TextStyle(
color: Colors.black, color: Colors.black,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
@ -362,13 +363,17 @@ class _HomePage extends State<HomePage> {
decorationColor: Color(0xFF585858), decorationColor: Color(0xFF585858),
fontSize: 12), fontSize: 12),
), ),
Text( Expanded(
child: Text(
S.of(context).jifen_(goods.price), S.of(context).jifen_(goods.price),
overflow: TextOverflow.ellipsis,
style: TextStyle( style: TextStyle(
color: Color(0xFF32A060), color: Color(0xFF32A060),
fontSize: 14, fontSize: 14,
fontWeight: FontWeight.bold), fontWeight: FontWeight.bold),
), ),
flex: 1,
),
], ],
), ),
], ],
@ -479,7 +484,6 @@ class _HomePage extends State<HomePage> {
child: AspectRatio( child: AspectRatio(
aspectRatio: 2, aspectRatio: 2,
child: Swiper( child: Swiper(
autoplay: false,
pagination: SwiperPagination( pagination: SwiperPagination(
margin: EdgeInsets.only(bottom: 20), margin: EdgeInsets.only(bottom: 20),
alignment: Alignment.bottomCenter, alignment: Alignment.bottomCenter,
@ -491,28 +495,29 @@ class _HomePage extends State<HomePage> {
color: Colors.white.withAlpha(76), color: Colors.white.withAlpha(76),
), ),
), ),
physics: BouncingScrollPhysics(),
loop: false,
itemBuilder: (context, position) { itemBuilder: (context, position) {
return Container( return Container(
margin: EdgeInsets.all(16), margin: EdgeInsets.all(16),
decoration: BoxDecoration( decoration: BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(8))), borderRadius: BorderRadius.all(Radius.circular(8))),
child: MImage( child: MImage(
(bannerData != null && position < bannerData.length) ? bannerData[position].imgUrl : "", (bannerData != null && position < bannerData.length)
? bannerData[position].imgUrl
: "",
radius: BorderRadius.all(Radius.circular(8)), radius: BorderRadius.all(Radius.circular(8)),
fit: BoxFit.cover, fit: BoxFit.cover,
errorSrc: "assets/image/default_2_1.png", errorSrc: "assets/image/default_2_1.png",
fadeSrc: "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), itemCount: bannerData != null ? bannerData.length : 1),
), ),
); );
} }
@override
bool get wantKeepAlive => true;
} }

4
lib/home/huixiang_brand_page.dart

@ -145,6 +145,7 @@ class _BrandPage extends State<BrandPage>
elevation: 0, elevation: 0,
), ),
body: Container( body: Container(
padding: EdgeInsets.only(bottom: 76.h),
child: Stack( child: Stack(
children: [ children: [
Container( Container(
@ -422,6 +423,7 @@ class _BrandPage extends State<BrandPage>
color: Colors.black.withAlpha(76), color: Colors.black.withAlpha(76),
), ),
), ),
physics: BouncingScrollPhysics(),
itemBuilder: (context, position) { itemBuilder: (context, position) {
return MImage( return MImage(
(bannerData != null && (bannerData != null &&
@ -434,7 +436,7 @@ class _BrandPage extends State<BrandPage>
fadeSrc: "assets/image/default_2_1.png", fadeSrc: "assets/image/default_2_1.png",
); );
}, },
itemCount: (bannerData != null) itemCount: (bannerData != null && bannerData.length > 0)
? bannerData.length ? bannerData.length
: 1), : 1),
), ),

7
lib/home/main_home_page.dart

@ -2,9 +2,9 @@ import 'package:flutter/material.dart';
import 'package:huixiang/generated/l10n.dart'; import 'package:huixiang/generated/l10n.dart';
import 'package:huixiang/home/activity_list_page.dart'; import 'package:huixiang/home/activity_list_page.dart';
import 'package:huixiang/home/home_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/home/points_mall_page.dart';
import 'package:huixiang/view_widget/my_tab.dart'; import 'package:huixiang/view_widget/my_tab.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
class MainHomePage extends StatefulWidget { class MainHomePage extends StatefulWidget {
@override @override
@ -83,10 +83,13 @@ class _MainHomePage extends State<MainHomePage>
), ),
]), ]),
), ),
body: TabBarView( body: Container(
padding: EdgeInsets.only(bottom: 76.h),
child: TabBarView(
children: _widgetOptions, children: _widgetOptions,
controller: tabcontroller, controller: tabcontroller,
), ),
),
)); ));
} }

7
lib/home/points_mall_page.dart

@ -29,7 +29,7 @@ class PointsMallPage extends StatefulWidget {
} }
} }
class _PointsMallPage extends State<PointsMallPage> { class _PointsMallPage extends State<PointsMallPage> with AutomaticKeepAliveClientMixin {
var _itemText = S.current.morenpaixu; var _itemText = S.current.morenpaixu;
ApiService client; ApiService client;
@ -349,6 +349,7 @@ class _PointsMallPage extends State<PointsMallPage> {
children: [ children: [
Text( Text(
goods.name, goods.name,
overflow: TextOverflow.ellipsis,
style: TextStyle( style: TextStyle(
color: Colors.black, color: Colors.black,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
@ -537,4 +538,8 @@ class _PointsMallPage extends State<PointsMallPage> {
), ),
); );
} }
@override
bool get wantKeepAlive => true;
} }

21
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/mine/mine_page.dart';
import 'package:huixiang/union/union_page.dart'; import 'package:huixiang/union/union_page.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:permission_handler/permission_handler.dart';
class MainPage extends StatefulWidget { class MainPage extends StatefulWidget {
@override @override
@ -48,6 +49,15 @@ class _MainPage extends State<MainPage> {
"assets/image/icon_meng_n.png", "assets/image/icon_meng_n.png",
"assets/image/icon_wo_n.png", "assets/image/icon_wo_n.png",
]; ];
}
requestPermission() async {
if(!await Permission.storage.isGranted) {
await Permission.storage.request();
}
} }
PageController pageController = PageController(); PageController pageController = PageController();
@ -55,6 +65,7 @@ class _MainPage extends State<MainPage> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
resizeToAvoidBottomInset: false,
body: Container( body: Container(
child: PageView( child: PageView(
controller: pageController, controller: pageController,
@ -65,7 +76,6 @@ class _MainPage extends State<MainPage> {
setState(() {}); setState(() {});
}, },
), ),
margin: EdgeInsets.only(bottom: 76),
), ),
extendBody: true, extendBody: true,
bottomNavigationBar: Container( bottomNavigationBar: Container(
@ -81,7 +91,10 @@ class _MainPage extends State<MainPage> {
) )
], ],
borderRadius: BorderRadius.only( borderRadius: BorderRadius.only(
topRight: Radius.circular(4), topLeft: Radius.circular(4))), topRight: Radius.circular(4),
topLeft: Radius.circular(4),
),
),
height: 82.h, height: 82.h,
child: Row( child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround, mainAxisAlignment: MainAxisAlignment.spaceAround,
@ -117,7 +130,7 @@ class _MainPage extends State<MainPage> {
: MainAxisAlignment.start, : MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center,
children: [ children: [
if(Platform.isIOS) if (Platform.isIOS)
SizedBox( SizedBox(
height: 4.h, height: 4.h,
), ),
@ -189,7 +202,7 @@ class _MainPage extends State<MainPage> {
: MainAxisAlignment.start, : MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center,
children: [ children: [
if(Platform.isIOS) if (Platform.isIOS)
SizedBox( SizedBox(
height: 4.h, height: 4.h,
), ),

2
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:huixiang/view_widget/mine_vip_view.dart';
import 'package:shared_preferences/shared_preferences.dart'; import 'package:shared_preferences/shared_preferences.dart';
import 'package:dio/dio.dart'; import 'package:dio/dio.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
class MinePage extends StatefulWidget { class MinePage extends StatefulWidget {
@override @override
@ -82,6 +83,7 @@ class _MinePage extends State<MinePage> with AutomaticKeepAliveClientMixin {
return Scaffold( return Scaffold(
backgroundColor: Color(0xFFF7F7F7), backgroundColor: Color(0xFFF7F7F7),
body: Container( body: Container(
padding: EdgeInsets.only(bottom: 76.h),
child: SingleChildScrollView( child: SingleChildScrollView(
physics: BouncingScrollPhysics(), physics: BouncingScrollPhysics(),
child: Container( child: Container(

4
lib/retrofit/retrofit_api.dart

@ -180,4 +180,8 @@ abstract class ApiService {
@GET("/home/brand") @GET("/home/brand")
Future<BaseData> queryHomeBrand(); Future<BaseData> queryHomeBrand();
///
@GET("/auth/mini/login/{storeId}")
Future<BaseData> minLogin(@Path("storeId") String storeId);
} }

128
lib/union/union_details_page.dart

@ -1,11 +1,15 @@
import 'dart:convert'; import 'dart:convert';
import 'dart:io';
import 'package:dio/dio.dart'; import 'package:dio/dio.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:huixiang/generated/l10n.dart'; import 'package:huixiang/generated/l10n.dart';
import 'package:huixiang/retrofit/data/base_data.dart'; import 'package:huixiang/retrofit/data/base_data.dart';
import 'package:huixiang/retrofit/data/store_info.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/data/user_info.dart';
import 'package:huixiang/retrofit/retrofit_api.dart'; import 'package:huixiang/retrofit/retrofit_api.dart';
import 'package:huixiang/utils/min.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/round_button.dart';
import 'package:huixiang/view_widget/separator.dart'; import 'package:huixiang/view_widget/separator.dart';
import 'package:flutter_swiper_null_safety/flutter_swiper_null_safety.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:shared_preferences/shared_preferences.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart'; import 'package:pull_to_refresh/pull_to_refresh.dart';
@ -300,7 +305,7 @@ class _UnionDetailsPage extends State<UnionDetailsPage> {
flex: 1, flex: 1,
), ),
InkWell( InkWell(
onTap: _startMin, onTap: _loginMin,
child: Container( child: Container(
padding: EdgeInsets.only(top: 16.h, bottom: 16.h), padding: EdgeInsets.only(top: 16.h, bottom: 16.h),
decoration: BoxDecoration( decoration: BoxDecoration(
@ -497,7 +502,14 @@ class _UnionDetailsPage extends State<UnionDetailsPage> {
Text( Text(
S.of(context).youxiaoqizhi( S.of(context).youxiaoqizhi(
(storeInfo != null && (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]}" ? "${storeInfo.couponVOList[position].useStartTime.replaceAll("-", ".").split(" ")[0]}-${storeInfo.couponVOList[position].useEndTime.replaceAll("-", ".").split(" ")[0]}"
: "", : "",
), ),
@ -626,7 +638,8 @@ class _UnionDetailsPage extends State<UnionDetailsPage> {
), ),
child: Text( child: Text(
(storeInfo != null && storeInfo.promotionList != null) (storeInfo != null && storeInfo.promotionList != null)
? storeInfo.promotionList[position].activityStartTime.split(" ")[0] ? storeInfo.promotionList[position].activityStartTime
.split(" ")[0]
: "", : "",
style: TextStyle( style: TextStyle(
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
@ -682,19 +695,46 @@ class _UnionDetailsPage extends State<UnionDetailsPage> {
); );
} }
_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 (storeInfo == null) return;
if (!(await Min.isInitialize())) { if (!(await Min.isInitialize())) {
await Min.initialize(); await Min.initialize();
} }
printMin();
Min.clickListener(); Min.clickListener();
if (!(await Min.isExistsApp("__UNI__ACD00DA"))) { if (!(await Min.isExistsApp("__UNI__ACD00DA"))) {
await Min.reloadWgt("__UNI__ACD00DA", String filePath = "";
"/storage/emulated/0/Android/data/com.zsw.huixiang/files/__UNI__ACD00DA.wgt"); 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(); SharedPreferences sharedPreferences = await SharedPreferences.getInstance();
String token = sharedPreferences.getString("token");
String userId = sharedPreferences.getString("userId");
String nickname = sharedPreferences.getString("nick"); String nickname = sharedPreferences.getString("nick");
String mobile = sharedPreferences.getString("mobile"); String mobile = sharedPreferences.getString("mobile");
String user = sharedPreferences.getString('user'); String user = sharedPreferences.getString('user');
@ -714,4 +754,76 @@ class _UnionDetailsPage extends State<UnionDetailsPage> {
}, },
}); });
} }
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<Color>(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();
}
});
}
}
} }

16
lib/union/union_page.dart

@ -219,7 +219,12 @@ class _UnionPage extends State<UnionPage> with AutomaticKeepAliveClientMixin {
AMapApiKey aMapApiKeys = AMapApiKey( AMapApiKey aMapApiKeys = AMapApiKey(
androidKey: 'f39d1daa020a56f208eb2519f63e9534', androidKey: 'f39d1daa020a56f208eb2519f63e9534',
iosKey: 'feaae7986201b571cace1b83728be5bb'); iosKey: 'feaae7986201b571cace1b83728be5bb');
return Scaffold( return GestureDetector(
onTap: (){
FocusScope.of(context).requestFocus(FocusNode());
},
child: Scaffold(
resizeToAvoidBottomInset: true,
body: NestedScrollView( body: NestedScrollView(
physics: BouncingScrollPhysics(), physics: BouncingScrollPhysics(),
headerSliverBuilder: (context, inner) { headerSliverBuilder: (context, inner) {
@ -235,9 +240,12 @@ class _UnionPage extends State<UnionPage> with AutomaticKeepAliveClientMixin {
markers: markers.toSet(), markers: markers.toSet(),
scrollGesturesEnabled: true, scrollGesturesEnabled: true,
customStyleOptions: _customStyleOptions, customStyleOptions: _customStyleOptions,
onPoiTouched: (poiTouch){
FocusScope.of(context).requestFocus(FocusNode());
},
gestureRecognizers: <Factory<OneSequenceGestureRecognizer>>[ gestureRecognizers: <Factory<OneSequenceGestureRecognizer>>[
Factory<OneSequenceGestureRecognizer>( Factory<OneSequenceGestureRecognizer>(
() => EagerGestureRecognizer()) () => EagerGestureRecognizer()),
].toSet(), ].toSet(),
)), )),
]; ];
@ -254,7 +262,7 @@ class _UnionPage extends State<UnionPage> with AutomaticKeepAliveClientMixin {
}, },
child: ListView.builder( child: ListView.builder(
itemCount: storeList == null ? 0 : storeList.length, itemCount: storeList == null ? 0 : storeList.length,
padding: EdgeInsets.only(top: 8.h, bottom: 8.h), padding: EdgeInsets.only(top: 8.h, bottom: 84.h),
itemBuilder: (context, position) { itemBuilder: (context, position) {
return GestureDetector( return GestureDetector(
onTap: () { onTap: () {
@ -268,6 +276,7 @@ class _UnionPage extends State<UnionPage> with AutomaticKeepAliveClientMixin {
), ),
), ),
), ),
),
); );
} }
@ -294,6 +303,7 @@ class _UnionPage extends State<UnionPage> with AutomaticKeepAliveClientMixin {
} else { } else {
await Permission.location.request(); await Permission.location.request();
startLocation(); startLocation();
getLatLng();
} }
} else { } else {
//enabledLocation //enabledLocation

6
lib/utils/min.dart

@ -16,6 +16,12 @@ class Min {
return isExists; return isExists;
} }
static Future<String> getAppVersionInfo(appid) async {
final String code = await _channel
.invokeMethod('getAppVersionInfo', <String, dynamic>{"appid": appid});
return code;
}
static Future<String> getAppBasePath() async { static Future<String> getAppBasePath() async {
final String getAppBasePath = await _channel.invokeMethod( final String getAppBasePath = await _channel.invokeMethod(
'getAppBasePath', 'getAppBasePath',

2
pubspec.lock

@ -526,7 +526,7 @@ packages:
source: hosted source: hosted
version: "0.2.1" version: "0.2.1"
path_provider: path_provider:
dependency: transitive dependency: "direct main"
description: description:
name: path_provider name: path_provider
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"

1
pubspec.yaml

@ -64,6 +64,7 @@ dependencies:
# flukit: ^1.0.2 # flukit: ^1.0.2
# azlistview: ^1.1.1 # azlistview: ^1.1.1
path_provider: ^1.2.0
cached_network_image: ^2.0.0 cached_network_image: ^2.0.0
flutter_html: ^1.3.0 #2.1.0 flutter_html: ^1.3.0 #2.1.0

Loading…
Cancel
Save