define([], function () { require([], function () { //绑定data-toggle=addresspicker属性点击事件 $(document).on('click', "[data-toggle='addresspicker']", function () { var that = this; var callback = $(that).data('callback'); var input_id = $(that).data("input-id") ? $(that).data("input-id") : ""; var lat_id = $(that).data("lat-id") ? $(that).data("lat-id") : ""; var lng_id = $(that).data("lng-id") ? $(that).data("lng-id") : ""; var zoom_id = $(that).data("zoom-id") ? $(that).data("zoom-id") : ""; var lat = lat_id ? $("#" + lat_id).val() : ''; var lng = lng_id ? $("#" + lng_id).val() : ''; var zoom = zoom_id ? $("#" + zoom_id).val() : ''; var url = "/addons/address/index/select"; url += (lat && lng) ? '?lat=' + lat + '&lng=' + lng + (input_id ? "&address=" + $("#" + input_id).val() : "") + (zoom ? "&zoom=" + zoom : "") : ''; Fast.api.open(url, '位置选择', { callback: function (res) { input_id && $("#" + input_id).val(res.address).trigger("change"); lat_id && $("#" + lat_id).val(res.lat).trigger("change"); lng_id && $("#" + lng_id).val(res.lng).trigger("change"); zoom_id && $("#" + zoom_id).val(res.zoom).trigger("change"); try { //执行回调函数 if (typeof callback === 'function') { callback.call(that, res); } } catch (e) { } } }); }); }); require(['fast', 'layer'], function (Fast, Layer) { var _fastOpen = Fast.api.open; Fast.api.open = function (url, title, options) { options = options || {}; options.area = Config.betterform.area; options.offset = Config.betterform.offset; options.anim = Config.betterform.anim; options.shadeClose = Config.betterform.shadeClose; options.shade = Config.betterform.shade; return _fastOpen(url, title, options); }; if (isNaN(Config.betterform.dialoganim)) { var _layerOpen = Layer.open; Layer.open = function (options) { var classNameArr = {slideDown: "layer-anim-slide-down", slideLeft: "layer-anim-slide-left", slideUp: "layer-anim-slide-up", slideRight: "layer-anim-slide-right"}; var animClass = "layer-anim " + classNameArr[options.anim] || "layer-anim-fadein"; var index = _layerOpen(options); var layero = $('#layui-layer' + index); layero.addClass(classNameArr[options.anim] + "-custom"); layero.addClass(animClass).one('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', function () { $(this).removeClass(animClass); }); return index; } } }); require.config({ paths: { 'clicaptcha': '../addons/clicaptcha/js/clicaptcha' }, shim: { 'clicaptcha': { deps: [ 'jquery', 'css!../addons/clicaptcha/css/clicaptcha.css' ], exports: '$.fn.clicaptcha' } } }); require(['form'], function (Form) { window.clicaptcha = function (captcha) { require(['clicaptcha'], function (undefined) { captcha = captcha ? captcha : $("input[name=captcha]"); if (captcha.length > 0) { var form = captcha.closest("form"); var parentDom = captcha.parent(); // 非文本验证码 if ($("a[data-event][data-url]", parentDom).length > 0) { return; } if (captcha.parentsUntil(form, "div.form-group").length > 0) { captcha.parentsUntil(form, "div.form-group").addClass("hidden"); } else if (parentDom.is("div.input-group")) { parentDom.addClass("hidden"); } captcha.attr("data-rule", "required"); // 验证失败时进行操作 captcha.on('invalid.field', function (e, result, me) { //必须删除errors对象中的数据,否则会出现Layer的Tip delete me.errors['captcha']; captcha.clicaptcha({ src: '/addons/clicaptcha/index/start', success_tip: '验证成功!', error_tip: '未点中正确区域,请重试!', callback: function (captchainfo) { form.trigger("submit"); return false; } }); }); // 监听表单错误事件 form.on("error.form", function (e, data) { captcha.val(''); }); } }); }; // clicaptcha($("input[name=captcha]")); if (typeof Frontend !== 'undefined') { Frontend.api.preparecaptcha = function (btn, type, data) { require(['form'], function (Form) { $("#clicaptchacontainer").remove(); $("
").attr("id", "clicaptchacontainer").addClass("hidden").html(Template("captchatpl", {})).appendTo("body"); var form = $("#clicaptchacontainer form"); form.data("validator-options", { valid: function (ret) { data.captcha = $("input[name=captcha]", form).val(); Frontend.api.sendcaptcha(btn, type, data, function (data, ret) { console.log("ok"); }); return true; } }) Form.api.bindevent(form); }); }; } var _bindevent = Form.events.bindevent; Form.events.bindevent = function (form) { _bindevent.apply(this, [form]); var captchaObj = $("input[name=captcha]", form); if (captchaObj.length > 0) { clicaptcha(captchaObj); if ($(form).attr("name") === 'captcha-form') { setTimeout(function () { captchaObj.trigger("invalid.field", [{key: 'captcha'}, {errors: {}}]); }, 100); } } } }); require(['form', 'upload'], function (Form, Upload) { var _bindevent = Form.events.bindevent; Form.events.bindevent = function (form) { _bindevent.apply(this, [form]); if ($("#croppertpl").length == 0) { var allowAttr = [ 'aspectRatio', 'autoCropArea', 'cropBoxMovable', 'cropBoxResizable', 'minCropBoxWidth', 'minCropBoxHeight', 'minContainerWidth', 'minContainerHeight', 'minCanvasHeight', 'minCanvasWidth', 'croppedWidth', 'croppedHeight', 'croppedMinWidth', 'croppedMinHeight', 'croppedMaxWidth', 'croppedMaxHeight', 'fillColor', 'containerMinHeight', 'containerMaxHeight', 'customWidthHeight', 'customAspectRatio' ]; String.prototype.toLineCase = function () { return this.replace(/[A-Z]/g, function (match) { return "-" + match.toLowerCase(); }); }; var btnAttr = []; $.each(allowAttr, function (i, j) { btnAttr.push('data-' + j.toLineCase() + '="<%=data.' + j + '%>"'); }); var btn = ''; var insertBtn = function () { return arguments[0].replace(arguments[2], btn + arguments[2]); }; $("").appendTo("body"); } $(".plupload[data-preview-id],.faupload[data-preview-id]").each(function () { var preview_id = $(this).data("preview-id"); var previewObj = $("#" + preview_id); var tpl = previewObj.length > 0 ? previewObj.data("template") : ''; if (!tpl) { if (!$(this).hasClass("cropper")) { $(this).addClass("cropper"); } previewObj.data("template", "croppertpl"); } }); //图片裁剪 $(document).off('click', '.btn-cropper').on('click', '.btn-cropper', function () { var image = $(this).closest("li").find('.thumbnail').data('url'); var input = $("#" + $(this).data("input-id")); var url = image; var data = $(this).data(); var params = []; $.each(allowAttr, function (i, j) { if (typeof data[j] !== 'undefined' && data[j] !== '') { params.push(j + '=' + data[j]); } }); try { var parentWin = (parent ? parent : window); parentWin.Fast.api.open('/addons/cropper/index/cropper?url=' + image + (params.length > 0 ? '&' + params.join('&') : ''), '裁剪', { callback: function (data) { if (typeof data !== 'undefined') { var arr = data.dataURI.split(','), mime = arr[0].match(/:(.*?);/)[1], bstr = atob(arr[1]), n = bstr.length, u8arr = new Uint8Array(n); while (n--) { u8arr[n] = bstr.charCodeAt(n); } var urlArr = url.split('.'); var suffix = 'png'; url = urlArr.join(''); var filename = url.substr(url.lastIndexOf('/') + 1); var exp = new RegExp("\\." + suffix + "$", "i"); filename = exp.test(filename) ? filename : filename + "." + suffix; var file = new File([u8arr], filename, {type: mime}); Upload.api.send(file, function (data) { input.val(input.val().replace(image, data.url)).trigger("change"); }, function (data) { }); } }, area: [Math.min(parentWin.$(parentWin.window).width(), Config.cropper.dialogWidth) + "px", Math.min(parentWin.$(parentWin.window).height(), Config.cropper.dialogHeight) + "px"], }); } catch (e) { console.error(e); } return false; }); } }); require.config({ paths: { 'csmtable_xcore': '../addons/csmtable/library/xcore/js/xcore', 'csmtable_csminputstyle': '../addons/csmtable/library/xcore/js/csminputstyle', 'jquery.simple-color': '../addons/csmtable/library/xcore/js/jquery.simple-color', 'csmtable': '../addons/csmtable/js/csmtable', 'fixedcolumns': '../addons/csmtable/js/bootstrap-table-fixed-columns', 'tablereorderrows': '../addons/csmtable/js/bootstrap-table-reorder-rows', 'tablestickyheader': '../addons/csmtable/js/bootstrap-table-sticky-header', 'tabletreegrid': '../addons/csmtable/js/bootstrap-table-treegrid', 'jquerytablednd': '../addons/csmtable/js/jquery.tablednd.min', 'jquerytreegrid': '../addons/csmtable/js/jquery.treegrid.min', 'xeditable2': '../addons/csmtable/js/select2', }, shim: { 'csmtable_xcore': { deps: ["css!../addons/csmtable/library/xcore/css/xcore.css"] }, 'csmtable_csminputstyle': { deps: ["css!../addons/csmtable/library/xcore/css/csminputstyle.css"] }, 'csmtable': { deps: ["css!../addons/csmtable/css/csmtable.css", 'bootstrap-table'] }, 'fixedcolumns': { deps: ["css!../addons/csmtable/css/bootstrap-table-fixed-columns.css", 'bootstrap-table'] }, 'tablereorderrows':{ deps: ["css!../addons/csmtable/css/bootstrap-table-reorder-rows.css",'jquerytablednd', 'bootstrap-table'] }, 'tablestickyheader':{ deps: ["css!../addons/csmtable/css/bootstrap-table-sticky-header.css", 'bootstrap-table'] }, 'tabletreegrid':{ deps: ["css!../addons/csmtable/css/jquery.treegrid.min.css",'jquerytreegrid', 'bootstrap-table'] }, 'xeditable2':{ deps: ["css!../addons/csmtable/css/select2.css","css!../addons/csmtable/css/select2-bootstrap.css",'bootstrap-table','editable'] }, } }); //判断系统深色模式变化,修改切换按钮 var matchMedia = window.matchMedia(('(prefers-color-scheme: dark)')); matchMedia.addEventListener('change', function () { var mode = this.matches ? 'dark' : 'light'; //只有当cookie中无手动定义值时才进行操作 if (document.cookie.indexOf("thememode=") === -1 && Config.darktheme.mode === 'auto') { $("body").toggleClass("darktheme", mode === "dark"); } }); if (typeof Config.darktheme !== 'undefined' && Config.darktheme.switchbtn) { // 切换模式 var switchMode = function (mode) { // 获取当前深色模式 if (mode === 'auto') { var isDarkMode = window.matchMedia('(prefers-color-scheme: dark)').matches; mode = isDarkMode ? 'dark' : 'light'; } if (mode === 'auto') { } else if (mode === 'dark') { $("body").addClass("darktheme"); $(".darktheme-link").removeAttr("media"); } else { $("body").removeClass("darktheme"); $(".darktheme-link").attr("media", "(prefers-color-scheme: dark)"); } }; // 创建Cookie var createCookie = function (name, value) { var date = new Date(); date.setTime(date.getTime() + (365 * 24 * 60 * 60 * 1000)); var url = Config.moduleurl.replace(location.origin, ""); var path = url ? url.substring(url.lastIndexOf("/")) : "/"; document.cookie = encodeURIComponent(Config.cookie.prefix + name) + "=" + encodeURIComponent(value) + "; path=" + path + "; expires=" + date.toGMTString(); }; if (Config.controllername === 'index' && Config.actionname === 'index') { var mode = Config.darktheme.mode; if (mode === 'auto') { var isDarkMode = window.matchMedia('(prefers-color-scheme: dark)').matches; mode = isDarkMode ? 'dark' : 'light'; } var html = '