diff --git a/lib/layui_plugins/okUtils/okUtils.js b/lib/layui_plugins/okUtils/okUtils.js index 3a29913..ee7735d 100644 --- a/lib/layui_plugins/okUtils/okUtils.js +++ b/lib/layui_plugins/okUtils/okUtils.js @@ -71,7 +71,31 @@ layui.define("layer", function (exports) { // 刷新当前页table数据 $(".layui-laypage-btn")[0].click(); }); - }, + } + }, + /** + * 判断是否为一个正常的数字 + * @param num + */ + isNum: function (num) { + if (num && !isNaN(num)) { + return true; + } + return false; + }, + /** + * 判断一个数字是否包括在某个范围 + * @param num + * @param begin + * @param end + */ + isNumWith: function (num, begin, end) { + if (this.isNum(num)) { + if (num >= begin && num <= end) { + return true; + } + return false; + } } } diff --git a/pages/system/system-setting.html b/pages/system/system-setting.html index f34024b..2fbea42 100644 --- a/pages/system/system-setting.html +++ b/pages/system/system-setting.html @@ -195,8 +195,8 @@ var storage = window.localStorage; var skin = storage.getItem("skin"); var anim = storage.getItem("anim"); - $("#skin").val(skin); - $("#anim").val(anim); + $("#skin").val(okUtils.isNumWith(skin, 1, 4) ? skin : 1); + $("#anim").val(okUtils.isNumWith(anim, 0, 7) ? anim : 0); form.render() form.on("submit(skinAnimSubmit)", function (data) {