layui.use(["form","layer","jquery"],function(){function e(e="local"){switch(e){case"local":t("legend").text("本地存储 - 配置"),t(".LocalConfig").removeClass("layui-hide"),t(".OssConfig").addClass("layui-hide"),t(".CosConfig").addClass("layui-hide"),t(".OssBucket,.endpoint,.accessKeyId,.accessKeySecret").removeAttr("lay-verify"),t(".CosBucket,.region,.secretId,.secretKey").removeAttr("lay-verify");break;case"oss":t("legend").text("OSS存储 - 配置"),t(".LocalConfig").addClass("layui-hide"),t(".OssConfig").removeClass("layui-hide"),t(".CosConfig").addClass("layui-hide"),t(".endpoint").attr("lay-verify","url"),t(".OssBucket,.accessKeyId,.accessKeySecret").attr("lay-verify","required"),t(".CosBucket,.region,.secretId,.secretKey").removeAttr("lay-verify");break;case"cos":t("legend").text("COS存储 - 配置"),t(".LocalConfig").addClass("layui-hide"),t(".OssConfig").addClass("layui-hide"),t(".CosConfig").removeClass("layui-hide"),t(".CosBucket,.region,.secretId,.secretKey").attr("lay-verify","required"),t(".OssBucket,.endpoint,.accessKeyId,.accessKeySecret").removeAttr("lay-verify")}s.render()}var s=layui.form,a=void 0===parent.layer?layui.layer:top.layer,t=layui.jquery;t.ajax({url:"../../ajax.php?act=systemParameter&bool=true",dataType:"json",success:function(s){var a=s.data,o=a.oss,i=a.cos;t(".name").val(a.name),!a.type&&(a.type="local"),t('input[type="radio"][name="type"][value="'+a.type+'"]').prop("checked",!0),t('input[type="radio"][name="verify"][value="'+a.verify+'"]').prop("checked",!0),e(a.type),t(".localhost").val(a.localhost),t(".OssBucket").val(o.bucket),t(".endpoint").val(o.endpoint),t(".accessKeyId").val(o.accessKeyId),t(".accessKeySecret").val(o.accessKeySecret),t(".ossdomain").val(o.ossdomain),t(".osshost").val(o.osshost),t(".CosBucket").val(i.bucket),t(".region").val(i.region),t(".secretId").val(i.secretId),t(".secretKey").val(i.secretKey),t(".coshost").val(i.coshost),t(".indexpass").val(a.indexpass),t(".record").val(a.record),t(".tongji").val(a.tongji)}}),s.on("submit(WebConfig)",function(e){var s=a.msg("数据提交中，请稍候",{icon:16,time:!1,shade:.8});return t.ajax({url:"../../ajax.php?act=webconfig",type:"POST",data:e.field,dataType:"json",success:function(e){setTimeout(function(){a.close(s),a.msg(e.msg,{icon:e.code,time:1e3})},500)}}),!1}),s.on("radio()",function(s){e(s.value)}),s.verify({host:function(e){if(e){if("/"==e.substr(0,1))return"目录名称不能以/开头";if("/"!=e.substr(-1))return"目录名称必须以/结尾"}},Endpoint:function(e){var s=/^http(s)?:\/\/([\w-]+\.)+[\w-]+(\/[\w- .\/?%&=]*)?$/i;if(!s.test(e))return"Endpoint格式错误"}})});