|
|
@@ -182,6 +182,126 @@
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
+ function checkTel (tel) {
|
|
|
+ var telObj = {}
|
|
|
+ if (/^1(3|4|5|7|8)\d{9}$/.test(tel)) {
|
|
|
+ telObj.type = '移动电话'
|
|
|
+ telObj.typeNumber = 1
|
|
|
+ telObj.isPass = true
|
|
|
+ } else if (/^0\d{2,3}-?\d{7,8}$/.test(tel)) {
|
|
|
+ telObj.type = '固定电话'
|
|
|
+ telObj.typeNumber = 2
|
|
|
+ telObj.isPass = true
|
|
|
+ } else {
|
|
|
+ telObj.type = '不是有效的电话号码!'
|
|
|
+ telObj.typeNumber = 0
|
|
|
+ telObj.isPass = false
|
|
|
+ }
|
|
|
+ return telObj
|
|
|
+ }
|
|
|
+ function checkEmail (email) {
|
|
|
+ return (/^[A-Za-z\d]+([-_.][A-Za-z\d]+)*@([A-Za-z\d]+[-.])+[A-Za-z\d]{2,5}$/.test(email))
|
|
|
+ }
|
|
|
+ function changeContact() {
|
|
|
+ var contractValue = $(".feedback_right input[dataValue='contact']").val()
|
|
|
+ if (contractValue == '') {
|
|
|
+ $(".feedback_right input[dataValue='contact']").addClass("is_error")
|
|
|
+ $(".feedback_error[dataValue='contact']").text('请输入联系人')
|
|
|
+ return false
|
|
|
+ } else if (contractValue.length >10 || contractValue.length < 2) {
|
|
|
+ $(".feedback_right input[dataValue='contact']").addClass("is_error")
|
|
|
+ $(".feedback_error[dataValue='contact']").text('长度在2-10个字符')
|
|
|
+ return false
|
|
|
+ } else {
|
|
|
+ $(".feedback_right input[dataValue='contact']").removeClass("is_error")
|
|
|
+ $(".feedback_error[dataValue='contact']").text('')
|
|
|
+ return true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ function changeTel() {
|
|
|
+ var teltValue = $(".feedback_right input[dataValue='tel']").val()
|
|
|
+ if (teltValue == '') {
|
|
|
+ $(".feedback_right input[dataValue='tel']").addClass("is_error")
|
|
|
+ $(".feedback_error[dataValue='tel']").text('请输入电话')
|
|
|
+ return false
|
|
|
+ } else {
|
|
|
+ var checkTelObj = checkTel(teltValue)
|
|
|
+ if (!checkTelObj.isPass) {
|
|
|
+ $(".feedback_right input[dataValue='tel']").addClass("is_error")
|
|
|
+ $(".feedback_error[dataValue='tel']").text(checkTelObj.type)
|
|
|
+ return false
|
|
|
+ } else {
|
|
|
+ $(".feedback_right input[dataValue='tel']").removeClass("is_error")
|
|
|
+ $(".feedback_error[dataValue='tel']").text('')
|
|
|
+ return true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ function changeEmail() {
|
|
|
+ var emailValue = $(".feedback_right input[dataValue='email']").val()
|
|
|
+ if (emailValue == '') {
|
|
|
+ $(".feedback_right input[dataValue='email']").addClass("is_error")
|
|
|
+ $(".feedback_error[dataValue='email']").text('请输入邮箱')
|
|
|
+ return false
|
|
|
+ } else {
|
|
|
+ var checkEmailObj = checkEmail(emailValue)
|
|
|
+ if (!checkEmailObj) {
|
|
|
+ $(".feedback_right input[dataValue='email']").addClass("is_error")
|
|
|
+ $(".feedback_error[dataValue='email']").text('请输入正确的邮箱地址')
|
|
|
+ return false
|
|
|
+ } else {
|
|
|
+ $(".feedback_right input[dataValue='email']").removeClass("is_error")
|
|
|
+ $(".feedback_error[dataValue='email']").text('')
|
|
|
+ return true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ function changeContent() {
|
|
|
+ var contentValue = $(".feedback_right textarea[dataValue='content']").val()
|
|
|
+ if (contentValue == '') {
|
|
|
+ $(".feedback_right textarea[dataValue='content']").addClass("is_error")
|
|
|
+ $(".feedback_error[dataValue='content']").text('请输入反馈内容')
|
|
|
+ return false
|
|
|
+ } else if (contentValue.length > 500 || contentValue.length < 5) {
|
|
|
+ $(".feedback_right textarea[dataValue='content']").addClass("is_error")
|
|
|
+ $(".feedback_error[dataValue='content']").text('长度在5-500个字符')
|
|
|
+ return false
|
|
|
+ } else {
|
|
|
+ $(".feedback_right textarea[dataValue='content']").removeClass("is_error")
|
|
|
+ $(".feedback_error[dataValue='content']").text('')
|
|
|
+ return true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ function feedbackCancel() {
|
|
|
+ $(".tips-popup").hide();
|
|
|
+ }
|
|
|
+ function feedbackSubmit() {
|
|
|
+ changeContact()
|
|
|
+ changeTel()
|
|
|
+ changeEmail()
|
|
|
+ changeContent()
|
|
|
+ var submitResult = changeContact() && changeTel() && changeEmail() && changeContent()
|
|
|
+ if (submitResult) {
|
|
|
+ $.ajax({
|
|
|
+ url: 'http://' + window.location.host+ '/api/serviceleague/f/v1/feedback',
|
|
|
+ type: "post",
|
|
|
+ dataType: "json",
|
|
|
+ data:{
|
|
|
+ "applyContent": $(".feedback_right textarea[dataValue='content']").val(),
|
|
|
+ "applyEmail": $(".feedback_right input[dataValue='email']").val(),
|
|
|
+ "applyName": $(".feedback_right input[dataValue='contact']").val(),
|
|
|
+ "applyPhone": $(".feedback_right input[dataValue='tel']").val(),
|
|
|
+ },
|
|
|
+ success: function (result) {
|
|
|
+ succeedMessage('反馈成功')
|
|
|
+ $(".tips-popup").hide();
|
|
|
+ },
|
|
|
+ error: function () {
|
|
|
+ errorMessage('反馈失败')
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
</script>
|
|
|
</head>
|
|
|
<body>
|