operations.webshare.Edit.js 1.32 KB
webpackJsonp([98],[
/* 0 */
/***/ function(module, exports, __webpack_require__) {

	/**
	 * Created by ty on 2016/7/6.
	 * 活动分享编辑
	 */

	var $ = __webpack_require__(1),
	    common = __webpack_require__(2);

	var id = $("#edit-content").data("id"),
	    url = $("#edit-content").attr("url"),
	    module = {},
	    edit = new common.edit2("#edit-content",{bucket: "taobaocms"});

	if(id) {
	    common.util.__ajax({
	        async: false,
	        url: "/webShare/selectWebShare",
	        data: {id: id}
	    }, function (res) {
	        module = res.data;
	    },true);
	}

	$("#edit-content").html(common.util.__template2($("#edit-template").html(), module));
	edit.init();
	edit.on("file_onComplete", function (obj) {
	    module[obj.field] = obj.data;
	});
	if(id) {
	    $("#choose-status").show();
	    new common.dropDown({el: "#status"});
	}

	//监听数据变化
	$(document).on("change", ".observe", function () {
	    module[$(this).data("field")] = $(this).val();
	});

	//保存数据
	$(document).on("click", "#save_btn", function () {
	    if(edit.validate()) {
	        common.util.__ajax({
	            url: url,
	            data: module
	        }, function () {
	            setTimeout(function () {
	                location.href = "/operations/webshare/index";
	            },600);
	        });
	    }
	});

/***/ }
]);