1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- import 'dart:convert';
- import 'package:flutter/cupertino.dart';
- import 'package:flutter/material.dart';
- import 'package:url_launcher/url_launcher.dart';
- import 'package:webview_flutter/webview_flutter.dart';
- import 'package:ysairplane2/base/YSBase.dart';
- import 'package:ysairplane2/tools/YSNetWorking.dart';
- class YSWebLoad extends StatefulWidget {
- final type;
- const YSWebLoad({Key key, this.type}) : super(key: key);
- @override
- _YSWebLoadState createState() => _YSWebLoadState();
- }
- class _YSWebLoadState extends State<YSWebLoad> {
- WebViewController _controller;
- @override
- Widget build(BuildContext context) {
- return YSBase(
- ystitle: widget.type==null?'产品简介':widget.type==1?'软件许可及服务协议':widget.type==3?'用户协议':'隐私保护协议',
- yschild: Container(
- color: Colors.white,
- width: MediaQuery.of(context).size.width,
- height: MediaQuery.of(context).size.height-MediaQuery.of(context).padding.top-44,
- child: widget.type==1||widget.type==2?WebView(
- javascriptMode: JavascriptMode.unrestricted,
- onWebViewCreated: (WebViewController webViewController) {
- _controller = webViewController;
- _getHtmlData();
- },
- ):WebView(
- initialUrl: widget.type==3?'https://api.s-fly.cn/txt/用户协议.html':'http://www.s-fly.cn',
- javascriptMode: JavascriptMode.unrestricted,
- navigationDelegate: (NavigationRequest request) {
- if(request.url.contains("mailto:")||request.url.contains("tel:")){
- launch(request.url);
- return NavigationDecision.prevent;
- }else if(request.url.contains("qq")){
- print('================${request.url}');
- return NavigationDecision.prevent;
- }
- return NavigationDecision.navigate;
- },
- ),
- ),
- );
- }
- _getHtmlData() async{
- Map dict = await ysRequestHttp(context,type: requestType.get,api: '/app/applets/dic/dtDic/${widget.type==1?'getServiceAgreement':'getPrivacyAgreement'}',parameter: {},isLoading: false,isToken: true);
- if(dict!=null){
- _controller.loadUrl(Uri.dataFromString('${dict['data']['value']}', mimeType: 'text/html', encoding: Encoding.getByName('utf-8')).toString());
- }
- }
- }
|