$(document).ready(function () {
    var app = {
        methods: {
            get: function () {
                $.ajax({
                    url: 'mgm/setting',
                    method: 'GET',
                    success: function (content) {
                        if (content.success) {
                            var data = content.data;
                            data && $('#corpIdInput').val(data.corpId);
                        } else {
                            alert(content.message);
                        }
                    }
                });
            },
            save: function () {
                $.ajax({
                    url: 'mgm/setting/corp',
                    method: 'POST',
                    data: $('#form').serialize(),
                    success: function (content) {
                        if (content.success) {
                            alert('保存成功');
                            window.location.reload();
                        } else {
                            alert(content.message);
                        }
                    }
                });
            }
        },
        init: function () {
            $('.btn-save').click(function(){
                app.methods.save();
            });

            app.methods.get();
        }
    };

    app.init();
});