//高德地图
var map = new AMap.Map("container", {
    zoom: 30,
    center: [113.241678, 22.69780]
    // center:[113.241538,22.698132]
});
var marker = new AMap.Marker({
    position: new AMap.LngLat(113.241678, 22.69780),
    title: "高路华"
});
map.add(marker)




function ajaxPost(type, addMsgApi, captchaApi) {
    let message_content;
    let message_name;
    let message_phone;
    let message_mail;
    let message_address;
    let captcha;

    if (type == 'pc') {
        message_content = $('textarea[name="message_content"]').val();
        message_name = $('input[name="message_name"]').val();
        message_phone = $('input[name="message_phone"]').val();
        message_mail = $('input[name="message_mail"]').val();
        message_address = $('input[name="message_address"]').val();
        captcha = $('input[name="captcha"]').val();
    } else {
        message_content = $('textarea[name="message_content_app"]').val();
        message_name = $('input[name="message_name_app"]').val();
        message_phone = $('input[name="message_phone_app"]').val();
        message_mail = $('input[name="message_mail_app"]').val();
        message_address = $('input[name="message_address_app"]').val();
        captcha = $('input[name="captcha_app"]').val();
    }


    console.log('表单数据');
    $.ajax({
        url: addMsgApi,
        type: "POST",
        data: {
            message_content: message_content,
            message_name: message_name,
            message_phone: message_phone,
            message_mail: message_mail,
            message_address: message_address,
            captcha: captcha,
        },
        success: function (data) {
            if (data.code == 0) {
                alert(data.msg);
            } else {
                alert(data.msg);
            }
            //留言后刷新验证码
            if (type == 'pc') {
                $('#msg_code').attr("src", captchaApi + '?' + Math.random())
            } else {
                $('#msg_code_app').attr("src", captchaApi + '?' + Math.random())
            }
        }

    })
}

