index.html 6.6 KB
<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <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="http://at.alicdn.com/t/font_705837_t04jt4gjgqg.css" />
    <link rel="stylesheet" type="text/css" href="__TMPL__/css/myweui.css"/>
    <link rel="stylesheet" type="text/css" href="__TMPL__/css/init.css" />
    <link rel="stylesheet" type="text/css" href="__TMPL__/css/swiper-3.4.2.min.css" />
    <link rel="stylesheet" type="text/css" href="__TMPL__/css/index/write_form.css"/>
    <script src="__TMPL__/js/base.js" type="text/javascript" charset="utf-8"></script>
    <script src="http://res.wx.qq.com/open/js/jweixin-1.2.0.js"></script>
    <title>填写表单</title>
    <style type="text/css">
        body{
            background-color: #fff;
            padding-bottom: 1rem;
        }
        .weui-toast {
            min-height: 1rem;
            text-align: center;
            display: flex;
            justify-content: center;
            align-items: center;
            min-width: 3.4rem;
            margin: 0 auto;
            left: 0;
            right: 0;
            /*padding: 0.1rem 0.15rem;*/
            padding: 0 0.2rem;
        }

        .weui-toast__content {
            margin-bottom: 0;
        }
        .btn{
            position: fixed;
        }
    </style>
</head>

<body>
<div class="container">
    <div class="form_item">
        <p class="tit">姓名</p>
        <input type="text" name="" id="name" data-text='请输入姓名' value="" class="form_input" placeholder="请输入您的真实姓名"/>
    </div>
    <div class="form_item">
        <p class="tit">联系电话</p>
        <input type="text" name="tel" id="tel" data-text='请输入联系电话' value="" class="form_input" placeholder="请输入您的联系电话"/>
    </div>
    <div class="form_item">
        <p class="tit">居住地址</p>
        <input type="text" name="" id="address" data-text='请输入居住地址' value="" class="form_input" placeholder="请输入您的居住地址"/>
    </div>
    <div class="form_item">
        <p class="tit">身份证号码</p>
        <input type="text" name="id_card" id="id_card" data-text='请输入正确身份证号码' value="" class="form_input" placeholder="请输入您的身份证号码"/>
    </div>
    <div class="form_item">
        <p class="tit">备注信息</p>
        <input type="text" name="" id="note" data-text='请输入备注信息' value="" class="form_input" placeholder="请输入您的备注信息"/>
    </div>
    <!--btn-->
    <div class="btn">
        确认提交
    </div>

    <div id="toast" style="display: none;">
        <div class="weui-mask_transparent"></div>
        <div class="weui-toast">
            <p class="weui-toast__content">已完成</p>
        </div>
    </div>
</div>
<script src="__TMPL__/js/jquery.min.js" type="text/javascript" charset="utf-8"></script>
<script src="__TMPL__/js/weui.js" type="text/javascript" charset="utf-8"></script>
<script src="__TMPL__/js/myweui.js" type="text/javascript" charset="utf-8"></script>

<script type="text/javascript">
    $(document).ready(function() {
    })


    var mobile = /^(13[0-9]|14[579]|15[0-3,5-9]|16[6]|17[0135678]|18[0-9]|19[89])\d{8}$/;
    var reg = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/;
    var num = 0;
    $('.btn').click(function() {
        var input_length = $('.form_input').length
        var pass;
        $('.form_input').each(function(){
            pass = true;
            if(this.value == '') {
                pass = false
                toast($(this).data().text)
                return false;
            }else{
                if(this.name == 'tel'){
                    if(!mobile.test(this.value)){
                        pass = false
                        toast('手机号码格式有误')
                        return false
                    }
                } else if(this.name == 'id_card'){
                    if(!reg.test(this.value)){
                        pass = false
                        toast('身份证号码有误')
                        return false
                    }
                }
            }
        })
        if(pass) {
            var coach_id={$coach_id};
            var package_id={$package_id};
            $.ajax({
                url:"{:url('sign/Index/signUp')}",
                data:{
                    coach_id:coach_id,
                    package_id:package_id,
                    name:$("#name").val(),
                    tel:$("#tel").val(),
                    address:$("#address").val(),
                    id_card:$("#id_card").val(),
                    note:$("#note").val()
                },
                type:"POST",
                dataType:"JSON",
                
                success: function (data) {
                    console.log(data.data);
                    wx.chooseWXPay({
                        timestamp: data.data.timeStamp, // 支付签名时间戳,注意微信jssdk中的所有使用timestamp字段均为小写。但最新版的支付后台生成签名使用的timeStamp字段名需大写其中的S字符
                        nonceStr: data.data.nonceStr, // 支付签名随机串,不长于 32 位
                        package: data.data.package, // 统一支付接口返回的prepay_id参数值,提交格式如:prepay_id=\*\*\*)
                        signType: data.data.signType, // 签名方式,默认为'SHA1',使用新版支付需传入'MD5'
                        paySign: data.data.paySign, // 支付签名
                        success: function (res) {
                            if (res.errMsg == "chooseWXPay:ok") {
                                window.location.href=data.url;
                            }
                        },
                        cancel: function () {
                            //取消订单是否需要删除无用订单?
                        }
                    });
                }
            })
        }
    })

    wx.config({
        debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
        appId: '{$js_sdk.appId}', // 必填,公众号的唯一标识
        timestamp: '{$js_sdk.timestamp}', // 必填,生成签名的时间戳
        nonceStr: '{$js_sdk.nonceStr}', // 必填,生成签名的随机串
        signature: '{$js_sdk.signature}',// 必填,签名
        jsApiList: [
            'chooseWXPay'
        ] // 必填,需要使用的JS接口列表
    });

</script>
</body>

</html>