doum
2025-09-23 920ad7c1062549f8ff6e5034f84a90c725dc89dd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
$(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('提交失败!')
            }
        });
    }