my js

my js

 .footer-buyer-login {
            padding: 12px 0;
            line-height: 24px;
        }

        .footer-buyer-login p {
            margin: 0;
            line-height: 24px;
        }

        .footer-buyer-login a:hover {
            color: #ff7300;
        }

        .vercode-btn {
            height: 46px;
            line-height: 46px;
            width: 130px;
            margin-left: 5px;
            margin-top: 5px;
            font-size: 14px;
            cursor: pointer;
            text-align: center;
            letter-spacing: 2px;
            border-radius: 3px;
            transition: 0.2s;
            border: 1px solid #eee;
            background: #eee;
            color: #999;
            user-select: none;
            float: right;

            &:hover {
                background-color: #f18933;
                border: 1px solid #f18933;
                color: #fff;
            }
        }

        .vercode-btn-disabled {
            cursor: no-drop;
            &:hover {
                border: 1px solid #eee;
                background: #eee;
                color: #999;
            }
        }

        .login-type-btn {
            cursor: pointer;
            font-size: 12px;
            margin: 10px 0;
            display: inline-block;
            &:hover {
                text-decoration: underline;
            }
        }

这是css代码

 .footer-buyer-login {
            padding: 12px 0;
            line-height: 24px;
        }

        .footer-buyer-login p {
            margin: 0;
            line-height: 24px;
        }

        .footer-buyer-login a:hover {
            color: #ff7300;
        }

        .vercode-btn {
            height: 46px;
            line-height: 46px;
            width: 130px;
            margin-left: 5px;
            margin-top: 5px;
            font-size: 14px;
            cursor: pointer;
            text-align: center;
            letter-spacing: 2px;
            border-radius: 3px;
            transition: 0.2s;
            border: 1px solid #eee;
            background: #eee;
            color: #999;
            user-select: none;
            float: right;

            &:hover {
                background-color: #f18933;
                border: 1px solid #f18933;
                color: #fff;
            }
        }

        .vercode-btn-disabled {
            cursor: no-drop;
            &:hover {
                border: 1px solid #eee;
                background: #eee;
                color: #999;
            }
        }

        .login-type-btn {
            cursor: pointer;
            font-size: 12px;
            margin: 10px 0;
            display: inline-block;
            &:hover {
                text-decoration: underline;
            }
        }
<div class="head fn-clear">
    <div class="wrap1000 fn-clear">
        <div style='float: left;height: 76px;width: 170px;cursor: pointer;' onclick='toFirstPage();' title="有市首页">
            <img src="/auth/img/logo_3.png">
        </div>
        <span class="title"
              style="width: 155px;text-align: right;padding-top: 0px;border-left: 1px solid silver;margin-top: 2px">卖家管理中心</span>
        <span class="number">客服热线:400-930-2128</span>
    </div>
</div>
   function register() {
        window.location.href = getBaseUrl() + "/auth2u/registry";
    }

    function forgetPwd() {
        window.location.href = getLotsUrl() + "/retrievePassword/?type=1";
    }

    function toFirstPage() {
        var baseUrl = getBaseUrl();
        window.location.href = baseUrl;
    }

    //注册
    $(function () {
        var url = window.location.href;
        if (url.substring(url.indexOf('?') + 1).indexOf('error') !== -1) {
            $('.setBox').css('display', '');
        }
        //隐藏
        $(".inputDefault").bind('click', function () {
            $("#alertId").hide();
        });

        (function () { // 读取记住的帐号
            var userName = window._helper.getCookie('_seller_login_name_');
            if (userName) {
                $('#userNameId').val(decodeURI(userName));
            }
        })();
        //登录
        $("#loginBtnId").on('click', function () {
            var name = $('#userNameId').val();
            var password = $('input[name="password"]').val();
            if (name != '' && password != '') {
                window._helper.setCookie('_seller_login_name_', encodeURI(name), 30)
            }
        });
        $("#loginFormId").on('submit', function () {
            var j_password = $("input[name='password']").val();
            $("input[name='password']").val(hex_md5(j_password));
        });

        $('#codeLoginBtn').on('click', function () {
            $('.tab_login_password').hide();
            $('.tab_login_phone').show();
        });

        $('#userLoginBtn').on('click', function () {
            $('.tab_login_password').show();
            $('.tab_login_phone').hide();
        });

        function codeErrorCallback () {
            var appid = '2014014128';
            // 生成容灾票据或自行做其它处理
            var ticket = "terror_1001_" + appid + "_" + Math.floor(new Date().getTime() / 1000)
            codeCallback({
                ret: 0,
                randstr: "@" + Math.random().toString(36).substr(2),
                ticket: ticket,
                errorCode: 1001,
                errorMessage: "jsload_error"
            })
        }

        function jumpLots (accept, token) {
            var hash = window.location.hash;
            var url = '/lots-web/seller/index.html';
            if (hash) {
                url = url + hash;
            } else {
                url = url + '#/welcome';
            }

            window.location.href = url + "?Accept=" +
            accept +
            "&minuteToken=" +
            token
        }

        function setCookie(name, value, days) {
            let expires = "";
            if (days) {
                const date = new Date();
                date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
                expires = "; expires=" + date.toUTCString();
            }
            document.cookie = name + "=" + (value || "") + expires + "; path=/";
        }

        function getAccept (token ) {
            $.ajax({
                url: "/apis/vendor/v1/users/accepts",
                type: 'get',
                dataType: 'json',
                headers: {
                    'Authorization': `Bearer ${token}`,
                },
                success: function(response, status, xhr) {
                    var resp = response;
                    if(resp.accept){
                        jumpLots(resp.accept, resp.minuteToken)
                    }
                }
               
            }); 
        }




        function codeCallback (res) {
            var ticket = '';
            if (res.ret === 0) {
                ticket = res.ticket;
            }

            var phone = $('.j_phone').val();
            if (ticket) {
                $.ajax({
                    url: "/apis/common/v1/sms/verifyCode/identifyCode",
                    type: 'get',
                    data: {
                        phone: phone,
                        type: 5,
                        ticket: ticket,
                        captchaAppId: '2014014128'
                    },
                    success: function(response, status, xhr) {
                        console.log('loginBtnPhone-response, status, xhr', response, status, xhr);

                        var resp = response;
                        if(resp.recode === 200){
                            var timmer = 59;
                            $('#captchaId').html(timmer + '秒').addClass('vercode-btn-disabled');

                            var interId = setInterval(function () {
                                timmer = timmer - 1;
                                $('#captchaId').html(timmer + '秒');
                                if (timmer <= 0) {
                                    $('#captchaId').html('重新获取验证码').removeClass('vercode-btn-disabled');
                                    
                                    clearInterval(interId);
                                }
                            }, 1000);
                        } else {
                            $('.phoneMsgSpan').html(resp.msg || '获取验证码失败');
                            $('#phoneMsg').show();
                        }
                    }
                });
            }
        }

        var timer = null, timeNum = 0;
        $('#captchaId').on('click',function () {
            if (timeNum > 0 ) {
                return false;
            }
            var phone = $('.j_phone').val().trim();

            if (phone === "") {
                alert("手机号不能为空");
                return;
            }
            
            if(!(/^1\d{10}$/.test(phone))){
                alert("手机号格式错误");
                return;
            }

            try {
                var captcha = new TencentCaptcha('2014014128', codeCallback, {});
                // 调用方法,显示验证码
                captcha.show();
            } catch (error) {
                // 加载异常,调用验证码js加载错误处理函数
                codeErrorCallback();
            }
        });

        $('#loginBtnPhone').on('click', function () {
            var phone = $('.j_phone').val().trim();
            var vercode = $('.j_vercode').val().trim();

            if (phone == '' || vercode == '') {
                return false;
            }
          
            $.ajax({
                url: "/auth/api/auth2u/token",
                type: 'post',
                dataType: 'json',
                contentType: 'application/x-www-form-urlencoded', 
                data: {
                    grant_type: "verification_code",
                    client_type: 'mc',
                },
                headers: {
                    'Authorization': `Basic ${window.btoa(`${phone}:${vercode}`)}`,

                },
                success: function(response, status, xhr) {
                    var resp = response;
                    if(resp.access_token){
                        getAccept(resp.access_token)
                    } else {
                        var msg = resp.error_description || "登录失败";
                        if (resp.code === "40004" || resp.code === "40102")
                            msg = "用户名或密码不正确,请重新输入!";
                        if (resp.code === "40103" || resp.code === "40104") msg = "验证码错误!";
                        if (resp.code === "40007") msg = "验证码已过期!";
                        if (resp.code === "40005") msg = "客户端类型和用户类型不匹配!";

                        $('#phoneMsg').show();
                        $('.phoneMsgSpan').html(msg);
                    }
                },
                error: function(xhr, status, error) {
                    var err = JSON.parse(xhr.responseText)
                    var msg = err.error_description || "登录失败";
                    if (err.code === "40004" || err.code === "40102")
                        msg = "用户名或密码不正确,请重新输入!";
                    if (err.code === "40103" || err.code === "40104") msg = "验证码错误!";
                    if (err.code === "40007") msg = "验证码已过期!";
                    if (err.code === "40005") msg = "客户端类型和用户类型不匹配!";

                    $('#phoneMsg').show();
                    $('.phoneMsgSpan').html(msg);
                }
            }); 
        });
    });

© 版权声明
THE END
点赞6 分享
Suggestion
评论 抢沙发

请登录后发表评论

    暂无评论内容