|  | @@ -1,121 +1,138 @@
 | 
	
		
			
				|  |  | -$(document).ready(function() {
 | 
	
		
			
				|  |  | -    const lSPName = getLocalCache('project_name');
 | 
	
		
			
				|  |  | -    const lSPCode = getLocalCache('project_code');
 | 
	
		
			
				|  |  | -    if (lSPName !== null) {
 | 
	
		
			
				|  |  | -        $('#project_name').text(lSPName);
 | 
	
		
			
				|  |  | -        $('#project').val(lSPCode);
 | 
	
		
			
				|  |  | -        $('#forget-project').val(lSPCode);
 | 
	
		
			
				|  |  | -        $('#account').focus();
 | 
	
		
			
				|  |  | -    }
 | 
	
		
			
				|  |  | -    $("#login-tab a[data-toggle='tab']").on('shown.bs.tab', function () {
 | 
	
		
			
				|  |  | -        let type = $(this).data('type');
 | 
	
		
			
				|  |  | -        type = parseInt(type);
 | 
	
		
			
				|  |  | -        type = isNaN(type) || type <= 0 ? 1 : type;
 | 
	
		
			
				|  |  | -        $("input[name='type']:hidden").val(type);
 | 
	
		
			
				|  |  | -    });
 | 
	
		
			
				|  |  | -    // $('#username').blur(function () {
 | 
	
		
			
				|  |  | -    //     let account = $(this).val();
 | 
	
		
			
				|  |  | -    //     // 判断输入的邮箱/手机是否格式正确
 | 
	
		
			
				|  |  | -    //     if(/^1[3456789]\d{9}$/.test(account) || /^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$/.test(account)) {
 | 
	
		
			
				|  |  | -    //         $('#error-msg').hide();
 | 
	
		
			
				|  |  | -    //     } else {
 | 
	
		
			
				|  |  | -    //         $('#error-msg').show();
 | 
	
		
			
				|  |  | -    //         $('#error-msg').text('账号格式有误');
 | 
	
		
			
				|  |  | -    //     }
 | 
	
		
			
				|  |  | -    // })
 | 
	
		
			
				|  |  | -    $('#project').blur(function () {
 | 
	
		
			
				|  |  | -        if ($(this).val() == '') {
 | 
	
		
			
				|  |  | -            $('#project_name').text('');
 | 
	
		
			
				|  |  | -            $('#forget-project').val('');
 | 
	
		
			
				|  |  | -            removeLocalCache('project_code');
 | 
	
		
			
				|  |  | -            removeLocalCache('project_name');
 | 
	
		
			
				|  |  | -        } else {
 | 
	
		
			
				|  |  | -            const pcode = getLocalCache('project_code');
 | 
	
		
			
				|  |  | -            if ($(this).val() !== pcode) {
 | 
	
		
			
				|  |  | -                const pc = $(this).val();
 | 
	
		
			
				|  |  | -                $.ajax({
 | 
	
		
			
				|  |  | -                    type: 'get',
 | 
	
		
			
				|  |  | -                    url: '/project/name',
 | 
	
		
			
				|  |  | -                    data: { code: pc },
 | 
	
		
			
				|  |  | -                    dataType: 'json',
 | 
	
		
			
				|  |  | -                    success: function (result) {
 | 
	
		
			
				|  |  | -                        setLocalCache('project_code', pc);
 | 
	
		
			
				|  |  | -                        if (result.err === 1) {
 | 
	
		
			
				|  |  | -                            $('#project_name').text('');
 | 
	
		
			
				|  |  | -                            $('#forget-project').val('');
 | 
	
		
			
				|  |  | -                            console.log(result.msg);
 | 
	
		
			
				|  |  | -                            toast(result.msg, 'error', 'exclamation-circle');
 | 
	
		
			
				|  |  | -                            removeLocalCache('project_name');
 | 
	
		
			
				|  |  | -                        } else {
 | 
	
		
			
				|  |  | -                            setLocalCache('project_name', result.data);
 | 
	
		
			
				|  |  | -                            $('#project_name').text(result.data);
 | 
	
		
			
				|  |  | -                            $('#forget-project').val(pc);
 | 
	
		
			
				|  |  | -                        }
 | 
	
		
			
				|  |  | -                    }
 | 
	
		
			
				|  |  | -                })
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -    });
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -    $('#forget-btn').click(function () {
 | 
	
		
			
				|  |  | -        let flag = true;
 | 
	
		
			
				|  |  | -        if ($('#forget-project').val() == '') {
 | 
	
		
			
				|  |  | -            $('#forget-project').addClass('is-invalid');
 | 
	
		
			
				|  |  | -            $('#forget-project').siblings('div.invalid-feedback').html('项目编号不能为空。');
 | 
	
		
			
				|  |  | -            flag = false;
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -        if ($('#forget-name').val() == '') {
 | 
	
		
			
				|  |  | -            $('#forget-name').addClass('is-invalid');
 | 
	
		
			
				|  |  | -            $('#forget-name').siblings('div.invalid-feedback').html('登录账号不能为空。');
 | 
	
		
			
				|  |  | -            flag = false;
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -        if(flag) {
 | 
	
		
			
				|  |  | -            $.ajax({
 | 
	
		
			
				|  |  | -                type: 'post',
 | 
	
		
			
				|  |  | -                url: '/reset/password',
 | 
	
		
			
				|  |  | -                data: { code: $('#forget-project').val(), name: $('#forget-name').val() },
 | 
	
		
			
				|  |  | -                dataType: 'json',
 | 
	
		
			
				|  |  | -                beforeSend: function(xhr) {
 | 
	
		
			
				|  |  | -                    let csrfToken = csrf;
 | 
	
		
			
				|  |  | -                    xhr.setRequestHeader('x-csrf-token', csrfToken);
 | 
	
		
			
				|  |  | -                },
 | 
	
		
			
				|  |  | -                success: function (result) {
 | 
	
		
			
				|  |  | -                    if (result.err === 1) {
 | 
	
		
			
				|  |  | -                        if (result.index === 1) {
 | 
	
		
			
				|  |  | -                            $('#forget-project').addClass('is-invalid');
 | 
	
		
			
				|  |  | -                            $('#forget-project').siblings('div.invalid-feedback').html(result.msg);
 | 
	
		
			
				|  |  | -                        } else if (result.index === 2) {
 | 
	
		
			
				|  |  | -                            $('#forget-name').addClass('is-invalid');
 | 
	
		
			
				|  |  | -                            $('#forget-name').siblings('div.invalid-feedback').html(result.msg);
 | 
	
		
			
				|  |  | -                        } else {
 | 
	
		
			
				|  |  | -                            toast(result.msg, 'error');
 | 
	
		
			
				|  |  | -                        }
 | 
	
		
			
				|  |  | -                    } else {
 | 
	
		
			
				|  |  | -                        $('#fg-password-done').find('b').eq(0).text(result.data.name);
 | 
	
		
			
				|  |  | -                        $('#fg-password-done').find('b').eq(1).text(result.data.account);
 | 
	
		
			
				|  |  | -                        $('#fg-password-done').find('b').eq(2).text(result.data.mobile);
 | 
	
		
			
				|  |  | -                        setLocalCache('project_name', result.data.pName);
 | 
	
		
			
				|  |  | -                        setLocalCache('project_code', $('#forget-project').val());
 | 
	
		
			
				|  |  | -                        $('#fg-password').modal('hide');
 | 
	
		
			
				|  |  | -                        $('#fg-password-done').modal('show');
 | 
	
		
			
				|  |  | -                        $('#account').val($('#forget-name').val());
 | 
	
		
			
				|  |  | -                        $('#project').val($('#forget-project').val());
 | 
	
		
			
				|  |  | -                        $('#project_name').text(result.data.pName);
 | 
	
		
			
				|  |  | -                        $('#forget-name').val('');
 | 
	
		
			
				|  |  | -                    }
 | 
	
		
			
				|  |  | -                }
 | 
	
		
			
				|  |  | -            })
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -    })
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -    $('input').focus(function () {
 | 
	
		
			
				|  |  | -        if($(this).hasClass('is-invalid')) {
 | 
	
		
			
				|  |  | -            $(this).removeClass('is-invalid');
 | 
	
		
			
				|  |  | -            $(this).siblings('div.invalid-feedback').html('');
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -    });
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -    $('#focus-pwd').click(function () {
 | 
	
		
			
				|  |  | -        $('#project-password').focus();
 | 
	
		
			
				|  |  | -    })
 | 
	
		
			
				|  |  | -});
 | 
	
		
			
				|  |  | +$(document).ready(function() {
 | 
	
		
			
				|  |  | +    // const lSPName = getLocalCache('project_name');
 | 
	
		
			
				|  |  | +    const lSPCode = getLocalCache('project_code');
 | 
	
		
			
				|  |  | +    if (lSPCode !== null) {
 | 
	
		
			
				|  |  | +        // $('#project_name').text(lSPName);
 | 
	
		
			
				|  |  | +        $('#project').val(lSPCode);
 | 
	
		
			
				|  |  | +        $('#forget-project').val(lSPCode);
 | 
	
		
			
				|  |  | +        $('#account').focus();
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        $.ajax({
 | 
	
		
			
				|  |  | +            type: 'get',
 | 
	
		
			
				|  |  | +            url: '/project/name',
 | 
	
		
			
				|  |  | +            data: { code: lSPCode },
 | 
	
		
			
				|  |  | +            dataType: 'json',
 | 
	
		
			
				|  |  | +            success: function (result) {
 | 
	
		
			
				|  |  | +                if (result.err === 1) {
 | 
	
		
			
				|  |  | +                    $('#project_name').text('');
 | 
	
		
			
				|  |  | +                    $('#forget-project').val('');
 | 
	
		
			
				|  |  | +                    toast(result.msg, 'error', 'exclamation-circle');
 | 
	
		
			
				|  |  | +                } else {
 | 
	
		
			
				|  |  | +                    $('#project_name').text(result.data);
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        })
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    $("#login-tab a[data-toggle='tab']").on('shown.bs.tab', function () {
 | 
	
		
			
				|  |  | +        let type = $(this).data('type');
 | 
	
		
			
				|  |  | +        type = parseInt(type);
 | 
	
		
			
				|  |  | +        type = isNaN(type) || type <= 0 ? 1 : type;
 | 
	
		
			
				|  |  | +        $("input[name='type']:hidden").val(type);
 | 
	
		
			
				|  |  | +    });
 | 
	
		
			
				|  |  | +    // $('#username').blur(function () {
 | 
	
		
			
				|  |  | +    //     let account = $(this).val();
 | 
	
		
			
				|  |  | +    //     // 判断输入的邮箱/手机是否格式正确
 | 
	
		
			
				|  |  | +    //     if(/^1[3456789]\d{9}$/.test(account) || /^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$/.test(account)) {
 | 
	
		
			
				|  |  | +    //         $('#error-msg').hide();
 | 
	
		
			
				|  |  | +    //     } else {
 | 
	
		
			
				|  |  | +    //         $('#error-msg').show();
 | 
	
		
			
				|  |  | +    //         $('#error-msg').text('账号格式有误');
 | 
	
		
			
				|  |  | +    //     }
 | 
	
		
			
				|  |  | +    // })
 | 
	
		
			
				|  |  | +    $('#project').blur(function () {
 | 
	
		
			
				|  |  | +        if ($(this).val() == '') {
 | 
	
		
			
				|  |  | +            $('#project_name').text('');
 | 
	
		
			
				|  |  | +            $('#forget-project').val('');
 | 
	
		
			
				|  |  | +            removeLocalCache('project_code');
 | 
	
		
			
				|  |  | +            removeLocalCache('project_name');
 | 
	
		
			
				|  |  | +        } else {
 | 
	
		
			
				|  |  | +            const pcode = getLocalCache('project_code');
 | 
	
		
			
				|  |  | +            if ($(this).val() !== pcode) {
 | 
	
		
			
				|  |  | +                const pc = $(this).val();
 | 
	
		
			
				|  |  | +                $.ajax({
 | 
	
		
			
				|  |  | +                    type: 'get',
 | 
	
		
			
				|  |  | +                    url: '/project/name',
 | 
	
		
			
				|  |  | +                    data: { code: pc },
 | 
	
		
			
				|  |  | +                    dataType: 'json',
 | 
	
		
			
				|  |  | +                    success: function (result) {
 | 
	
		
			
				|  |  | +                        setLocalCache('project_code', pc);
 | 
	
		
			
				|  |  | +                        if (result.err === 1) {
 | 
	
		
			
				|  |  | +                            $('#project_name').text('');
 | 
	
		
			
				|  |  | +                            $('#forget-project').val('');
 | 
	
		
			
				|  |  | +                            console.log(result.msg);
 | 
	
		
			
				|  |  | +                            toast(result.msg, 'error', 'exclamation-circle');
 | 
	
		
			
				|  |  | +                            removeLocalCache('project_name');
 | 
	
		
			
				|  |  | +                        } else {
 | 
	
		
			
				|  |  | +                            setLocalCache('project_name', result.data);
 | 
	
		
			
				|  |  | +                            $('#project_name').text(result.data);
 | 
	
		
			
				|  |  | +                            $('#forget-project').val(pc);
 | 
	
		
			
				|  |  | +                        }
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                })
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +    });
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    $('#forget-btn').click(function () {
 | 
	
		
			
				|  |  | +        let flag = true;
 | 
	
		
			
				|  |  | +        if ($('#forget-project').val() == '') {
 | 
	
		
			
				|  |  | +            $('#forget-project').addClass('is-invalid');
 | 
	
		
			
				|  |  | +            $('#forget-project').siblings('div.invalid-feedback').html('项目编号不能为空。');
 | 
	
		
			
				|  |  | +            flag = false;
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        if ($('#forget-name').val() == '') {
 | 
	
		
			
				|  |  | +            $('#forget-name').addClass('is-invalid');
 | 
	
		
			
				|  |  | +            $('#forget-name').siblings('div.invalid-feedback').html('登录账号不能为空。');
 | 
	
		
			
				|  |  | +            flag = false;
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        if(flag) {
 | 
	
		
			
				|  |  | +            $.ajax({
 | 
	
		
			
				|  |  | +                type: 'post',
 | 
	
		
			
				|  |  | +                url: '/reset/password',
 | 
	
		
			
				|  |  | +                data: { code: $('#forget-project').val(), name: $('#forget-name').val() },
 | 
	
		
			
				|  |  | +                dataType: 'json',
 | 
	
		
			
				|  |  | +                beforeSend: function(xhr) {
 | 
	
		
			
				|  |  | +                    let csrfToken = csrf;
 | 
	
		
			
				|  |  | +                    xhr.setRequestHeader('x-csrf-token', csrfToken);
 | 
	
		
			
				|  |  | +                },
 | 
	
		
			
				|  |  | +                success: function (result) {
 | 
	
		
			
				|  |  | +                    if (result.err === 1) {
 | 
	
		
			
				|  |  | +                        if (result.index === 1) {
 | 
	
		
			
				|  |  | +                            $('#forget-project').addClass('is-invalid');
 | 
	
		
			
				|  |  | +                            $('#forget-project').siblings('div.invalid-feedback').html(result.msg);
 | 
	
		
			
				|  |  | +                        } else if (result.index === 2) {
 | 
	
		
			
				|  |  | +                            $('#forget-name').addClass('is-invalid');
 | 
	
		
			
				|  |  | +                            $('#forget-name').siblings('div.invalid-feedback').html(result.msg);
 | 
	
		
			
				|  |  | +                        } else {
 | 
	
		
			
				|  |  | +                            toast(result.msg, 'error');
 | 
	
		
			
				|  |  | +                        }
 | 
	
		
			
				|  |  | +                    } else {
 | 
	
		
			
				|  |  | +                        $('#fg-password-done').find('b').eq(0).text(result.data.name);
 | 
	
		
			
				|  |  | +                        $('#fg-password-done').find('b').eq(1).text(result.data.account);
 | 
	
		
			
				|  |  | +                        $('#fg-password-done').find('b').eq(2).text(result.data.mobile);
 | 
	
		
			
				|  |  | +                        setLocalCache('project_name', result.data.pName);
 | 
	
		
			
				|  |  | +                        setLocalCache('project_code', $('#forget-project').val());
 | 
	
		
			
				|  |  | +                        $('#fg-password').modal('hide');
 | 
	
		
			
				|  |  | +                        $('#fg-password-done').modal('show');
 | 
	
		
			
				|  |  | +                        $('#account').val($('#forget-name').val());
 | 
	
		
			
				|  |  | +                        $('#project').val($('#forget-project').val());
 | 
	
		
			
				|  |  | +                        $('#project_name').text(result.data.pName);
 | 
	
		
			
				|  |  | +                        $('#forget-name').val('');
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +            })
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +    })
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    $('input').focus(function () {
 | 
	
		
			
				|  |  | +        if($(this).hasClass('is-invalid')) {
 | 
	
		
			
				|  |  | +            $(this).removeClass('is-invalid');
 | 
	
		
			
				|  |  | +            $(this).siblings('div.invalid-feedback').html('');
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +    });
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    $('#focus-pwd').click(function () {
 | 
	
		
			
				|  |  | +        $('#project-password').focus();
 | 
	
		
			
				|  |  | +    })
 | 
	
		
			
				|  |  | +});
 |