From d0df50a4afc3da90fc160a60a0813e0791977111 Mon Sep 17 00:00:00 2001 From: merelendor Date: Thu, 16 Dec 2021 11:17:34 +0100 Subject: [PATCH] changes for CRM API definition, CSS updates for tasks 07.12-16.12.21 --- api/index.php | 65 +- images/icons/icon-file.svg | 5 + .../about.contacts.list/component.php | 6 +- .../templates/.default/script.js | 86 +- .../templates/.default/template.php | 16 +- .../catalog/templates/.default/template.php | 4 +- .../slider.main/templates/.default/script.js | 2 +- .../bitrix/main.share/evolution/script.js | 4 + .../bitrix/main.share/evolution/style.css | 2 + .../bitrix/menu/evolution/template.php | 4 +- .../catalog/template.php | 4 +- .../evolution/css/components/style.css | 2 +- .../evolution/css/components/style.css.map | 2 +- .../evolution/css/components/style.less | 40 +- .../templates/evolution/css/footer/style.css | 2 +- .../evolution/css/footer/style.css.map | 2 +- .../templates/evolution/css/footer/style.less | 22 +- local/templates/evolution/css/forms/style.css | 2 +- .../evolution/css/forms/style.css.map | 2 +- .../templates/evolution/css/forms/style.less | 9 +- .../templates/evolution/css/header/style.css | 2 +- .../evolution/css/header/style.css.map | 2 +- .../templates/evolution/css/header/style.less | 21 +- local/templates/evolution/css/main/style.css | 2 +- .../evolution/css/main/style.css.map | 2 +- local/templates/evolution/css/main/style.less | 174 ++- local/templates/evolution/css/reset.css | 2 + local/templates/evolution/css/var.css | 1051 +---------------- local/templates/evolution/css/var.css.map | 2 +- local/templates/evolution/css/var.less | 47 +- local/templates/evolution/js/main.js | 6 +- 31 files changed, 451 insertions(+), 1141 deletions(-) create mode 100644 images/icons/icon-file.svg diff --git a/api/index.php b/api/index.php index 5691eb7..24cc10f 100644 --- a/api/index.php +++ b/api/index.php @@ -3,10 +3,9 @@ require_once($_SERVER['DOCUMENT_ROOT'] . "/bitrix/modules/main/include/prolog_before.php"); header('Content-Type: application/json; charset=utf-8'); +use \Bitrix\Main\Service\GeoIp; $httpClient = new \Bitrix\Main\Web\HttpClient(); -const API_HOST = "https://web-api.evoleasing.ru:8443"; - $PARAM_1 = $_REQUEST["PARAM_1"]; $PARAM_2 = $_REQUEST["PARAM_2"]; $PARAM_3 = $_REQUEST["PARAM_3"]; @@ -222,6 +221,59 @@ switch($PARAM_1) } break; + case "update": + { + if($auth['username'] !== 'crm') { header('HTTP/1.0 401 Unauthorized'); print json_encode(["status" => "error", "error" => "unauthorized", "message" => "Unauthorized"]); die(); } + + $existedUserRes = \CUser::GetByLogin($REQ["email"]); + if($existedUser = $existedUserRes->Fetch()) + { + $user = new \CUser; + $profile = [ + "XML_ID" => $REQ['crm_id'], + "NAME" => $REQ['firstname'], + "SECOND_NAME" => $REQ['secondname'], + "LAST_NAME" => $REQ['lastname'], + "PASSWORD" => $REQ['password'], + "CONFIRM_PASSWORD" => $REQ['password'], + "EMAIL" => $REQ['email'], + "UF_ORG_TITLE" => (string)$REQ['org_title'], + "UF_INN" => (string)$REQ['inn'], + "UF_KPP" => (string)$REQ['kpp'], + "UF_OGRN" => (string)$REQ['ogrn'], + "UF_PHONE_NUMBER" => (int)$REQ['phone'], + ]; + + $user->Update($existedUser['ID'], $profile); + + if($user->LAST_ERROR) + { + print json_encode([ + "status" => "error", + "error" => "wrong_payload", + "message" => $user->LAST_ERROR, + ]); + } + else + { + print json_encode([ + "status" => "success" + ]); + } + } + else + { + print json_encode([ + "status" => "error", + "error" => "unknown_user", + "message" => "Unknown user", + ]); + } + + die(); + } + break; + default: { print json_encode([ @@ -475,6 +527,11 @@ switch($PARAM_1) { if(CModule::IncludeModule('form')) { + $ipAddress = GeoIp\Manager::getRealIp(); + $result = GeoIp\Manager::getDataResult($ipAddress, "ru"); + + $REQ['FORM_FIELD_REGION'] = $result->getGeoData()->regionName.", ".$result->getGeoData()->cityName; + $error = ""; $arr = Array(); $form_errors = Array(); @@ -609,7 +666,7 @@ switch($PARAM_1) $url = API_HOST."/site/RequestFromSite"; $payload = json_encode([ - "region" => "Московская область", + "region" => $REQ['FORM_FIELD_REGION'], "name" => $REQ['FORM_FIELD_FIO'], "phone" => $REQ['FORM_FIELD_PHONE'], "email" => $REQ['FORM_FIELD_EMAIL'], @@ -1025,7 +1082,7 @@ switch($PARAM_1) curl_setopt($c, CURLOPT_POSTFIELDS, $payload); curl_setopt($c, CURLOPT_HTTPHEADER, array('Content-Type:application/json')); - $response = curl_exec($c); + $response = curl_exec($c) or die(curl_error($c)); curl_close($c); print $response; diff --git a/images/icons/icon-file.svg b/images/icons/icon-file.svg new file mode 100644 index 0000000..baff826 --- /dev/null +++ b/images/icons/icon-file.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/local/components/evolution/about.contacts.list/component.php b/local/components/evolution/about.contacts.list/component.php index 302f4e7..de4ab21 100644 --- a/local/components/evolution/about.contacts.list/component.php +++ b/local/components/evolution/about.contacts.list/component.php @@ -31,15 +31,11 @@ if($this->StartResultCache(60*60*24, md5(var_export($_POST, true)))) { $ar_res = $obElement->GetFields(); $ar_res['PROPERTIES'] = $obElement->GetProperties(); - $ar_res['PROPERTIES']['REGION']['RELATED'] = get_related(15, $ar_res['PROPERTIES']['REGION']['VALUE']); + //$ar_res['PROPERTIES']['REGION']['RELATED'] = get_related_array(15, $ar_res['PROPERTIES']['REGION']['VALUE']); $arResult['AGENCIES'][] = $ar_res; } - //print "
";
-		//print_r($arResult['AGENCIES']);
-		//print "
"; - $this->IncludeComponentTemplate(); } } \ No newline at end of file diff --git a/local/components/evolution/about.contacts.list/templates/.default/script.js b/local/components/evolution/about.contacts.list/templates/.default/script.js index 6294ff7..cc28db8 100644 --- a/local/components/evolution/about.contacts.list/templates/.default/script.js +++ b/local/components/evolution/about.contacts.list/templates/.default/script.js @@ -1,46 +1,68 @@ $(function() { - /* - $.get("/api/regions/", - { - params: {}, - }, function(response) - { - for(let i in response.regions) - { - //$("#regions_select").append(""); - //$("#regions_select_mobile").append(""); - } - //$("#regions_select")[0].selectedIndex = 1; - //$("#regions_select_mobile")[0].selectedIndex = 1; - }, "json"); - */ - $(".regions_select").on("change", function() { - var geo = $(this).find(':selected').data("geo"); - var zoom = $(this).find(':selected').data("zoom"); - var coords = geo.split(","); - - window.map.setCenter([ coords[0], coords[1] ], zoom); - - if($('.tab.active').index() === 1) + if($(this).val() === "") { - $(".dropdown_block").removeClass("open"); - $("#region_"+parseInt($(this).val(), 10)).addClass("open"); - $('html, body').animate({ - scrollTop: $("#region_"+parseInt($(this).val(), 10)).offset().top - 100 - }, 200); + $(".region_selected").remove(); + $(".region_block").css("display", "block"); + + window.map.setCenter([ 55.178521758435, 61.416163746216 ], 3.8); } else { - $('html, body').animate({ - scrollTop: $("#contacts_top").offset().top - 100 - }, 200); + var geo = $(this).find(':selected').data("geo"); + var zoom = $(this).find(':selected').data("zoom"); + var coords = geo.split(","); + + window.map.setCenter([ coords[0], coords[1] ], zoom); + + if($('.tab.active').index() === 1) + { + $('html, body').animate({ + scrollTop: $("#contacts_top").offset().top - 100 + }, 200); + } + else + { + $('html, body').animate({ + scrollTop: $("#contacts_top").offset().top - 100 + }, 200); + } + + $(".region_selected").remove(); + $(".region_block").css("display", "none"); + + var text_blocks = $(".column_desktop").find(".region_"+parseInt($(this).val(), 10)); + + text_blocks.map(function(index, item) + { + var n = $(item).clone(); + $(n).addClass("open").addClass("region_selected").css("display", "block"); + + if(index % 2 == 0) + { + $(".column_left").append(n); + } + else + { + $(".column_right").append(n); + } + }); + + var text_blocks = $(".column_mobile").find(".region_"+parseInt($(this).val(), 10)); + + text_blocks.map(function(index, item) + { + var n = $(item).clone(); + $(n).addClass("open").addClass("region_selected").css("display", "block"); + + $(".column_all").append(n); + }); } }); - $(".contacts_show_office_on_map").on("click", function() + $("body").on("click", ".contacts_show_office_on_map", function() { const geo = $(this).data("geo"); var coords = geo.split(","); diff --git a/local/components/evolution/about.contacts.list/templates/.default/template.php b/local/components/evolution/about.contacts.list/templates/.default/template.php index eb9bb0a..4274671 100644 --- a/local/components/evolution/about.contacts.list/templates/.default/template.php +++ b/local/components/evolution/about.contacts.list/templates/.default/template.php @@ -37,9 +37,9 @@ $this->setFrameMode(true);
- Показываем представительства, которые обслуживают выбранный регион

- */?> +
IncludeComponent( "evolution:regions.list", @@ -287,10 +287,10 @@ $this->setFrameMode(true); } } ?> -
+
-