Browse Source

1、Android 拼多多webView重定向问题

2、商品详情优惠券问题
tags/0.0.2+7^2
PH2 4 years ago
parent
commit
c040649866
2 changed files with 21 additions and 4 deletions
  1. +18
    -1
      lib/pages/webview/base_webview.dart
  2. +3
    -3
      lib/widgets/goods_details/coupon/counpon_widget.dart

+ 18
- 1
lib/pages/webview/base_webview.dart View File

@@ -1,5 +1,11 @@
import 'dart:io';

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:zhiying_base_widget/pages/launch_page/launch_page.dart';
import 'package:zhiying_comm/util/log/let_log.dart';
import 'package:zhiying_comm/util/empty_util.dart';
import 'package:url_launcher/url_launcher.dart';
import 'package:webview_flutter/webview_flutter.dart';

class BaseWebview extends StatefulWidget {
@@ -33,7 +39,18 @@ class _BaseWebviewState extends State<BaseWebview> {
onWebViewCreated: (WebViewController webViewController) {
_webViewController = webViewController;
},
navigationDelegate: (NavigationRequest request) {
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) {


+ 3
- 3
lib/widgets/goods_details/coupon/counpon_widget.dart View File

@@ -58,7 +58,7 @@ class _CounponWidgetContainerState extends State<CounponWidgetContainer> {

/// 点击领取
void _onJump(CounponModel model) async{
TurnChainUtil.openReceiveCoupon(context, _user, model.provider, model.toJson());
TurnChainUtil.openReceiveCoupon(context, _user, model.provider, model?.convertArgs?.toJson());
}

@override
@@ -73,7 +73,7 @@ class _CounponWidgetContainerState extends State<CounponWidgetContainer> {
},
builder: (context, state) {
if (state is CounponLoadedState) {
return _getMainWdiget(state.model);
return _getMainWidget(state.model);
}
return CounponSkeleton();
},
@@ -81,7 +81,7 @@ class _CounponWidgetContainerState extends State<CounponWidgetContainer> {
}

/// 主视图
Widget _getMainWdiget(CounponModel model) {
Widget _getMainWidget(CounponModel model) {
return Visibility(
visible: !EmptyUtil.isEmpty(model?.coupon_price),
child: GestureDetector(


Loading…
Cancel
Save