first_page.dart 12.1 KB
import 'dart:io';

import 'package:amap_map_fluttify/amap_map_fluttify.dart';
import 'package:common_utils/common_utils.dart';
import 'package:dio/dio.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bugly/flutter_bugly.dart';
import 'package:flutter_easyrefresh/ball_pulse_footer.dart';
import 'package:flutter_easyrefresh/easy_refresh.dart';
import 'package:flutter_easyrefresh/material_header.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:fluwx/fluwx.dart';
import 'package:one_key/app.dart';
import 'package:one_key/res/colors.dart';
import 'package:one_key/route/navigator_util.dart';
import 'package:one_key/utils/dialog_util.dart';
import 'package:one_key/utils/utils.dart';
import 'package:one_key/widgets/MyDivider.dart';
import 'package:one_key/widgets/round_button.dart';
import 'package:one_key/widgets/v_empty_view.dart';
import 'package:provider/provider.dart';
import 'package:intl/date_symbol_data_local.dart';

import '../../net/dio_util.dart';
import '../../net/http_url.dart';
import '../../utils/screen_util.dart';

class FirstPage extends StatefulWidget {
  FirstPage({Key key}) : super(key: key);

  @override
  _FirstPageState createState() => _FirstPageState();
}

class _FirstPageState extends State<FirstPage> {
  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    // Utils.changeStatusColor(color: MyColours.color_199095);
  }

  _ontherInit() async {
    initDio();
    await _initFluwx();
    LogUtil.init(isDebug: true, tag: 'ONE_KEY');
    Provider.debugCheckInvalidValueType = null;
    await initializeDateFormatting();

    // 设置EasyRefresh的默认样式
    EasyRefresh.defaultHeader = MaterialHeader();
    EasyRefresh.defaultFooter = BallPulseFooter();
    App.sp.setBool("isFirst", false);
    //进入应用
    NavigatorUtil.goLoginPage(context);
    // FlutterBugly.init(androidAppId: "f71a313f42", iOSAppId: "3089e4587e");
  }

  //初始化微信SDK
  _initFluwx() async {
    await registerWxApi(
        // appId: "wx85aa3cdd0f791e65",
        appId: "wx4d105e36a36a6139",
        doOnAndroid: true,
        doOnIOS: true,
        universalLink: "https://xt04.colorcun.com/link/OneKey/");
    var result = await isWeChatInstalled;
    if (result != null && result) {
      App.isInstallWx = true;
    } else {
      App.isInstallWx = false;
    }
    LogUtil.v("is installed $result");
  }

//初始化dio
  initDio() {
    DioUtil.openDebug();
    BaseOptions options = DioUtil.getDefOptions();
    options.baseUrl = HttpUrl.server_address;
    HttpConfig config = new HttpConfig(
        options: options, status: "ret", code: "ret", msg: "msg", data: "data");
    DioUtil().setConfig(config);
    _initAmap();
  }

  _initAmap() async {
    await AmapLocation.instance.updatePrivacyShow(true);
    await AmapLocation.instance.updatePrivacyAgree(true);
    await AmapService.instance.init(
        iosKey: '24fe3a700e69114a4328d4e46823dcda',
        androidKey: '13464ddadd6a5d825e79f90e10ba72d2');

    await AmapLocation.instance.init(
      iosKey: '24fe3a700e69114a4328d4e46823dcda',
    );
  }

  @override
  Widget build(BuildContext context) {
    // ScreenUtil.init(context, width: 750, height: 1334);
    return Scaffold(
      body: Container(
          color: MyColours.color_199095,
          height: double.infinity,
          padding: EdgeInsets.symmetric(
              horizontal: ScreenUtil().setWidth(40),
              vertical: ScreenUtil().setWidth(80)),
          child: Center(
              child: Container(
            height: ScreenUtil().setWidth(690),
            decoration: BoxDecoration(
              color: MyColours.color_ffffff,
              borderRadius: BorderRadius.circular(ScreenUtil().setWidth(20)),
            ),
            child: Column(
              children: [
                VEmptyView(40),
                Text(
                  '温馨提示',
                  style: TextStyle(
                      color: MyColours.color_333333,
                      fontWeight: FontWeight.bold,
                      fontSize: ScreenUtil().setSp(34)),
                ),
                VEmptyView(40),
                MyDivider(double.infinity, ScreenUtil().setWidth(1)),
                Expanded(
                    child: SingleChildScrollView(
                  child: Column(children: [
                    VEmptyView(50),
                    Padding(
                      padding: EdgeInsets.symmetric(
                          horizontal: ScreenUtil().setWidth(30)),
                      child: Column(
                        crossAxisAlignment: CrossAxisAlignment.start,
                        children: [
                          Text(
                            '亲爱的用户,感谢您信任并使用周到安排商家!',
                            style: TextStyle(
                              color: MyColours.color_333333,
                              fontSize: ScreenUtil().setSp(28),
                            ),
                            strutStyle: StrutStyle(
                                // forceStrutHeight: true,
                                // height: 1,
                                leading: 0.3),
                          ),
                          VEmptyView(16),
                          Wrap(
                            runSpacing: w(1),
                            children: [
                              Text(
                                '我们制定了',
                                style: TextStyle(
                                  color: MyColours.color_333333,
                                  fontSize: ScreenUtil().setSp(28),
                                ),
                                strutStyle: StrutStyle(
                                    // forceStrutHeight: true,
                                    // height: 1,
                                    leading: 0.3),
                              ),
                              InkWell(
                                onTap: () {
                                  NavigatorUtil.goWebPage(
                                      context, '《隐私政策》', "zc",
                                      need: true);
                                },
                                child: Text(
                                  '《隐私政策》',
                                  style: TextStyle(
                                    color: MyColours.color_2bb5b7,
                                    fontSize: ScreenUtil().setSp(28),
                                  ),
                                  strutStyle: StrutStyle(
                                      // forceStrutHeight: true,
                                      // height: 1,
                                      leading: 0.3),
                                ),
                              ),
                              Text(
                                '和',
                                style: TextStyle(
                                  color: MyColours.color_333333,
                                  fontSize: ScreenUtil().setSp(28),
                                ),
                                strutStyle: StrutStyle(
                                    // forceStrutHeight: true,
                                    // height: 1,
                                    leading: 0.3),
                              ),
                              InkWell(
                                onTap: () {
                                  NavigatorUtil.goWebPage(
                                      context, '软件服务协议', "xy",
                                      need: true);
                                },
                                child: Text(
                                  '《软件服务协议》',
                                  style: TextStyle(
                                    color: MyColours.color_2bb5b7,
                                    fontSize: ScreenUtil().setSp(28),
                                  ),
                                  strutStyle: StrutStyle(
                                      // forceStrutHeight: true,
                                      // height: 1,
                                      leading: 0.3),
                                ),
                              ),
                              Text(
                                '请您点击同意之前仔细阅读并充分理解相关条款,其中的重点条款已为您标注,方便您了解自己的权利。',
                                style: TextStyle(
                                  color: MyColours.color_333333,
                                  fontSize: ScreenUtil().setSp(28),
                                ),
                                strutStyle: StrutStyle(
                                    // forceStrutHeight: true,
                                    // height: 1,
                                    leading: 0.3),
                              ),
                            ],
                          ),
                          VEmptyView(16),
                          Text(
                            '我们将通过《隐私政策》向您说明:\n我们在您使用我们的产品与/或服务时如何收集、使用、保存、共享和转让这些信息,以及我们为您提供的访问、更新、控制和保护这些信息的方式。',
                            style: TextStyle(
                              color: MyColours.color_333333,
                              fontWeight: FontWeight.bold,
                              fontSize: ScreenUtil().setSp(28),
                            ),
                            strutStyle: StrutStyle(
                                // forceStrutHeight: true,
                                // height: 1,
                                leading: 0.3),
                          ),
                        ],
                      ),
                    )
                  ]),
                )),
                VEmptyView(40),
                Row(
                  mainAxisAlignment: MainAxisAlignment.spaceEvenly,
                  children: [
                    RoundButton(
                        width: ScreenUtil().setWidth(100 * 2),
                        height: ScreenUtil().setWidth(70),
                        radius: ScreenUtil().setWidth(10),
                        text: '拒绝',
                        fontSize: 28,
                        isBold: false,
                        textColor: MyColours.color_199095,
                        gradientStart: MyColours.color_efefef,
                        gradientEnd: MyColours.color_efefef,
                        onPressed: () {
                          //修改之前有内容,则弹框
                          DialogUtil.cupertinoAlertDialog(context,
                              title: "",
                              content: "您需要同意《周到安排商家隐私政策》,才能继续使用我们的服务哦。",
                              lTitle: "暂不",
                              rTitle: "去同意", lCallback: () {
                            print("取消");
                            //退出应用
                            exit(0);
                          }, rCallback: () {
                            print("确定");
                          });
                        }),
                    RoundButton(
                        width: ScreenUtil().setWidth(100 * 2),
                        height: ScreenUtil().setWidth(70),
                        radius: ScreenUtil().setWidth(10),
                        text: '同意',
                        fontSize: 28,
                        isBold: false,
                        textColor: MyColours.color_ffffff,
                        gradientStart: MyColours.color_199095,
                        gradientEnd: MyColours.color_199095,
                        onPressed: () {
                          _ontherInit();
                          // App.sp.setBool("isFirst", false);
                          // //进入应用
                          // NavigatorUtil.goLoginPage(context);
                        }),
                  ],
                ),
                VEmptyView(40),
              ],
            ),
          ))),
    );
  }
}