亚洲必赢手机入口_亚洲必赢官网_www.633.net

亚洲必赢手机入口_亚洲必赢官网_www.633.net

通过radio按钮切换 item选项的隐藏和显示




<div class="layui-form" lay-filter="add-form-list" id="add-form-list" style="padding: 20px 30px 0 0;">
    <div class="layui-form-item">
        <label class="layui-form-label">优惠券类型</label>
        <div class="layui-input-block">
            <script type="text/html" template  >
                <input type="radio" name="coupon_type"  lay-filter="coupon_type"  checked value="1" title="满减">
                <input type="radio" name="coupon_type"  lay-filter="coupon_type" value="2" title="折扣">
            </script>
        </div>
    </div>
    <div class="layui-form-item money">
        <label class="layui-form-label">满足条件</label>
        <div class="layui-input-block">
            <script type="text/html" template  >
                <input type="number" min="0" name="max_money" id="max_money"  lay-verify="required"  value=""  placeholder="请输入满足条件" autocomplete="off" class="layui-input">
            </script>
        </div>
    </div>
    <div class="layui-form-item money">
        <label class="layui-form-label">优惠金额</label>
        <div class="layui-input-block">
            <script type="text/html" template  >
                <input type="number" min="0" name="money" id="money" value=""  lay-verify="required"   placeholder="请输入优惠金额" autocomplete="off" class="layui-input">
            </script>
        </div>
    </div>
    <div class="layui-form-item discount" style="display: none" >
        <label class="layui-form-label">折扣</label>
        <div class="layui-input-block">
            <script type="text/html" template  >
                <input type="number" min="0" name="discount" id="discount" value=""  placeholder="请输入折扣" autocomplete="off" class="layui-input">
            </script>
        </div>
    </div>
    <div class="layui-form-item "  >
        <label class="layui-form-label">数量</label>
        <div class="layui-input-block">
            <script type="text/html" template  >
                <input type="number" min="0" name="count" value=""  lay-verify="required" placeholder="请输入发放数量" autocomplete="off" class="layui-input">
            </script>
        </div>
    </div>
    <div class="layui-form-item " >
        <label class="layui-form-label">有效时长/天</label>
        <div class="layui-input-block">
            <script type="text/html" template  >
                <input type="number" min="0" name="expire_in" value="" lay-verify="required"  placeholder="请输入有效时长" autocomplete="off" class="layui-input">
            </script>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label"></label>
        <div class="layui-input-inline">
            <input type="button" lay-submit lay-filter="add-form-submit" value="确认" class="layui-btn">
        </div>
    </div>
</div>


image.png

coupon_type();
form.on('radio(coupon_type)', function(data){
    coupon_type();
});
function coupon_type(){
    var type = $('input[name="coupon_type"]:checked').val();
    console.log(type)
    if(type == 1){
        $('.money').show();
        $('.discount').hide();
        $('#money').attr('lay-verify','required')
        $('#max_money').attr('lay-verify','required')
        $('#discount').removeAttr('lay-verify')
    }else if(type == 2){
        $('.money').hide();
        $('.discount').show();
        $('#money').removeAttr('lay-verify')
        $('#max_money').removeAttr('lay-verify')
        $('#discount').attr('lay-verify','required')
    }
}


本人主要从事APP,小程序开发,有专业的团队。微信:wqy0601415 (请注明需求);

上一篇: layuiadmin 路由
下一篇:



0.275954s
Baidu
sogou