ali_auth flutter 一键登录

 AliAuthModel aliAuthModel = AliAuthModel(
appid,
      isDelay: false,
      isDebug: true,
      pageType: PageType.fullPort,
      privacyOffsetX: -1,
      statusBarColor: '#FF91DBFF',
      bottomNavColor: "#FFFFFF",
      isLightColor: true,
      isStatusBarHidden: false,
      statusBarUIFlag: UIFAG.systemUiFalgFullscreen,
      navColor: '#00FFFFFF',
      navText: "",
      navHidden: true,
      navTextColor: "#ffffff",
      navReturnImgPath: "assets/images/icon_lablel_back_normal_24.png",
      navReturnImgWidth: 24,
      navReturnImgHeight: 24,
      navReturnHidden: false,
      navReturnScaleType: ScaleType.fitCenter,
      logoImgPath: "assets/images/logo.png",
      logoHidden: true,
      numberColor: "#FF333333",
      numberSize: 24,
      switchAccHidden: false,
      switchAccTextColor: "#3BBEFF",
      logBtnText: "一键登录/注册",
      logBtnTextSize: 17,
      logBtnTextColor: "#FFFFFF",
      protocolOneName: "《用户协议》",
      protocolOneURL: "${staticUrl}/#/agreement/6",
      protocolTwoName: "《隐私政策》",
      protocolTwoURL: "${staticUrl}/#/agreement/7",
      protocolCustomColor: "#FF3BBEFF",
      protocolThreeName: "",
      protocolThreeURL: "",
      protocolColor: "#FF999999",
      protocolLayoutGravity: Gravity.centerHorizntal,
      sloganText: '同一个世界,同一个频率\n        遇见同频的你',
      sloganTextColor: '#FF333333',
      sloganTextSize: 18,
      sloganHidden: true,
      isHiddenLoading: true,
      logBtnBackgroundPath:
          "assets/images/button.png,assets/images/button.png,assets/images/button.png",
      //loadingImgPath: "assets/images/logo@3x.png",
      logoOffsetY: 100,
      logoOffsetY_B: -1,
      logoScaleType: ScaleType.fitXy,
      numFieldOffsetY_B: 310,
      numberFieldOffsetX: -1,
      numberLayoutGravity: Gravity.centerHorizntal,
      switchOffsetY: -1,
      switchOffsetY_B: 190,
      logBtnOffsetY_B: 230,
      logBtnHeight: 66,
      dialogWidth: -1,
      logBtnOffsetX: -1,
      logBtnMarginLeftAndRight: 30,
      logBtnLayoutGravity: Gravity.centerHorizntal,
      privacyOffsetY: -1,
      privacyOffsetY_B: 28,
      checkBoxWidth: 18,
      checkBoxHeight: 18,
      checkboxHidden: false,
      navTextSize: 18,
      logoWidth: 120,
      logoHeight: 120,
      switchAccTextSize: 16,
      switchAccText: "切换到其他方式",
      uncheckedImgPath: "assets/images/check_off.png",
      checkedImgPath: "assets/images/check_on.png",
      privacyState: false,
      protocolGravity: Gravity.centerHorizntal,
      privacyTextSize: 12,
      privacyMargin: 28,
      privacyBefore: "我已阅读并同意",
      privacyEnd: "",
      vendorPrivacyPrefix: "《",
      vendorPrivacySuffix: "》",
      dialogHeight: -1,
      dialogBottom: false,
      dialogOffsetX: -1,
      dialogOffsetY: -1,
      pageBackgroundPath: "assets/images/beijing.png",
      webViewStatusBarColor: "#FFFFFFFF",
      webNavColor: "#FFFFFFFF",
      webNavTextColor: "#FF333333",
      webNavTextSize: 20,
      webNavReturnImgPath: "assets/images/icon_lablel_back_normal_24.png",
      webSupportedJavascript: true,
      authPageActIn: "in_activity",
      activityOut: "out_activity",
      authPageActOut: "in_activity",
      activityIn: "out_activity",
      screenOrientation: -1,
      // logBtnToastHidden: false,
      dialogAlpha: 1.0,
      privacyOperatorIndex: 0,
      backgroundPath: "assets/images/beijing.png",
      sloganOffsetY: 240,
      logBtnToastHidden: true);
  initAli()  {
    AliAuth.loginListen(onEvent: (onEvent) async {
      print("----------------> $onEvent <----------------");
      if (onEvent.runtimeType.toString() ==
          '_InternalLinkedHashMap<Object?, Object?>') {
        var code = onEvent['code'];
        status = onEvent.toString();
        switch (code) {
          case '600001':
          case '600024':
            showBack = true;
            update();
            break;
          case '600016':
          case '700000':
          case '600005':
          case '700001':
          case '600011':
          case '600007':
          case '600008':
          case '600009':
          showBack = false;
          update();
            break;
          case '700002':
            if (onEvent['data']['isChecked'] == true) {
              agreement = true;
              bCanPress = false;
              press++;
              if(!showBack){
                ToastUtil.error('请打开数据流量并检查网络状态');
              }
              AliAuth.quitPage();
            } else if (onEvent['data']['isChecked'] == false) {
              if (bCanPress) {
                press == 0
                    ? Fluttertoast.showToast(
                        msg: "请同意服务条款",
                        toastLength: Toast.LENGTH_SHORT,
                        gravity: ToastGravity.BOTTOM,
                        timeInSecForIosWeb: 1,
                        backgroundColor: Colours.toast_error1,
                        textColor: Colors.white,
                        fontSize: 28.f)
                    : null;
                bCanPress = false;
                press++;
                Future.delayed(Duration(milliseconds: 2000), () {
                  bCanPress = true;
                  press = 0;
                });
              }
            }

            break;
          case '600015':
            showBack = false;
            update();
            break;
          case '600000':
            tocken = onEvent['data'].toString();
            if (ObjectUtil.isNotEmpty(tocken)) {
              print(first.toString() + '//');
              if (first) {
                getLogin(tocken);
              }
            }
            break;
          case '700003':
            agreement = onEvent['data']['isChecked'];
            update();
            break;
          default:
            break;
        }
      }
    });
     initSdk();
  }

initSdk() {
AliAuth.initSdk(aliAuthModel);
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值