keepPhone.html 6.2 KB
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title></title>
    <script src="../../assets/js/fontsize.js"></script>
    <link rel="stylesheet" href="../../assets/css/api.css"/>
    <link rel="stylesheet" href="../../assets/css/login_index.css">
    <link rel="stylesheet" href="../../assets/icon/iconfont.css">
    <style>
        .agree_box {
            margin-top: 0.5rem;
        }
    </style>
</head>
<body>
<div id="app">
    <form action="">
        <div class="login_input"><input type="number" placeholder="请输入手机号" maxlength="11" v-model="phone"></div>
        <div class="login_input"><input type="number" placeholder="请输入验证码" v-model="code">
            <span v-if="show" @click="getCode" class="count">获取验证码</span>
            <span v-else class="count">{{count}}S后可重发</span>
        </div>
        <div class="login_btn" @click="login">绑定</div>
        <div class="no_reg">首次第三方登陆需要绑定手机号</div>
        <div class="agree_box">
    <span :class="['iconfont',isAgree?'icon-yigouxuan':'icon-weigouxuan']"
          @click="isAgree=!isAgree"></span>
            <span>我同意</span>
            <span class="agreement" @click="agree_content">《慈界医养用户服务协议》</span>
        </div>
    </form>
</div>
</body>
</html>
<script type="text/javascript" src="../../assets/js/api.js"></script>
<script type="text/javascript" src="../../assets/js/public.js"></script>
<script type="text/javascript" src="../../assets/js/fastclick.js"></script>
<script>
    new FastClick(document.body);
</script>
<script type="text/javascript" src="../../assets/js/vue.min.js"></script>
<script type="text/javascript" src="../../assets/js/axios.min.js"></script>
<script type="text/javascript" src="../../assets/icon/iconfont.js"></script>
<script>
    var app = new Vue({
        el: '#app',
        data: {
            show: true,
            count: '',
            timer: null,
            isAgree: true,
            phone: '',
            code: '',
            nickname: '',
            openid: '',
            avatar: ''
        },
        created: function () {
            apiready = function () {
                app.nickname = api.pageParam.nickname;
                app.openid = api.pageParam.openid;
                app.avatar = api.pageParam.avatar;
                app.login_type = api.pageParam.login_type;
                // alert(app.login_type)
            }
        },
        methods: {
            getCode: function () {
                if (!mobileReg.test(app.phone)) {
                    toastMsg('手机号不正确')
                }
                else {
                    const TIME_COUNT = 60;
                    var post = {
                        tel: app.phone,
                    };
                    var header = {
                        'XX-Device-Type': getDevice()
                    };
                    getRequest('post', 'home/index/loginBySMS', post, header).then(function (res) {
                        if (res.data.code === 1) {
                            toastMsg(res.data.msg)
                            if (!app.timer) {
                                app.count = TIME_COUNT;
                                app.show = false;
                                app.timer = setInterval(function () {
                                    if (app.count > 0 && app.count <= TIME_COUNT) {
                                        app.count--;
                                    } else {
                                        app.show = true;
                                        clearInterval(app.timer);
                                        app.timer = null;
                                    }
                                }, 1000)
                            }
                        } else {
                            toastMsg(res.data.msg)
                        }
                    })
                }
            },
            login: function () {
                if (app.phone == '') {
                    toastMsg('请输入手机号')
                }
                else if (app.code == '') {
                    toastMsg('请输入验证码')
                }
                else if (app.isAgree == false) {
                    toastMsg('请同意慈界医养用户服务协议')
                }
                else {
                    var post = {
                        code: app.code,
                        tel: app.phone,
                        openid: app.openid,
                        nickname: app.nickname,
                        avatar: app.avatar,
                        login_type: app.login_type
                    };
                    var header = {
                        'XX-Device-Type': getDevice()
                    };
                    // alert(JSON.stringify(post));
                    getRequest('POST', 'home/index/secondLogin', post, header).then(function (res) {
                        // alert(JSON.stringify(res.data.data))
                        if (res.data.code == 1) {
                            $api.setStorage('token', res.data.data);
                            api.openWin({
                                name: 'index_win',
                                url: '../common/index_win.html',
                            });
                            api.sendEvent({
                                name: 'index0',
                                extra: {
                                    index: 0
                                }
                            });
                        } else {
                            toastMsg(res.data.msg)
                        }
                    })
                }
            },
            agree_content: function () {
                openView('agree_content', 'common/agree_content', '慈界医养用户服务协议', 'agree_content', false, {
                    title_name: '慈界医养用户服务协议',
                    id: 3
                }, false)
            },
        }
    })
</script>