marketing.Vip.Add.js 1.95 KB
webpackJsonp([92],[
/* 0 */
/***/ function(module, exports, __webpack_require__) {

	var $ = __webpack_require__(1);
	var edit = __webpack_require__(6);

	var e = new edit("#basicForm");

	e.on("bind", function () {
	    $("select").change(function () {
	        if ($(this).is($("#type1"))) {
	            $("#type").val($("#type1").val());
	        }
	    });
	});

	e.on("bind", function () {
	    $("select").change(function () {
	        if ($(this).is($("#num1"))) {
	            $("#num").val($("#num1").val());
	        }

	    });
	});

	e.on("validate", function () {
	    var title = $.trim($("#title").val());
	    if (/[~#^$@%&!*]/gi.test(title)) {
	        return "名称不能包含特殊字符";
	    }
	    return true;
	});

	e.on("validate", function () {
	    var beginOperateTime = $.trim($("#beginOperateTime").val());
	    var endOperateTime = $.trim($("#endOperateTime").val());
	    if (new Date(endOperateTime) <= new Date(beginOperateTime)) {
	        return "开始时间不能小于结束时间";
	    }
	    return true;
	});

	e.init();


	//提交
	var submit = function (callback) {
	    e.submit($("#basicForm").attr("action"), function (option) {
	        option.success = function (res) {
	            if (res.code == "200") {
	                e.$tip('提交成功', function () {
	                    location.href = "/market/vipamount/index";
	                }, 'growl-success');
	            } else {
	                e.$tip(res.message);
	            }
	            return false;
	        };
	        option.error = function () {
	            e.$tip("提交失败");
	        };
	        option.data.startTime = new Date(option.data.startTime.replace(/-/g, '/')).getTime() / 1000;
	        option.data.endTime = new Date(option.data.endTime.replace(/-/g, '/')).getTime() / 1000;
	        callback && callback(option.data);
	    });
	};

	$("#save_brand").click(function () {
	    submit(function (data) {

	    });
	    return false;
	});

/***/ }
]);