bannerEdit.js 3.61 KB
'use strict';
var $ = require('jquery'),
    common = require('../../../common/common');

require('../../../common/umeditor.config');
require('../../../common/umeditor');
require('../../../common/zh-cn');
var edit = require('../../../common/edit');


var UMdescriptioner = UM.getEditor('banner');
UMdescriptioner.setContent($("#searchBanner").val());


var mainData = window.ViewModel;
console.log(mainData);
var e = new edit("#basicForm", {bucket: "goodsimg"});
e.on("validate", function () {    
    if ($.trim($('#caption').val()) === ''){
        return "名称不能为空";
    }
    if ($.trim(UMdescriptioner.getContent()) === ''){
        return "内容不能为空";
    }
    return true;
});
e.init();

$(document).on('click','#save_banner',function () {
    e.submit($("#basicForm").attr("action"), function (option) {        
        option.data.data = UMdescriptioner.getContent();
        
        option.success = function (res) {
            if (res.code == "200") {
                e.$tip("提交成功", function () {
                    location.href = "/search/bannerIndex"
                }, 'growl-success');
            } else {
                e.$tip(res.message);
            }
            return false;
        };
        option.error = function (res) {
            e.$tip(res.message);
        };
        console.log(option.data);
    });
    return false;

});

// 初始化品类
/*品类初始化*/
var SORTDATA={
    url:"/goods/query/querySortBySmallSort",
    datas:[
        {id:mainData.maxSortId, sortName:mainData.maxSortName},
        {id:mainData.middleSortId, sortName:mainData.middleSortName},
        {id:mainData.smallSortId, sortName:mainData.smallSortName},
        {id:mainData.sortId, sortName:mainData.sortName}
    ],
    otherParam:function(){
        return {}
    },
    complete:function(data, bool){
        if(!bool){
            /*if(data.length>2){
                Bll.productNameArr[2]=data[data.length-1].sortName;
                Bll.setProductName();
            }
            if(data[0]&&data[0].text&&data[0].text.indexOf("潮童")>-1){
                $("#ageLevel").val("2|3|4|5");
            }else{
                $("#ageLevel").val("1");
            }
            $(":checkbox[name=ageLevel]").prop("checked",false);
            $(":checkbox[name=ageLevel]").each(function(){
                var name=$("#ageLevel").val();
                if(name.indexOf($(this).val())>-1){
                    $(this).prop("checked",true)
                }
            });*/
        }
    },
};
var tabTree=new common.tabTree("#sortTree",SORTDATA);
tabTree.isfeeze=true;
tabTree.init(SORTDATA.datas);

new common.dropDown({el:"#postionId", ajax:"searchPostion", params:function(){
    return {postionId:$("#postionId").val()};
}});
new common.dropDown({el:"#templetId",ajax:"searchTemplet",params:function(){
    return {templetId:$("#templetId").val()};
}});
new common.dropDown({el:"#sizeId",ajax:"sortsize",params:function(){
    return {sizeId:$("#sizeId").val()};
}});


// 初始化风格的多选框
common.util.__ajax({
    url: '/operations/search/queryAllStyle',
    data: {
        //categoryId: basicInfo.smallSortId
    }
},function(res){
        var data = res;
        data.selectStyle = mainData.style;
        $('#styleDiv').html(common.util.__template2($('#templateStyle').html(), data));
},true);


// 初始化颜色单选选项列表
common.util.__ajax({
    url: '/basegoods/queryProductColors',
    data: {
    }
},function(res){
        var colorList = res.data;
        colorList.selectColor = mainData.color;
        $('#colorDiv').html(common.util.__template2($('#templateColor').html(), colorList));
},true);