<title>标题</title>
<!--当前位置开始-->
<div class="layui-card layadmin-header">
    <div class="layui-breadcrumb" lay-filter="breadcrumb">
        <script type="text/html" template lay-done="layui.data.updateMainBreadcrumb();">
        </script>
    </div>
</div>
<!--当前位置结束-->
<style>
    /* 重写样式 */
    .layui-form-item label { width: 140px; }
    .classifyimg { margin-bottom: 20px; width: 672px !important; }
    .classifyimg-item { display: inline-block; width: 140px; }
    .classifyimg img { width: 100px; display: block; }
    .classifyimg .layui-form-radio { vertical-align: top; display: block; margin-bottom: 10px; }
    .image_storage_type .item { display: none; }
    .layui-elem-quote { margin: 10px; }
    .layui-tab-content { padding: 15px 0; }
</style>
<script type="text/html" template lay-type="Post" lay-url="{{ layui.setter.apiUrl }}Api/CoreCmsSetting/GetIndex" lay-done="layui.data.done(d);">
    <div class="layui-fluid">
        <div class="layui-row layui-col-space15">

            <div class="layui-col-md12">
                <div class="layui-card">

                    <div class="layui-card-body">
                        <div class="layui-tab  layui-tab-card" lay-filter="setting">
                            <ul class="layui-tab-title">
                                <li lay-id="sms" class="layui-this">短信设置</li>
                            </ul>
                            <div class="layui-tab-content">

                                <div class="layui-tab-item layui-show">
                                    <div class="layui-form coreshop-form">
                                        <div class="layui-form-item">
                                            <label class="layui-form-label">{{d.data.configs['smsEnabled']['sKey']}}：</label>
                                            <div class="layui-input-inline layui-inline-7">
                                                <input type="radio" name="smsEnabled" value="1" title="开启" {{d.data.configs['smsEnabled']['sValue']==="1" ? 'checked':''}}>
                                                <input type="radio" name="smsEnabled" value="2" title="关闭" {{d.data.configs['smsEnabled']['sValue']==="2" ? 'checked':''}}>
                                            </div>
                                        </div>


                                        <div class="layui-form-item">
                                            <label class="layui-form-label">{{d.data.configs['smsUserId']['sKey']}}：</label>
                                            <div class="layui-input-inline layui-inline-5">
                                                <input type="text" name="smsUserId" value="{{d.data.configs['smsUserId']['sValue']}}" lay-verify="number" autocomplete="off" placeholder="" class="layui-input">
                                            </div>
                                        </div>

                                        <div class="layui-form-item">
                                            <label class="layui-form-label">{{d.data.configs['smsAccount']['sKey']}}：</label>
                                            <div class="layui-input-inline layui-inline-5">
                                                <input type="text" name="smsAccount" value="{{d.data.configs['smsAccount']['sValue']}}" lay-verify="title" autocomplete="off" placeholder="" class="layui-input">
                                            </div>
                                        </div>

                                        <div class="layui-form-item">
                                            <label class="layui-form-label">{{d.data.configs['smsPassword']['sKey']}}：</label>
                                            <div class="layui-input-inline layui-inline-5">
                                                <input type="text" name="smsPassword" value="{{d.data.configs['smsPassword']['sValue']}}" lay-verify="title" autocomplete="off" placeholder="" class="layui-input">
                                            </div>
                                        </div>

                                        <div class="layui-form-item">
                                            <label class="layui-form-label">{{d.data.configs['smsApiUrl']['sKey']}}：</label>
                                            <div class="layui-input-inline layui-inline-12">
                                                <input type="text" name="smsApiUrl" value="{{d.data.configs['smsApiUrl']['sValue']}}" lay-verify="title" autocomplete="off" placeholder="" class="layui-input">
                                            </div>
                                            <div class="layui-form-mid layui-word-aux">默认地址为：http://sms.corecms.net:9999/sms.aspx</div>
                                        </div>


                                        <div class="layui-form-item">
                                            <label class="layui-form-label">{{d.data.configs['smsSignature']['sKey']}}：</label>
                                            <div class="layui-input-inline layui-inline-5">
                                                <input type="text" name="smsSignature" value="{{d.data.configs['smsSignature']['sValue']}}" lay-verify="title" autocomplete="off" placeholder="" class="layui-input">
                                            </div>
                                            <div class="layui-form-mid layui-word-aux">短信签名，2-8个汉字以内</div>
                                        </div>

                                        <div class="layui-form-item">
                                            <label class="layui-form-label">&nbsp;</label>
                                            <div class="layui-input-block">
                                                <button class="layui-btn" lay-submit="" lay-filter="save">保存更改</button>
                                            </div>
                                        </div>
                                    </div>
                                </div>

                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</script>
<script>
    var indexData;
    var debug = layui.setter.debug;
    layui.data.done = function (d) {
        //开启调试情况下获取接口赋值数据
        if (debug) { console.log(d); }
        indexData = d.data;
        layui.use(['admin', 'form', 'coreHelper', 'element', 'table', 'util', 'view', 'table', 'cropperImg'], function () {
            var $ = layui.$
                , setter = layui.setter
                , admin = layui.admin
                , coreHelper = layui.coreHelper
                , form = layui.form
                , element = layui.element
                , table = layui.table
                , util = layui.util
                , view = layui.view
                , cropperImg = layui.cropperImg
                , router = layui.router()
                , search = router.search;
            form.render();

            form.verify({
                money: [/((^[1-9]\d*)|^0)(\.\d{0,2}){0,1}$/, '请输入合法整数或小数'],
            });

            //保存数据
            form.on('submit(save)', function (data) {
                formData = data.field;
                if (!formData) {
                    layer.msg('请先完善数据', {
                        time: 1300
                    });
                    return false;
                }
                var field = data.field;
                var keys = Object.keys(field);
                var postData = [];
                for (var i = 0; i < keys.length; i++) {
                    var keyName = Object.keys(field)[i];

                    var entity = {};
                    entity.sKey = keyName;
                    entity.sValue = field[keyName];
                    postData.push(entity);
                }
                console.log(postData);
                coreHelper.Post("Api/CoreCmsSmsSetting/DoSave", { entity: postData }, function (e) {
                    if (debug) { console.log(e); } //开启调试返回数据
                    layer.msg(e.msg);
                });
            });
        });
    }
</script>