﻿//获取登录状态
jQuery.GetIsAuthenticated = function(callback) {
    $.ajax({
        type: "POST",
        contentType: "application/json",
        url: "/webservices/user.asmx/GetIsAuthenticated",
        data: "{}",
        dataType: 'json',
        cache: false,
        success: function(result) {
            callback(result.d);
        }
    });
}

///返回已经登录的会员ID
jQuery.GetUserID = function(callback) {
    $.ajax({
        type: "POST",
        contentType: "application/json",
        url: "/webservices/user.asmx/GetUserID",
        data: "{}",
        dataType: 'json',
        success: function(result) {
            callback(result.d);
        }
    });
}


//返回电子邮件是否已经存在
jQuery.GetEmailIsExist = function(email, callback) {
    $.ajax({
        type: "POST",
        contentType: "application/json",
        url: "/webservices/user.asmx/GetEmailIsExist",
        data: "{email:'" + email + "'}",
        dataType: 'json',
        success: function(result) {
            callback(result.d);
        }
    });
}

//返回手机号码是否已经存在
jQuery.GetMobileExist = function(mobile,callback) {
    $.ajax({
        type: "POST",
        contentType: "application/json",
        url: "/webservices/user.asmx/GetMobileExist",
        data: "{mobile:'" + mobile + "'}",
        dataType: 'json',
        success: function(result) {
            callback(result.d);
        }
    });
}


///返回购物车数量
jQuery.GetMyCartGoodsCount = function(callback) {
    $.ajax({
        type: "POST",  
        contentType: "application/json", 
        url: "/webservices/user.asmx/GetMyCartGoodsCount", 
        data: "{}",
        dataType: 'json',
        success: function(result) {      
            callback(result.d);
        }
    });
}

//无规格商品
jQuery.AddToCart = function(vGoodsID) {
    $.ajax({
        type: "POST",
        contentType: "application/json",
        url: "/webservices/cart.asmx/AddToCart",
        data: "{GoodsID:" + vGoodsID + ",Quantity:1}",
        dataType: 'json',
        success: function(result) {
            if (result.d) pop_Message();
            else alert("添加失败，当前商品可能未上架或在购物车中已经存在！");
        }
    });
}


//添加只有一个规格的商品
jQuery.AddSpecToCart = function(vGoodsID, vSpecID, vSpecValue) {
    $.ajax({
        type: "POST",
        contentType: "application/json",
        url: "/webservices/cart.asmx/AddSpecToCart",
        data: "{GoodsID:" + vGoodsID + ",Quantity:1,SpecID:" + vSpecID + ",SpecValue:'" + vSpecValue + "'}",
        dataType: 'json',
        success: function(result) {
            if (result.d) pop_Message();
            else alert("添加失败，当前商品可能未上架或在购物车中已经存在！");
        }
    });
}



