审查视图

public/themes/simpleboot3/user/profile/perinfo_stu.html 5.1 KB
xiaohu authored
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 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta content="yes" name="apple-mobile-web-app-capable">
    <meta content="yes" name="apple-touch-fullscreen">
    <meta name="viewport"
          content="width=device-width, initial-scale=1,maximum-scale=1,maximum-scale=1, minimum-scale=1, user-scalable=no">
    <title>学员个人信息</title>
    <link rel="stylesheet" href="/static/css/common.css">
    <link rel="stylesheet" href="/static/css/style.css">
    <style>
        .btn_keep {
            outline: none;
            display: block;
            border: 0;
            background-color: transparent;
        }
    </style>
</head>
<body style="background-color: #f6f6f6">
<div class="box">
    <form id="form" enctype="multipart/form-data">
        <div class="perInfo">
            <div class="headImg">
                <b>头像</b>
                <i></i>
                <div class="genggai_head">
                    <input type="file" name="headimgurl" class="shangchuan_head" id='file' onchange="c()">
                    <img src="{$data.headimgurl}" id="show"/>
                </div>
            </div>
        </div>
        <div class="perInfo">
            <div class="headImg">
                <b>真实姓名:</b>
                <input type="text" name="user_nickname" value="{$data.user_nickname}" class="xiugaiName perName">
            </div>
        </div>
        <div class="perInfo">
            <div class="headImg">
                <b>手机号码:</b>
                <input type="tel" name="mobile" value="{$data.mobile}" class="xiugaiName perPhone">
            </div>
        </div>
        <div class="perInfo">
            <div class="headImg">
                <b>验证码:</b>
                <input type="number" name="sms_code" value="" class="user_code">
                <u class="get_code">获取验证码</u>
            </div>
        </div>
    </form>
    <button class="btn_keep">
        <img src="/static/image/keep.png"/>
    </button>
</div>
<script type="text/javascript" src="/static/js/jquery-1.11.0.min.js"></script>
<script type="text/javascript" src="/static/js/layer/layer.js"></script>
<script type="text/javascript" src="/static/js/common.js"></script>
<script type="text/javascript" src="http://res.wx.qq.com/open/js/jweixin-1.2.0.js"></script>
<script>
    function c() {
        var r= new FileReader();
        f=document.getElementById('file').files[0];
        r.onload = function (e) {
            document.getElementById('show').src = this.result;
        };
        if (f) {
            r.readAsDataURL(f);
        } else {
            r.onload = function (e) {
                document.getElementById('show').src = "";
            };
        }

        return f;

    };
    //获取短信验证码
    var validCode = true;
    $(".get_code").click(function () {
        if (validCode) {
            validCode = false;
            var user_phone=$(".perPhone").val();
            console.log(user_phone);
            if(!user_phone){
                alert("手机号码格式不正确")
            }else {
                $.ajax({
                    type: "post",
                    url: "{:url('portal/tool/get_sms_code')}",
                    data: {
                        mobile: user_phone
                    },
                    success: function () {
                        var time = 60;
                        var elem_code = $('.get_code');
                        var t = setInterval(function () {
                            if (time >= 0) {
                                time--;
                                elem_code.text(time + 's');
                            } else {
                                clearInterval(t);
                                elem_code.text('重新获取');
                                validCode = true;
                            }
                        }, 1000);

                    }
                });
            }
        }
    });
    $('.btn_keep').click(function () {
        var formdata = new FormData();
        var flie = c();
        var perName=$('.perName').val();
        var perPhone=$('.perPhone').val();
        var user_code=$('.user_code').val();
        formdata.append("headimgurl",flie);
        formdata.append("user_nickname",perName);
        formdata.append("mobile",perPhone);
        formdata.append("sms_code",user_code);
        $.ajax({
            type: "post",
            url: "{:url('perinfo_ins')}",
            data: formdata,
            cache: false,
            processData: false,
            contentType: false,
            success: function (res) {
                console.log(res);
                if(res.code==1){
                    layer.msg("保存成功");
                    window.location.href="/user/profile/percenter";
                }else if(res.code==0){
                    layer.msg(res.msg);
                }

            }
        });
    });
</script>
</body>
</html>