<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>修改金额</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <meta name="decorator" content="base"/>
    <link rel="stylesheet" type="text/css" href="${ctxPlugin}/static/css/reset.css"/>

</head>
<body>
<div class="layui-fluid">
    <div>
        <input type="text" id="amount" value="${amount}" class="layui-input" style="height: 38px;width: 70%;display: inline-block">
        <span style="width: 30%">KW*1500</span>
    </div>
</div>
<div class="layui-form-item text-c operate-footer">
    <button type="button" class="layui-btn" id="refuseNotRetaial">确定</button>
    <button class="layui-btn layui-btn-primary" onclick="closeSelf()">取消</button>
</div>

<script src="${ctxPlugin}/lib/layuiAdmin/dist/layuiadmin/layui/layui.js"></script>
<script>
    layui.config({
        base: '${ctxPlugin}/lib/layuiAdmin/dist/layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'form', 'layedit', 'laydate', 'jquery', 'upload', 'layer'], function () {

        $ = layui.$;
        layer = layui.layer;
        form = layui.form;

        var refuseNotFlag = true;
        $('#refuseNotRetaial').click(function () {
            if (!refuseNotFlag) {
                return;
            }
            var amount = $('#amount').val();
            if(!/^\d+(\.\d{1,2})?$/.test(amount) || parseFloat(amount) < 0) {
                layer.msg("请输入大于等于零的数字，最多保留两位小数！");
                return ;
            }
            refuseNotFlag = false;
            $.ajax({
                type:"POST",
                url:"${ctx}/account/editAmount",
                data:{
                    traderId:'${traderId}',
                    type:'${type}',
                    amount:amount*1500
                },
                success:function(result){
                    if(result.code =='200'){
                        layer.msg("保存成功",{icon:1,time:1000},function(){
                            var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                            parent.$('#searchBtn').click()
                            parent.layer.close(index); //再执行关闭
                        })
                    }else{
                        layer.msg("修改失败！")
                    }

                }
            })
        });


    })

    window.closeSelf = function () {
        var index = parent.layer.getFrameIndex(window.name);
        parent.layer.close(index);//关闭当前页
    }

    function isBlank(val) {
        if (val == null || val == '' || val == undefined) {
            return true;
        }
        return false;
    }
</script>
</body>
</html>

