$(document).ready(function() {
|
let url = 'http://121.41.112.139:8099'
|
var product = null
|
|
$.ajax({
|
async: false,
|
url: 'http://www.dmtt.run:81/web/productList',
|
type: 'POST',
|
success: function (res) {
|
console.log(res)
|
let options = document.getElementById('options')
|
for (const item of res.data) {
|
$('#options').append(new Option(item.name, item.id))
|
}
|
},
|
error: function (error) {
|
console.log(error)
|
}
|
})
|
});
|
function submitInfo() {
|
let name = $('#name').val()
|
let product = $('#options').val()
|
let phone = $('#phone').val()
|
let email = $('#email').val()
|
var tableTop = $('#name').offset().top;
|
if (!product) {
|
$(document).scrollTop(tableTop);
|
alert('请选择产品名称')
|
return
|
}
|
if (!name) {
|
$(document).scrollTop(tableTop);
|
$('#name').focus()
|
alert('请输入姓名')
|
return
|
}
|
if (!phone) {
|
$(document).scrollTop(tableTop);
|
$('#phone').focus()
|
alert('请输入电话')
|
return
|
}
|
$.ajax({
|
url: 'http://www.dmtt.run:81/web/createCustomer',
|
data: JSON.stringify({
|
productId: product,
|
name: name,
|
phone: phone,
|
email: email
|
}),
|
type: "post",
|
dataType: "json",
|
crossDomain: true,
|
contentType: "application/json",
|
success: function (res) {
|
if (res.code !== 200) {
|
alert(res.message)
|
return
|
}
|
alert('您好,您的数据已提交,我们会尽快回复您!')
|
$('#name').val('');
|
$('#phone').val('');
|
$('#email').val('');
|
$('.filter-title').val('')
|
product = null
|
},
|
error: function (error) {
|
alert('提交失败!')
|
}
|
});
|
}
|