diff --git a/example/android/app/build.gradle b/example/android/app/build.gradle index df43368..796ba3c 100644 --- a/example/android/app/build.gradle +++ b/example/android/app/build.gradle @@ -108,33 +108,33 @@ android { // 应用信息配置 -// productFlavors { -// // 智夜生活 -// zhiying { -// applicationId "cn.zhios.zhiying" -// versionCode 31 -// dimension "app" -// versionName '1.2.31' -// // 签名信息 -// signingConfig signingConfigs.zhiying -// } -// } -// -// // 打包脚本 -// android.applicationVariants.all { variant -> -// if (variant.buildType.name != "debug") { -// variant.getPackageApplicationProvider().get().outputDirectory = new File(project.rootDir.absolutePath + "/app/build/outputs/apk") -// } -// -// variant.outputs.all { output -> -// def outputFile = output.outputFile -// if (outputFile != null && outputFile.name.endsWith('.apk')) { -// //这里修改apk文件名 -// def fileName = "${variant.productFlavors[0].name}_${releaseTime()}01_&V${variant.productFlavors[0].versionCode}.apk" -// outputFileName = fileName -// } -// } -// } + productFlavors { + // 智夜生活 + zhiying { + applicationId "cn.zhios.zhiying" + versionCode 32 + dimension "app" + versionName '1.2.32' + // 签名信息 + signingConfig signingConfigs.zhiying + } + } + + // 打包脚本 + android.applicationVariants.all { variant -> + if (variant.buildType.name != "debug") { + variant.getPackageApplicationProvider().get().outputDirectory = new File(project.rootDir.absolutePath + "/app/build/outputs/apk") + } + + variant.outputs.all { output -> + def outputFile = output.outputFile + if (outputFile != null && outputFile.name.endsWith('.apk')) { + //这里修改apk文件名 + def fileName = "${variant.productFlavors[0].name}_${releaseTime()}01_&V${variant.productFlavors[0].versionCode}.apk" + outputFileName = fileName + } + } + } configurations.all { resolutionStrategy.eachDependency { DependencyResolveDetails details -> @@ -215,6 +215,7 @@ MobSDK { Wechat { appId "wx598aaef252cd78e4" appSecret "d2fc2edf9ece746765b3bfc0bf1b230e" + shareByAppClient true withShareTicket true bypassApproval false enable true diff --git a/lib/pages/goods_details_page/goods_details_page.dart b/lib/pages/goods_details_page/goods_details_page.dart index d0814e9..24d09c1 100644 --- a/lib/pages/goods_details_page/goods_details_page.dart +++ b/lib/pages/goods_details_page/goods_details_page.dart @@ -19,8 +19,9 @@ import 'notifier/goods_details_appbar_color_notifier.dart'; class GoodsDetailsPage extends StatefulWidget { final Map data; + final bool isFree; - GoodsDetailsPage(this.data, {Key key}) : super(key: key); + GoodsDetailsPage(this.data, {this.isFree = false, Key key}) : super(key: key); @override _GoodsDetailsPageState createState() => _GoodsDetailsPageState(); @@ -43,9 +44,11 @@ class _GoodsDetailsPageState extends State { ChangeNotifierProvider.value(value: GoodsDetailsAppBarColorNotifier()), ], child: BlocProvider( - create: (_) => GoodsDetailsPageBloc(repository: GoodsDetailsPageRepository()) - ..add(GoodsDetailsPageInitEvent(model: widget?.data)), - child: GoodsDetailsContainer(widget?.data), + create: (_) => GoodsDetailsPageBloc(repository: GoodsDetailsPageRepository())..add(GoodsDetailsPageInitEvent(model: widget?.data)), + child: GoodsDetailsContainer( + widget?.data, + isFree: widget?.isFree, + ), ), ); } @@ -53,8 +56,9 @@ class _GoodsDetailsPageState extends State { class GoodsDetailsContainer extends StatefulWidget { final Map data; + final bool isFree; - const GoodsDetailsContainer(this.data); + const GoodsDetailsContainer(this.data, {this.isFree = false}); @override _GoodsDetailsContainerState createState() => _GoodsDetailsContainerState(); @@ -160,7 +164,10 @@ class _GoodsDetailsContainerState extends State { )), /// 底部 - bottomNavigationBar: GoodsDetailsFooterWidget(!EmptyUtil.isEmpty(datas) ? datas[datas.length - 1] : null), + bottomNavigationBar: GoodsDetailsFooterWidget( + !EmptyUtil.isEmpty(datas) ? datas[datas.length - 1] : null, + isFree: widget.isFree, + ), ); } diff --git a/lib/pages/webview/base_webview.dart b/lib/pages/webview/base_webview.dart index d4343de..92ba57d 100644 --- a/lib/pages/webview/base_webview.dart +++ b/lib/pages/webview/base_webview.dart @@ -1,3 +1,4 @@ +import 'dart:async'; import 'dart:io'; import 'package:flutter/cupertino.dart'; @@ -24,6 +25,8 @@ class _BaseWebviewState extends State { String _title; WebViewController _webViewController; bool _isiOSReview = false; + double progress = 0.0; + Timer timer; @override void initState() { @@ -31,6 +34,37 @@ class _BaseWebviewState extends State { _settingIosReview(); super.initState(); } + + @override + void dispose() { + // TODO: implement dispose + timer?.cancel(); + super.dispose(); + } + + loadData() { + print("加载数据"); + progress = 0.0; + if(timer?.isActive??false){ + timer?.cancel(); + } + timer = Timer.periodic(Duration(milliseconds: 10), (timer) { + if (progress > 0.8) { + progress = progress + 0.01; + } else if (progress > 0.7) { + progress = progress + 0.002; + } else if (progress > 0.5) { + progress += 0.005; + } else { + progress = progress + 0.01; + } + if (progress > 1.1) { + timer.cancel(); + } + setState(() {}); + }); + } + void _settingIosReview() async { String is_ios_review = await SharedPreferencesUtil.getStringValue(GlobalConfig.IS_IOS_REVIEW, defaultVal: '0'); setState(() { @@ -40,42 +74,53 @@ class _BaseWebviewState extends State { } }); } + @override Widget build(BuildContext context) { return Scaffold( appBar: _createNav(), backgroundColor: Colors.white, - body: WebView( - initialUrl: _url, - javascriptMode: JavascriptMode.unrestricted, - onWebViewCreated: (WebViewController webViewController) { - _webViewController = webViewController; - }, - navigationDelegate: (NavigationRequest request) async{ - // 解决Android的拼多多webview 转发的问题 - if(Platform.isAndroid){ - String url = request?.url?.toString(); - if(!EmptyUtil.isEmpty(url) && !url.startsWith('https://') && !url.startsWith('http://')){ - Logger.log('navigation url = $url'); - // if(await canLaunch(url)){ - // await launch(url); - // } - return NavigationDecision.prevent; - } - } - return NavigationDecision.navigate; - }, - onPageStarted: (String url) { - print('Page started loading: $url'); - }, - onPageFinished: (String url) { - print('Page finished loading: $url'); - _webViewController.getTitle().then((title) { - _title = title; - setState(() {}); - }); - }, - gestureNavigationEnabled: true, + body: Stack( + children: [ + WebView( + initialUrl: _url, + javascriptMode: JavascriptMode.unrestricted, + onWebViewCreated: (WebViewController webViewController) { + _webViewController = webViewController; + loadData(); + }, + navigationDelegate: (NavigationRequest request) async { + // 解决Android的拼多多webview 转发的问题 + if (Platform.isAndroid) { + String url = request?.url?.toString(); + if (!EmptyUtil.isEmpty(url) && !url.startsWith('https://') && !url.startsWith('http://')) { + Logger.log('navigation url = $url'); + // if(await canLaunch(url)){ + // await launch(url); + // } + return NavigationDecision.prevent; + } + } + return NavigationDecision.navigate; + }, + onPageStarted: (String url) { + print('Page started loading: $url'); + }, + onPageFinished: (String url) { + if(progress<0.8){ + progress = 0.8; + } + setState(() {}); + print('Page finished loading: $url'); + _webViewController.getTitle().then((title) { + _title = title; + setState(() {}); + }); + }, + gestureNavigationEnabled: true, + ), + progress <= 1.0 ? _createProgress() : Container(), + ], ), ); } @@ -115,11 +160,28 @@ class _BaseWebviewState extends State { ), ), trailing: GestureDetector( - child: _isiOSReview ? Container() : Icon(Icons.refresh, size: 20,), + child: _isiOSReview + ? Container() + : Icon( + Icons.refresh, + size: 20, + ), onTap: () { _webViewController.reload(); + loadData(); }, ), ); } + + _createProgress() { + return Container( + constraints: BoxConstraints(maxHeight: 2), + child: LinearProgressIndicator( + backgroundColor: Colors.white, + valueColor: AlwaysStoppedAnimation(Colors.red), + value: progress, + ), + ); + } } diff --git a/lib/widgets/goods_details/footer/goods_details_footer_widget.dart b/lib/widgets/goods_details/footer/goods_details_footer_widget.dart index 02a51be..133f4e5 100644 --- a/lib/widgets/goods_details/footer/goods_details_footer_widget.dart +++ b/lib/widgets/goods_details/footer/goods_details_footer_widget.dart @@ -20,8 +20,8 @@ import 'package:zhiying_comm/util/turn_chain/turn_chain_util.dart'; /// class GoodsDetailsFooterWidget extends StatelessWidget { final Map model; - - const GoodsDetailsFooterWidget(this.model); + final bool isFree; + const GoodsDetailsFooterWidget(this.model,{this.isFree}); @override Widget build(BuildContext context) { @@ -42,8 +42,8 @@ class GoodsDetailsFooterWidget extends StatelessWidget { class _GoodsDetailsFooterContainer extends StatefulWidget { final Map model; - - const _GoodsDetailsFooterContainer(this.model, {Key key}) : super(key: key); + final bool isFree; + const _GoodsDetailsFooterContainer(this.model, {this.isFree,Key key}) : super(key: key); @override _GoodsDetailsFooterContainerState createState() => _GoodsDetailsFooterContainerState(); @@ -104,7 +104,7 @@ class _GoodsDetailsFooterContainerState extends State<_GoodsDetailsFooterContain /// 自购省 void _saveMoneyOnClick(GoodsDetailsFooterModel model) async { - await TurnChainUtil.openReceiveCoupon(context, _user, model?.good_id, model?.provider, model?.convertArgs?.toJson()); + await TurnChainUtil.openReceiveCoupon(context, _user, model?.good_id, model?.provider, model?.convertArgs?.toJson(),isFree: widget?.isFree); } @override