From 2bc26ee02bb3957fbb33b6f3068f0f891f1fef26 Mon Sep 17 00:00:00 2001 From: gzbender Date: Wed, 22 Aug 2018 13:57:19 +0500 Subject: [PATCH] =?UTF-8?q?LIL-629=20=D0=9F=D0=BE=D0=BF=D0=B0=D0=BF=20?= =?UTF-8?q?=D1=81=20=D0=B2=D1=8B=D0=B1=D0=BE=D1=80=D0=BE=D0=BC=20=D0=B4?= =?UTF-8?q?=D0=BD=D0=B5=D0=B9=20=D0=BF=D0=B5=D1=80=D0=B5=D0=B4=20=D0=BF?= =?UTF-8?q?=D0=BE=D0=BA=D1=83=D0=BF=D0=BA=D0=BE=D0=B9=20=D0=BF=D0=BE=D0=BA?= =?UTF-8?q?=D0=B0=D0=B7=D1=8B=D0=B2=D0=B0=D1=82=D1=8C=20=D0=BD=D0=B5=20?= =?UTF-8?q?=D0=B0=D0=B2=D1=82=D0=BE=D1=80=D0=B8=D0=B7=D0=BE=D0=B2=D0=B0?= =?UTF-8?q?=D0=BD=D0=BD=D1=8B=D0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/school/templates/blocks/day_pay_btn.html | 4 +- .../templates/blocks/schedule_item.html | 12 +++--- apps/school/templates/summer/promo.html | 4 -- project/templates/blocks/popup_auth.html | 12 +++--- project/templates/blocks/popup_buy.html | 2 +- web/src/js/modules/auth.js | 29 ++++++++++++--- web/src/js/modules/popup.js | 37 ++++++++++++++++--- 7 files changed, 68 insertions(+), 32 deletions(-) diff --git a/apps/school/templates/blocks/day_pay_btn.html b/apps/school/templates/blocks/day_pay_btn.html index 155b8827..f4cd2f40 100644 --- a/apps/school/templates/blocks/day_pay_btn.html +++ b/apps/school/templates/blocks/day_pay_btn.html @@ -1,7 +1,5 @@ купить diff --git a/apps/school/templates/blocks/schedule_item.html b/apps/school/templates/blocks/schedule_item.html index 7860e437..27d4fcd4 100644 --- a/apps/school/templates/blocks/schedule_item.html +++ b/apps/school/templates/blocks/schedule_item.html @@ -5,17 +5,17 @@
{{ school_schedule }}
- {% if purchased and live_lesson %} + {% if is_purchased and live_lesson %}
{{ live_lesson.date }}
{% endif %}
{{ school_schedule.start_at }} (МСК)
- {% if purchased %} - {% if school_schedule.weekday in school_schedules_purchased %} - {% if live_lesson and live_lesson.title %} - {% include './open_lesson.html' %} - {% endif %} + {% if is_purchased %} + {% if school_schedule.weekday in school_schedules_purchased and live_lesson and live_lesson.title %} + {% include './open_lesson.html' %} {% endif %} + {% else %} + {% include './day_pay_btn.html' %} {% endif %}
diff --git a/apps/school/templates/summer/promo.html b/apps/school/templates/summer/promo.html index 6995c7b9..3d52d65b 100644 --- a/apps/school/templates/summer/promo.html +++ b/apps/school/templates/summer/promo.html @@ -10,11 +10,7 @@
@@ -53,7 +53,7 @@
или
@@ -96,10 +96,10 @@
@@ -122,7 +122,7 @@
или
diff --git a/project/templates/blocks/popup_buy.html b/project/templates/blocks/popup_buy.html index 96b3b29d..d3080ec9 100644 --- a/project/templates/blocks/popup_buy.html +++ b/project/templates/blocks/popup_buy.html @@ -89,7 +89,7 @@
- ПЕРЕЙТИ К ОПЛАТЕ + ПЕРЕЙТИ К ОПЛАТЕ
diff --git a/web/src/js/modules/auth.js b/web/src/js/modules/auth.js index 07f65cda..09a9bae6 100644 --- a/web/src/js/modules/auth.js +++ b/web/src/js/modules/auth.js @@ -4,7 +4,7 @@ import isEmpty from 'validator/lib/isEmpty'; import isLength from 'validator/lib/isLength'; $(document).ready(function () { - let auth = $('.js-auth'), + let popup = $('.js-popup-auth'), type = auth.find('.js-auth-type'), tab = auth.find('.js-auth-tab'), login = auth.find('.js-auth-login'), @@ -153,7 +153,13 @@ $(document).ready(function () { }) .done(function (data) { if (data.success === true) { - location.reload(); + const nextUrl = popup.data('next-url'); + if(nextUrl){ + window.location.href = nextUrl; + } + else{ + window.location.reload(); + } } else { authButton.removeClass('loading'); } @@ -234,7 +240,13 @@ $(document).ready(function () { }) .done(function (data) { if (data.success === true) { - location.reload(); + const nextUrl = popup.data('next-url'); + if(nextUrl){ + window.location.href = nextUrl; + } + else{ + window.location.reload(); + } } else { registrationButton.removeClass('loading'); } @@ -275,7 +287,7 @@ $(document).ready(function () { if (facebookResponse) { if (facebookResponse.status === 'connected') { - login_with_facebook(facebookResponse.authResponse.accessToken); + login_with_facebook(facebookResponse.authResponse.accessToken, popup.data('next-url')); return; } } @@ -305,14 +317,19 @@ function load_facebook() { }); } -function login_with_facebook(accessToken) { +function login_with_facebook(accessToken, nextUrl) { $.ajax('/auth/facebook_login/', { method: 'POST', data: {'access_token': accessToken}, }) .done(function (data) { if (data.success === true) { - location.reload(); + if(nextUrl){ + window.location.href = nextUrl; + } + else{ + window.location.reload(); + } } }) .fail(function (xhr) { diff --git a/web/src/js/modules/popup.js b/web/src/js/modules/popup.js index a1a91d9f..425f81cd 100644 --- a/web/src/js/modules/popup.js +++ b/web/src/js/modules/popup.js @@ -31,6 +31,24 @@ $(document).ready(function () { }); is_extend = true; } + if(! window.LIL_STORE.user.id) { + const $btn = popup.find('.buy__btn'); + $btn.click(function(event) { + event.preventDefault(); + hidePopup().then(() => { + popup = $('.js-popup-auth'); + popup.data('next-url', $btn.attr('href')); + showPopup(); + }); + }); + } + } + if( data === '.js-popup-auth') { + let nextUrl = $(this).data('auth-next-url'); + if(nextUrl === 'href') { + nextUrl = $(this).attr('href'); + } + popup.data('next-url', nextUrl); } if($(this).data('day')) { @@ -70,21 +88,28 @@ $(document).ready(function () { function showPopup(){ body.addClass('no-scroll'); popup.addClass('open'); - setTimeout(function(){ - popup.addClass('visible'); - }, 100); + return new Promise((resolve) => { + setTimeout(function(){ + popup.addClass('visible'); + resolve(); + }, 100); + }); } function hidePopup(){ body.removeClass('no-scroll'); popup.removeClass('visible'); - setTimeout(function(){ - popup.removeClass('open'); - }, 300); + popup.data('next-url', null); if($('#password-reset__sent').is(':visible')) { window.location.reload(); } + return new Promise((resolve) => { + setTimeout(function(){ + popup.removeClass('open'); + resolve(); + }, 300); + }); } $(document).on('change', '[data-day]', function(){