core/api/modules/foto_cart/mod.js

40 lines
1.3 KiB
JavaScript
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

var allFotosCena = new Map(); //храним тут все цены
$(".razmer_foto").change(function(event) {
var foto_id = $(this).data("fotoid");
var foto_razmer = $(this).val();
if ($(this).val() == "0") var mycena = 0;
if ($(this).val() == "1") var mycena = 100;
if ($(this).val() == "2") var mycena = 55;
if ($(this).val() == "3") var mycena = 30;
if ($(this).val() == "4") var mycena = 150;
if ($(this).val() == "5") var mycena = 200;
if (mycena == 0)
allFotosCena.delete(foto_id); // true
else
allFotosCena.set(foto_id, mycena);
$.ajax({
type: "POST",
url: "/act/foto_cart",
data: "act=update&foto_id=" + foto_id + "&foto_razmer=" + foto_razmer,
success: function(data) {}
})
var summa = 0; //иницализируем перемешку
for (let key of allFotosCena.keys()) summa = summa + allFotosCena.get(key); // щитаем итого
strSumma = summa.toString() + " р.";
$("#spanItogo").text(strSumma);
})
$(".otmena").click(function(event) {
var foto_id = $(this).data('id');
$.ajax({
type: "POST",
url: "/act/foto_cart",
data: "act=otmena&foto_id=" + foto_id,
success: function(data) {}
})
$("#" + foto_id).hide(700);
})