You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
151 lines
3.1 KiB
151 lines
3.1 KiB
/********迷你購物車加減********/
|
|
function flowClickCartNum(a,b)
|
|
{
|
|
var b = parseInt(b);
|
|
var c = $("#goods_number_"+a);
|
|
var d = parseInt(c.val());
|
|
if(d < 1 || !$.isNumeric(d))
|
|
{
|
|
alert("請輸入正確的商品數量");
|
|
e = 1;
|
|
}
|
|
|
|
if(b == -1)
|
|
{
|
|
if(d == 1)
|
|
{
|
|
alert("購買數量不能小於1件");
|
|
}
|
|
else
|
|
{
|
|
e = d + b;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
e = d + b;
|
|
}
|
|
flow_change_goods_number(a,e);
|
|
}
|
|
|
|
async function flow_change_goods_number(rec_id, goods_number)
|
|
{
|
|
let res = await axios.post('flow.php?step=ajax_update_cart',{rec_id , goods_number})
|
|
flow_change_goods_number_response(res.data)
|
|
}
|
|
|
|
function flow_change_goods_number_response(res)
|
|
{
|
|
let result = res
|
|
|
|
if (result.error == 0)
|
|
{
|
|
var rec_id = result.rec_id;
|
|
|
|
$('#goods_number_' +rec_id).val(result.goods_number);//更新數量
|
|
$('#total_items_' +rec_id).html(result.goods_subtotal);//更新小計
|
|
$('#totalSkuPrice').html(result.total_price); //更新合計
|
|
$('#selectedCount').html(result.total_goods_count);//更新購物車數量
|
|
$('#selectedCount').html(result.total_number) //更新總數量
|
|
|
|
}
|
|
|
|
else if (result.error == 999 )
|
|
{
|
|
if (confirm(result.message))
|
|
{
|
|
location.href = 'user.php';
|
|
}
|
|
}
|
|
else if (result.error == 888 )
|
|
{
|
|
alert(result.message);
|
|
}
|
|
|
|
else if (result.message != '')
|
|
{
|
|
alert(result.message);
|
|
}
|
|
}
|
|
|
|
/* *
|
|
* 檢查收貨地址信息表單中填寫的內容
|
|
*/
|
|
function checkConsignee(frm)
|
|
{
|
|
var msg = new Array();
|
|
var err = false;
|
|
|
|
if (frm.elements['country'] && frm.elements['country'].value == 0)
|
|
{
|
|
msg.push(country_not_null);
|
|
err = true;
|
|
}
|
|
|
|
if (frm.elements['province'] && frm.elements['province'].value == 0 && frm.elements['province'].length > 1)
|
|
{
|
|
err = true;
|
|
msg.push(province_not_null);
|
|
}
|
|
|
|
if (frm.elements['city'] && frm.elements['city'].value == 0 && frm.elements['city'].length > 1)
|
|
{
|
|
err = true;
|
|
msg.push(city_not_null);
|
|
}
|
|
|
|
if (frm.elements['district'] && frm.elements['district'].length > 1)
|
|
{
|
|
if (frm.elements['district'].value == 0)
|
|
{
|
|
err = true;
|
|
msg.push(district_not_null);
|
|
}
|
|
}
|
|
|
|
if (Utils.isEmpty(frm.elements['consignee'].value))
|
|
{
|
|
err = true;
|
|
msg.push(consignee_not_null);
|
|
}
|
|
|
|
if ( ! Utils.isEmail(frm.elements['email'].value))
|
|
{
|
|
err = true;
|
|
msg.push(invalid_email);
|
|
}
|
|
|
|
if (frm.elements['address'] && Utils.isEmpty(frm.elements['address'].value))
|
|
{
|
|
err = true;
|
|
msg.push(address_not_null);
|
|
}
|
|
|
|
if (frm.elements['zipcode'] && frm.elements['zipcode'].value.length > 0 && (!Utils.isNumber(frm.elements['zipcode'].value)))
|
|
{
|
|
err = true;
|
|
msg.push(zip_not_num);
|
|
}
|
|
|
|
if (Utils.isEmpty(frm.elements['mobile'].value))
|
|
{
|
|
err = true;
|
|
msg.push(mobile_not_null);
|
|
}
|
|
else
|
|
{
|
|
if (!Utils.isMobile(frm.elements['mobile'].value))
|
|
{
|
|
err = true;
|
|
msg.push(mobile_invaild);
|
|
}
|
|
}
|
|
|
|
if (err)
|
|
{
|
|
message = msg.join("\n");
|
|
alert(message);
|
|
}
|
|
return ! err;
|
|
}
|