<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">$('#loginCatcha').click(function () {
    $(this).attr('src', "/user/login/captchalogin.html" + '?t=' + Math.random());
});
$('#regCatcha').click(function () {
    $(this).attr('src', "/user/login/captcharegister.html" + '?t=' + Math.random());
});
// 鏄剧ず鐧诲綍绐楀彛
function showLogin(type='login') {
    if(type=='login'){
        $('.login-model').show();
    }else{
        $('.reg-model').show();
    }
    layer.open({
        type: 1,
        shade: 0.8,
        title: false, //涓嶆樉绀烘爣棰�
        content: $('.login-box'),
        end: function () {
            $('.login-model').hide();
            $('.reg-model').hide();
        }
    });
}
// 鍒囨崲鐧诲綍娉ㄥ唽
function tabLogin(type='login') {
    if(type == 'login'){
        $('.login-model').show();
        $('.reg-model').hide();
    }else{
        $('.login-model').hide();
        $('.reg-model').show();
    }
}

function login(){
    let data = {
        phone: $("#phone_login").val(),
        password: $("#password_login").val(),
        captcha: $("#code_login").val()
    };
    // 鏍￠獙琛ㄥ崟鏁版嵁 鎵嬫満鍙风爜鏍￠獙
    if (data.phone === '' || !checkPhone(data.phone)) {
        layer.alert('璇疯緭鍏ユ纭殑鎵嬫満鍙风爜', {icon: 2});
        return false;
    }
    if (data.password === '') {
        layer.alert('璇疯緭鍏ュ瘑鐮�', {icon: 2});
        return false;
    }
    if (data.captcha === '') {
        layer.alert('璇疯緭鍏ラ獙璇佺爜', {icon: 2});
        return false;
    }
    $.post("/user/login/login.html", data, function (ret, status) {
        if (ret.code === 1) {
            location.reload()
        } else {
            layer.alert(ret.msg, {icon: 2});
            $("#loginCatcha").click();
        }
    });
}
function checkPhone(phone) {
    let reg = /^1[3456789]\d{9}$/;
    return reg.test(phone);
}
// 鍙戦€佺煭淇�
function sendSms() {
    let phone = $("#phone_reg").val();
    let captcha = $("#code_reg").val();
    if (phone === '' || !checkPhone(phone)) {
        layer.alert('璇疯緭鍏ユ纭殑鎵嬫満鍙风爜', {icon: 2});
        return false;
    }
    if (captcha === '') {
        layer.alert('璇疯緭鍏ラ獙璇佺爜', {icon: 2});
        return false;
    }
    var load_index = layer.load(1, {
        shade: [0.1,'#fff'] //0.1閫忔槑搴︾殑鐧借壊鑳屾櫙
    });
    $.post("/user/login/sendsms.html", {phone: phone, captcha: captcha}, function (ret, status) {
        layer.close(load_index);
        if (ret.code === 1) {
            $("#send_sms_btn").attr('disabled', true);
            countDown();
            //layer.alert(ret.msg, {icon: 1});
        } else {
            $("#regCatcha").click();
            layer.alert(ret.msg, {icon: 2});
        }
    });
}
// 鍙戦€佺煭淇″悗楠岃瘉鐮佸€掕鏃�
function countDown() {
    let count = 120;
    let timer = setInterval(function () {
        if (count &gt; 0) {
            count--;
            $("#send_sms_btn").text(count + '绉掑悗閲嶅彂');
            $("#send_sms_btn").attr('disabled', true);
        } else {
            clearInterval(timer);
            $("#send_sms_btn").text('鍙戦€佺煭淇�');
            $("#send_sms_btn").attr('disabled', false);
        }
    }, 1000);
}
// 娉ㄥ唽
function register() {
    let data = {
        phone: $("#phone_reg").val(),
        password: $("#password_reg").val(),
        captcha: $("#code_reg").val(),
        smscode: $("#formSmsCode").val()
    };
    // 鏍￠獙琛ㄥ崟鏁版嵁 鎵嬫満鍙风爜鏍￠獙
    if (data.phone === '' || !checkPhone(data.phone)) {
        layer.alert('璇疯緭鍏ユ纭殑鎵嬫満鍙风爜', {icon: 2});
        return false;
    }
    if (data.password === '') {
        layer.alert('璇疯緭鍏ュ瘑鐮�', {icon: 2});
        return false;
    }
    if (data.captcha === '') {
        layer.alert('璇疯緭鍏ラ獙璇佺爜', {icon: 2});
        return false;
    }
    if (data.smscode === '') {
        layer.alert('璇疯緭鍏ョ煭淇￠獙璇佺爜', {icon: 2});
        return false;
    }
    $.post("/user/login/register.html", data, function (ret, status) {
        if (ret.code === 1) {
            layer.alert(ret.msg, {
                icon: 1,
                time: 1500,
                end: function () {
                    location.reload()
                }
            });
        } else {
            layer.alert(ret.msg, {icon: 2});
            $("#regCatcha").click();
        }
    });
}

function outlogin(){
    $.post("/user/login/logout.html", {}, function (ret, status) {
        location.reload()
    });
}</pre></body></html>