discount change

remotes/origin/hasaccess
Sanasol 8 years ago
parent 3db136f32d
commit c0a065f97d
  1. 5
      project/templates/lilcity/index.html
  2. 6
      web/src/js/modules/popup.js

@ -440,7 +440,7 @@
<div class="buy__list"> <div class="buy__list">
{% for school_schedule in school_schedules %} {% for school_schedule in school_schedules %}
<label class="switch switch_lesson"> <label class="switch switch_lesson">
<input class="switch__input" type="checkbox" data-day="{{school_schedule.weekday}}" data-price="{{school_schedule.month_price}}" data-discount="{{school_schedule.day_discount}}" autocomplete="off"> <input class="switch__input" type="checkbox" data-day="{{school_schedule.weekday}}" data-price="{{school_schedule.month_price}}" autocomplete="off">
<span class="switch__content"> <span class="switch__content">
<span class="switch__cell">{{ school_schedule }}</span> <span class="switch__cell">{{ school_schedule }}</span>
{% comment %} dont delete {% endcomment %} {% comment %} dont delete {% endcomment %}
@ -479,6 +479,9 @@
</div> </div>
</div> </div>
<script type="text/javascript" src={% static "app.js" %}></script> <script type="text/javascript" src={% static "app.js" %}></script>
<script>
var schoolDiscount = parseFloat({{ config.SERVICE_DISCOUNT }});
</script>
{% block foot %}{% endblock foot %} {% block foot %}{% endblock foot %}
</body> </body>

@ -52,10 +52,9 @@ $(document).ready(function () {
$(document).on('change', '[data-day]', function(){ $(document).on('change', '[data-day]', function(){
var weekday = $(this).data('day'); var weekday = $(this).data('day');
var price = $(this).data('price'); var price = $(this).data('price');
var discount = $(this).data('discount');
if($(this).is(':checked')) { if($(this).is(':checked')) {
console.log('checked'); console.log('checked');
selectedWeekdays[weekday] = {price:price, discount:discount}; selectedWeekdays[weekday] = {price:price};
} else { } else {
console.log('not checked'); console.log('not checked');
delete selectedWeekdays[weekday]; delete selectedWeekdays[weekday];
@ -69,14 +68,13 @@ $(document).ready(function () {
var weekdays = [], daysText = [], price = 0, discount = 0; var weekdays = [], daysText = [], price = 0, discount = 0;
for(var i in selectedWeekdays) { for(var i in selectedWeekdays) {
price += parseInt(selectedWeekdays[i].price); price += parseInt(selectedWeekdays[i].price);
discount += parseInt(selectedWeekdays[i].discount);
weekdays.push(i); weekdays.push(i);
daysText.push(days[i]); daysText.push(days[i]);
} }
var text = ''; var text = '';
if(weekdays.length >= 7) { if(weekdays.length >= 7) {
text = '<del>'+price+'</del> '+(price-discount)+'р.'; text = '<del>'+price+'</del> '+(price-schoolDiscount)+'р.';
} else { } else {
text = price+'p.'; text = price+'p.';
} }

Loading…
Cancel
Save