`
$(".popup-box").append(loading);
var content = $("#questionContent").val().trim();
if (!content) {
$(".loading-pos").remove();
alert("请输入提问内容");
return;
}
if (content.length < 5 || content.length > 60) {
$(".loading-pos").remove();
alert("提问内容请填写5到60个字");
return;
}
if (!$(".form-code").is(":hidden")) {
if (!checkCodeTel($(".form-tel input").val(), $(".form-code input").val())) {
$(".loading-pos").remove();
return;
}
}
var phoneNum = $(".form-tel input").val();
var code = $(".form-code input").val();
var category = '500015021';
var city = '';
var cookieid = typeof (P_Tongji_SessionID) == 'undefined' ? "" : P_Tongji_SessionID;
var adunion = $.cookie("adunion");
var unionid = "0";
if (adunion && /uid=(\d+)/.test(adunion)) {
unionid = /uid=(\d+)/.exec(adunion)[1];
}
///edu/comHandler.ashx
$.ajax({
url: `/wen/Home/PostQuestion`,
type: 'post',
dataType: 'json',
data: { content: encodeURIComponent(content), category: category, city: city, phone: phoneNum, code: code, cookieid: cookieid, unionid: unionid, url: encodeURIComponent(url) },
success: function (r) {
console.log(r);
if (r.code == 200) {
$(".popup-layer").remove();
if (r.data) {
tipLayer("提问成功", r.data);
}
else {
alert("提问成功,提问将在审核通过后自动发布");
}
}
else {
alert(r.msg);
}
$(".loading-pos").remove();
},
error: function () {
alert('发生异常,请稍后重试或联系客服');
$(".loading-pos").remove();
}
});
})
// 验证输入的手机号码格式
function checkPhone(tel) {
var phoneReg = /^1\s*[0123456789]\s*(\d\s*){9}$/
if (tel == "") {
alert('请输入手机号')
return
} else if (phoneReg.test(tel) == false) {
alert('请输入正确的手机号')
return
} else {
return true
}
}
// 验证手机号和验证码不为空
function checkCodeTel(tel, code) {
var phoneReg = /^1\s*[0123456789]\s*(\d\s*){9}$/;
var codeReg = /^[0-9]*$/;
if (!tel) {
alert('请输入手机号')
return false
} else if (!phoneReg.test(tel)) {
alert('请输入正确的手机号')
return false
} else if (code == "") {
alert('请输入验证码')
return false
} else if (!codeReg.test(code)) {
alert('请输入正确的验证码')
return false
} else {
return true
}
}
});
$(document).on("change", ".popup-box input[name='bxk-notice']", function () {
if ($(this).prop("checked")) {
$(this).parent(".bxk-notice").siblings("div").find(".question-submit-btn").removeClass("bxk-disable");
} else {
$(this).parent(".bxk-notice").siblings("div").find(".question-submit-btn").addClass("bxk-disable");
}
})