public void floatWindowButtonClicked() { // 授权页面配置 OLAuthViewModel viewModel = new OLAuthViewModel(); viewModel.backgroundColor = "#FFFFFF"; viewModel.defaultCheckBoxState = true; viewModel.switchButtonHidden = true; // popup viewModel.isPopup = true; // 设置弹窗的大小位置 double screenWidth = UnityEngine.Screen.width / 3; double screenHeight = UnityEngine.Screen.height / 3; viewModel.popupRect = (screenHeight - 340).ToString() + ",0,0,0,0,0," + screenWidth.ToString() + ",340"; viewModel.popupCornerRadius = 10; viewModel.popupRectCorners = new int[2]; viewModel.popupRectCorners[0] = 1; viewModel.popupRectCorners[1] = 2; viewModel.popupAnimationStyle = 0; viewModel.closePopupTopOffset = 8; viewModel.closePopupRightOffset = -10; viewModel.canClosePopupFromTapGesture = true; // 进入授权页面 enterAuthController(serializeModelToJsonString(viewModel), null); }
public string serializeModelToJsonString(OLAuthViewModel viewModel) { if (null == viewModel) { return(""); } string jsonStr = JsonUtility.ToJson(viewModel); Console.WriteLine("============ serializeDictionaryToJsonString: {0} ============ ", jsonStr); return(jsonStr); }
public void popupButtonClicked() { // 授权页面配置 OLAuthViewModel viewModel = new OLAuthViewModel(); viewModel.backgroundColor = "#FFFFFF"; viewModel.defaultCheckBoxState = true; viewModel.switchButtonHidden = true; // popup viewModel.isPopup = true; viewModel.popupRect = ""; viewModel.popupCornerRadius = 5; viewModel.popupAnimationStyle = 0; viewModel.closePopupTopOffset = 5; viewModel.closePopupRightOffset = -10; viewModel.canClosePopupFromTapGesture = true; // 进入授权页面 enterAuthController(serializeModelToJsonString(viewModel), null); }
public void enterAuthControllerClicked() { print("Enter auth controller button is clicked!"); // 授权页面配置 OLAuthViewModel viewModel = new OLAuthViewModel(); // statusBar viewModel.statusBarStyle = 0; viewModel.languageType = 2; // navigation bar viewModel.naviTitle = "一键登录Unity"; viewModel.naviTitleColor = "#FF4900"; viewModel.naviTitleFont = 17.0; viewModel.naviBgColor = "#00FF00"; viewModel.naviBackImage = "close_black"; viewModel.naviHidden = false; viewModel.backButtonRect = "10, 0, 20, 0, 0, 0, 20, 20"; viewModel.backButtonHidden = false; // logo viewModel.appLogo = "logo_icon"; viewModel.logoRect = ""; viewModel.logoHidden = false; viewModel.logoCornerRadius = 5; // phone viewModel.phoneNumColor = "#FF00FF"; viewModel.phoneNumFont = 24; viewModel.phoneNumRect = ""; // switch button viewModel.switchButtonText = "换个方式登录"; viewModel.switchButtonColor = "#6500FF"; viewModel.switchButtonBackgroundColor = "#FFFFFF"; viewModel.switchButtonFont = 15; viewModel.switchButtonRect = ""; viewModel.switchButtonHidden = false; // auth button // viewModel.authButtonImages = {"button_bg", "button_bg", "button_bg"}; viewModel.authButtonImages = new string[3]; viewModel.authButtonImages[0] = "authbutton_bg"; viewModel.authButtonImages[1] = "authbutton_bg"; viewModel.authButtonImages[2] = "authbutton_bg"; viewModel.authButtonTitle = "授权登录"; viewModel.authButtonTitleColor = "#FFFFFF"; viewModel.authButtonTitleFont = 17; viewModel.authButtonRect = ""; viewModel.authButtonCornerRadius = 5; // slogan viewModel.sloganRect = ""; viewModel.sloganTextColor = "#FFFF00"; viewModel.sloganTextFont = 13; viewModel.sloganText = "极验提供一键登录服务"; // privacy terms viewModel.defaultCheckBoxState = false; viewModel.checkedImage = ""; viewModel.uncheckedImage = ""; viewModel.checkBoxRect = ""; viewModel.privacyTermsColor = "#00FF00"; viewModel.privacyTermsFont = 14; // additionalPrivacyTerms 为自定义的服务条款,每条服务条款对应三个元素:条款名称、条款链接、条款索引,所以 additionalPrivacyTerms 的元素个数 = 服务条款数 * 3 viewModel.additionalPrivacyTerms = new string[6]; // 服务条款1 viewModel.additionalPrivacyTerms[0] = "自定义服务条款1"; viewModel.additionalPrivacyTerms[1] = "https://docs.geetest.com/onelogin/deploy/ios"; viewModel.additionalPrivacyTerms[2] = "0"; // 服务条款2 viewModel.additionalPrivacyTerms[3] = "自定义服务条款2"; viewModel.additionalPrivacyTerms[4] = "https://docs.geetest.com/onelogin/changelog/ios"; viewModel.additionalPrivacyTerms[5] = "1"; viewModel.termTextColor = "#0000FF"; viewModel.termsRect = ""; viewModel.auxiliaryPrivacyWords = new string[4]; viewModel.auxiliaryPrivacyWords[0] = "登录表示同意"; viewModel.auxiliaryPrivacyWords[1] = "与"; viewModel.auxiliaryPrivacyWords[2] = "&"; viewModel.auxiliaryPrivacyWords[3] = "并使用本机号码登录"; viewModel.termsAlignment = 1; viewModel.protocolShakeStyle = 1; viewModel.privacyCheckBoxMarginRight = 10; // background viewModel.backgroundColor = "#FFFFFF"; viewModel.backgroundImage = "background"; viewModel.landscapeBackgroundImage = ""; // 服务条款页面导航栏 viewModel.webNaviTitle = "一键登录Unity服务条款"; viewModel.webNaviTitleColor = "#1F90FF"; viewModel.webNaviTitleFont = 20; viewModel.webNaviBgColor = "#0F0F00"; // 未勾选服务条款勾选框时,点击授权按钮的提示 viewModel.notCheckProtocolHint = "请先阅读服务条款"; // modal style viewModel.modalPresentationStyle = 0; // pull auth viewcontroller style viewModel.pullAuthVCStyle = 0; // user interface style viewModel.userInterfaceStyle = 0; // authVCTransitionBlock viewModel.authVCTransitionBlock = "authVCTransitionBlock"; // tapAuthBackgroundBlock viewModel.tapAuthBackgroundBlock = "tapAuthBackground"; // viewLifeCycleBlock viewModel.viewLifeCycleBlock = "viewLifeCycle"; // clickBackButtonBlock viewModel.clickBackButtonBlock = "clickBackButton"; // clickSwitchButtonBlock viewModel.clickSwitchButtonBlock = "clickSwitchButton"; // clickCheckboxBlock viewModel.clickCheckboxBlock = "clickCheckbox"; // hintBlock viewModel.hintBlock = "hintCustom"; // widgets double screenWidth = UnityEngine.Screen.width / 3; double screenHeight = UnityEngine.Screen.height / 3; Console.WriteLine("============ screenWidth: {0}, screenHeight: {1} ============", screenWidth, screenHeight); // viewModel.widgets = new string[3]; // string widget0 = "{\"type\":\"UIButton\", \"image\":\"qq_icon\", \"action\":\"qqLoginAction\", \"frame\":\"" + (screenWidth/2 - 45 - 10).ToString() + "," + (screenHeight - 200).ToString() + ",45,45\"}"; // Console.WriteLine("============ widget0: {0} ============ ", widget0); // viewModel.widgets[0] = widget0; // string widget1 = "{\"type\":\"UIButton\", \"image\":\"weixin_icon\", \"action\":\"weixinLoginAction\", \"frame\":\"" + (screenWidth/2 + 10).ToString() + "," + (screenHeight - 200).ToString() + ",45,45\"}"; // Console.WriteLine("============ widget1: {0} ============ ", widget1); // viewModel.widgets[1] = widget1; // string widget2 = "{\"type\":\"UILabel\", \"textColor\":\"#D98866\", \"font\":15, \"textAlignment\":1, \"text\":\"三方登录\", \"frame\":\"" + ((screenWidth - 120)/2).ToString() + "," + (screenHeight - 250).ToString() + ",120,20\"}"; // viewModel.widgets[2] = widget2; // 添加自定义控件 OLWidget[] widgets = new OLWidget[3]; // 自定义 UIButton OLWidget widget0 = new OLWidget(); widget0.type = "UIButton"; widget0.image = "qq_icon"; widget0.action = "qqLoginAction"; widget0.frame = new double[4]; widget0.frame[0] = screenWidth / 2 - 45 - 10; widget0.frame[1] = screenHeight - 200; widget0.frame[2] = 45; widget0.frame[3] = 45; widgets[0] = widget0; // 自定义 UIButton OLWidget widget1 = new OLWidget(); widget1.type = "UIButton"; widget1.image = "weixin_icon"; widget1.action = "weixinLoginAction"; widget1.frame = new double[4]; widget1.frame[0] = screenWidth / 2 + 10; widget1.frame[1] = screenHeight - 200; widget1.frame[2] = 45; widget1.frame[3] = 45; widgets[1] = widget1; // 自定义 UILabel OLWidget widget2 = new OLWidget(); widget2.type = "UILabel"; widget2.textColor = "#D98866"; widget2.text = "三方登录"; widget2.font = 15; widget2.textAlignment = 1; widget2.frame = new double[4]; widget2.frame[0] = (screenWidth - 120) / 2; widget2.frame[1] = screenHeight - 250; widget2.frame[2] = 120; widget2.frame[3] = 20; widgets[2] = widget2; int len = widgets.Length; string[] widgetsString = new string[len]; for (int i = 0; i < len; i++) { OLWidget widget = widgets[i]; string widgetString = JsonUtility.ToJson(widget); Console.WriteLine("============ widgetString: {0} ============", widgetString); if (null != widgetString) { widgetsString[i] = widgetString; } } // 进入授权页面 enterAuthController(serializeModelToJsonString(viewModel), widgetsString); }