|
@@ -0,0 +1,97 @@
|
|
|
+/**
|
|
|
+ * 提示框
|
|
|
+ *
|
|
|
+ * @param string message
|
|
|
+ * @param string type
|
|
|
+ * @param string icon
|
|
|
+ * @return void
|
|
|
+ */
|
|
|
+function toast(message, type, icon) {
|
|
|
+ var toast = $(".toast");
|
|
|
+ toast.addClass(type);
|
|
|
+ toast.children('.message').html(message);
|
|
|
+ var iconClass = 'fa-' + icon;
|
|
|
+ toast.children('.icon').addClass(iconClass);
|
|
|
+ toast.fadeIn(500);
|
|
|
+
|
|
|
+ setTimeout(function() {
|
|
|
+ toast.fadeOut('fast');
|
|
|
+ toast.children('.message').text('');
|
|
|
+ toast.children('.icon').removeClass(iconClass);
|
|
|
+ }, 3000);
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 获取url中参数
|
|
|
+ * @param variable
|
|
|
+ * @returns {*}
|
|
|
+ */
|
|
|
+function getQueryVariable(variable) {
|
|
|
+ var query = window.location.search.substring(1);
|
|
|
+ var vars = query.split("&");
|
|
|
+ for (var i=0;i<vars.length;i++) {
|
|
|
+ var pair = vars[i].split("=");
|
|
|
+ if(pair[0] == variable){return pair[1];}
|
|
|
+ }
|
|
|
+ return(false);
|
|
|
+}
|
|
|
+
|
|
|
+const zeroRange = 0.00000001;
|
|
|
+function checkZero(value) {
|
|
|
+ return value === null || value === undefined || (_.isNumber(value) && Math.abs(value) < zeroRange);
|
|
|
+}
|
|
|
+function checkFieldChange(o, n) {
|
|
|
+ return o == n || ((!o || o === '') && (n === ''));
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 设置本地缓存
|
|
|
+ *
|
|
|
+ * @param {String} key
|
|
|
+ * @param {String|Number} value
|
|
|
+ * @return {void}
|
|
|
+ */
|
|
|
+function setLocalCache(key, value) {
|
|
|
+ const storage = window.localStorage;
|
|
|
+ if (!storage || key === '' || value === '') {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ storage.setItem(key, value);
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 获取本地缓存
|
|
|
+ *
|
|
|
+ * @param {String} key
|
|
|
+ * @return {String}
|
|
|
+ */
|
|
|
+function getLocalCache(key) {
|
|
|
+ const storage = window.localStorage;
|
|
|
+ if (!storage || key === '') {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ return storage.getItem(key);
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 移除本地缓存
|
|
|
+ * @param {String} key
|
|
|
+ * @returns {Boolean}
|
|
|
+ */
|
|
|
+function removeLocalCache(key) {
|
|
|
+ const storage = window.localStorage;
|
|
|
+ if (!storage || key === '') {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ return storage.removeItem(key);
|
|
|
+}
|
|
|
+
|
|
|
+function trimInvalidChar(str) {
|
|
|
+ return $.trim(str).replace(/\n/g, '').replace(/\r/g, '').replace(/\t/g, '');
|
|
|
+}
|
|
|
+
|
|
|
+function cleanSymbols(str) {
|
|
|
+ return $.trim(str).replace(/\\/g, '').replace(/\'/g, '').replace(/\"/g, '').replace(/\</g, '').replace(/\|/g, '');
|
|
|
+}
|