ProductAdd.helper.js

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ProductAdd.helper.js相关的知识,希望对你有一定的参考价值。

//(function () {
var selectProductType;
var selectProductBrand;
var contetAttributesEx;
var contetSKUs;
//var contetProductAccessories;
var contetRelatedProduct;
//var baseAccessoriehtml;

var hfCurrentProductType;
var hfCurrentProductBrand;
var hfCurrentAttributes;
var hfCurrentBaseProductSKUs;
var hfCurrentProductSKUs;
var hfProductImages;
var hfProductAccessories;
var btnOpenSKUs;
//var btnAddProductAccessories;
var btnAddRelatedProduct;

//Start Package relevant
var packageCheckList;
var selectPackage;
var txtPackageKeyWord;
var hrCurrentSelectPackage;
var btnPackage;
var delPackage;
var packageWindow;
var PackageShow;
var allpackage;
var packageDiv;
//End Package relevant
var selectedAllPackage;
var attributesTR;
var skusTR;
//var productAccessoriesTR;

var optionDefault = ‘<option selected="selected" value="" >请选择</option>‘;
var optionHTML = ‘<option value="{0}">{1}</option>‘;

var attributHTML = ‘<table cellspacing="0" cellpadding="0" width="100%" AttributeId="{0}" attributemode="{1}" id="{2}"><tr><td class="td_class" id="AttributName" >{3} :</td><td height="25" ><div style="width:800px;"><ul id="AttributeContent"></ul></div></td></tr></table><h2></h2>‘; //
var SelectAttributHTML = ‘<tr class="colorclass" style="display:none;"><td class="td_class"></td><td><table cellspacing="0" cellpadding="0" width="100%" id="color_{0}" class="table" style="display: none; margin-top: 10px;margin-bottom: 10px;"><thead><tr><th class="th">颜色</th><th  class="th">图片(无图片可不填)</th></tr></thead><tbody></tbody></table></td></tr>‘;
var colorTr = ‘<tr id="{0}" style="display: none; "><td class="tile"><label id="selectValueLabel_{1}"  title="{2}">{3}</label></td><td class="td"><input type="file" id="File_{4}" accept="image/gif, image/jpeg"/><img id="imgURL_{5}" value="" style="width: 28px; height: 28px;" /><div id="fileQueue" style="display:none;"> </div></td></tr>‘;

var attributInputHTML = ‘<input type="{0}" />‘;
var attributeLabelHTML = ‘<label for="{0}" title="{1}"  >{2}</label> ‘;
var attributeLabelHTMLForSpec = ‘<label for="{0}"  id="attrValuelabel_{1}" title="{6}" >{2}</label> <input id="attrValueText_{3}" maxlength="15" type="text" value="{4}" vid="{5}" style="display: none; " class="edit">‘;

var alertMessageHTML = ‘<table style="width: 100%; border-bottom: none; border-top: none; float: left;" cellpadding="2" cellspacing="1" class="border"><tr><td class="td_class"></td><td height="25">{0}</td></tr></table>‘;

var attributInputMode = { "Radio": "radio", "CheckBox": "checkbox", "Text": "text" };

var attributTagsHtml = "<li class=‘colord7‘ id=‘tag{0}‘ style=‘MARGIN-LEFT: 2px! important;‘><a href=‘javascript:void(0)‘ style=‘‘color:#0078B6‘  data-tag=‘{0}‘>{1}<span class=‘delpackage‘ style=‘ cursor: pointer‘ data-tag={0}>×</span></a> </li>";
var isFirstLoadAccessories = true;
var isFirstLoadRelatedProduct = true;

$(document).ready(function () {
    InitInput();

    $("[id$=‘txtProductSKU‘]").blur(function () {
        var currentText = $("[id$=‘txtProductSKU‘]");
        if (currentText.val()) {
            LoadCheckResult(currentText, currentText.val());
        }
    });

    selectProductType = $("#SelectProductType");
    selectProductBrand = $("#SelectProductBrand");
    contetAttributesEx = $("#ContetAttributesEx");
    contetSKUs = $("#contetSKUs");
    //contetProductAccessories = $("#contetProductAccessories");
    contetRelatedProduct = $(‘#contetRelatedProduct‘);

    //Start Package relevant

    selectPackage = $("#ctl00_ContentPlaceHolder1_ddlSelectPackageCategory");
    txtPackageKeyWord = $("#txt4Keyword");
    packageCheckList = $("#packageList input:checkbox");
    hrCurrentSelectPackage = $(‘[id$=Hidden_SelectPackage]‘);
    selectedAllPackage = $("#allpackage");
    delPackage = $(".delpackage");
    packageWindow = $(".packageWindow");
    PackageShow = $("#PackageShow");
    allpackage = $("#allpackage");
    packageDiv = $("#packageDiv");

    //End Package relevant

    attributesTR = $(".AttributesTR");
    skusTR = $(".SKUsTR");
    btnPackage = $("#btnPackage");

    hfCurrentProductType = $(‘[id$=hfCurrentProductType]‘);
    hfCurrentProductBrand = $(‘[id$=hfCurrentProductBrand]‘);
    hfCurrentAttributes = $(‘[id$=hfCurrentAttributes]‘);
    hfCurrentBaseProductSKUs = $(‘[id$=hfCurrentBaseProductSKUs]‘);
    hfCurrentProductSKUs = $(‘[id$=hfCurrentProductSKUs]‘);
    hfProductImages = $(‘[id$=hfProductImages]‘);
    btnOpenSKUs = $(‘#btnOpenSKUs‘);
    btnCloseSkus = $(‘#btnCloseSkus‘);
    // btnAddProductAccessories = $(‘#btnAddProductAccessories‘);
    btnAddRelatedProduct = $(‘#btnAddRelatedProducts‘);
    InitProductTypes();
    btnCloseSkus.hide();

    //Clear Backward Val
    hfCurrentProductType.val(selectProductType.val());

    //ProductType
    selectProductType.bind(‘change‘, function () {
        if (!$(this).val()) {
            hfCurrentProductType.val(‘‘);

            //Clear Brand
            selectProductBrand.find(‘option‘).remove();
            selectProductBrand.append(optionDefault);

            //Clear Attributes
            contetAttributesEx.find(‘table,h2‘).remove();
            attributesTR.hide();

            //Clear SKU
            if (btnOpenSKUs.css(‘display‘) == ‘none‘) {
                contetSKUs.find(‘table‘).remove();
                contetSKUs.append(alertMessageHTML.format(‘请您先选择商品类型! <a href="javascript:void(0);" style="color:blue;" onclick=GoTab(0,"SelectProductType")>点此返回选择</a>‘));
                skusTR.show();
            }

            return false;
        }
        if (hfCurrentProductType.val() && !confirm(‘切换商品类型将会导致已经编辑的品牌,属性和规格数据丢失,确定要切换吗?‘)) {
            $(this).val(hfCurrentProductType.val());
            return false;
        }
        hfCurrentProductType.val($(this).val());
        LoadProductBrands();
        LoadAttributes();
        if (btnOpenSKUs.css(‘display‘) == ‘none‘) {
            LoadSKUs();
            InitInput();
        }
    });

    //ProductBrand
    selectProductBrand.bind(‘change‘, function () {
        hfCurrentProductBrand.val($(this).val());
    });

    //Start Package relevant
    selectPackage.bind(‘change‘, function () {
        LoadPackageByCid(selectPackage.val(), txtPackageKeyWord.val());
    });
    txtPackageKeyWord.bind(‘keyup‘, function () {
        LoadPackageByCid(selectPackage.val(), txtPackageKeyWord.val());
    });

    packageCheckList.die("click").live("click", function () {
        if ($(this).is(‘:checked‘)) {
            if (!(hrCurrentSelectPackage.val().indexOf($(this).val()) !== -1)) {
                if (hrCurrentSelectPackage.val().length <= 0) {
                    hrCurrentSelectPackage.val($(this).val());
                    selectedAllPackage.append(attributTagsHtml.format($(this).val(), $(this).attr("pname")));
                } else {
                    hrCurrentSelectPackage.val(hrCurrentSelectPackage.val() + "," + $(this).val());
                    selectedAllPackage.append(attributTagsHtml.format($(this).val(), $(this).attr("pname")));
                }
            }
        }
        else {
            hrCurrentSelectPackage.val(hrCurrentSelectPackage.val().replace("" + $(this).val() + ",", ""));
            hrCurrentSelectPackage.val(hrCurrentSelectPackage.val().replace("" + $(this).val() + "", ""));
            $("#tag" + $(this).val() + "").remove();
        }
        hrCurrentSelectPackage.val(hrCurrentSelectPackage.val().replace(",,", ","));
        $.colorbox.resize();
    });

    delPackage.die("click").live("click", function () {
        $("#tag" + $(this).attr("data-tag") + "").remove();
        $("#p" + $(this).attr("data-tag") + "").prop("checked", false);
        hrCurrentSelectPackage.val(hrCurrentSelectPackage.val().replace("" + $(this).val() + ",", ""));
        hrCurrentSelectPackage.val(hrCurrentSelectPackage.val().replace("" + $(this).val() + "", ""));
    });
    packageWindow.click(function () {
        packageDiv.append(allpackage);
    });
    btnPackage.click(function () {
        PackageShow.prepend(allpackage);
        $.colorbox.close();
    });

    //End Package relevant

    //OpenSKU
    btnOpenSKUs.bind(‘click‘, function () {
        $(this).hide();
        $(‘#trbtnOpenSKUs‘).hide();
        btnCloseSkus.show();
        if (!hfCurrentProductType.val()) {
            contetSKUs.find(‘table‘).remove();
            contetSKUs.append(alertMessageHTML.format(‘请您先选择商品类型! <a href="javascript:void(0);" style="color:blue;" onclick=GoTab(0,"SelectProductType")>点此返回选择</a>‘));
            skusTR.show();
            return;
        }
        LoadSKUs();
        InitInput();
    });

    $(‘[id$=txtShortDescription]‘).autosize();
    //ProductAccessories
    //    btnAddProductAccessories.bind(‘click‘, function () {
    //        $(‘#AddProductAccessoriesTR‘).hide();
    //        if (isFirstLoadAccessories) {
    //            isFirstLoadAccessories = false;
    //            //$.jBox.tip("努力为您加载中,请稍后...", ‘loading‘);
    ////            window.setTimeout(function () {
    ////                $.jBox.closeTip();
    ////                $("#Accessories").attr(‘src‘, ‘/Admin/Shop/Products/SelectAccessorieNew.aspx‘);
    //            //            }, 3000);
    //            $("#Accessories").attr(‘src‘, ‘/Admin/Shop/Products/SelectAccessorieNew.aspx‘);
    //        }
    //        contetProductAccessories.show();
    //    });

    btnAddRelatedProduct.bind(‘click‘, function () {
        $(‘#AddRelatedProductTR‘).hide();
        if (isFirstLoadRelatedProduct) {
            isFirstLoadRelatedProduct = false;
            //$.jBox.tip("努力为您加载中,请稍后...", ‘loading‘);
            //            window.setTimeout(function () {
            //                $.jBox.closeTip();
            //                $("#RelatedProductIfram").attr(‘src‘, ‘/Admin/Shop/Products/SelectRelatedProducts.aspx‘);
            //            }, 3000);
            $("#RelatedProductIfram").attr(‘src‘, ‘/Admin/Shop/Products/SelectRelatedProducts.aspx‘);
        }
        contetRelatedProduct.show();
    });

    $.dynatextarea($(‘[id$=txtShortDescription]‘), 300, $(‘#progressbar1‘));

    $("#SelectProductType").get(0).selectedIndex = 0;
    $("#SelectProductType").change();
    $(‘#AttributeContent‘).find(‘input:checkbox‘).eq(0).attr(‘checked‘, ‘checked‘);
});

function InitInput() {
    $(".OnlyNum").OnlyNum();
    $(".OnlyFloat").OnlyFloat();
}

function GoTab(index, targetId) {
    nTabs($(‘[onclick="nTabs(this,‘ + index + ‘);"]‘).get(0), 0);
    if (targetId) {
        $(‘#‘ + targetId).focus();
    }
}

function SubForm() {

    var flag_skuCodeExist = false;
    if (!PageIsValid()) {
        nTabs($(‘[onclick="nTabs(this,0);"]‘).get(0), 0);
        return false;
    }
    if (!$(‘[id$=Hidden_SelectValue]‘).val()) {
        alert(‘请选择商品所在分类‘);
        return false;
    }
    if (!hfCurrentProductType.val()) {
        alert(‘请选择商品类型‘);
        return false;
    }

    if (!$("[id$=‘txtMarketPrice‘]").val()) {
        alert(‘请输入商品市场价格‘);
        return false;
    }
    if (!$(‘[id$=txtProductSKU]‘).val()) {
        alert(‘请输入商品编码‘);
        return false;
    } else {
        //Check SKU 是否存在
        $.ajax({
            url: ("/ShopManage.aspx?timestamp={0}").format(new Date().getTime()),
            type: ‘POST‘,
            dataType: ‘json‘,
            timeout: 10000,
            async: false,
            data: { Action: "IsExistSkuCode", SKUCode: $(‘[id$=txtProductSKU]‘).val() },
            //        beforeSend: function () {
            //            $.jBox.tip("正在检测商品编码的唯一性,请稍后...", ‘loading‘);
            //        },
            //        complete: function () {
            //            $.jBox.closeTip();
            //        },
            success: function (resultData) {
                switch (resultData.STATUS) {
                    case "FAILED":
                        //  $.jBox.closeTip();
                        $(‘[id$=txtProductSKU]‘).val(‘‘);
                        $(‘[id$=txtProductSKU]‘).focus();
                        flag_skuCodeExist = true;
                        break;
                    default:
                        break;
                }
            }, error: function (xmlHttpRequest, textStatus, errorThrown) {
                alert(xmlHttpRequest.responseText);
            }
        });
        if (flag_skuCodeExist) {
            alert(‘该商品编码已经存在,请重新输入!‘);
            return false;
        }
    }
    if (!$(‘[id$=txtSalePrice]‘).val()) {
        alert(‘请输入销售价‘);
        return false;
    }
    if (!$(‘[id$=txtStock]‘).val()) {
        alert(‘请输入商品库存‘);
        return false;
    }
    if (!$(‘[id$=txtAlertStock]‘).val()) {
        alert(‘请输入警戒库存‘);
        return false;
    }

    //AttributesJson
    hfCurrentAttributes.val(JSON.stringify(GetAttributes()));
//    if (!hfCurrentAttributes.val() || hfCurrentAttributes.val() == ‘[]‘) {
//        alert(‘请选择商品的属性‘);
//        return false;
//    }

    var flag_skuCode = false;
    flag_skuCodeExist = false;
    var flag_SalePrice = false;
    var flag_Stock = false;
    var flag_AlertStock = false;
    $(".GridViewStyle tr td :input").each(function (index) {
        if ($(this).attr(‘id‘) == "SKU") {
            if (!$(this).val()) {
                flag_skuCode = true;
                return false;
            } else {
                //Check SKU 是否存在
                $.ajax({
                    url: ("/ShopManage.aspx?timestamp={0}").format(new Date().getTime()),
                    type: ‘POST‘,
                    dataType: ‘json‘,
                    timeout: 10000,
                    async: false,
                    data: { Action: "IsExistSkuCode", SKUCode: $(this).val() },
                    //        beforeSend: function () {
                    //            $.jBox.tip("正在检测商品编码的唯一性,请稍后...", ‘loading‘);
                    //        },
                    //        complete: function () {
                    //            $.jBox.closeTip();
                    //        },
                    success: function (resultData) {
                        switch (resultData.STATUS) {
                            case "FAILED":
                                //  $.jBox.closeTip();
                                $(this).val(‘‘);
                                $(this).focus();
                                flag_skuCodeExist = true;
                                break;
                            default:
                                break;
                        }
                    }, error: function (xmlHttpRequest, textStatus, errorThrown) {
                        alert(xmlHttpRequest.responseText);
                    }
                });
                if ($(".GridViewStyle tr td :input[id=SKU][value=‘" + $(this).val() + "‘]").length > 1) {
                    $(this).val(‘‘);
                    $(this).focus();
                    flag_skuCodeExist = true;
                }
                //不终止, 继续清空重复的SKU
//                if (flag_skuCodeExist) {
//                    return false;
//                }
            }
        }
        if ($(this).attr(‘id‘) == "SalePrice") {
            if (!$(this).val()) {
                flag_SalePrice = true;
                return false;
            }
        }
        if ($(this).attr(‘id‘) == "Stock") {
            if (!$(this).val()) {
                flag_Stock = true;
                return false;
            }
        }
        if ($(this).attr(‘id‘) == "AlertStock") {
            if (!$(this).val()) {
                flag_AlertStock = true;
                return false;
            }
        }
    });

    if (flag_skuCode) {
        alert("开启的规格中的商品编码不能为空!");
        return false;
    }
    if (flag_skuCodeExist) {
        alert("开启的规格中的商品编码已经存在,请重新输入!");
        return false;
    }
    if (flag_SalePrice) {
        alert("开启的规格中的销售价不能为空!");
        return false;
    }
    if (flag_Stock) {
        alert("开启的规格中的库存数量不能为空!");
        return false;
    }
    if (flag_AlertStock) {
        alert("开启的规格中的警戒库存数量不能为空!");
        return false;
    }
    


//    if ($(‘[id$=hfSelectedAccessories]‘).val()) {
//        if (!$(‘[id$=txtAccessorieName]‘).val()) {
//            alert(‘请输入配件组名称‘);
//            return false;
//        }
//        if (!$(‘[id$=txtMinQuantity]‘).val()) {
//            alert(‘请输入最小购买量‘);
//            return false;s
//        }
//        if (!$(‘[id$=txtMaxQuantity]‘).val()) {
//            alert(‘请输入最大购买量‘);
//            return false;
//        }
//        if (!$(‘[id$=txtDiscountAmount]‘).val()) {
//            alert(‘请输入优惠额度‘);
//            return false;
//        }
//    }

    //check SKU
    //    if (btnOpenSKUs.css(‘display‘) == ‘none‘) {
    //        if (!CheckBaseSKU) {
    //            nTabs($(‘[onclick="nTabs(this,0);"]‘).get(0), 0);
    //            return false;
    //        }
    //    } else {
    //        if (!CheckGenSKU) {
    //            nTabs($(‘[onclick="nTabs(this,2);"]‘).get(0), 0);
    //            return false;
    //        }
    //    }


    //GenBaseSKUJson
    hfCurrentBaseProductSKUs.val(JSON.stringify(GetBaseSKU()));
    //SelectedSKUJson
    var selectedSku = GetSelectedSKU();
    if (selectedSku && selectedSku != ‘undefined‘) {
        hfCurrentProductSKUs.val(JSON.stringify(selectedSku));
    }

    hfProductImages.val(‘‘);
    //ProductImages
    $(‘.ImgUpload‘).each(function() {
        var img = $(this).find("input[type=hidden]").val();
        if (img) {
            hfProductImages.val(hfProductImages.val() + ‘|‘ + img);
        }
    });

    return true;
}

function InitProductTypes() {
    $.ajax({
        url: ("/ShopManage.aspx?timestamp={0}").format(new Date().getTime()),
        type: ‘POST‘,
        dataType: ‘json‘,
        timeout: 10000,
        async: false,
        data: { Action: "GetProductTypesKVList" },
        success: function(resultData) {
            switch (resultData.STATUS) {
            case "SUCCESS":
                selectProductType.find(‘option‘).remove();
                selectProductType.append(optionDefault);
                if (resultData.DATA.length == 0) {
                    ShowFailTip("您还没有设置任何商品类型, 请先设置商品类型");
                }
                $(resultData.DATA).each(function() {
                    selectProductType.append(optionHTML.format(this.TypeId, this.TypeName));
                });
                break;
            default:
                ShowFailTip("您还没有设置任何商品类型, 请先设置商品类型");
                break;
            }
        },
        error: function(xmlHttpRequest, textStatus, errorThrown) {
            alert(xmlHttpRequest.responseText);
        }
    });
}

function LoadProductBrands() {
    $.ajax({
        url: ("/ShopManage.aspx?timestamp={0}").format(new Date().getTime()),
        type: ‘POST‘,
        dataType: ‘json‘,
        timeout: 10000,
        async: false,
        data: { Action: "GetBrandsKVList", ProductTypeId: hfCurrentProductType.val() },
        success: function(resultData) {
            switch (resultData.STATUS) {
            case "SUCCESS":
                selectProductBrand.find(‘option‘).remove();
                selectProductBrand.append(optionDefault);
                $(resultData.DATA).each(function() {
                    selectProductBrand.append(optionHTML.format(this.BrandId, this.BrandName));
                });
                break;
            default:
                break;
            }
        },
        error: function(xmlHttpRequest, textStatus, errorThrown) {
            alert(xmlHttpRequest.responseText);
        }
    });
}

function LoadPackageByCid(cid, keyword) {
    $.ajax({
        url: ("/ShopManage.aspx?timestamp={0}").format(new Date().getTime()),
        type: ‘POST‘,
        dataType: ‘json‘,
        timeout: 10000,
        async: false,
        data: { Action: "GetPackage", id: cid, q: keyword },
        success: function(resultData) {
            switch (resultData.STATUS) {
            case "OK":
                $("#packageList").html("");
                $(resultData.DATA).each(function() {
                    $("#packageList").append($(attributInputHTML.format(attributInputMode.CheckBox)).val(this.PackageId).attr("id", "p" + this.PackageId).attr("pname", this.Name));
                    $("#packageList").append($(attributeLabelHTML.format("p" + this.PackageId, this.Name, this.Name)));
                });
                $.colorbox.resize();
                break;
            default:
                $("#packageList").html("");
                break;
            }
        },
        error: function(xmlHttpRequest, textStatus, errorThrown) {
            alert(xmlHttpRequest.responseText);
        }
    });
}

function LoadAttributes() {
    $.ajax({
        url: ("/ShopManage.aspx?timestamp={0}").format(new Date().getTime()),
        type: ‘POST‘,
        dataType: ‘json‘,
        timeout: 10000,
        async: false,
        data: { Action: "GetAttributesList", DataMode: 0, ProductTypeId: hfCurrentProductType.val() },
//        beforeSend: function () {
//            $.jBox.tip("努力为您加载中,请稍后...", ‘loading‘);
//        },
//        complete: function () {
//            $.jBox.closeTip();
//        },
        success: function (resultData) {
            switch (resultData.STATUS) {
                case "SUCCESS":
                    contetAttributesEx.find(‘table,h2‘).remove();
                    attributesTR.hide();
                    if (resultData.DATA.length == 0) {
//                       ShowFailTip("您还没有设置任何商品类型, 请先设置商品类型");
                    }
                    $(resultData.DATA).each(function () {
                        var data = this;
                        var target = $(attributHTML.format(
                            data.AttributeId, data.AttributeUsageMode, data.AttributeId,
                            data.AttributeName));
                        var inputMode;
                        switch (data.AttributeUsageMode) {
                            case 0:
                                inputMode = attributInputMode.Radio;
                                break;
                            case 1:
                                inputMode = attributInputMode.CheckBox;
                                break;
                            case 2:
                                inputMode = attributInputMode.Text;
                                break;
                            default:
                                alert(‘扩展属性模式不正确!‘);
                                return;
                        }
                        if (data.AttributeUsageMode == 2) {
                            target.find(‘#AttributeContent‘).append(
                                $(attributInputHTML.format(inputMode)).width(200).attr(‘maxlength‘, ‘200‘));
                        } else {
                            $(data.AttributeValues).each(function () {
                                target.find(‘#AttributeContent‘).append(‘<li id="li_‘+ this.valueId+‘">‘);
                                var targetInput = attributInputHTML.format(inputMode, data.AttributeId, data.AttributeName, this.valueStr);
                                var tarId = "AttributeValue" + this.valueId;
                                targetInput = $(targetInput);
                                targetInput.attr(‘name‘, "AttributeValue" + this.attributeId);
                                targetInput.attr(‘value‘, this.valueId);
                                targetInput.attr(‘id‘, tarId);
                                targetInput.css(‘cursor‘, ‘pointer‘);
                                target.find(‘#li_‘ + this.valueId).append(targetInput).append(
                                $(attributeLabelHTML.format(tarId, this.valueStr, cutstr(this.valueStr,10))).css(‘cursor‘, ‘pointer‘));
                                //target.find(‘#AttributeContent‘).append(targetInput).append(
                                //$(attributeLabelHTML.format(tarId, this.valueStr)).css(‘cursor‘, ‘pointer‘));
                                target.find(‘#AttributeContent‘).append(‘</li>‘);
                            });
                        }
                        // inputType
                        contetAttributesEx.append(target);
                         attributesTR.show();
                    });
                    break;
                default:
                    break;
            }
        }, error: function (xmlHttpRequest, textStatus, errorThrown) {
            alert(xmlHttpRequest.responseText);
        }
    });
}

//截取字符串
function cutstr(str, len) {
    var str_length = 0;
    var str_len = 0;
    if (!str) {
        return "";
    }
   var str_cut = new String();
    str_len = str.length;
    for (var i = 0; i < str_len; i++) {
        var a = str.charAt(i);
        str_length++;
        if (escape(a).length > 4) {
            //中文字符的长度经编码之后大于4
            str_length++;
        }
        str_cut = str_cut.concat(a);
        if (str_length >= len) {
            str_cut = str_cut.concat("...");
            return str_cut;
        }
    }
    //如果给定字符串小于指定长度,则返回源字符串;
    if (str_length < len) {
        return str;
    }
}

var definepic = "";
function LoadSKUs() {
    $.ajax({
        url: ("/ShopManage.aspx?timestamp={0}").format(new Date().getTime()),
        type: ‘POST‘,
        dataType: ‘json‘,
        timeout: 10000,
        async: false,
        data: { Action: "GetAttributesList", DataMode: 1, ProductTypeId: hfCurrentProductType.val() },
        //        beforeSend: function () {
        //            $.jBox.tip("努力为您加载中,请稍后...", ‘loading‘);
        //        },
        //        complete: function () {
        //            $.jBox.closeTip();
        //        },
        success: function (resultData) {
            switch (resultData.STATUS) {
                case "SUCCESS":
                    contetSKUs.find(‘table‘).remove();
                    if (contetSKUs.find(‘h2‘).length > 0) {
                        contetSKUs.find(‘h2‘).remove();
                    }
                    skusTR.hide();
                    if ($(resultData.DATA).length == 0) {
                        contetSKUs.append(alertMessageHTML.format(‘此商品类型没有设置规格!‘));
                    } else {
                        $(resultData.DATA).each(function () {
                            var data = this;
                            var target = $(attributHTML.format(
                                data.AttributeId, data.AttributeUsageMode, data.AttributeId,
                                data.AttributeName));
                            var inputMode = attributInputMode.CheckBox;
                            $(data.AttributeValues).each(function () {

                                target.find(‘#AttributeContent‘).append(‘<li id="li_‘ + this.valueId + ‘">‘);
                                var targetInput = attributInputHTML.format(inputMode);
     &nbs

以上是关于ProductAdd.helper.js的主要内容,如果未能解决你的问题,请参考以下文章