indexEdit.js 4.2 KB
var myLocateInfo = {};
var locations = {};
var direction = "";
var map = null,
    geocoder = null,
    geolocation = null;
var isLoading = false;
var urls = {
    "get": "/wanmei/seriesinfo/get",
    "save": "/wanmei/seriesinfo/save",
    "update": "/wanmei/seriesinfo/update",
    "fileupdate": "/wanmei/file/upload"
};

// 站点的信息
var stationList = null;
// 会议信息,用来做比对。
var meetingObject = null;

openMenu("meeting.html");

var indexEdit = {};


indexEdit.get = function() {
    var id = _getQueryString("id");
    var data = { id: id };
    $.ajax({
        "url": _REQUESTURL + urls.get,
        "data": data,
        "success": function(res) {
            if (res.success && res.code == 2000) {
                if (res.content) {
                    $("#series_name").attr("data-id", res.content.id);
                    $("#series_name").val(res.content.series_name);
                    $("#commercial").val(res.content.commercial);
                    $("#product_height_1").val(res.content.product_height_1);
                    $("#product_height_2").val(res.content.product_height_2);
                    $("#product_width_1").val(res.content.product_width_1);
                    $("#product_width_2").val(res.content.product_width_2);
                    $("#p_product_url_1").attr("src", res.content.product_url_1);
                    $("#p_product_url_2").attr("src", res.content.product_url_2);
                    $("#product_id").val(res.content.product_id);
                } else {}
            } else {
                alert("系统错误");
            }
        }
    });
}
indexEdit.get();

//上传图片
function uploadPic(obj, type, index, id) {

};



function initSelector() {
    if (stationList != null && meetingObject != null) {
        changeSelector();
    }
}

(function() {

    $("#save").on("click", function() {
        var id = $("#series_name").attr("data-id");
        var series_name = $("#series_name").val();
        var commercial = $("#commercial").val();
        var product_height_1 = $("#product_height_1").val();
        var product_height_2 = $("#product_height_2").val();
        var product_width_1 = $("#product_width_1").val();
        var product_width_2 = $("#product_width_2").val();
        var product_url_1 = $("#p_product_url_1").attr("src");
        var product_url_2 = $("#p_product_url_2").attr("src");
        var product_id = $("#product_id").val();
        var url = urls.save;
        if (id) {
            url = urls.update;
        } else {
            url = urls.save;
        }
        var data = {
            id: id,
            series_name: series_name,
            product_height_1: product_height_1,
            product_height_2: product_height_2,
            product_width_1: product_width_1,
            product_width_2: product_width_2,
            product_url_1: product_url_1,
            product_url_2: product_url_2,
            commercial: commercial,
            product_id:product_id
        };
        $.ajax({
            "url": _REQUESTURL + url,
            "data": data,
            "success": function(res) {
                if (res.success && res.code == 2000) {
                    alert("保存成功");
                    window.location.href = "index.html";
                } else {
                    alert("系统错误");
                }
            }
        });
    });

    $('#f_product_url_1').fileupload({
        url: "http://mat.marubi.cn" + urls.fileupdate,
        dataType: 'json',
        done: function(e, data) {
            var res = data.result;
            if (res.success && res.code == 2000) {
                $('#p_product_url_1').attr("src", "http://mat.marubi.com.cn/uploads" + res.content.url);
            } else {
                alert("系统错误");
            }

        }
    });

    $('#f_product_url_2').fileupload({
        url: "http://mat.marubi.cn" + urls.fileupdate,
        dataType: 'json',
        done: function(e, data) {
            var res = data.result;
            if (res.success && res.code == 2000) {
                $('#p_product_url_2').attr("src", "http://mat.marubi.com.cn/uploads" + res.content.url);
            } else {
                alert("系统错误");
            }

        }
    });
})();