Authored by 梁志锋

resolve conflict for mergerequest codereview by guanning

/**
* 购买咨询的提交页
* @author: liangzhifeng<zhifeng.liang@yoho.cn>
* @date: 2015/12/01
*/
var $ = require('jquery'),
tip = require('../../plugin/tip');
var $consultForm = $('.consult-form');
// 提交表单请求
$consultForm.on('submit', function() {
if (isSubmiting) {
return false;
}
// 简单的表单校验
if (!$(content).val()) {
tip.show('咨询内容不能为空');
return false;
}
isSubmiting = true;
loading.showLoadingMask();
$.ajax({
method: 'POST',
url: '/product/detail/consultsubmit',
data: $(this).serialize()
}).then(function(res) {
if ($.type(res) !== 'object') {
res = {};
}
if (res.code !== 200) {
tip.show(res.message || '网络出了点问题~');
isSubmiting = false;
loading.hideLoadingMask();
} else {
window.location.href = '/product/detail/index';
}
}).fail(function() {
tip.show('网络出了点问题~');
isSubmiting = false;
});
return false;
});