admin
2022-01-20 d8ef9a783b9e0b2a495f02fdf3daaf27ef49e99d
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
<!DOCTYPE html>
<html>
 
    <head>
        <meta charset="utf-8">
        <title>验证手机号</title>
        <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
        <link rel="stylesheet" type="text/css" href="./css/stylePhoneNumber.css" />
        <!-- <script src="https://cdn.bootcss.com/vConsole/3.3.0/vconsole.min.js"></script> -->
        <script>
            window.onresize = function() {
            document.documentElement.style.fontSize = document.documentElement.clientWidth / 7.5 + 'px';
        };
        window.onresize();
    </script>
        <script src="https://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
        <script src="../js/app.js"></script>
        <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
    </head>
 
    <body>
        <div id="root">
            <div style="color: #0E96FF;font-size: 0.34rem;line-height: 0.36rem;text-align: center;margin-top: 2rem;">
                我们需要身份验证
            </div>
            <div style="color: #0E96FF;font-size: 0.34rem;line-height: 0.36rem;text-align: center;margin-top: 0.1rem;">
                请使用绑定的手机号获取验证码
            </div>
            <div style="color: #333333;font-size: 0.48rem;margin-top: 0.1rem;margin-left: 0.72rem;margin-top: 1.09rem;">
                注销账户
            </div>
 
            <div class="div_PhoneBG">
                <div style="color: #000000;font-size: 0.28rem;margin-left: 0.72rem;height: 0.22rem; display: -webkit-flex;align-items: center;">
                    +86
                </div>
                <img src="img/arrow.png" style="width: 0.17rem;height: 0.25rem;margin-left: 0.2rem;margin-top: -0.03rem;">
                <input type="tel" class="input" placeholder="请输入手机号" @input="onInput" maxlength="13" />
            </div>
 
            <div style="background-color: #0E96FF; height:1px;margin-left: 0.7rem;width: 5.8rem;margin-top: 0.05rem;"></div>
 
            <div class="div_button" @click="fetchCode">
                获取短信验证码
            </div>
        </div>
    </body>
 
    <script>
    
        var host = "http://api.location.izzql.com:8090";
 
        var phone = null;
 
        $(function() {
            
            var app = new Vue({
                el: "#root",
                data: {
 
                },
                methods: {
                    fetchCode: function() {
                        phone = $('.input').val().replace(/\s/g, '');
                        if (phone.length != 11) return;
                        app.sendMsg();
                    },
 
                    sendMsg: function() {
                        var params = {
                            phone: phone
                        };
 
                        ksbridge.call("getRequestBaseParams", params, function(res) {
                            params = JSON.parse(res);
                            ksbridge.call("showLoading");
                            $.ajax({
                                type: "POST",
                                data:params,
                                url: host + "/api/v1/sms/sendSMS",
                                dataType: "json",
                                async: false,
                                success: function(result) {
                                    ksbridge.call("hideLoading");
                                    if (result.code == 0) {
                                        window.location.href = "fetchCode.html?phone=" + $('.input').val();
                                    } else {
                                        ksbridge.call("toast", {
                                            msg: result.msg
                                        });
                                    }
                                },
                                error: function(XMLHttpRequest, textStatus, errorThrown) {
                                    ksbridge.call("hideLoading");
                                    if (textStatus === 'timeout') {
                                        setTimeout(function() {}, 2000);
                                    }
                                }
                            });
                        });
                    },
                }
            });
 
            $('.input').on('keyup', function(e) {
                var val = $(this).val();
                if (val.length == 13) {
                    $('.div_button').css('background-color', '#0E96FF');
 
                } else {
                    $('.div_button').css('background-color', '#7fc7ff');
                }
                // 按键为删除时要执行下面的判断,不然删除到第三位和第八位时又回加空格,一直循环。
                if (e.keyCode === 8) {
                    $(this).val(val);
                    return;
                }
                if (val.length === 3 || val.length === 8) {
                    val += " ";
                    $(this).val(val);
                }
            })
        });
    </script>
 
</html>